davda54 commited on
Commit
0927925
1 Parent(s): 4620a93

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +29 -4
README.md CHANGED
@@ -25,7 +25,7 @@ datasets:
25
 
26
  <img align="center" src="https://huggingface.co/ltg/norbert3-base/resolve/main/norbert.png" width=12.5%>
27
 
28
- This is a model instruction-tuned on open datasets released under the most permissive apache-2.0 licence — thus we can release this model under the same license and make it openly available for commercial applications.
29
 
30
  The released weights are still a work in progress and they might change in the future. This is the first iteration of instruction-tuning our NorMistral models and it currently uses only the SFT phase without any preference optimization. Please let us know your feedback to improve the model in future releases.
31
 
@@ -39,7 +39,9 @@ The corpus was compiled by this process:
39
  4. Since most of that dataset contains only a single dialogue turn, we generated more turns using [Mixtral-8x7B](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1).
40
  5. Finally, we translated the resulting dataset into Bokmål and Nynorsk using [NorMistral-7b-warm](https://huggingface.co/norallm/normistral-7b-warm).
41
 
42
- ## Prompt format
 
 
43
 
44
  NorMistral uses ChatML-like format for structuring the (multi-turn) conversations. An example of a prompt in this format looks like the following (notice the special `<|im_start|>` and `<|im_end|>` tokens).
45
 
@@ -58,19 +60,42 @@ This prompt-format is available as a [chat template](https://huggingface.co/docs
58
  `tokenizer.apply_chat_template()` method:
59
 
60
  ```python
 
 
 
61
  messages = [
62
  {"role": "user", "content": "Hva er hovedstaden i Norge?"},
63
- {"role": "assistant", "content": "Hovedstaden i Norge er Oslo. Denne byen ligger i den sørøstlige delen av landet, ved Oslofjorden. Oslo er en av de raskest voksende byene i Europa, og den er kjent for sin rike historie, kultur og moderne arkitektur. Noen populære turistattraksjoner i Oslo inkluderer Vigelandsparken, som viser mer enn 200 skulpturer laget av den berømte norske skulptøren Gustav Vigeland, og det kongelige slott, som er den offisielle residensen til Norges kongefamilie. Oslo er også hjemsted for mange museer, gallerier og teatre, samt mange restauranter og barer som tilbyr et bredt utvalg av kulinariske og kulturelle opplevelser."}
64
  {"role": "user", "content": "Gi meg en liste over de beste stedene å besøke i hovedstaden"}
65
  ]
66
  gen_input = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
67
- model.generate(**gen_input)
68
  ```
69
 
70
  When tokenizing messages for generation, set `add_generation_prompt=True` when calling `apply_chat_template()`. This will append `<|im_start|>assistant\n` to your prompt, to ensure
71
  that the model continues with an assistant response.
72
 
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  ## About the base model
75
 
76
  NorMistral-7b-warm is a large Norwegian language model initialized from [Mistral-7b-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) and
 
25
 
26
  <img align="center" src="https://huggingface.co/ltg/norbert3-base/resolve/main/norbert.png" width=12.5%>
27
 
28
+ This is a model instruction-tuned on open datasets released under the most permissive apache-2.0 licence — thus we can release this model under the same license and make it openly available for commercial applications. The model has been finetuned on 4096 context length, twice as many tokens as the base model.
29
 
30
  The released weights are still a work in progress and they might change in the future. This is the first iteration of instruction-tuning our NorMistral models and it currently uses only the SFT phase without any preference optimization. Please let us know your feedback to improve the model in future releases.
31
 
 
39
  4. Since most of that dataset contains only a single dialogue turn, we generated more turns using [Mixtral-8x7B](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1).
40
  5. Finally, we translated the resulting dataset into Bokmål and Nynorsk using [NorMistral-7b-warm](https://huggingface.co/norallm/normistral-7b-warm).
41
 
42
+ ## How to run the model?
43
+
44
+ ### 1. Prompt format
45
 
46
  NorMistral uses ChatML-like format for structuring the (multi-turn) conversations. An example of a prompt in this format looks like the following (notice the special `<|im_start|>` and `<|im_end|>` tokens).
47
 
 
60
  `tokenizer.apply_chat_template()` method:
61
 
62
  ```python
63
+ from transformers import AutoTokenizer
64
+ tokenizer = AutoTokenizer.from_pretrained("norallm/normistral-7b-warm-instruct")
65
+
66
  messages = [
67
  {"role": "user", "content": "Hva er hovedstaden i Norge?"},
68
+ {"role": "assistant", "content": "Hovedstaden i Norge er Oslo. Denne byen ligger i den sørøstlige delen av landet, ved Oslofjorden. Oslo er en av de raskest voksende byene i Europa, og den er kjent for sin rike historie, kultur og moderne arkitektur. Noen populære turistattraksjoner i Oslo inkluderer Vigelandsparken, som viser mer enn 200 skulpturer laget av den berømte norske skulptøren Gustav Vigeland, og det kongelige slott, som er den offisielle residensen til Norges kongefamilie. Oslo er også hjemsted for mange museer, gallerier og teatre, samt mange restauranter og barer som tilbyr et bredt utvalg av kulinariske og kulturelle opplevelser."},
69
  {"role": "user", "content": "Gi meg en liste over de beste stedene å besøke i hovedstaden"}
70
  ]
71
  gen_input = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
 
72
  ```
73
 
74
  When tokenizing messages for generation, set `add_generation_prompt=True` when calling `apply_chat_template()`. This will append `<|im_start|>assistant\n` to your prompt, to ensure
75
  that the model continues with an assistant response.
76
 
77
 
78
+ ### 2. Generation parameters
79
+
80
+ The model is quite sensitive to generation parameters, it's important to set them correctly. We give an example of a reasonable generation setting below. Note that other libraries have different defaults and that it's important to check them.
81
+
82
+ ```python
83
+ from transformers import AutoModelForCausalLM
84
+ model = AutoModelForCausalLM.from_pretrained("norallm/normistral-7b-warm-instruct", torch_dtype=torch.bfloat16)
85
+
86
+ model.generate(
87
+ gen_input,
88
+ max_new_tokens=1024,
89
+ top_k=64, # top-k sampling
90
+ top_p=0.9, # nucleus sampling
91
+ temperature=0.3, # a low temparature to make the outputs less chaotic
92
+ repetition_penalty=1.0, # turn the repetition penalty off, having it on can lead to
93
+ do_sample=True, # randomly sample the outputs
94
+ use_cache=True # speed-up generation
95
+ )
96
+ ```
97
+
98
+
99
  ## About the base model
100
 
101
  NorMistral-7b-warm is a large Norwegian language model initialized from [Mistral-7b-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) and