Token推理接口
接口功能
提供Token推理处理功能。
接口格式
操作类型:POST
URL:https://{ip}:{port}/v2/models/${MODEL_NAME}[/versions/${MODEL_VERSION}]/infer
- {ip}和{port}请使用业务面的IP地址和端口号,即“ipAddress”和“port”。
- ${MODEL_NAME}字段指定需要查询的模型名称。
- [/versions/${MODEL_VERSION}]字段暂不支持,不传递。
请求参数
使用样例
请求样例:
POST https://{ip}:{port}/v2/models/llama3-70b/infer
请求消息体:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | { "id": "42", "inputs": [{ "name": "input0", "shape": [ 1, 10 ], "datatype": "UINT32", "data": [ 396, 319, 13996, 29877, 29901, 29907, 3333, 20718, 316, 23924 ] }], "outputs": [{ "name": "output0" }], "parameters": { "temperature": 0.5, "top_k": 10, "top_p": 0.95, "do_sample": true, "seed": null, "repetition_penalty": 1.03, "max_new_tokens": 20, "watermark": true, "priority": 5, "timeout": 10 } } |
响应样例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | { "id": "42", "outputs": [ { "name": "output0", "shape": [ 1, 20 ], "datatype": "UINT32", "data": [ 1, 396, 319, 13996, 29877, 29901, 29907, 3333, 20718, 316, 23924, 562, 2142, 1702, 425, 14015, 16060, 316, 383, 19498 ] } ] } |
输出说明
返回值 |
类型 |
说明 |
|
|---|---|---|---|
id |
string |
请求ID。 |
|
outputs |
list |
推理结果列表。 |
|
- |
name |
string |
默认"output0"。 |
shape |
list |
结构为[1, n],1表示1维数组,n表示data字段中token结果长度。 |
|
datatype |
string |
"UINT32"。 |
|
data |
list |
推理后生成的token id集合。 |
|
父主题: 兼容Triton接口