Instructions to use yentinglin/Taiwan-LLM-13B-v2.0-chat-awq with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yentinglin/Taiwan-LLM-13B-v2.0-chat-awq with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yentinglin/Taiwan-LLM-13B-v2.0-chat-awq") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("yentinglin/Taiwan-LLM-13B-v2.0-chat-awq") model = AutoModelForCausalLM.from_pretrained("yentinglin/Taiwan-LLM-13B-v2.0-chat-awq", 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 yentinglin/Taiwan-LLM-13B-v2.0-chat-awq with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yentinglin/Taiwan-LLM-13B-v2.0-chat-awq" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yentinglin/Taiwan-LLM-13B-v2.0-chat-awq", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/yentinglin/Taiwan-LLM-13B-v2.0-chat-awq
- SGLang
How to use yentinglin/Taiwan-LLM-13B-v2.0-chat-awq 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 "yentinglin/Taiwan-LLM-13B-v2.0-chat-awq" \ --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": "yentinglin/Taiwan-LLM-13B-v2.0-chat-awq", "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 "yentinglin/Taiwan-LLM-13B-v2.0-chat-awq" \ --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": "yentinglin/Taiwan-LLM-13B-v2.0-chat-awq", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use yentinglin/Taiwan-LLM-13B-v2.0-chat-awq with Docker Model Runner:
docker model run hf.co/yentinglin/Taiwan-LLM-13B-v2.0-chat-awq
awq quantization method
I'm curious of what dataset that is used for teh awq qantization. Do you just follow the steps in the (https://github.com/casper-hansen/AutoAWQ/blob/main/examples/quantize.py) which is using the default dataset (mit-han-lab/pile-val-backup https://huggingface.co/datasets/mit-han-lab/pile-val-backup)?
from awq import AutoAWQForCausalLM
from transformers import AutoTokenizer
model_path = 'mistralai/Mistral-7B-Instruct-v0.2'
quant_path = 'mistral-instruct-v0.2-awq'
quant_config = { "zero_point": True, "q_group_size": 128, "w_bit": 4, "version": "GEMM" }
# Load model
model = AutoAWQForCausalLM.from_pretrained(
model_path, **{"low_cpu_mem_usage": True, "use_cache": False}
)
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
# Quantize
model.quantize(tokenizer, quant_config=quant_config)
# Save quantized model
model.save_quantized(quant_path)
tokenizer.save_pretrained(quant_path)
print(f'Model is quantized and saved at "{quant_path}"')
The reason for asking this question is that I want to quantize the lastest model yentinglin/Llama-3-Taiwan-70B-Instruct myself.
Thank you for your prompt reply, I did not expect it at all :D .