Instructions to use UnicomLLM/Unichat-llama3-Chinese-8B-28K with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use UnicomLLM/Unichat-llama3-Chinese-8B-28K with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="UnicomLLM/Unichat-llama3-Chinese-8B-28K") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("UnicomLLM/Unichat-llama3-Chinese-8B-28K") model = AutoModelForCausalLM.from_pretrained("UnicomLLM/Unichat-llama3-Chinese-8B-28K", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use UnicomLLM/Unichat-llama3-Chinese-8B-28K with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "UnicomLLM/Unichat-llama3-Chinese-8B-28K" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "UnicomLLM/Unichat-llama3-Chinese-8B-28K", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/UnicomLLM/Unichat-llama3-Chinese-8B-28K
- SGLang
How to use UnicomLLM/Unichat-llama3-Chinese-8B-28K 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 "UnicomLLM/Unichat-llama3-Chinese-8B-28K" \ --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": "UnicomLLM/Unichat-llama3-Chinese-8B-28K", "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 "UnicomLLM/Unichat-llama3-Chinese-8B-28K" \ --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": "UnicomLLM/Unichat-llama3-Chinese-8B-28K", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use UnicomLLM/Unichat-llama3-Chinese-8B-28K with Docker Model Runner:
docker model run hf.co/UnicomLLM/Unichat-llama3-Chinese-8B-28K
Unichat-llama3-Chinese-8B-28K
ไป็ป
- ไธญๅฝ่้AIๅๆฐไธญๅฟๅๅธไธ็็ฌฌไธไธชllama3ไธญๆๆไปคๅพฎ่ฐๆจกๅ้ฟๆๆฌ็ๆฌ๏ผๅ จๅๆฐๅพฎ่ฐ(้lora/longlora)๏ผ2024ๅนด4ๆ26ๆฅ19็น
- ๆฌๆจกๅไปฅMeta Llama 3ไธบๅบ็ก,ๅขๅ ไธญๆๆฐๆฎ่ฟ่ก่ฎญ็ป,ๅฎ็ฐllama3ๆจกๅ้ซ่ดจ้ไธญๆ้ฎ็ญ
- ๆญคๆจกๅไธไธๆๅ็้ฟๅบฆ28K
- ๅบ็กๆจกๅ Meta-Llama-3-8B
๐ ๆฐๆฎ
- ้ซ่ดจ้้ฟๆๆฌๆไปคๆฐๆฎ๏ผ่ฆ็ๅคไธช้ขๅๅ่กไธ๏ผไธบๆจกๅ่ฎญ็ปๆไพๅ ่ถณ็ๆฐๆฎๆฏๆ
- ๅพฎ่ฐๆไปคๆฐๆฎ็ป่ฟไธฅๆ ผ็ไบบๅทฅ็ญๆฅ๏ผไฟ่ฏไผ่ดจ็ๆไปคๆฐๆฎ็จไบๆจกๅๅพฎ่ฐ
ๅบ็ก็คบไพ
- ๆๅใๆๆ้ฃไบไบๅฟใๅฐ่ฏด็ฌฌ[319]็ซ ่ณ[337]็ซ ๅ ๅฎน็บฆ1ไธ6ๅๅญๅทฆๅณ๏ผๅฏนๆ็ซ ๅ ๅฎน่ฟ่กๆ้ฎใ
- ้ฎ:ๆๆไธๅคง่ฅ็็ปๆๅ่่ดฃๆฏไปไน๏ผ
- ็ญ:ๆ นๆฎๆ็ซ ๅ ๅฎน,ๆๆไธๅคง่ฅ็็ปๆๅ่่ดฃๅฆไธ:
ไบๅ่ฅ:็ฑ้ชๅ ตๅๆญฅๅ ต็ปๆ,ๅไธบไธญๅใๅทฆๅใๅทฆๆๅใๅณๆๅใๅณๅจๅ,ๆ ไปปๆปๅป็ไธปๅใ
ไธๅ่ฅ:็ฑๆ้็่ๅค้ชๅ ต็ปๆ,ไธป่ฆๆฏไปฅ้ไฝฃๅ ตไธบไธป็ใไธๅฑๅ จ้จ้ฝๆฏ้ชๅ ต,่ฟๆฏ้ชๅ ต้จ้ไบบๆฐ่ฝ็ถไธๅค,ๅดๆฏๆฑๆฃฃๆไธๆไธบๅผบๆ็้ชๅ ตๅ้,ไปไปฌๅจๆไบไธญไธป่ฆๆ ไปป็ชๅป็่ง่ฒใ
็ฅๆบ่ฅ:ไฝฟ็จ็ซ็ฎๅ็ซ้ณ็ญ็ซๅจไธบไธป็้จ้,ๆฏๆๆๆฟๅบ็็ฎๅ ต้จ้ใๆฑๆฃฃๅๅฟไนๆไปฅ่ฆ็ปๅปบ่ฟๆ ท็ไธๆฏ้จ้,้ฃๆฏๆ็ๆทฑๅปๅๅ ็ใ
ๆไปฅ,ๆๆไธๅคง่ฅ็็ปๆๅ่่ดฃๆฏ:ไบๅ่ฅ่ด่ดฃๆปๅป,ไธๅ่ฅ่ด่ดฃ็ชๅป,็ฅๆบ่ฅ่ด่ดฃไฝฟ็จ็ซๅจ่ฟ่กๆๅปใ
ๅฟซ้ๅผๅง
import transformers
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "UnicomAI/Unichat-llama3-Chinese-8B-28K"
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device="cuda",
)
messages = [
{"role": "system", "content": "A chat between a curious user and an artificial intelligence assistant.The assistant gives helpful, detailed, and polite answers to the user's questions."},
{"role": "user", "content": "ไฝ ๆฏ่ฐ"},
]
prompt = pipeline.tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
terminators = [
pipeline.tokenizer.eos_token_id,
pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
outputs = pipeline(
prompt,
max_new_tokens=2048,
eos_token_id=terminators,
do_sample=True,
temperature=0.6,
top_p=1,
repetition_penalty=1.15
)
print(outputs[0]["generated_text"][len(prompt):])
่ตๆบ
ๆดๅคๆจกๅ,ๆฐๆฎ้ๅ่ฎญ็ป็ธๅ ณ็ป่่ฏทๅ่:
- Github๏ผUnichat-llama3-Chinese
- Downloads last month
- 8,571