---
title: baichuan_agent
canonical_url: "https://www.modelscope.cn/models/HOPE_FOR_FUTURE/baichuan_agent"
md_url: "https://www.modelscope.cn/models/HOPE_FOR_FUTURE/baichuan_agent.md"
repository: HOPE_FOR_FUTURE/baichuan_agent
last_updated: 2023-07-10
license: "Apache License 2.0"
pipeline_tag: text-generation
tasks:
  - text-generation
library_name:
  - pytorch
frameworks:
  - Pytorch
downloads: 205
stars: 9
tags:
  - Baichuan
---

# baichuan_agent

> baichuan_agent - HOPE_FOR_FUTURE 在 ModelScope 开源的模型。Baichuan Agent是基于Baichuan-7B在3k条agent数据集中通过lora微调得到的具有api调用能力的agent模型。Baichuan Agent能够在提供的几种api场景上，模型自适应的去生成调用请求。

HOPE_FOR_FUTURE/baichuan_agent 是 ModelScope 魔搭社区上的text-generation模型，采用 Apache License 2.0 许可。

- **Repository**: HOPE_FOR_FUTURE/baichuan_agent
- **License**: Apache License 2.0
- **Tasks**: text-generation
- **Tags**: Baichuan
- **Downloads**: 205
- **Stars**: 9
- **Last updated**: 2023-07-10

Source: https://www.modelscope.cn/models/HOPE_FOR_FUTURE/baichuan_agent

---

## Baichuan Agent

<div align=center>
<img src="image.png" width="400" />
</div>

Baichuan Agent是基于Baichuan-7B在3k条agent数据集中通过lora微调得到的具有api调用能力的agent模型。Baichuan Agent能够在提供的几种api场景上，模型自适应的去生成调用请求。

可以通过集成一些小模型到LLM，增强LLM本身缺失的能力（比如，语音、视频、图像），以完成一些复杂的AI任务。

## 可调用APIs

- 地址识别：[MGeo门址地址结构化要素解析-中文-地址领域-base](https://modelscope.cn/models/damo/mgeo_geographic_elements_tagging_chinese_base/summary)
- 通用信息抽取：[SiameseUIE通用信息抽取-中文-base](https://modelscope.cn/models/damo/nlp_structbert_siamese-uie_chinese-base/summary)
- 图片生成：[通义-文本生成图像大模型-中英文-通用领域](https://modelscope.cn/models/damo/cv_diffusion_text-to-image-synthesis/summary)
- 语音合成：[语音合成-中文-多情感领域-16k-多发音人](https://modelscope.cn/models/damo/speech_sambert-hifigan_tts_zh-cn_16k/summary)

## 使用方法

```python
from modelscope import pipeline, snapshot_download
from modelscope.utils.constant import Tasks
import torch

prompt = """{system}

### 用户
{user}

### 助手
"""
model_id = "HOPE_FOR_FUTURE/baichuan_agent"
model_dir = snapshot_download(model_id, "v1.0.5")
system = """你是达摩院的ModelScopeGPT(魔搭助手)，你是个大语言模型， 是2023年达摩院的工程师训练得到的。你有多种能力，可以通过插件集成魔搭社区的模型api来回复用户的问题，还能解答用户使用模型遇到的问题和模型知识相关问答。1. {"plugin_name": "modelscope_text-address", "plugin_owner": "ModelScopeGPT", "plugin_type": "default", "plugin_schema_for_model": {"name": "modelscope_text-address", "description": "针对中文的地址信息，识别出里面的元素，包括省、市、区、镇、社区、道路、路号、POI、楼栋号、户室号等", "url": "http://159.1.4.174:3210/", "paths": [{"name": "modelscope_text-address", "model_id": "/damo/mgeo_geographic_elements_tagging_chinese_base", "method": "post", "description": "针对中文的地址信息，识别出里面的元素，包括省、市、区、镇、社区、道路、路号、POI、楼栋号、户室号等", "parameters": [{"name": "text", "description": "用户输入的地址信息", "required": "True"}]}]}}

2. {\"plugin_name\": \"modelscope_speech-generation\", \"plugin_owner\": \"ModelScopeGPT\", \"plugin_type\": \"default\", \"plugin_schema_for_model\": {\"name\": \"modelscope_speech-generation\", \"description\": \"针对回复的内容，用语音表示，同时可以选择是男声或者女声\", \"url\": \"http://90.49.118.175:2603/\", \"paths\": [{\"name\": \"modelscope_speech-generation\", \"model_id\": \"/damo/speech_sambert-hifigan_tts_zh-cn_16k\", \"method\": \"post\", \"description\": \"针对回复的内容，用语音表示，同时可以选择是男声或者女声\", \"parameters\": [{\"name\": \"text\", \"description\": \"要转成语音的文本\", \"required\": \"True\"}, {\"name\": \"gender\", \"description\": \"用户身份\", \"required\": \"True\"}]}]}}

3. {\"plugin_name\": \"modelscope_text-ie\", \"plugin_owner\": \"ModelScopeGPT\", \"plugin_type\": \"default\", \"plugin_schema_for_model\": {\"name\": \"modelscope_text-ie\", \"description\": \"针对中文的文本，根据schema要抽取的内容，找出其中对应信息，并用json格式展示\", \"url\": \"http://114.42.178.183:8005/\", \"paths\": [{\"name\": \"modelscope_text-ie\", \"model_id\": \"/damo/nlp_structbert_siamese-uie_chinese-base\", \"method\": \"post\", \"description\": \"针对中文的文本，根据schema要抽取的内容，找出其中对应信息，并用json格式展示\", \"parameters\": [{\"name\": \"text\", \"description\": \"用户输入的文本\", \"required\": \"True\"}, {\"name\": \"schema\", \"description\": \"要抽取信息的json表示\", \"required\": \"True\"}]}]}}"""

user = '现在我给你另一条地址，请识别出里面的元素。输入地址：广东省深圳市南山区科技园北区'
text = prompt.format(system=system, user=user)

pipe = pipeline(Tasks.text_generation, model=model_dir, device_map='auto', torch_dtype=torch.float16)
pipe(text)
"""
<|startofthink|>```JSON
{"api_name": "modelscope_text-address", "url": "http://172.163.158.154:5325/damo/mgeo_geographic_elements_tagging_chinese_base", "parameters": {"text": "广东省深圳市南山区科技园北区"}}
```<|endofthink|>

<|startofexec|>```JSON
{"prov": "广东省", "city": "深圳市", "district": "南山区", "road": "科技园北区"}
```<|endofexec|>
地址识别json表示：{"prov": "广东省", "city": "深圳市", "district": "南山区", "road": "科技园北区"}。我使用的模型是ModelScope的'damo/mgeo_geographic_elements_tagging_chinese_base'模型。这是基于达摩院联合高德发布的多任务多模态地址预训练底座MGeo模型微调得到的。
"""
```


#### Clone with HTTP
```bash
 git clone https://www.modelscope.cn/HOPE_FOR_FUTURE/baichuan_agent.git
```
