# Chinese Llama 2 7B 全部开源,完全可商用的**中文版 Llama2 模型及中文 SFT 数据集**。 ![Chinese LLaMA2 7B](https://github.com/LinkSoul-AI/Chinese-Llama-2-7b/raw/main/.github/preview.jpg) ## 在线试玩 > Talk is cheap, Show you the Demo. - [Demo 地址 / HuggingFace Spaces](#) - [Colab 一键启动](#) ## 快速测试 ```python from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer model_path = "LinkSoul/Chinese-Llama-2-7b" tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False) model = AutoModelForCausalLM.from_pretrained(model_path).half().cuda() streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True) instruction = """[INST] <>\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\n<>\n\n{} [/INST]""" prompt = instruction.format("用英文回答,什么是夫妻肺片?") generate_ids = model.generate(tokenizer(prompt, return_tensors='pt').input_ids.cuda(), max_new_tokens=4096, streamer=streamer) ``` ## 资源下载 - 模型下载:[Chinese Llama2 Chat Model](#) > 我们使用了中文 SFT 数据集,数据量 1000 万。 - 数据集:[https://huggingface.co/datasets/LinkSoul/instruction_merge_set](https://huggingface.co/datasets/LinkSoul/instruction_merge_set) ## 如何训练 ```bash python train.py --args ... ``` ## 相关项目 - [Llama2](#) ## 项目协议 [Apache-2.0 license](https://github.com/LinkSoul-AI/Chinese-Llama-2-7b/blob/main/LICENSE)