---
title: Unichat-llama3-Chinese-8B-28K
canonical_url: "https://www.modelscope.cn/models/UnicomAI/Unichat-llama3-Chinese-8B-28K"
md_url: "https://www.modelscope.cn/models/UnicomAI/Unichat-llama3-Chinese-8B-28K.md"
repository: UnicomAI/Unichat-llama3-Chinese-8B-28K
chinese_name: "Unichat-llama3-8B-28K-中文版"
last_updated: 2024-04-28
license: apache-2.0
pipeline_tag: text-generation
tasks:
  - text-generation
model_type:
  - llama
architectures:
  - LlamaForCausalLM
library_name:
  - pytorch
  - transformer
frameworks:
  - Pytorch
language:
  - en
  - zh
inference_backends:
  - "deploy_task text/emb"
  - "lmdeploy 0.9.1"
  - "lmdeploy_turbomind 0.9.1"
  - "sglang 0.5.2"
  - "vllm 0.9.2"
downloads: 391
stars: 7
---

# Unichat-llama3-Chinese-8B-28K

> Unichat-llama3-Chinese-8B-28K - UnicomAI 在 ModelScope 开源的模型。Unichat-llama3-Chinese-8B-28K

UnicomAI/Unichat-llama3-Chinese-8B-28K 是 ModelScope 魔搭社区上的text-generation模型，采用 apache-2.0 许可，可用 deploy_task text/emb、lmdeploy 0.9.1、lmdeploy_turbomind 0.9.1 部署。

- **Repository**: UnicomAI/Unichat-llama3-Chinese-8B-28K
- **License**: apache-2.0
- **Tasks**: text-generation
- **Inference backends**: deploy_task text/emb, lmdeploy 0.9.1, lmdeploy_turbomind 0.9.1, sglang 0.5.2, vllm 0.9.2
- **Downloads**: 391
- **Stars**: 7
- **Last updated**: 2024-04-28

Source: https://www.modelscope.cn/models/UnicomAI/Unichat-llama3-Chinese-8B-28K

---

# Unichat-llama3-Chinese-8B-28K


## 介绍
* 中国联通AI创新中心发布业界第一个llama3中文指令微调模型长文本版本，全参数微调(非lora/longlora)，2024年4月26日19点
* 本模型以[**Meta Llama 3**](https://huggingface.co/collections/meta-llama/meta-llama-3-66214712577ca38149ebb2b6)为基础,增加中文数据进行训练,实现llama3模型高质量中文问答
* 此模型上下文原生长度28K
* 基础模型 [**Meta-Llama-3-8B**](https://huggingface.co/meta-llama/Meta-Llama-3-8B)
  

### 📊 数据
- 高质量长文本指令数据，覆盖多个领域和行业，为模型训练提供充足的数据支持
- 微调指令数据经过严格的人工筛查，保证优质的指令数据用于模型微调

## 基础示例

* 摘取《明朝那些事儿》小说第[319]章至[337]章内容约1万6千字左右，对文章内容进行提问。
* 问:明朝三大营的组成及职责是什么？
* 答:根据文章内容,明朝三大营的组成及职责如下:

1. 五军营:由骑兵和步兵组成,分为中军、左军、左掖军、右掖军、右哨军,担任攻击的主力。

2. 三千营:由投降的蒙古骑兵组成,主要是以雇佣兵为主的。下属全部都是骑兵,这支骑兵部队人数虽然不多,却是朱棣手下最为强悍的骑兵力量,他们在战争中主要担任突击的角色。

3. 神机营:使用火炮和火铳等火器为主的部队,是明朝政府的炮兵部队。朱棣同志之所以要组建这样的一支部队,那是有着深刻原因的。

所以,明朝三大营的组成和职责是:五军营负责攻击,三千营负责突击,神机营负责使用火器进行打击。

## 快速开始

```python
import transformers
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "UnicomAI/Unichat-llama3-Chinese-8B-28K"

pipeline = transformers.pipeline(
    "text-generation",
    model=model_id,
    model_kwargs={"torch_dtype": torch.bfloat16},
    device="cuda",
)


messages = [
    {"role": "system", "content": "A chat between a curious user and an artificial intelligence assistant.The assistant gives helpful, detailed, and polite answers to the user's questions."},
    {"role": "user", "content": "你是谁"},
]


prompt = pipeline.tokenizer.apply_chat_template(
      messages,
      tokenize=False,
      add_generation_prompt=True
)

terminators = [
      pipeline.tokenizer.eos_token_id,
      pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")
]


outputs = pipeline(
        prompt,
        max_new_tokens=2048,
        eos_token_id=terminators,
        do_sample=True,
        temperature=0.6,
        top_p=1,
        repetition_penalty=1.15
)
print(outputs[0]["generated_text"][len(prompt):])
```

## 资源
更多模型,数据集和训练相关细节请参考:
* Github：[**Unichat-llama3-Chinese**](https://github.com/UnicomAI/Unichat-llama3-Chinese)
