Instructions to use SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct") model = AutoModelForCausalLM.from_pretrained("SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct
- SGLang
How to use SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct 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 "SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct with Docker Model Runner:
docker model run hf.co/SYSU-MUCFC-FinTech-Research-Center/ZhiLu-2-8B-Instruct
ZhiLu-2是一款基于llama3微调的中文消费金融领域对话大模型。与ZhiLu相比,ZhiLu-2性能有了显著提升。我们不仅收集了全新的高质量指令数据进行对齐,还创新性地设计了独特的数据合成方法,并将大量合成数据应用于模型训练。通过这些努力,ZhiLu-2在性能上取得了显著的突破,展示了卓越的性能。
训练细节 在第二版的智鹿训练中,我们引入了全新的指令微调数据,并且加入了合成数据。我们相信,合成数据的使用将带来意想不到的惊喜效果。以下是一些重要的训练细节:
🚀 高效训练
我们使用llama-factory作为训练框架,并配备多块A100显卡,通过DeepSpeed(ds)实现数据并行、模型并行、管道并行和张量并行等优化技术。在微调方法的选择上,我们对Full-Rank FT、LORA、BAdam、LoRA+和DoRA进行了详细比较,评估了各方法在训练时间、显卡占用、推理时间和模型性能等多项指标上的表现。最终,我们决定采用DoRA进行微调,以获得最佳的性价比和性能。
⚡ 加速技术
为了提高资源的利用率并缩短训练时间,我们采用了以下两项关键技术:
Packing FlashAttention-2 🔒 安全性与对齐
我们使用 DPO 来训练模型。DPO具有使用便捷、成效快速的优势,可以达到近似RLHF的偏好对齐效果,确保输出的安全和无害。
🛡️ 避免灾难性遗忘
为了防止训练后模型的灾难性遗忘,并平衡模型在各个任务上的能力,我们使用了 merging 技术。
🌱 自我进化
通过设计新的框架,我们使模型能够自我生成训练数据,从而实现自我进化。
更多细节参见:ZhiLu-2-github仓库
- Downloads last month
- 24