🚀 中文版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
相關項目
微信交流群
歡迎加入微信群
信息表格