robinsmits commited on
Commit
cb4fd22
1 Parent(s): d5433c6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -1
README.md CHANGED
@@ -27,9 +27,52 @@ This finetuned model is an adapter model based on [Qwen/Qwen1.5-7B-Chat](https:/
27
 
28
  Finetuning was performed on the Dutch [BramVanroy/ultrachat_200k_dutch](https://huggingface.co/datasets/BramVanroy/ultrachat_200k_dutch) dataset.
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  ## Intended uses & limitations
31
 
32
- 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 validating.
33
 
34
  The used dataset does not allow commercial usage.
35
 
 
27
 
28
  Finetuning was performed on the Dutch [BramVanroy/ultrachat_200k_dutch](https://huggingface.co/datasets/BramVanroy/ultrachat_200k_dutch) dataset.
29
 
30
+ ## Model usage
31
+
32
+ A basic example of how to use the finetuned model.
33
+
34
+ ```
35
+ import torch
36
+ from peft import AutoPeftModelForCausalLM
37
+ from transformers import AutoTokenizer
38
+
39
+ device = 'cuda'
40
+ model_name = 'robinsmits/Qwen1.5-7B-Dutch-Chat-Sft'
41
+
42
+ model = AutoPeftModelForCausalLM.from_pretrained(model_name,
43
+ device_map = "auto",
44
+ load_in_4bit = True,
45
+ torch_dtype = torch.bfloat16)
46
+
47
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
48
+
49
+ messages = [{"role": "user", "content": "Hoi hoe gaat het ermee? Wat kun je me vertellen over appels?"}]
50
+
51
+ encoded_ids = tokenizer.apply_chat_template(messages,
52
+ add_generation_prompt = True,
53
+ return_tensors = "pt")
54
+
55
+ generated_ids = model.generate(input_ids = encoded_ids.to(device),
56
+ max_new_tokens = 256,
57
+ do_sample = True)
58
+ decoded = tokenizer.batch_decode(generated_ids)
59
+ print(decoded[0])
60
+ ```
61
+
62
+ Below the chat template with the generated output.
63
+
64
+ ```
65
+ <|im_start|>system
66
+ Je bent een behulpzame AI assistent<|im_end|>
67
+ <|im_start|>user
68
+ Hoi hoe gaat het ermee? Wat kun je me vertellen over appels?<|im_end|>
69
+ <|im_start|>assistant
70
+ Hallo! Appels zijn fruit dat heel populair is. Ze zijn lekker en er zijn veel verschillende soorten, zoals rode, witte en bruine appels. Je kunt ze eten met wat kaas of op een salade voor een fris gerecht. Het is ook goed voor je gezondheid omdat ze rijk zijn aan vitamine C en vezels.<|im_end|>
71
+ ```
72
+
73
  ## Intended uses & limitations
74
 
75
+ 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.
76
 
77
  The used dataset does not allow commercial usage.
78