文心一言-千帆大模型平台
  1. Llama-2
文心一言-千帆大模型平台
  • 体验中心
  • 常见问题
  • 大模型技术测试服务协议
  • 账号与权限管理
    • 账号创建与权限分配
    • 通过子账户隔离实现账单隔离
  • 产品简介
    • 什么是百度智能云千帆大模型平台
    • 百度智能云千帆大模型平台产品优势
    • 百度智能云千帆大模型平台常用概念
  • 新手指南
    • SFT调优快速手册
    • SFT最佳实践
    • 平台使用快速开始
    • 导入并部署第三方模型
      • 快速导入并部署第三方模型
      • SQLCoder自定义模型导入·详细操作
  • 模型广场
    • 查看与管理预置模型
    • 预置调用免费模型列表
  • 我的模型
    • 创建我的模型
    • 查看与管理我的模型
  • Prompt 工程
    • 什么 Prompt 工程
    • Prompt 模板
    • Prompt 优化
    • Prompt 工程使用技巧
      • Prompt 的使用技巧
      • 基础的 Basic Prompt Framework
      • 丰富的 CRISPE Prompt Framework
      • 轻量化的 Few-shot Prompt
  • 模型服务
    • 应用接入
    • 在线服务
    • 调用统计
  • 模型调优
    • 模型精调
      • Post-pretrain
        • 什么是 Post-pretrain
        • 创建 Post-pretrain 任务
        • 查看与管理 Post-pretrain
      • SFT
        • 创建 SFT 任务
        • 查看与管理 SFT 运行
      • RLHF
        • 什么是 RLHF 训练
        • 创建奖励模型训练任务
        • 查看与管理奖励模型训练运行
        • 创建强化学习训练任务
        • 查看与管理强化学习训练运行
    • 模型评估
      • 创建模型评估任务
      • 查看与管理模型评估任务
    • 模型压缩
      • 创建模型压缩任务
      • 查看模型压缩任务
  • 数据管理
    • 数据回流
    • 数据集对应关系说明
    • 数据集管理
      • 创建数据集
      • 数据分析
      • 导入文本对话数据
      • 导入泛文本无标注数据
      • 导入 query 问题集数据
      • 导入文生图数据
      • 管理数据集版本
      • 导出数据
      • 数据集的其他操作
    • 数据标注
      • 在线标注
      • 众测标注
    • 数据处理
      • 数据清洗
      • 数据增强
    • 知识库
      • 什么是千帆大模型知识库
      • 知识库管理
      • 命中测试
  • 系统配置
    • 计算资源
    • 计费管理
    • 插件编排
      • 什么是插件应用
      • 插件编排使用说明
      • 应用创建
        • 对话场景类应用
        • 生成场景类应用
      • 插件
        • 插件列表
        • 自定义插件
        • 插件开发者文档
  • API 鉴权及调用
    • API 介绍
    • API 列表
    • API 调用指南
      • API 调用流程
      • 错误码
      • API 在线调试
    • 鉴权认证
      • 鉴权介绍
      • 使用网页调试工具获取 access_token
      • 获取 access_token
    • 对话 Chat
      • Llama-2
        • Llama-2-7b-chat
          POST
        • Llama-2-13b-chat
          POST
        • Llama-2-70b-chat
          POST
      • ERNIE-Bot 4.0
        POST
      • ERNIE-Bot
        POST
      • ERNIE-Bot-turbo
        POST
      • BLOOMZ-7B
        POST
      • Qianfan-BLOOMZ-7B-compressed
        POST
      • Mistral-7B-Instruct
        POST
      • Qianfan-Chinese-Llama-2-7B
        POST
      • Qianfan-Chinese-Llama-2-13B
        POST
      • Linly-Chinese-LLaMA-2-7B
        POST
      • Linly-Chinese-LLaMA-2-13B
        POST
      • ChatGLM2-6B
        POST
      • ChatGLM2-6B-32K
        POST
      • ChatGLM2-6B-INT4
        POST
      • Baichuan2-13B-Chat
        POST
      • XVERSE-13B-Chat
        POST
      • Falcon-7B
        POST
      • Falcon-40B-Instruct
        POST
      • AquilaChat-7B
        POST
      • RWKV-4-World
        POST
      • RWKV-4-pile-14B
        POST
      • RWKV-Raven-14B
        POST
      • OpenLLaMA-7B
        POST
      • Dolly-12B
        POST
      • MPT-7B-Instruct
        POST
      • MPT-30B-instruct
        POST
      • OA-Pythia-12B-SFT-4
        POST
      • Falcon-180B-Chat
        POST
      • RWKV-5-World
        POST
      • Flan-UL2
        POST
    • 续写 Completions
      • SQLCoder-7B
      • CodeLlama-7b-Instruct
      • AquilaCode-multi
      • Cerebras-GPT-13B
      • Pythia-12B
      • GPT-J-6B
      • GPT-NeoX-20B
      • GPT4All-J
      • StarCoder
      • StableLM-Alpha -7B
      • Pythia-6.9B
      • Cerebras-GPT-6.7B
    • 向量 Embeddings
      • Embedding-V1
      • bge-large-zh
      • bge-large-en
    • 图像 Images
      • Stable-Diffusion-XL
    • 自定义模型调用 API
      • 自定义模型调用 API
      • 续写模式
    • 模型服务
      • 创建服务
      • 查询服务详情
    • 模型管理
      • 获取模型版本详情
      • 获取模型详情
      • 训练任务发布为模型
    • 模型调优
      • 创建训练任务
      • 创建任务运行
      • 获取任务运行详情
      • 停止任务运行
    • 数据管理
      • 创建数据集
      • 发起数据集发布任务
      • 发起数据集导入任务
      • 获取数据集详情
      • 获取数据集状态详情
      • 发起数据集导出任务
      • 删除数据集
      • 获取数据集导出记录
      • 获取数据集导入错误详情
    • Prompt 工程
      • Prompt 模板
    • 插件应用
      • 知识库
      • 智慧图问
      • 天气
  • SDK 参考
    • 千帆 SDK 介绍
    • SDK 安装及使用流程
    • 对话 Chat
    • 续写 Completions
    • 向量 Embeddings
    • 模型服务
      • 创建服务
      • 查询服务详情
    • 模型管理
      • 获取模型详情
      • 获取模型版本详情
      • 训练任务发布为模型
    • 模型调优
      • 创建训练任务
      • 创建任务运行
      • 获取任务运行详情
      • 停止任务运行
    • 数据管理
      • 创建数据集
      • 发起数据集发布任务
      • 发起数据集导入任务
      • 获取数据集详情
      • 获取数据集状态详情
      • 发起数据集导出任务
      • 删除数据集
      • 获取数据集导出记录
      • 获取数据集导入错误详情
    • 插件应用
      • 知识库
      • 智能图问
      • 天气
  • 价格说明
    • 千帆大模型平台价格文档
  1. Llama-2

