Instructions to use robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16") 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("robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16") model = AutoModelForCausalLM.from_pretrained("robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16
- SGLang
How to use robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16 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 "robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16" \ --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": "robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16", "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 "robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16" \ --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": "robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16 with Docker Model Runner:
docker model run hf.co/robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16
Qwen1.5-7B-Dutch-Chat-Sft-Bf16
Model description
This finetuned model is the merged version of the adapter model robinsmits/Qwen1.5-7B-Dutch-Chat-Sft.
Finetuning was performed on the Dutch BramVanroy/ultrachat_200k_dutch dataset.
See Qwen/Qwen1.5-7B-Chat for all information about the base model.
Model usage
A basic example of how to use the finetuned model.
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
device = 'cuda'
model_name = 'robinsmits/Qwen1.5-7B-Dutch-Chat-Sft-Bf16'
model = AutoModelForCausalLM.from_pretrained(model_name,
device_map = "auto",
torch_dtype = torch.bfloat16)
tokenizer = AutoTokenizer.from_pretrained(model_name)
messages = [{"role": "user", "content": "Hoi hoe gaat het ermee? Wat kun je me vertellen over appels?"}]
encoded_ids = tokenizer.apply_chat_template(messages,
add_generation_prompt = True,
return_tensors = "pt")
generated_ids = model.generate(input_ids = encoded_ids.to(device),
max_new_tokens = 256,
do_sample = True)
decoded = tokenizer.batch_decode(generated_ids)
print(decoded[0])
Below the chat template with the generated output.
<|im_start|>system
Je bent een behulpzame AI assistent<|im_end|>
<|im_start|>user
Hoi hoe gaat het ermee? Wat kun je me vertellen over appels?<|im_end|>
<|im_start|>assistant
Hallo! Appels zijn zo'n heerlijk fruit. Ze komen in verschillende kleuren en smaken, zoals rode, witte, en goudbruine appels. Appels bevatten veel vezels en vitamines die goed zijn voor je gezondheid. Je kunt ze op verschillende manieren eten, bijvoorbeeld gesneden met wat kaneel of in een smoothie. Wil je meer weten over de voedingswaarde van appels of heb je interesse in andere fruitsoorten?<|im_end|>
Intended uses & limitations
As with all LLM's this model can also experience bias and hallucinations. Regardless of how you use this model always perform the necessary testing and validation.
The used dataset does not allow commercial usage.
Training and evaluation data
The training notebook is available at the following link: Qwen1_5_7B_Dutch_Chat_SFT
Training was performed with Google Colab PRO on a A100 - 40GB.
As the amount of data was more than would fit within the maximum 24 hour session that Google Colab PRO allows I split the dataset in 2 equal parts. Training for each part lasted around 14 hours. In the second part I enabled 'resume_from_checkpoint' to continue the training.
Training procedure
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 0.0003
- train_batch_size: 2
- eval_batch_size: 4
- seed: 42
- gradient_accumulation_steps: 32
- total_train_batch_size: 64
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: cosine
- lr_scheduler_warmup_ratio: 0.05
- training_steps: 1466
Training results
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 1.4493 | 0.2 | 146 | 1.4083 |
| 1.3638 | 0.4 | 292 | 1.3213 |
| 1.3146 | 0.6 | 438 | 1.2731 |
| 1.2756 | 0.8 | 584 | 1.2400 |
| 1.2533 | 1.0 | 730 | 1.2165 |
| 1.2388 | 1.19 | 876 | 1.1998 |
| 1.2246 | 1.39 | 1022 | 1.1882 |
| 1.211 | 1.59 | 1168 | 1.1802 |
| 1.204 | 1.79 | 1314 | 1.1763 |
| 1.2041 | 1.99 | 1460 | 1.1756 |
Framework versions
- PEFT 0.9.0
- Transformers 4.38.2
- Pytorch 2.2.1+cu121
- Datasets 2.17.1
- Tokenizers 0.15.2
Citation
Thanks to the creators of Qwen1.5 for there great work!
@article{qwen,
title={Qwen Technical Report},
author={Jinze Bai and Shuai Bai and Yunfei Chu and Zeyu Cui and Kai Dang and Xiaodong Deng and Yang Fan and Wenbin Ge and Yu Han and Fei Huang and Binyuan Hui and Luo Ji and Mei Li and Junyang Lin and Runji Lin and Dayiheng Liu and Gao Liu and Chengqiang Lu and Keming Lu and Jianxin Ma and Rui Men and Xingzhang Ren and Xuancheng Ren and Chuanqi Tan and Sinan Tan and Jianhong Tu and Peng Wang and Shijie Wang and Wei Wang and Shengguang Wu and Benfeng Xu and Jin Xu and An Yang and Hao Yang and Jian Yang and Shusheng Yang and Yang Yao and Bowen Yu and Hongyi Yuan and Zheng Yuan and Jianwei Zhang and Xingxuan Zhang and Yichang Zhang and Zhenru Zhang and Chang Zhou and Jingren Zhou and Xiaohuan Zhou and Tianhang Zhu},
journal={arXiv preprint arXiv:2309.16609},
year={2023}
}
- Downloads last month
- 53