获取模型详情
所有文档
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_list = resources.Model.list(model_id = "am-gh0azfeb9adu")
print(model_list)

返回示例

QfResponse(code=200,
           headers={...},
           body={
               'log_id': '2299317951',
               'result': {
                   'modelId':5862,
                   'modelIdStr': 'am-txtetxxxq9sb',
                   'modelName':'强化_bloom',
                   'source':'UserCreate',
                   'modelType':0,
                   'createUserId':20,
                   'createUser':'baidu_aipd',
                   'createTime':'2023-09-22T22:41:11+08:00',
                   'modifyTime':'2023-09-22T22:41:11+08:00',
                   'description':'',
                   'languageSupport':['xxx'],
                   'expansion':['xxx'],
                   'modelVersionList': [{
                       'modelId':5862,
                       'modelIdStr': 'am-txtetxxxq9sb',
                       'modelName':'强化_bloom',
                       'modelVersionId':7203,
                       'modelVersionIdStr': 'amv-sxw7xxxa4jk0',
                       'version':'1',
                       'description':'',
                       'sourceType':'Train',
                       'sourceExtra': {
                           'trainSourceExtra': {
                               'taskId': 8753,
                               'taskName': 'cmc_rlhf',
                               'iterationVersion': 1,
                               'runId': 4973,
                               'devType': 3,
                               'modelType': 20,
                               'templateType': 2000
                           },
                           'sourceType': 'Train'
                       },
                       'framework':'pytorch',
                       'algorithm':'opensource-bloomz-7b1-mt',
                       'modelNet':'bloomz-7b1-mt',
                       'state':'Ready',
                       'ioMode':'chat',
                       'ioLength':'',
                       'copyright':'Copyright (C) BigScience',
                       'property': {},
                       'createTime':'2023-09-22T22:41:11+08:00',
                       'modifyTime':'2023-09-22T22:43:13+08:00',
                       'deployResource': ['Private'],
                       'supportOptions':
                       ['Deploy', 'Evaluation', 'Acceleration'] 
                   }],
                   'trainType':'ernieBotLite'
               }
           })

请求参数

名称 类型 必填 描述
model_id string 模型ID,示例:am-gh0azfeb9adu,说明:
(1)通过以下方法获取该字段值:在控制台-我的模型查看,如下图所示
image.png
(2)该字段新增支持string类型,如果之前使用的是int类型,建议变更为string类型,后续可能将逐步废弃int类型

返回参数

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

result说明

名称 类型 描述
modelId string 模型id,注意:该字段后续可能废弃,如需使用模型id,请使用modelIdStr
modelIdStr string 模型id,字符串类型
modelName string 模型名称
modelType int 模型类型
source string 模型来源,说明:
用户模型:UserCreate
预置模型:PlatformPreset
tags list[string] 业务标签
createUser string 创建人
createUserId string 创建人id
createTime string 创建时间
modifyTime string 修改时间
description string 模型描述,只有模型来源source字段是预置模型PlatformPreset时,返回该字段
languageSupport string[] 支持的语言,示例值“中文”
expansion string[] 模型扩展能力,示例值“人设增强”
modelVersionList list[dict] 模型版本列表
trainType string 基础模型,说明:
(1)字段值说明:
· 当基础模型是ernieBotLite各版本模型,该字段返回ernieBotLite;例如基础模型是ernieBotLite-v201-8k,返回trainType值为ernieBotLite
· 当基础模型是chatglm2-6b、chatglm2-6b-32k,该字段返回chatglm2-6b
· 其他,该字段返回对应基础模型
(2)在将训练任务发布为模型场景,使用该字段时,需注意以下,更多详情请参考训练任务发布为模型
该字段值需和模型调优-获取任务运行详情接口返回的trainType字段配合使用

modelVersionList说明

