🚀 中文版Llama2 7B模型
这是一个完全开源且可商用的中文版Llama2模型及中英文SFT数据集。其输入格式严格遵循 llama - 2 - chat 格式,能兼容适配所有针对原版 llama - 2 - chat 模型的优化。

🚀 快速开始
基础演示

在线试玩
空谈无益,展示演示。
资源下载
我们使用了中英文SFT数据集,数据量达1000万。
快速测试
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] <<SYS>>\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<</SYS>>\n\n{} [/INST]"""
prompt = instruction.format("用英文回答,什么是夫妻肺片?")
generate_ids = model.generate(tokenizer(prompt, return_tensors='pt').input_ids.cuda(), max_new_tokens=4096, streamer=streamer)
✨ 主要特性
- 完全开源且可商用,为开发者提供了极大的便利。
- 输入格式严格遵循 llama - 2 - chat 格式,能很好地兼容适配针对原版 llama - 2 - chat 模型的优化。
📦 安装指南
文档未提及具体安装步骤,可参考训练及推理代码中的说明:https://github.com/LinkSoul-AI/Chinese-Llama-2-7b
💻 使用示例
基础用法
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] <<SYS>>\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<</SYS>>\n\n{} [/INST]"""
prompt = instruction.format("用英文回答,什么是夫妻肺片?")
generate_ids = model.generate(tokenizer(prompt, return_tensors='pt').input_ids.cuda(), max_new_tokens=4096, streamer=streamer)
📚 详细文档
可参考以下资源获取更多详细信息:
📄 许可证
本项目遵循 Apache - 2.0 license
相关项目
微信交流群
欢迎加入微信群
信息表格