日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

API詳情

OpenNLU開放域文本理解模型

說明

支持的領域/任務:OpenNLU可以在任意領域完成各類NLU任務。

OpenNLU全稱Open Domain Natural Language Understanding,是開箱即用的文本理解大模型,適用于中文、英文在零樣本條件下進行文本理解任務,如信息抽取、文本分類等。

OpenNLU將NLU任務分成兩個大類:抽取和分類。抽取任務目標是從給定文本中抽取一些片段,如實體識別、事件抽取、關鍵詞抽取等。分類任務目標是將給定文本按照給定的類別體系進行分類,如主題分類、情感分類、意圖分類等。

重要

雖然OpenNLU已經在大量任務上訓練且具備泛化性,但由于實際NLU任務的多樣性、復雜性,其在不同具體任務上的效果可能有較大差別,請謹慎評估模型效果是否符合需求。

模型概覽

模型名

模型簡介

opennlu-v1

開箱即用的文本理解大模型,適用于中文、英文零樣本條件下進行文本理解任務,如信息抽取、文本分類等。

SDK使用

前提條件

以下示例展示了調用OpenNLU模型對一個用戶指令進行響應的代碼。

說明

請先參考“配置API-KEY到環境變量”正確設置您的API-KEY。

# coding=utf-8
# For prerequisites running the following sample, visit http://m.bestwisewords.com/document_detail/611472.html

from dashscope import Understanding
from http import HTTPStatus
import json


response = Understanding.call(
    model='opennlu-v1',
    sentence='老師今天表揚我了',
    labels='積極,消極',
    task='classification')

if response.status_code == HTTPStatus.OK:
    print(json.dumps(response.output, indent=4, ensure_ascii=False))
else:
    print('Code: %d, status: %s, message: %s' % (response.status_code, response.code, response.message))
import com.alibaba.dashscope.nlp.understanding.Understanding;
import com.alibaba.dashscope.nlp.understanding.UnderstandingParam;
import com.alibaba.dashscope.nlp.understanding.UnderstandingResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;

public class Main {

    public static void main(String[] args) {
      try{
        UnderstandingParam param =
                UnderstandingParam.builder()
                        .model(Understanding.Models.OPENNLU_V1)
                        .sentence("老師今天表揚我了")
                        .labels("積極,消極")
                        .task("classification")
                        .build();
        // 如果正常返回即可以直接使用
        // 否則會拋出ApiException異常,檢查e.getStatus()即可拿到錯誤信息
        Understanding understanding = new Understanding();
        UnderstandingResult result = understanding.call(param);
        System.out.println(result.getOutput().getText());
        System.exit(0);
      } catch (ApiException | NoApiKeyException | InputRequiredException e) {
        e.printStackTrace();
      }
    }
}

參數配置

參數

類型

必選

描述

示例值

model

String

指明需要調用的模型。

opennlu-v1

task

String

任務類型,可選項是 extraction classification,默認為extraction

sentence

String

用戶輸入的需要處理的文本內容,支持中英文。(input最長限制1024個tokens,為input所有字段的總和)

老師今天表揚我了

labels

String

對于抽取任務,label為需要抽取的類型名稱。對于分類任務,label為分類體系。不同標簽用中文逗號分隔。

抽取任務:

實體識別:人名,地名

閱讀理解:小明的年齡是多少?,小明的身高是多少?

分類任務:

主題分類:體育新聞,娛樂新聞

情感分類:積極,消極

返回結果

  • 返回結果示例

{
    "status_code": 200,
    "request_id": "39a41abe-1bed-430a-b9b5-277130c7eb82",
    "code": "",
    "message": "",
    "output": {
        "text": "積極;"
    },
    "usage": {
        "output_tokens":2,
        "input_tokens":11,
        "total_tokens":13
    }
}
  • 返回參數說明

返回參數

類型

說明

status_code

int

