Instructions to use hiyouga/Llama-2-Chinese-13b-chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hiyouga/Llama-2-Chinese-13b-chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hiyouga/Llama-2-Chinese-13b-chat")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("hiyouga/Llama-2-Chinese-13b-chat") model = AutoModelForCausalLM.from_pretrained("hiyouga/Llama-2-Chinese-13b-chat") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use hiyouga/Llama-2-Chinese-13b-chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hiyouga/Llama-2-Chinese-13b-chat" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hiyouga/Llama-2-Chinese-13b-chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/hiyouga/Llama-2-Chinese-13b-chat
- SGLang
How to use hiyouga/Llama-2-Chinese-13b-chat with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "hiyouga/Llama-2-Chinese-13b-chat" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hiyouga/Llama-2-Chinese-13b-chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "hiyouga/Llama-2-Chinese-13b-chat" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hiyouga/Llama-2-Chinese-13b-chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use hiyouga/Llama-2-Chinese-13b-chat with Docker Model Runner:
docker model run hf.co/hiyouga/Llama-2-Chinese-13b-chat
Use Docker images
docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "hiyouga/Llama-2-Chinese-13b-chat" \
--host 0.0.0.0 \
--port 30000# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "hiyouga/Llama-2-Chinese-13b-chat",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'A bilingual instruction-tuned LoRA model of https://huggingface.co/meta-llama/Llama-2-13b-hf
- Instruction-following datasets used: alpaca, alpaca-zh, open assistant
- Training framework: LLaMA-Factory
Usage:
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
tokenizer = AutoTokenizer.from_pretrained("hiyouga/Llama-2-Chinese-13b-chat")
model = AutoModelForCausalLM.from_pretrained("hiyouga/Llama-2-Chinese-13b-chat").cuda()
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
query = "晚上睡不着怎么办"
template = (
"A chat between a curious user and an artificial intelligence assistant. "
"The assistant gives helpful, detailed, and polite answers to the user's questions.\n"
"Human: {}\nAssistant: "
)
inputs = tokenizer([template.format(query)], return_tensors="pt")
inputs = inputs.to("cuda")
generate_ids = model.generate(**inputs, max_new_tokens=256, streamer=streamer)
You could also alternatively launch a CLI demo by using the script in LLaMA-Factory
python src/cli_demo.py --template default --model_name_or_path hiyouga/Llama-2-Chinese-13b-chat
The model is trained using the web UI of LLaMA-Factory.
How to use this web UI: https://zhuanlan.zhihu.com/p/645010851
Loss curve:
Examples:
Q: 你是谁
A: 我是 <NAME>,一款由 <AUTHOR> 开发的人工智能助手。我可以回答各种问题,提供帮助和支持。
Q: 如何提高公司的销售额?
A: 以下是一些有助于提高公司销售额的想法:
- 改善销售流程:通过优化销售流程,销售人员可以更有效地与客户进行沟通,提高销售效率。
- 引入新产品:引入新产品可以吸引新客户,并增加现有客户的购买次数。
- 提高客户满意度:通过提高客户满意度,可以提高客户忠诚度和销售额。
- 营销活动:举办营销活动可以吸引新客户,并提高销售额。
Q: 给定下面的两个列表,使用Python解释器找到它们之间的相同元素。 List1:[1, 2, 3, 4, 5, 6] List2:[4, 5, 6, 7, 8, 9]
A: 以下是使用Python解释器找到两个列表中共同元素的示例:
# 列表1
lst1 = [1, 2, 3, 4, 5, 6]
# 列表2
lst2 = [4, 5, 6, 7, 8, 9]
# 找到共同元素
common_elements = list(set(lst1) & set(lst2))
print(common_elements)
此示例创建两个列表,然后使用Python中的集合操作符(&)找到它们共同的元素。最后,输出结果。 在此示例中,共同元素为[4, 5, 6]。
Q: 将以下文本翻译成英语:我想去旅行并尽可能多地了解世界上的文化。
A: I want to travel and learn as much as possible about the cultures of the world.
Q: 解释以下缩写: JSON、CEO、PDF、HTML、NASA
A: 以下是缩写的解释:
- JSON(JavaScript Object Notation):一种用于序列化和交换数据的格式,常用于网络应用程序之间的通信。
- CEO(Chief Executive Officer):公司的最高负责人,负责公司的总体运营和管理。
- PDF(Portable Document Format):一种格式,可以将文档保存为一个无需特殊软件即可打开和查看的电子文件。
- HTML(Hypertext Markup Language):一种用于创建网页的标记语言,它包含用于格式化文本和添加元素的标记。
- NASA(National Aeronautics and Space Administration):美国的国家航空航天局,负责美国的宇宙计划和太空探索活动。
- Downloads last month
- 21


Install from pip and serve model
# Install SGLang from pip: pip install sglang# Start the SGLang server: python3 -m sglang.launch_server \ --model-path "hiyouga/Llama-2-Chinese-13b-chat" \ --host 0.0.0.0 \ --port 30000# Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hiyouga/Llama-2-Chinese-13b-chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'