johannhartmann commited on
Commit
0c5fb53
1 Parent(s): e8368ac

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +39 -24
README.md CHANGED
@@ -22,6 +22,45 @@ Brezn-7B is a dpo aligned merge of the following models using [LazyMergekit](htt
22
  * [mayflowergmbh/Wiedervereinigung-7b-dpo-laser](https://huggingface.co/mayflowergmbh/Wiedervereinigung-7b-dpo-laser)
23
  * [cognitivecomputations/openchat-3.5-0106-laser](https://huggingface.co/cognitivecomputations/openchat-3.5-0106-laser)
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  ## mt-bench-de
26
  ```yaml
27
  {
@@ -67,27 +106,3 @@ dtype: bfloat16
67
  random_seed: 0
68
  ```
69
 
70
- ## 💻 Usage
71
-
72
- ```python
73
- !pip install -qU transformers accelerate
74
-
75
- from transformers import AutoTokenizer
76
- import transformers
77
- import torch
78
-
79
- model = "mayflowergmbh/Brezn-7B"
80
- messages = [{"role": "user", "content": "What is a large language model?"}]
81
-
82
- tokenizer = AutoTokenizer.from_pretrained(model)
83
- prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
84
- pipeline = transformers.pipeline(
85
- "text-generation",
86
- model=model,
87
- torch_dtype=torch.float16,
88
- device_map="auto",
89
- )
90
-
91
- outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
92
- print(outputs[0]["generated_text"])
93
- ```
 
22
  * [mayflowergmbh/Wiedervereinigung-7b-dpo-laser](https://huggingface.co/mayflowergmbh/Wiedervereinigung-7b-dpo-laser)
23
  * [cognitivecomputations/openchat-3.5-0106-laser](https://huggingface.co/cognitivecomputations/openchat-3.5-0106-laser)
24
 
25
+
26
+ ## 💻 Usage
27
+
28
+ In order to leverage instruction fine-tuning, your prompt should be surrounded by `[INST]` and `[/INST]` tokens. The very first instruction should begin with a begin of sentence id. The next instructions should not. The assistant generation will be ended by the end-of-sentence token id.
29
+
30
+ E.g.
31
+ ```
32
+ text = "<s>[INST] What is your favourite condiment? [/INST]"
33
+ "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!</s> "
34
+ "[INST] Do you have mayonnaise recipes? [/INST]"
35
+ ```
36
+
37
+ This format is available as a [chat template](https://huggingface.co/docs/transformers/main/chat_templating) via the `apply_chat_template()` method:
38
+
39
+ ```python
40
+ from transformers import AutoModelForCausalLM, AutoTokenizer
41
+
42
+ device = "cuda" # the device to load the model onto
43
+
44
+ model = AutoModelForCausalLM.from_pretrained("mayflowergmbh/Brezn-7b")
45
+ tokenizer = AutoTokenizer.from_pretrained("mayflowergmbh/Brezn-7b")
46
+
47
+ messages = [
48
+ {"role": "user", "content": "Was ist dein Lieblingsgewürz??"},
49
+ {"role": "assistant", "content": "Nun, ich mag besonders gerne einen guten Spritzer frischen Zitronensaft. Er fügt genau die richtige Menge an würzigem Geschmack hinzu, egal was ich gerade in der Küche zubereite!"},
50
+ {"role": "user", "content": "Hast du Mayonnaise-Rezepte?"}
51
+ ]
52
+
53
+ encodeds = tokenizer.apply_chat_template(messages, return_tensors="pt")
54
+
55
+ model_inputs = encodeds.to(device)
56
+ model.to(device)
57
+
58
+ generated_ids = model.generate(model_inputs, max_new_tokens=1000, do_sample=True)
59
+ decoded = tokenizer.batch_decode(generated_ids)
60
+ print(decoded[0])
61
+ ```
62
+
63
+
64
  ## mt-bench-de
65
  ```yaml
66
  {
 
106
  random_seed: 0
107
  ```
108