200(HTTPStatus.OK)表示請求成功,否則表示請求失敗,可以通過code獲取錯誤碼,通過message字段獲取錯誤詳細信息。

request_Id

string

系統生成的標志本次調用的id。

code

string

表示請求失敗,表示錯誤碼,成功忽略。

message

string

失敗,表示失敗詳細信息,成功忽略。

output

dict

調用結果信息,包含輸出text。

output.text

string

模型生成回復。

usage

dict

計量信息,表示本次請求計量數據。

usage.input_tokens

int

用戶輸入文本轉換成Token后的長度。

usage.output_tokens

int

模型生成回復轉換為Token后的長度。

usage.total_tokens

int

input_tokens + output_tokens。

HTTP調用接口

功能描述

OpenNLU模型支持 HTTP 調用來響應客戶請求。

前提條件

提交接口調用

POST https://dashscope.aliyuncs.com/api/v1/services/nlp/nlu/understanding

入參描述

字段

類型

傳參方式

必選

描述

示例值

Content-Type

String

Header

請求類型:application/json

application/json

Authorization

String

Header

API-Key,例如:Bearer d1**2a

Bearer d1**2a

X-DashScope-WorkSpace

String

Header

指明本次調用需要使用的workspace;需要注意的是,對于子賬號Apikey調用,此參數為必選項,子賬號必須歸屬于某個workspace才能調用;對于主賬號Apikey此項為可選項,添加則使用對應的workspace身份,不添加則使用主賬號身份。

ws_QTggmeAxxxxx

model

String

Body

指明需要調用的模型。

opennlu-v1

input.task

String

Body

任務類型,可選項是 extraction classification,默認是 extraction

input.sentence

String

Body

用戶輸入的需要處理的文本內容,支持中英文。(input最長限制1024個tokens,為input所有字段的總和)

老師今天表揚我了

input.labels

String

Body

對于抽取任務,label為需要抽取的類型名稱。對于分類任務,label為分類體系。不同標簽用中文逗號分隔。

抽取任務:

實體識別:人名,地名

閱讀理解:小明的年齡是多少?,小明的身高是多少?

分類任務:

主題分類:體育新聞,娛樂新聞

情感分類:積極,消極

出參描述

字段

類型

描述

示例值

output.text

String

本次請求的算法輸出內容。

積極

usage.output_tokens

Integer

本次請求算法輸出內容的token數目。

200

usage.input_tokens

Integer

本次請求輸入內容的 token 數目,包括input所有內容

20

usage.total_tokens

Integer

本次請求用量計量的總內容,上面output_tokens和input_tokens的和。

220

request_id

String

本次請求的系統唯一碼

7574ee8f-38a3-4b1e-9280-11c33ab46e51

請求示例

以下示例展示通過CURL命令來調用 opennlu-v1 模型的腳本。

說明

需要使用您的API-KEY替換示例中的 your-api-key ,代碼才能正常運行。

curl --location 'https://dashscope.aliyuncs.com/api/v1/services/nlp/nlu/understanding' \
--header 'Authorization: Bearer <<YOUR_API_KEY> \
--header 'Content-Type: application/json' \
--data '{
    "model": "opennlu-v1",
    "input":{
        "sentence":"老師今天表揚我了",
        "task": "classification",
        "labels":"積極,消極"
    },
    "parameters": {
    }
}'

響應示例

{
    "output":{
        "text":"積極",
    },
    "usage":{
        "output_tokens":2,
        "input_tokens":11,
        "total_tokens":13
    },
    "request_id":"d89c06fb-46a1-47b6-acb9-bfb17f814969"
}

異常響應示例

在訪問請求出錯的情況下,輸出的結果中會通過code和message指明出錯原因。

{
    "code":"InvalidApiKey",
    "message":"Invalid API-key provided.",
    "request_id":"fb53c4ec-1c12-4fc4-a580-cdb7c3261fc1"
}

狀態碼說明

大模型服務平臺通用狀態碼請查閱:錯誤碼