Llama-2-13b-chat

开发环境
http://dev-cn.your-api-server.com
开发环境
http://dev-cn.your-api-server.com
POST
https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/llama_2_13b
Llama-2-13b-chat由Meta AI研发并开源,在编码、推理及知识应用等场景表现优秀,Llama-2-13b-chat是性能与效果均衡的原生开源版本,适用于对话场景。本文介绍了相关API。

创建chat#

调用本接口,发起一次对话请求。

返回说明#

注意 :同步模式和流式模式,响应参数返回不同,详细内容参考示例描述。
同步模式下,响应参数为以上字段的完整json包。
流式模式下,各字段的响应参数为 data: {响应参数}。

请求示例(多轮)#

bash
Python

响应示例(多轮)#

JSON
{
    "id": "as-hn4futxccq",
    "object": "chat.completion",
    "created": 1693290436,
    "result": " Sure, I can help you with that! Shanghai is a city located in eastern China, and its weather is influenced by its coastal position and subtropical maritime climate. Here's what you can expect:\n\n1. Seasonal weather: Shanghai has four distinct seasons, with hot and humid summers, and cold and dry winters. The best time to visit Shanghai is in the spring (March to May) and autumn (September to November), when the weather is mild and comfortable.\n2. Temperature: The average temperature in Shanghai ranges from 2°C (36°F) in January (the coldest month) to 28°C (82°F) in July (the hottest month).\n3. Humidity: Shanghai is known for its high humidity, especially during the summer months. The average relative humidity is around 60-70%, but it can feel much higher due to the heat and moisture in the air.\n4. Sunshine: Shanghai experiences a significant amount of sunshine throughout the year, with an average of 1,900 hours of sunshine per year.\n5. Rainfall: Shanghai receives most of its rainfall during the summer months, with an average of 10-15 rainy days per month from June to August.\n6. Typhoons: Shanghai is susceptible to typhoons, which are tropical cyclones that form in the Pacific Ocean and can bring strong winds, heavy rainfall, and flooding to the city. The typhoon season in Shanghai typically runs from June to September.\n\nOverall, the weather in Shanghai can be quite hot and humid during the summer months, and cold and dry during the winter months. It's important to pack accordingly and be prepared for the season you're visiting in.",
    "is_truncated": false,
    "need_clear_history": false,
    "usage": {
        "prompt_tokens": 147,
        "completion_tokens": 345,
        "total_tokens": 492
    }
}

请求示例(流式)#

bash
Python

响应示例(流式)#

data: {"id":"as-wyjuy3n4vb","object":"chat.completion","created":1693290799,"sentence_id":0,"is_end":false,"is_truncated":false,"result":" Hello! As a helpful and respectful assistant, I\'d be happy to recommend some Chinese self-driving tour routes for you!\\n\\nBefore I begin, I just want to clarify that it\'s important to always prioritize safety when traveling, especially when driving. It\'s essential to follow all local traffic laws and regulations, and to be mindful of your own and others\' well-being on the road.\\n\\nWith that said, ","need_clear_history":false,"usage":{"prompt_tokens":11,"completion_tokens":91,"total_tokens":102}}

