搜索本产品文档关键词
获取模型版本详情
所有文档
menu
没有找到结果,请重新输入

千帆大模型服务与开发平台ModelBuilder

获取模型版本详情

注意:

  • 为提升开发者使用体验,推荐使用模型管理V2版本接口,功能更全面、且接口更规范,详见模型管理API列表
  • 模型管理V1版本接口功能不再升级,本文档于2024年8月5日下线;由于V1版本接口后续可能下线停止服务,为避免影响使用,建议接入模型管理V2版本接口。

功能介绍

本接口用于根据模型版本id获取模型版本详情,如模型名称、版本号、模型版本来源类型等。

SDK调用

使用说明

调用本文API,需使用安全认证AK/SK鉴权,调用流程及鉴权介绍详见SDK安装及使用流程

调用示例

import os
from qianfan import resources

# 使用安全认证AK/SK鉴权,通过环境变量方式初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
os.environ["QIANFAN_ACCESS_KEY"] = "your_iam_ak"
os.environ["QIANFAN_SECRET_KEY"] = "your_iam_sk"

model = resources.Model.detail(model_version_id = "amv-g73j3faikzpz")
print(model)

返回示例

QfResponse(code = 200, headers = {...}, body = {
'log_id': '2456493788',
'result':
{
    'modelId': 2,
    'modelIdStr': 'am-ju3hi4ts39u9',
    'modelName': 'ERNIE-Bot-turbo',
    'modelVersionId': 7170,
    'modelVersionIdStr': 'amv-qb8ijukaish3',
    'version': 'ERNIE-Bot-turbo-0725',
    'description': '支持7K输入+1K输出,支持系统设置,新增推理参数',
    'sourceType': 'PlatformPreset',
    'sourceExtra':
    {},
    'framework': 'paddle',
    'algorithm': 'ERNIE_EB-ERNIEBOT_V201_8K',
    'modelNet': 'paddlepaddle-ERNIE_EB-ERNIEBOT_V201_8K',
    'state': 'Ready',
    'ioMode': 'chat',
    'ioLength': '7K+1K',
    'copyright': '',
    'property':
    {},
    'createTime': '2023-09-22T20:14:06+08:00',
    'modifyTime': '2024-01-11T16:59:26+08:00',
    'deployResource': ['Private'],
    'supportOptions': ['Deploy', 'Evaluation', 'APIDoc', 'FineTuning'],
    'trainType': 'ernieBotLite',
    'params':
    {
        'input':
        {
            'type': 'object',
            'required': ['messages'],
            'properties':
            {
                'messages':
                {
                    'type': 'array',
                    'items':
                    {
                        'type': 'object',
                        'required': ['role', 'content'],
                        'properties':
                        {
                            'role':
                            {
                                'name': 'role',
                                'type': 'string',
                                'default': 'user',
                                'description': '当前支持以下两个role: "user": 用户 "assistant": 对话助手'
                            },
                            'content':
                            {
                                'name': 'content',
                                'type': 'string',
                                'description': '对话内容,不能为空'
                            }
                        }
                    }
                },
                'stream':
                {
                    'name': 'stream',
                    'type': 'boolean',
                    'description': '是否以流式接口的形式返回数据; 默认false'
                },
                'user_id':
                {
                    'name': 'user_id',
                    'type': 'string',
                    'description': '表示最终用户的唯一标识符,可以监视和检测滥用行为,防止接口恶意调用。'
                },
                'temperature':
                {
                    'name': 'temperature',
                    'type': 'number',
                    'format': 'float',
                    'description': '较高的数值会使输出更加随机,而较低的数值会使其更加集中和确定。 默认0.95,范围 (0, 1.0],不能为0 建议该参数和top_p只设置1个'
                },
                'top_p':
                {
                    'name': 'top_p',
                    'type': 'number',
                    'format': 'float',
                    'description': '影响输出文本的多样性,取值越大,生成文本的多样性越强。 默认0.8,取值范围 [0, 1.0] 建议该参数和temperature只设置1个'
                },
                'penalty_score':
                {
                    'name': 'penalty_score',
                    'type': 'number',
                    'format': 'float',
                    'description': '通过对已生成的token增加惩罚,减少重复生成的现象。值越大表示惩罚越大。 默认1.0,取值范围:[1.0, 2.0]'
                }
            }
        },
        'output':
        {
            'type': 'object',
            'required': [],
            'properties':
            {
                'id':
                {
                    'name': 'id',
                    'type': 'string',
                    'description': '本轮对话的id'
                },
                'object':
                {
                    'name': 'object',
                    'type': 'string',
                    'description': '回包类型 “chat.completion”:多轮对话返回'
                },
                'created':
                {
                    'name': 'created',
                    'type': 'integer',
                    'format': 'int32',
                    'description': '时间戳'
                },
                'sentence_id':
                {
                    'name': 'sentence_id',
                    'type': 'integer',
                    'format': 'int32',
                    'description': '流式接口模式下会返回,表示当前子句的序号'
                },
                'is_end':
                {
                    'name': 'is_end',
                    'type': 'boolean',
                    'description': '流式接口模式下会返回,表示当前子句是否是最后一句'
                },
                'is_truncated':
                {
                    'name': 'is_truncated',
                    'type': 'boolean',
                    'description': '标识当前生成的结果是否被截断'
                },
                'result':
                {
                    'name': 'result',
                    'type': 'string',
                    'description': '对话返回结果, 当前对话返回结果限制在1000个token'
                },
                'need_clear_history':
                {
                    'name': 'need_clear_history',
                    'type': 'boolean',
                    'description': '值为true表示用户输入存在安全风险,建议关闭当前会话,清理历史会话信息'
                },
                'ban_round':
                {
                    'name': 'ban_round',
                    'type': 'integer',
                    'format': 'int32',
                    'description': '当need_clear_history为true时,此字段会告知第几轮对话有敏感信息,如果是当前问题,ban_round = -1'
                },
                'usage':
                {
                    'type': 'object',
                    'required': [],
                    'description': 'token统计信息,token数 = 汉字数+单词数*1.3 (仅为估算逻辑)',
                    'properties':
                    {
                        'prompt_tokens':
                        {
                            'name': 'prompt_tokens',
                            'type': 'integer',
                            'format': 'int32',
                            'description': '问题tokens数(包含历史QA)'
                        },
                        'completion_tokens':
                        {
                            'name': 'completion_tokens',
                            'type': 'integer',
                            'format': 'int32',
                            'description': '回答tokens数'
                        },
                        'total_tokens':
                        {
                            'name': 'total_tokens',
                            'type': 'integer',
                            'format': 'int32',
                            'description': 'tokens总数'
                        }
                    }
                }
            }
        }
    }
}
)

请求参数

名称 类型 必填 描述
model_version_id string 模型版本id,示例:amv-g73j3faikzpz,说明:
(1)通过以下方式获取该字段值:
· 方式一,通过调用获取模型详情接口,返回的modelVersionIdStr字段获取
· 方式二,在控制台-我的模型-点击某模型详情,在版本列表中查看
image.png
(2)该字段新增支持string类型,如果之前使用的是int类型,建议变更为string类型,后续可能将逐步废弃int类型;例如通过调用获取模型详情接口,返回的modelVersionId字段获取,请替换为接口返回的modelVersionIdStr字段获取

返回参数

名称 类型 描述
log_id string 请求ID
result dict 请求结果

result说明

名称 类型 描述
modelName string 模型名称
modelId int 模型id,注意:该字段后续可能废弃,如需使用模型id,请使用modelIdStr
modelIdStr string 模型id
modelVersionId int 版本id,注意:该字段后续可能废弃,如需使用版本id,请使用modelVersionIdStr
modelVersionIdStr string 版本id
state string 状态,说明:
Ready:已就绪
Creating:创建中
Fail:创建失败
version string 版本号
sourceType string 模型版本来源类型,说明:
Train:大模型训练产生
Acceleration:模型加速产生
PlatformPreset:平台预置模型版本
Import:外部导入模型
sourceExtra dict 版本来源回溯信息
modelNet string 网络类型
framework string 版本框架
algorithm string 算法类型
description string 版本描述
createTime int 版本创建时间戳
modifyTime string 版本修改时间戳
ioMode string 输入输出模式,说明:
chat:对话模式
completion:续写模式
ioLength string 输入输出长度,示例:3K+1K
params dict 出入参
copyright string 版权信息,仅开源模型及其衍生模型返回该字段
license string 开源协议,仅预置开源模型返回该字段
property string 模型的额外属性信息,json字符串
deployResource dict 模型可部署的资源池类型
supportOptions list[string] 模型支持的下游操作,说明:
Deploy:部署
Acceleration:压缩
Evaluation:评估
trainType string 基础模型,说明:
(1)字段值说明:
· 当基础模型是ernieBotLite各版本模型,该字段返回ernieBotLite;例如基础模型是ernieBotLite-v201-8k,返回trainType值为ernieBotLite
· 当基础模型是chatglm2-6b、chatglm2-6b-32k,该字段返回chatglm2-6b
· 其他,该字段返回对应基础模型
(2)在将训练任务发布为模型场景,使用该字段时,需注意以下,更多详情请参考训练任务发布为模型
该字段值需和模型调优-获取任务运行详情接口返回的trainType字段配合使用
isMainVersion bool 是否为主线版本
inputTokens int 输入tokens,说明:当模型为重排序Reranker类型,不返回此字段
outputTokens int 输出tokens,说明:当模型为重排序Reranker类型,不返回此字段
characterCnt int 上下文字符数,说明:当模型为重排序Reranker类型,不返回此字段
queryCharacterCnt int 查询Token字符限制,说明:只有当模型为重排序Reranker类型,返回此字段
docCharacterCnt int 文档Token字符限制,说明:只有当模型为重排序Reranker类型,返回此字段
queryTokens int 查询Token,说明:只有当模型为重排序Reranker类型,返回此字段
documentTokens int 文档Token,说明:只有当模型为重排序Reranker类型,返回此字段
baseModelId string 用户模型对应的基础模型id
baseModelVersionId string 用户模型对应的基础模型版本id

sourceExtra说明

名称 类型 描述
sourceType string 版本来源类型,不同类型对应不同的数据结构,说明:
Train:大模型训练产生
Acceleration:模型加速产生
Import:外部导入模型
trainSourceExtra dict 大模型训练回溯信息
accelerationSourceExtra dict 模型加速回溯信息
importModelVersionSourceExtra dict 导入模型回溯信息

trainSourceExtra说明

名称 类型 描述
taskId int 训练ID,注意:该字段后续可能废弃,如需使用训练ID,请使用taskIdStr
taskIdStr string 训练ID
taskName string 训练名称
iterationVersion int 训练任务版本
runId int 训练运行ID,注意:该字段后续可能废弃,如需使用训练运行ID,请使用runIdStr
runIdStr string 训练运行ID
devType int 说明:
1:大模型调优
2:RLHF-奖励模型
3:RLHF-强化学习
modelType int 模型类型
step int 如果是选择的step发布,字段值为选择的对应step

accelerationSourceExtra说明

名称 类型 描述
taskId int 加速任务id
taskName string 加速任务名称
sourceModelVersionId int 源模型id

importModelVersionSourceExtra说明

名称 类型 描述
bucket string bos bucket
object string bos object

params说明

名称 类型 描述
input string 入参,json字符串
output int 出参,json字符串

deployResource说明

名称 类型 描述
isAvailablePublic bool 是否支持公有资源池
privateResource List 私有资源池支持信息

privateResource说明

名称 类型 描述
resourceType string 资源类型
cuNum integer 资源数级

HTTP调用

鉴权说明

调用本文API,使用“基于安全认证AK/SK”进行签名计算鉴权,即使用安全认证中的Access Key ID 和 Secret Access Key进行鉴权,具体鉴权认证机制参考HTTP调用鉴权说明

请求说明

  • 基本信息

请求地址: https://qianfan.baidubce.com/wenxinworkshop/modelrepo/modelVersionDetail

请求方式: POST

  • Header参数
名称 类型 必填 描述
Content-Type string 固定值:application/json
x-bce-date string 当前时间,遵循ISO8601规范,格式如2016-04-06T08:23:49Z
Authorization string 用于验证请求合法性的认证信息,更多内容请参考鉴权认证机制,签名工具可参考IAM签名工具
  • Body参数
名称 类型 必填 描述
modelVersionId string 模型版本id,示例:amv-g73j3faikzpz,说明:
(1)通过以下方式获取该字段值:
· 方式一,通过调用获取模型详情接口,返回的modelVersionIdStr字段获取
· 方式二,在控制台-我的模型-点击某模型详情,在版本列表中查看
image.png
(2)该字段新增支持string类型,如果之前使用的是int类型,建议变更为string类型,后续可能将逐步废弃int类型;例如通过调用获取模型详情接口,返回的modelVersionId字段获取,请替换为接口返回的modelVersionIdStr字段获取

响应说明

名称 类型 描述
log_id string 请求ID
result object 请求结果

result说明

名称 类型 描述
modelName string 模型名称
modelId integer 模型id,注意:该字段后续可能废弃,如需使用模型id,请使用modelIdStr
modelIdStr string 模型id
modelVersionId integer 版本id,注意:该字段后续可能废弃,如需使用版本id,请使用modelVersionIdStr
modelVersionIdStr string 版本id
state string 状态,说明:
Ready:已就绪
Creating:创建中
Fail:创建失败
version string 版本号
sourceType string 模型版本来源类型,说明:
Train:大模型训练产生
Acceleration:模型加速产生
PlatformPreset:平台预置模型版本
Import:外部导入模型
sourceExtra object 版本来源回溯信息
modelNet string 网络类型
framework string 版本框架
algorithm string 算法类型
description string 版本描述
createTime integer 版本创建时间戳
modifyTime string 版本修改时间戳
ioMode string 输入输出模式,说明:
chat:对话模式
completion:续写模式
ioLength string 输入输出长度,示例:3K+1K
params object 出入参
copyright string 版权信息,仅开源模型及其衍生模型返回该字段
license string 开源协议,仅预置开源模型返回该字段
property string 模型的额外属性信息,json字符串
deployResource object 模型可部署的资源池类型
supportOptions []string 模型支持的下游操作,说明:
Deploy:部署
Acceleration:压缩
Evaluation:评估
trainType string 基础模型,说明:
(1)字段值说明:
· 当基础模型是ernieBotLite各版本模型,该字段返回ernieBotLite;例如基础模型是ernieBotLite-v201-8k,返回trainType值为ernieBotLite
· 当基础模型是chatglm2-6b、chatglm2-6b-32k,该字段返回chatglm2-6b
· 其他,该字段返回对应基础模型
(2)在将训练任务发布为模型场景,使用该字段时,需注意以下,更多详情请参考训练任务发布为模型
该字段值需和模型调优-获取任务运行详情接口返回的trainType字段配合使用
isMainVersion bool 是否为主线版本
inputTokens int 输入tokens,说明:当模型为重排序Reranker类型,不返回此字段
outputTokens int 输出tokens,说明:当模型为重排序Reranker类型,不返回此字段
characterCnt int 上下文字符数,说明:当模型为重排序Reranker类型,不返回此字段
queryCharacterCnt int 查询Token字符限制,说明:只有当模型为重排序Reranker类型,返回此字段
docCharacterCnt int 文档Token字符限制,说明:只有当模型为重排序Reranker类型,返回此字段
queryTokens int 查询Token,说明:只有当模型为重排序Reranker类型,返回此字段
documentTokens int 文档Token,说明:只有当模型为重排序Reranker类型,返回此字段
baseModelId string 用户模型对应的基础模型id
baseModelVersionId string 用户模型对应的基础模型版本id

sourceExtra说明

名称 类型 描述
sourceType string 版本来源类型,不同类型对应不同的数据结构,说明:
Train:大模型训练产生
Acceleration:模型加速产生
Import:外部导入模型
trainSourceExtra object 大模型训练回溯信息
accelerationSourceExtra object 模型加速回溯信息
importModelVersionSourceExtra object 导入模型回溯信息

trainSourceExtra说明

名称 类型 描述
taskId integer 训练ID,注意:该字段后续可能废弃,如需使用训练ID,请使用taskIdStr
taskIdStr string 训练ID
taskName string 训练名称
iterationVersion integer 训练任务版本
runId integer 训练运行ID,注意:该字段后续可能废弃,如需训练运行ID,请使用runIdStr
runIdStr string 训练运行ID
devType integer 说明:
1:大模型调优
2:RLHF-奖励模型
3:RLHF-强化学习
modelType integer 模型类型
step integer 如果是选择的step发布,字段值为选择的对应step

accelerationSourceExtra说明

名称 类型 描述
taskId integer 加速任务id
taskName string 加速任务名称
sourceModelVersionId integer 源模型id

importModelVersionSourceExtra说明

名称 类型 描述
bucket string bos bucket
object string bos object

params说明

名称 类型 描述
input string 入参,json字符串
output integer 出参,json字符串

deployResource说明

名称 类型 描述
isAvailablePublic bool 是否支持公有资源池
privateResource []object 私有资源池支持信息

privateResource说明

名称 类型 描述
resourceType string 资源类型
cuNum integer 资源数级

请求示例

# 替换下列示例中的Authorization值、x-bce-date值、modelVersionId值
curl --location 'https://qianfan.baidubce.com/wenxinworkshop/modelrepo/modelVersionDetail' \
--header 'Authorization: bce-auth-v1/f0ee7axxxx/2023-09-19T13:42:13Z/180000/host;x-bce-date/9a8cfb8ee58a8f44a21a52640015de61bc55ca2e6d8cc23d080016e374525543' \
--header 'x-bce-date: 2023-09-19T13:37:10Z' \
--header 'Content-Type: application/json' \
--data '{
    "modelVersionId":"amv-g73j3faikzpz"
}'