名称 类型 描述
modelId string 模型id,注意:该字段后续可能废弃,如需使用模型id,请使用modelIdStr
modelIdStr string 模型id
modelName string 模型名称
modelVersionId string 版本id,注意:该字段后续可能废弃,如需使用模型id,请使用modelVersionIdStr
modelVersionIdStr string 版本id
version string 版本号
description string 描述
sourceType string 模型版本来源类型,说明:
Train:大模型训练产生
Acceleration:模型加速产生
PlatformPreset:平台预置模型版本
Import:外部导入模型
sourceExtra string 模型版本来源详细信息
modelNet string 网络类型
framework string 框架
algorithm string 算法
state string 状态,说明:
Ready:已就绪
Creating:创建中
Fail:创建失败
createTime string 创建时间
modifyTime string 修改时间
ioMode string 输入输出模式,说明:
chat:对话模式
completion:续写模式
ioLength string 输入输出大小,示例:3K+1K
copyright string 版权信息,仅开源模型及其衍生模型返回该字段
license string 开源协议,仅预置开源模型返回该字段
property string 模型的额外属性信息
deployResource list[string] 模型可部署的资源池类型,说明:
Public:公共资源池
Private:私有资源池
supportOptions list[string] 模型支持的下游操作,说明:
Deploy:部署
Acceleration:压缩
Evaluation:评估
queryCharacterCnt int 查询Token字符限制,说明:只有当模型为重排序Reranker类型,返回此字段
docCharacterCnt int 文档Token字符限制,说明:只有当模型为重排序Reranker类型,返回此字段
queryTokens int 查询Token,说明:只有当模型为重排序Reranker类型,返回此字段
documentTokens int 文档Token,说明:只有当模型为重排序Reranker类型,返回此字段

HTTP调用

鉴权说明

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

请求说明

  • 基本信息

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

请求方式: POST

  • Header参数
名称 类型 必填 描述
Content-Type string 固定值:application/json
x-bce-date string 当前时间,遵循ISO8601规范,格式如2016-04-06T08:23:49Z
Authorization string 用于验证请求合法性的认证信息,更多内容请参考鉴权认证机制,签名工具可参考IAM签名工具
  • Body参数
名称 类型 必填 描述
modelId string 模型ID,示例:am-gh0azfeb9adu,说明:
(1)通过以下方法获取该字段值:在控制台-我的模型查看,如下图所示
image.png
(2)该字段新增支持string类型,如果之前使用的是number类型,建议变更为string类型,后续可能将逐步废弃number类型

响应说明

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

result说明

名称 类型 描述
modelId int 模型id,注意:该字段后续可能废弃,如需使用模型id,请使用modelIdStr
modelIdStr string 模型id,字符串类型
modelName string 模型名称
modelType integer 模型类型
source string 模型来源,说明:
· 用户模型:UserCreate
· 预置模型:PlatformPreset
tags string[] 业务标签
createUser string 创建人
createUserId integer 创建人id
createTime string 创建时间
modifyTime string 修改时间
description string 模型描述,只有模型来源source字段是预置模型PlatformPreset时,返回该字段
languageSupport string[] 支持的语言,示例值“中文”
expansion string[] 模型扩展能力,示例值“人设增强”
modelVersionList object[] 模型版本列表
trainType string 基础模型,说明:
(1)字段值说明:
· 当基础模型是ernieBotLite各版本模型,该字段返回ernieBotLite;例如基础模型是ernieBotLite-v201-8k,返回trainType值为ernieBotLite
· 当基础模型是chatglm2-6b、chatglm2-6b-32k,该字段返回chatglm2-6b
· 其他,该字段返回对应基础模型
(2)在将训练任务发布为模型场景,使用该字段时,需注意以下,更多详情请参考训练任务发布为模型
该字段值需和模型调优-获取任务运行详情接口返回的trainType字段配合使用

modelVersionList说明