data: {"id":"as-wyjuy3n4vb","object":"chat.completion","created":1693290801,"sentence_id":1,"is_end":false,"is_truncated":false,"result":"here are some popular Chinese self-driving tour routes that you may consider:\\n\\n1. The Golden Route: This route takes you through some of China\'s most iconic destinations, including Beijing, Xi\'an, Lhasa, and Shanghai. You\'ll have the opportunity to explore the Forbidden City, the Great Wall, and the Potala Palace, among other famous landmarks.\\n2. The Yellow Mountains Route: This route takes you through the stunning Yellow ","need_clear_history":false,"usage":{"prompt_tokens":11,"completion_tokens":91,"total_tokens":193}}

data: {"id":"as-wyjuy3n4vb","object":"chat.completion","created":1693290803,"sentence_id":2,"is_end":false,"is_truncated":false,"result":"Mountains in Anhui Province, known for their breathtaking scenery and unique rock formations. You\'ll have the chance to hike, bike, and take in the natural beauty of this UNESCO World Heritage Site.\\n3. The Silk Road Route: This route takes you through the ancient Silk Road, which connects China with Central Asia and the Middle East. You\'ll have the opportunity to explore historic sites like ","need_clear_history":false,"usage":{"prompt_tokens":11,"completion_tokens":87,"total_tokens":280}}

data: {"id":"as-wyjuy3n4vb","object":"chat.completion","created":1693290806,"sentence_id":3,"is_end":false,"is_truncated":false,"result":"the Terracotta Warriors in Xi\'an, the ancient city of Loulan in Xinjiang, and the majestic Karakoram Highway.\\n4. The Tibetan Plateau Route: This route takes you through the breathtaking landscapes of the Tibetan Plateau, including the Nyingchi Prefecture and the Mount Kailash region. You\'ll have the chance to experience the unique culture and stunning natural beauty of this remote and sacred region.\\n5. The Coastal Route: ","need_clear_history":false,"usage":{"prompt_tokens":11,"completion_tokens":88,"total_tokens":368}}

data: {"id":"as-wyjuy3n4vb","object":"chat.completion","created":1693290808,"sentence_id":4,"is_end":false,"is_truncated":false,"result":"This route takes you along China\'s stunning coastline, including the cities of Qingdao, Tianjin, and Shanghai. You\'ll have the opportunity to explore historic sites like the Great Wall, enjoy delicious seafood, and take in the vibrant city life of these bustling coastal cities.\\n\\nThese are just a few examples of the many Chinese self-driving tour routes available. Before embarking on your journey, I recommend doing ","need_clear_history":false,"usage":{"prompt_tokens":11,"completion_tokens":88,"total_tokens":456}}

data: {"id":"as-wyjuy3n4vb","object":"chat.completion","created":1693290810,"sentence_id":5,"is_end":true,"is_truncated":false,"result":"thorough research on the routes and destinations that interest you, and planning your itinerary accordingly. Additionally, be sure to check the current travel advisories and local health and safety guidelines before traveling.\\n\\nI hope this information is helpful in planning your Chinese self-driving tour! If you have any further questions or need more information, please don\'t hesitate to ask.","need_clear_history":false,"usage":{"prompt_tokens":11,"completion_tokens":79,"total_tokens":535}}

错误码#

如果请求错误,服务器返回的JSON文本包含以下参数。
名称描述
error_code错误码
error_msg错误描述信息,帮助理解和解决发生的错误
例如Access Token失效返回以下内容,需要重新获取新的Access Token再次请求。
{
  "error_code": 110,
  "error_msg": "Access token invalid or no longer valid"
}
千帆大模型平台相关错误码,请查看错误码说明。
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/llama_2_13b?access_token	=' \
--header 'Content-Type: application/json' \
--data-raw '{
    "messages\t": [
        {
            "role\t": "string",
            "content": "string"
        }
    ],
    "stream": true,
    "temperature\t": 0,
    "top_k\t": 0,
    "top_p\t": 0,
    "penalty_score": 0,
    "stop\t": [
        "string"
    ],
    "user_id": "string"
}'
响应示例响应示例
{
    "id": "string",
    "object": "string",
    "created": 0,
    "result": "string",
    "is_truncated": true,
    "need_clear_history": true,
    "usage": {
        "prompt_tokens": 0,
        "completion_tokens": 0,
        "total_tokens": 0
    }
}

请求参数

Query 参数

Body 参数application/json

示例

返回响应

🟢200成功
application/json
Body

修改于 2023-11-15 09:15:18
上一页
Llama-2-7b-chat
下一页
Llama-2-70b-chat
Built with