Text Generation
Transformers
PyTorch
English
Chinese
llama
baichuan
llama2
baichuan2
text-generation-inference
Instructions to use hiyouga/Baichuan2-7B-Chat-LLaMAfied with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hiyouga/Baichuan2-7B-Chat-LLaMAfied with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hiyouga/Baichuan2-7B-Chat-LLaMAfied")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("hiyouga/Baichuan2-7B-Chat-LLaMAfied") model = AutoModelForCausalLM.from_pretrained("hiyouga/Baichuan2-7B-Chat-LLaMAfied", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use hiyouga/Baichuan2-7B-Chat-LLaMAfied with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hiyouga/Baichuan2-7B-Chat-LLaMAfied" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hiyouga/Baichuan2-7B-Chat-LLaMAfied", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/hiyouga/Baichuan2-7B-Chat-LLaMAfied
- SGLang
How to use hiyouga/Baichuan2-7B-Chat-LLaMAfied 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/Baichuan2-7B-Chat-LLaMAfied" \ --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/Baichuan2-7B-Chat-LLaMAfied", "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/Baichuan2-7B-Chat-LLaMAfied" \ --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/Baichuan2-7B-Chat-LLaMAfied", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use hiyouga/Baichuan2-7B-Chat-LLaMAfied with Docker Model Runner:
docker model run hf.co/hiyouga/Baichuan2-7B-Chat-LLaMAfied
This is the LLaMAfied version of Baichuan2-7B-Chat model by Baichuan Inc.
This model is converted with https://github.com/hiyouga/LLaMA-Factory/blob/main/tests/llamafy_baichuan2.py
You may use this model for fine-tuning in downstream tasks, we recommend using our efficient fine-tuning toolkit. https://github.com/hiyouga/LLaMA-Factory
- Developed by: Baichuan Inc.
- Language(s) (NLP): Chinese/English
- License: Baichuan2 License
Usage:
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
tokenizer = AutoTokenizer.from_pretrained("hiyouga/Baichuan2-7B-Chat-LLaMAfied", use_fast=False)
model = AutoModelForCausalLM.from_pretrained("hiyouga/Baichuan2-7B-Chat-LLaMAfied").cuda()
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
query = "<reserved_106>ๆไธ็กไธ็ๆไนๅ<reserved_107>"
inputs = tokenizer([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 baichuan2 --model_name_or_path hiyouga/Baichuan2-7B-Chat-LLaMAfied
Open LLM Leaderboard Evaluation Results
Detailed results can be found here
| Metric | Value |
|---|---|
| Avg. | 47.92 |
| ARC (25-shot) | 52.47 |
| HellaSwag (10-shot) | 74.04 |
| MMLU (5-shot) | 53.88 |
| TruthfulQA (0-shot) | 48.04 |
| Winogrande (5-shot) | 69.14 |
| GSM8K (5-shot) | 10.92 |
| DROP (3-shot) | 26.94 |
- Downloads last month
- 81