---
title: Llama3-Chinese-8B-Instruct-Agent-v1
canonical_url: "https://www.modelscope.ai/models/swift/Llama3-Chinese-8B-Instruct-Agent-v1"
md_url: "https://www.modelscope.ai/models/swift/Llama3-Chinese-8B-Instruct-Agent-v1.md"
repository: swift/Llama3-Chinese-8B-Instruct-Agent-v1
last_updated: 2025-09-06
license: "Apache License 2.0"
pipeline_tag: text-generation
tasks:
  - text-generation
model_type:
  - llama
library_name:
  - safetensors
  - pytorch
frameworks:
  - Pytorch
downloads: 131
stars: 0
---

# Llama3-Chinese-8B-Instruct-Agent-v1

> Llama3-Chinese-8B-Instruct-Agent-v1 - An open-source model by swift on ModelScope. 魔搭Llama3 8b中文Agent智能体模型

swift/Llama3-Chinese-8B-Instruct-Agent-v1 is a text-generation model on ModelScope. licensed under Apache License 2.0.

- **Repository**: swift/Llama3-Chinese-8B-Instruct-Agent-v1
- **License**: Apache License 2.0
- **Tasks**: text-generation
- **Downloads**: 131
- **Stars**: 0
- **Last updated**: 2025-09-06

Source: https://www.modelscope.ai/models/swift/Llama3-Chinese-8B-Instruct-Agent-v1

---

# 魔搭Llama3 8b中文Agent智能体模型

本模型使用Llama3-8b-instruct基模型进行训练，适配中文通用场景，且支持ReACT格式的Agent调用。

## 模型使用

### 推理

```shell
# 安装依赖
pip install ms-swift -U
```

```python
# 推理
swift infer --model_type llama3-8b-instruct --model_id_or_path swift/Llama3-Chinese-8B-Instruct-Agent-v1
```

```shell
# 部署
swift deploy --model_type llama3-8b-instruct --model_id_or_path swift/Llama3-Chinese-8B-Instruct-Agent-v1
```

本模型可以联合ModelScopeAgent框架使用，请参考：

https://github.com/modelscope/swift/blob/main/docs/source/LLM/Agent%E5%BE%AE%E8%B0%83%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5.md#%E6%90%AD%E9%85%8Dmodelscope-agent%E4%BD%BF%E7%94%A8

### 模型训练信息

为了适配中文及Agent场景，我们针对语料进行了一定混合配比，训练Llama3使用的语料如下：

\- COIG-CQIA：https://modelscope.cn/datasets/AI-ModelScope/COIG-CQIA/summary 该数据集包含了中国传统知识、豆瓣、弱智吧、知乎等中文互联网信息

\- 魔搭通用Agent训练数据集: https://modelscope.cn/datasets/AI-ModelScope/ms-agent-for-agentfabric/summary

\- alpaca-en: https://modelscope.cn/datasets/AI-ModelScope/alpaca-gpt4-data-en/summary

\- ms-bench魔搭通用中文问答数据集: https://modelscope.cn/datasets/iic/ms_bench/summary

| **超参数**                  | **值** |
| --------------------------- | ------ |
| lr                          | 5e-5   |
| epoch                       | 2      |
| lora_rank                   | 8      |
| lora_alpha                  | 32     |
| lora_target_modules         | ALL    |
| batch_size                  | 2      |
| gradient_accumulation_steps | 16     |

## 模型训练命令

```shell
NPROC_PER_NODE=8 \
swift sft \
  --model_type llama3-8b-instruct \
  --dataset ms-agent-for-agentfabric-default alpaca-en ms-bench ms-agent-for-agentfabric-addition coig-cqia-ruozhiba coig-cqia-zhihu coig-cqia-exam coig-cqia-chinese-traditional coig-cqia-logi-qa coig-cqia-segmentfault coig-cqia-wiki \
  --batch_size 2 \
  --max_length 2048 \
  --use_loss_scale true \
  --gradient_accumulation_steps 16 \
  --learning_rate 5e-5 \
  --use_flash_attn true \
  --eval_steps 500 \
  --save_steps 500 \
  --train_dataset_sample -1 \
  --dataset_test_ratio 0.1 \
  --val_dataset_sample 10000 \
  --num_train_epochs 2 \
  --check_dataset_strategy none \
  --gradient_checkpointing true \
  --weight_decay 0.01 \
  --warmup_ratio 0.03 \
  --save_total_limit 2 \
  --logging_steps 10 \
  --sft_type lora \
  --lora_target_modules ALL \
  --lora_rank 8 \
  --lora_alpha 32
```

## 模型评测信息

| 评测模型                            | ARC    | CEVAL  | GSM8K  |
| ----------------------------------- | ------ | ------ | ------ |
| Llama3-8b-instruct                  | 0.7645 | 0.5089 | 0.7475 |
| Llama3-Chinese-8B-Instruct-Agent-v1 | 0.7577 | 0.4903 | 0.652  |

GSM8K英文数学能力下降了8个点左右，经过消融实验我们发现去除alpaca-en语料会导致GSM8K下降至少十个点以上。
