文档

词向量(基础版)

更新时间:

词向量(基础版-通用)

调用须知

  • 该服务为基础版的能力,需要开通基础版才能免费调用。点击这里确认开通状态:点击确认开通

  • 支持语言:中文

  • 支持领域:通用领域

  • 能力说明:词向量是一种简单有效的将最小语义单元 —— 词转化为数值表示的方法。通过词向量得到的数值表示的形式是高维稠密向量。这种数值表示的特点是语义相近的词(如“红色”和“蓝色”)在向量空间中的位置接近。这种数值表示可以支撑语义相似度计算等具体应用。

请求参数

名称

类型

是否必选

示例值

描述

Action

String

GetWeChGeneral

系统规定参数,取值:GetWeChGeneral

ServiceCode

String

alinlp

固定值,只支持alinlp

Text

String

请输入文本

需要分析的文本,最大长度1024个字符

Size

String

50

词向量维度,支持50、100、200,默认值:100

Type

String

word

分析文本的切分方式。支持以下几种:

  • “word”表示将句子切成词

  • “char_unigram”表示将句子切成字

  • “char_bigram”表示将句子切成双字

  • 默认值:”word”

Operation

String

none

句子表示方法

  • “none”给句子中的每个词一个表示

  • “max”用按维度取最大值的方式进行句子表示

  • “average”用按维度取平均的方式进行句子表示

  • 默认值:”average”

返回数据

名称

类型

示例值

描述

RequestId

String

FA53D08F-37D1-4D81-BEE7-41F24E825F60

唯一请求id,排查问题的依据

Data

String

{
  "result": [
    {
      "vec": [
        0.572929,
        …
        (skip)
        …
        0.039206
      ],
      "id": "0",
      "token": "请"
    },
    {
      "vec": [
        -1.263492,
        …
        (skip)
        …
        2.302645
      ],
      "id": "1",
      "token": "输入"
    },
    {
      "vec": [
        1.511844,
        …
        (skip)
        …
        -1.557032
      ],
      "id": "2",
      "token": "文本"
    }
  ],
  "success": true
}

如果operation为”none”,返回一个列表。

列表中的每个项是一个dict,成员包括:

  • vec -ListFloat -代表词向量

  • id -string -代表词序号

  • token -string -代表切分结果

如果operation为”max”或”average”,返回一个dict。

成员包括:

  • vec -ListFloat -代表词向量

调用接入

  1. 代码接入请参考:快速入门

  2. 在线快速试用请参考:在线试用

错误码

调用过程中如果出现错误可对照下表,查看对应描述,描述中包含具体错误原因和解决方案

HttpCode

错误码

错误信息

描述

400

UserStatusInvalid

The user status is invalid.

用户状态无效,请检查账户是否欠费和有未支付的账单

400

BasicServiceNotActivated

The NLP API (Version : base) service has not been activated. Please click the url to confirm the activation status:https://common-buy.aliyun.com/?commodityCode=nlp_alinlpBasePost_public_cn#/buy

NLP API(基础版)服务未开通,请点击链接确认开通状态:https://common-buy.aliyun.com/?commodityCode=nlp_alinlpBasePost_public_cn#/buy

400

AdvancedServiceNotActivated

The NLP API (Version : advanced) service has not been activated. Please click the url to confirm the activation status:https://common-buy.aliyun.com/?commodityCode=nlp_alinlpAdvancedPost_public_cn#/buy

NLP API(高级版)服务未开通,请点击链接确认开通状态:https://common-buy.aliyun.com/?commodityCode=nlp_alinlpAdvancedPost_public_cn#/buy

400

IndustryServiceNotActivated

The NLP API (Version : industry) service has not been activated. Please click the url to confirm the activation status:https://common-buy.aliyun.com/?commodityCode=nlp_alinlpIndustryPost_public_cn#/buy

NLP API(行业应用版)服务未开通,请点击链接确认开通状态:https://common-buy.aliyun.com/?commodityCode=nlp_alinlpIndustryPost_public_cn#/buy

401

InvalidParameter

The parameter is invalid.

参数无效,请检查入参

403

Forbidden.NoAuth

You are not authorized to operate on the specified resource. Please click the URL for help information:https://help.aliyun.com/document_detail/177209.html

您的账号无权限操作指定的资源,请点击URL以获取帮助信息:https://help.aliyun.com/document_detail/177209.html

405

TextLimitExceeded

The maximum length of the text is exceeded.

文本长度超过限制

406

TextCodingError

An encoding error occurred to the input text.

输入文本编码错误

410

FrameworkError

Framework internal server error.

框架错误

411

FrameworkApiError

Framework API error.

框架API错误

412

FrameworkFormatError

Framework request format error.

框架请求格式错误

413

FrameworkReturnError

Framework return type format error.

框架返回格式错误

429

Throttling.User

Flow control has been triggered.

超过了每秒最大查询数(QPS),请单击URL以获取帮助信息:https://help.aliyun.com/document_detail/69780.html#p-wq5-zb9-5wu

500

InternalError

A server error occurred while processing your request. Please try again later or contact customer support.

处理您的请求时发生服务错误,请稍后再试或联系客户支持。

  • 本页导读 (0)
文档反馈