Instructions to use hon9kon9ize/CantoneseLLM-v1.0-72B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hon9kon9ize/CantoneseLLM-v1.0-72B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hon9kon9ize/CantoneseLLM-v1.0-72B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("hon9kon9ize/CantoneseLLM-v1.0-72B") model = AutoModelForCausalLM.from_pretrained("hon9kon9ize/CantoneseLLM-v1.0-72B") 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
- vLLM
How to use hon9kon9ize/CantoneseLLM-v1.0-72B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hon9kon9ize/CantoneseLLM-v1.0-72B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hon9kon9ize/CantoneseLLM-v1.0-72B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/hon9kon9ize/CantoneseLLM-v1.0-72B
- SGLang
How to use hon9kon9ize/CantoneseLLM-v1.0-72B 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 "hon9kon9ize/CantoneseLLM-v1.0-72B" \ --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": "hon9kon9ize/CantoneseLLM-v1.0-72B", "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 "hon9kon9ize/CantoneseLLM-v1.0-72B" \ --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": "hon9kon9ize/CantoneseLLM-v1.0-72B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use hon9kon9ize/CantoneseLLM-v1.0-72B with Docker Model Runner:
docker model run hf.co/hon9kon9ize/CantoneseLLM-v1.0-72B
CantoneseLLMChat-v1.0-72B
Cantonese LLM Chat v1.0 is the first generation Cantonese LLM from hon9kon9ize. Building upon the sucess of v0.5 preview, the model excels in Hong Kong related specific knowledge and Cantonese conversation.
Model description
Base model obtained via Continuous Pre-Training of Qwen 2.5 72B with 600 millions publicaly available Hong Kong news articles and Cantonese websites. Instructions fine-tuned model trained with a dataset consists of 75,000 instrutions pairs. 45,000 pairs were Cantonese insturctions generated by other LLMs and reviewed by humans.
The model trained with 16 Nvidia H100 96GB HBM2e GPUs on Genkai Supercomputer.
Basic Usage
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "hon9kon9ize/CantoneseLLMChat-v1.0-72B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
def chat(messages, temperature=0.9, max_new_tokens=200):
input_ids = tokenizer.apply_chat_template(conversation=messages, tokenize=True, add_generation_prompt=True, return_tensors='pt').to('cuda:0')
output_ids = model.generate(input_ids, max_new_tokens=max_new_tokens, temperature=temperature)
response = tokenizer.decode(output_ids[0][input_ids.shape[1]:], skip_special_tokens=False)
return response
prompt = "邊個係香港特首?"
messages = [
{"role": "system", "content": "you are a helpful assistant."},
{"role": "user", "content": prompt}
]
print(chat(messages)) # 香港特別行政區行政長官係李家超。<|im_end|>
- Downloads last month
- 1
