Word embedding (comments)

Updated at:

Word embedding (Premium Edition - Comments domain)

Before you begin

  • This service is a feature of the Premium Edition. After you subscribe to the Premium Edition, you can call this service for free. To confirm your subscription status, click Confirm subscription.

  • Supported language: Chinese

  • Supported domain: Comments

  • Description: Word embedding is a simple and effective method that converts words, the smallest units of meaning, into high-dimensional dense vectors. In this vector space, words with similar meanings, such as "red" and "blue", are positioned close to each other. This numerical representation supports applications such as calculating semantic similarity.

Request parameters

Name

Type

Required

Example value

Description

Action

String

Yes

GetWeChComment

A required parameter. Set the value to GetWeChComment.

ServiceCode

String

Yes

alinlp

A static field. Only `alinlp` is supported.

Text

String

Yes

Please enter the text

The text to analyze. The maximum length is 1024 characters.

TokenizerId

String

Yes

COMMENT

A static field. Set the value to `COMMENT`.

Size

String

No

50

The word embedding dimensions. Valid values are 50, 100, and 200.

Type

String

No

word

The method used to chunk the text for analysis. The following values are supported:

  • `word`: Chunks the sentence into words.

  • `char_unigram`: Chunks the sentence into single characters.

  • `char_bigram`: Chunks the sentence into bigrams.

Operation

String

No

none

The method used to represent the sentence.

  • The "none" setting assigns a representation to each word in the sentence.

  • `max`: Represents the sentence by taking the maximum value for each dimension across all word vectors.

  • `average`: Represents the sentence by taking the average value for each dimension across all word vectors.

Return Data

Name

Type

Example value

Description

Data

String

{
  "result": [
    {
      "vec": [
        0.572929,
        …
        (skip)
        …
        0.039206
      ],
      "id": "0",
      "token": "Please"
    },
    {
      "vec": [
        -1.263492,
        …
        (skip)
        …
        2.302645
      ],
      "id": "1",
      "token": "enter"
    },
    {
      "vec": [
        1.511844,
        …
        (skip)
        …
        -1.557032
      ],
      "id": "2",
      "token": "text"
    }
  ],
  "success": true
}

If `Operation` is set to `none`, a list is returned.

Each item in the list is a dictionary that contains the following parameters:

  • `vec`: List<Float>. The word embedding vector.

  • `id`: String. The ordinal number of the word.

  • `token`: String. The tokenized word or character.

If `Operation` is set to `max` or `average`, a dictionary is returned.

The members are as follows:

  • `vec`: List<Float>. The sentence embedding vector.

RequestId

String

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

The unique ID of the request. Use this ID to troubleshoot issues.

API access

  1. For more information about code integration, see Quick Start.

  2. To try the service online, see Online trial.

Error codes

If an error occurs during a call, refer to the following table for error descriptions and solutions.

HttpCode

Error code

Error message

Description

400

UserStatusInvalid

The user status is invalid.

The user status is invalid. Check if your account has an overdue payment or an unpaid bill.

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

The NLP API (Basic Edition) service is not activated. Click the link to confirm the activation status: 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

The NLP API (Premium Edition) service is not activated. Click the link to confirm the activation status: 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

The NLP API (Industry Application Edition) service is not activated. Click the link to confirm the activation status: https://common-buy.aliyun.com/?commodityCode=nlp_alinlpIndustryPost_public_cn#/buy

401

InvalidParameter

The parameter is invalid.

The parameter is invalid. Check the request parameters.

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

Your account does not have the permissions to operate on the specified resource. Click the URL for help: https://help.aliyun.com/document_detail/177209.html

405

TextLimitExceeded

The maximum length of the text is exceeded.

The text length exceeds the limit.

406

TextCodingError

An encoding error occurred to the input text.

The input text has an encoding error.

410

FrameworkError

Framework internal server error.

Framework error.

411

FrameworkApiError

Framework API error.

Framework API error.

412

FrameworkFormatError

Framework request format error.

Framework request format error.

413

FrameworkReturnError

Framework return type format error.

Framework return format error.

429

Throttling.User

Flow control has been triggered.

The maximum number of queries per second (QPS) is exceeded. Click the URL for help: 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.

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