响应示例

{
    "log_id": "3306310492",
    "result": {
        "modelId": 456,
        "modelIdStr": "am-txtetnsfq9sb",
        "modelName": "chatglm32k_v10",
        "modelVersionId": 638,
        "modelVersionIdStr": "amv-sxw7atka4jk0",
        "version": "2",
        "description": "clc_test_publish_chatglm32k_v10",
        "sourceType": "Train",
        "isMainVersion":"是否为主线版本",
        "inputTokens":xxx,
        "outputTokens":xxx,
        "characterCnt":xxx,
        "baseModelId":"xxxxx",
        "baseModelVersionId":"xxxxx",
        "sourceExtra": {
            "trainSourceExtra": {
                "taskId": 417,
                "taskIdStr": "job-bzh162wfyrg8",
                "taskName": "ccm_test",
                "iterationVersion": 4,
                "runId": 1498,
                "runIdStr": "task-g0b6i9pvn5sj",
                "devType": 1,
                "modelType": 20,
                "templateType": 2000
            },
            "sourceType": "Train"
        },
        "framework": "paddlepaddle",
        "algorithm": "ERNIE_EB-ERNIEBOT_V202_FUSE",
        "modelNet": "paddlepaddle-ERNIE_EB-ERNIEBOT_V202_FUSE",
        "state": "Ready",
        "ioMode": "chat",
        "ioLength": "",
        "copyright": "",
        "property": {},
        "createTime": "2023-12-15T16:30:06+08:00",
        "modifyTime": "2024-01-04T16:10:45+08:00",
        "deployResource": {
			"isAvailablePublic": false,
			"privateResource": [{
				"resourceType": "gpu",
				"cuNum": 2
			}]
		},
        "supportOptions": [
            "Deploy",
            "Evaluation"
        ],
        "trainType": "ernieBotLite",
        "params": {
            "input": {
                "type": "object",
                "required": [
                    "messages"
                ],
                "properties": {
                    "messages": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "required": [
                                "role",
                                "content"
                            ],
                            "properties": {
                                "role": {
                                    "name": "role",
                                    "type": "string",
                                    "default": "user",
                                    "description": "当前支持以下两个role: \"user\": 用户 \"assistant\": 对话助手"
                                },
                                "content": {
                                    "name": "content",
                                    "type": "string",
                                    "description": "对话内容,不能为空"
                                }
                            }
                        }
                    },
                    "stream": {
                        "name": "stream",
                        "type": "boolean",
                        "description": "是否以流式接口的形式返回数据; 默认false"
                    },
                    "user_id": {
                        "name": "user_id",
                        "type": "string",
                        "description": "表示最终用户的唯一标识符,可以监视和检测滥用行为,防止接口恶意调用。"
                    }
                }
            },
            "output": {
                "type": "object",
                "required": [],
                "properties": {
                    "id": {
                        "name": "id",
                        "type": "string",
                        "description": "本轮对话的id"
                    },
                    "object": {
                        "name": "object",
                        "type": "string",
                        "description": "回包类型 “chat.completion”:多轮对话返回"
                    },
                    "created": {
                        "name": "created",
                        "type": "integer",
                        "format": "int32",
                        "description": "时间戳"
                    },
                    "sentence_id": {
                        "name": "sentence_id",
                        "type": "integer",
                        "format": "int32",
                        "description": "流式接口模式下会返回,表示当前子句的序号"
                    },
                    "is_end": {
                        "name": "is_end",
                        "type": "boolean",
                        "description": "流式接口模式下会返回,表示当前子句是否是最后一句"
                    },
                    "is_truncated": {
                        "name": "is_truncated",
                        "type": "boolean",
                        "description": "标识当前生成的结果是否被截断"
                    },
                    "result": {
                        "name": "result",
                        "type": "string",
                        "description": "对话返回结果, 当前对话返回结果限制在1000个token"
                    },
                    "need_clear_history": {
                        "name": "need_clear_history",
                        "type": "boolean",
                        "description": "值为true表示用户输入存在安全风险,建议关闭当前会话,清理历史会话信息"
                    },
                    "ban_round": {
                        "name": "ban_round",
                        "type": "integer",
                        "format": "int32",
                        "description": "当need_clear_history为true时,此字段会告知第几轮对话有敏感信息,如果是当前问题,ban_round = -1"
                    },
                    "usage": {
                        "type": "object",
                        "required": [],
                        "description": "token统计信息,token数 = 汉字数+单词数*1.3 (仅为估算逻辑)",
                        "properties": {
                            "prompt_tokens": {
                                "name": "prompt_tokens",
                                "type": "integer",
                                "format": "int32",
                                "description": "问题tokens数(包含历史QA)"
                            },
                            "completion_tokens": {
                                "name": "completion_tokens",
                                "type": "integer",
                                "format": "int32",
                                "description": "回答tokens数"
                            },
                            "total_tokens": {
                                "name": "total_tokens",
                                "type": "integer",
                                "format": "int32",
                                "description": "tokens总数"
                            }
                        }
                    }
                }
            }
        }
    }
}

错误码

若请求错误,服务器将返回的JSON文本包含以下参数:

名称 描述
error_code 错误码
error_msg 错误描述信息,帮助理解和解决发生的错误

例如参数错误返回:

{
  "error_code": 500001,
  "error_msg": "param invalid"
}

更多错误码,请查看错误码说明