名称 类型 描述
modelId int 模型id,注意:该字段后续可能废弃,如需使用模型id,请使用modelIdStr
modelIdStr string 模型id
modelName string 模型名称
modelVersionId int 版本id,注意:该字段后续可能废弃,如需使用模型id,请使用modelVersionIdStr
modelVersionIdStr string 版本id
version string 版本号
description string 描述
sourceType string 模型版本来源类型,说明:
· Train:大模型训练产生
· Acceleration:模型加速产生
· PlatformPreset:平台预置模型版本
· Import:外部导入模型
sourceExtra string 模型版本来源详细信息
modelNet string 网络类型
framework string 框架
algorithm string 算法
state string 状态,说明:
· Ready:已就绪
· Creating:创建中
· Fail:创建失败
createTime string 创建时间
modifyTime string 修改时间
ioMode string 输入输出模式,说明:
· chat:对话模式
· completion:续写模式
ioLength string 输入输出大小,示例:3K+1K
copyright string 版权信息,仅开源模型及其衍生模型返回该字段
license string 开源协议,仅预置开源模型返回该字段
property string 模型的额外属性信息
deployResource string[] 模型可部署的资源池类型,说明:
· Public:公共资源池
· Private:私有资源池
supportOptions string[] 模型支持的下游操作,说明:
· Deploy:部署
· Acceleration:压缩
· Evaluation:评估
queryCharacterCnt int 查询Token字符限制,说明:只有当模型为重排序Reranker类型,返回此字段
docCharacterCnt int 文档Token字符限制,说明:只有当模型为重排序Reranker类型,返回此字段
queryTokens int 查询Token,说明:只有当模型为重排序Reranker类型,返回此字段
documentTokens int 文档Token,说明:只有当模型为重排序Reranker类型,返回此字段

请求示例

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

响应示例

{
    "log_id": "2268019247",
    "result": {
        "modelId": 456,
        "modelIdStr": "am-txtetnsfq9sb",
        "modelName": "chatglm32k_v10",
        "source": "UserCreate",
        "modelType": 0,
        "createUserId": 1,
        "createUser": "百xx蕊",
        "createTime": "2023-12-15T16:18:39+08:00",
        "modifyTime": "2023-12-28T11:33:07+08:00",
        "description": "",
        "trainType": "ernieBotLite",
        "languageSupport":["xxx"],
        "expansion":["xxx"],
        "modelVersionList": [
            {
                "modelId": 456,
                "modelIdStr": "am-txtetnsfq9sb",
                "modelName": "chatglm32k_v10",
                "modelVersionId": 638,
                "modelVersionIdStr": "amv-sxw7atka4jk0",
                "version": "2",
                "description": "clc_test_publish_chatglm32k_v10",
                "sourceType": "Train",
                "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": [
                    "Private"
                ],
                "supportOptions": [
                    "Deploy",
                    "Evaluation"
                ],
                "trainType": "ernieBotLite"
            },
            {
                "modelId": 456,
                "modelIdStr": "am-txtetnsfq9sb",
                "modelName": "chatglm32k_v10",
                "modelVersionId": 637,
                "modelVersionIdStr": "amv-dh7vgw3wacyy",
                "version": "1",
                "description": "",
                "sourceType": "Train",
                "sourceExtra": {
                    "trainSourceExtra": {
                        "taskId": 390,
                        "taskIdStr": "job-bmevuxzs5a1p",
                        "taskName": "chatglm32k",
                        "iterationVersion": 10,
                        "runId": 1442,
                        "runIdStr": "task-r7kttcs8i8t3",
                        "devType": 1,
                        "modelType": 20,
                        "templateType": 2000
                    },
                    "sourceType": "Train"
                },
                "framework": "pytorch",
                "algorithm": "opensource-chatglm2-6b-32k",
                "modelNet": "pytorch-chatglm2-6b-32k-1.13.1",
                "state": "Ready",
                "ioMode": "chat",
                "ioLength": "",
                "copyright": "",
                "property": {},
                "createTime": "2023-12-15T16:18:39+08:00",
                "modifyTime": "2024-01-04T16:10:45+08:00",
                "deployResource": [
                    "Private"
                ],
                "supportOptions": [
                    "Deploy",
                    "Export"
                ],
                "trainType": "chatglm2-6b"
            }
        ]
    }
}

错误码

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

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

例如参数错误返回:

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

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