Pythia-6.9B
POST
https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/completions/{申请发布时填写的API地址}注意:该模型目前面向测试企业用户开放,如需使用请填写申请表单,我们将尽快评估您的需求。
Pythia-6.9B由EleutherAI研发并开源,在Pile数据集上训练的6.9B参数transformer语言模型。本文介绍了相关API。
创建completion
调用本接口,发起一次文本续写请求。
请求示例(流式)
# 步骤一,获取access_token,替换下列示例中的应用API Key与应用Secret Key
curl 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=[应用API Key]&client_secret=[应用Secret Key]'
# 步骤二,调用本文API,使用步骤一获取的access_token,替换下列示例中的“调用接口获取的access_token”;替换示例中的申请发布时填写的API名称
curl -X POST 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/completions/[申请发布时填写的API名称]?access_token=[步骤一调用接口获取的access_token]' -d '{
"prompt":"Introduce the city Beijing",
"stream": true
}'
响应示例(流式)
data: {"id":"as-9092ws9jgh","object":"completion","created":1693811126,"sentence_id":0,"is_end":false,"result":", China.\nBeijing is the capital city of China and is located in the northern part of the country. It is the largest city in China and is known for its modern architecture, cultural heritage, and historical significance. The city is home to many famous landmarks, such as the Forbidden City, Tiananmen Square","is_safe":1,"usage":{"prompt_tokens":5,"completion_tokens":67,"total_tokens":72}}
data: {"id":"as-9092ws9jgh","object":"completion","created":1693811128,"sentence_id":1,"is_end":true,"result":", and the Great Wall of China. It is also known for its vibrant nightlife, delicious food, and stunning scenery.","is_safe":1,"usage":{"prompt_tokens":5,"completion_tokens":24,"total_tokens":96}}
错误码
如果请求错误,服务器返回的JSON文本包含以下参数。
名称 | 描述 |
---|---|
error_code | 错误码 |
error_msg | 错误描述信息,帮助理解和解决发生的错误 |
例如Access Token失效返回以下内容,需要重新获取新的Access Token再次请求。
{
"error_code": 110,
"error_msg": "Access token invalid or no longer valid"
}
千帆大模型平台相关错误码,请查看错误码说明。
请求参数
Path 参数
申请发布时填写的API地址
string
必需
Body 参数application/json
prompt
string
请求信息
stream
boolean
可选
是否以流式接口的形式返回数据,默认false
temperature
number
可选
说明: (1)较高的数值会使输出更加随机,而较低的数值会使其更加集中和确定 (2)范围 (0, 1.0],不能为0 (3)建议该参数和top_p只设置1个
top_k
integer
可选
Top-K 采样参数,在每轮token生成时,保留k个概率最高的token作为候选。说明: (1)影响输出文本的多样性,取值越大,生成文本的多样性越强 (2)取值范围:正整数
top_p
number
可选
说明: (1)影响输出文本的多样性,取值越大,生成文本的多样性越强 (2)取值范围 [0, 1.0] (3)建议该参数和temperature只设置1个
penalty_score
number
可选
通过对已生成的token增加惩罚,减少重复生成的现象。说明: (1)值越大表示惩罚越大 (2)取值范围:[1.0, 2.0]
stop
array[string]
可选
生成停止标识。当模型生成结果以stop中某个元素结尾时,停止文本生成。说明: (1)每个元素长度不超过20字符。 (2)最多4个元素
user_id
string
可选
表示最终用户的唯一标识符,可以监视和检测滥用行为,防止接口恶意调用
示例
{
"prompt": "string",
"stream": true,
"temperature\t": 0,
"top_k\t": 0,
"top_p\t": 0,
"penalty_score": 0,
"stop\t": [
"string"
],
"user_id": "string"
}
示例代码
返回响应
成功(200)
HTTP 状态码: 200
内容格式: JSONapplication/json
数据结构
id
string
本轮对话的id
object
string
必需
回包类型。 chat.completion:多轮对话返回
created
integer
时间戳
result
string
对话返回结果
need_clear_history
boolean
必需
表示用户输入是否存在安全,是否关闭当前会话,清理历史会话信息 true:是,表示用户输入存在安全风险,建议关闭当前会话,清理历史会话信息 false:否,表示用户输入无安全风险
usage
object
必需
token统计信息,token数 = 汉字数+单词数*1.3 (仅为估算逻辑)
prompt_tokens
integer
问题tokens数
completion_tokens
integer
回答tokens数
total_tokens
integer
tokens总数
示例
{
"id": "as-rq3wwusja8",
"object": "completion",
"created": 1693811110,
"result": " China.\nBeijing is the capital city of China and is located in the northern part of the country. It is the largest city in China and is known for its modern architecture, cultural heritage, and historical significance. The city is home to many famous landmarks, such as the Forbidden City, Tiananmen Square, and the Great Wall of China. It is also known for its vibrant nightlife, delicious food, and stunning scenery.",
"is_safe": 1,
"usage": {
"prompt_tokens": 5,
"completion_tokens": 92,
"total_tokens": 97
}
}
最后修改时间: 1 年前