Text Generation
Transformers
Safetensors
Chinese
English
llama
conversational
text-generation-inference
Instructions to use yuyijiong/Llama3-8B-Chinese-Chat-32k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yuyijiong/Llama3-8B-Chinese-Chat-32k with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yuyijiong/Llama3-8B-Chinese-Chat-32k") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("yuyijiong/Llama3-8B-Chinese-Chat-32k") model = AutoModelForCausalLM.from_pretrained("yuyijiong/Llama3-8B-Chinese-Chat-32k", 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 yuyijiong/Llama3-8B-Chinese-Chat-32k with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yuyijiong/Llama3-8B-Chinese-Chat-32k" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yuyijiong/Llama3-8B-Chinese-Chat-32k", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/yuyijiong/Llama3-8B-Chinese-Chat-32k
- SGLang
How to use yuyijiong/Llama3-8B-Chinese-Chat-32k 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 "yuyijiong/Llama3-8B-Chinese-Chat-32k" \ --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": "yuyijiong/Llama3-8B-Chinese-Chat-32k", "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 "yuyijiong/Llama3-8B-Chinese-Chat-32k" \ --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": "yuyijiong/Llama3-8B-Chinese-Chat-32k", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use yuyijiong/Llama3-8B-Chinese-Chat-32k with Docker Model Runner:
docker model run hf.co/yuyijiong/Llama3-8B-Chinese-Chat-32k
| license: llama3 | |
| datasets: | |
| - yuyijiong/Long-Instruction-with-Paraphrasing | |
| language: | |
| - zh | |
| - en | |
| pipeline_tag: text-generation | |
| # Llama3-8b-chinese-chat-32k | |
| ## 训练方式 | |
| * 使用 NTK-aware 方法扩展上下文长度至32k | |
| * 以 [shenzhi-wang/Llama3-8B-Chinese-Chat](https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat) 为基础 | |
| 在 [Long-Instruction-with-Paraphrasing](https://huggingface.co/datasets/yuyijiong/Long-Instruction-with-Paraphrasing) | |
| 数据集上,使用 QLora 微调 1 epoch。 | |
| ## 长上下文表现 | |
| 相比原始版本,拥有更强的长上下文能力 | |
| ### LongBench (en) | |
| | model | hotpotqa | multifieldqa_en| passage_retrieval_en|qmsum| trec| | |
| |---------------------------|-----------|--|--|--|--| | |
| | llama3-8b-chinese-chat | 45.88 |50.56|68.0|22.52|73.0| | |
| | llama3-8b-chinese-chat-32k| **47.64** |49.98|**100.0**|**25.13**|**75.0**| | |
| ### LongBench (zh) | |
| | model | dureader | multifieldqa_zh| passage_retrieval_zh|qmsum| trec| | |
| |-----------------------------------|-----------|--|--|--|--| | |
| | llama3-8b-chinese-chat | 29.08 |58.4|93.5|22.52|73.0| | |
| | llama3-8b-chinese-chat-32k | **32.31** |**58.66**|82.5|**25.13**|**75.0**| |