mpasila commited on
Commit
1f5574f
1 Parent(s): 42b2773

Added weights

Browse files
README.md ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ tags:
5
+ - finnish
6
+ - llama
7
+ inference: true
8
+ pipeline_tag: text-generation
9
+ ---
10
+ This is an EXL2 quantized model in 4bpw of [Finnish-NLP/llama-7b-finnish-instruct-v0.2](https://huggingface.co/Finnish-NLP/llama-7b-finnish-instruct-v0.2) using the default calibration dataset.
11
+
12
+ Prompt format is custom (it seems to be kinda broken):
13
+
14
+ ```
15
+ <|alku|> Olet tekoälyavustaja. Seuraavaksi saat kysymyksen tai tehtävän. Kirjoita vastaus parhaasi mukaan siten että se täyttää kysymyksen tai tehtävän vaatimukset.
16
+ <|ihminen|> Kysymys/Tehtävä:
17
+ {}
18
+ <|avustaja|> Vastauksesi:
19
+ <|loppu|>
20
+ ```
21
+
22
+ # Original Model card:
23
+
24
+ # Llama-7b-instruct-v0.2 for Finnish
25
+
26
+
27
+ - This is 0.2 version release of our Instruct finetuned model from https://huggingface.co/Finnish-NLP/llama-7b-finnish
28
+ - Model was trained for 3 epochs using 21946 samples and for this release we chose checkpoint at 8000 steps.
29
+ - Future DPO/SFT+DPO variants are in the pipeline. Also we are investigating and testing different merging techiques
30
+
31
+ For finetuning we try to select well known and widely used dataset and then filter/translate those with multiple methods:
32
+ For this version we used a mix 21946 samples in total from the the following datasets:
33
+ - LIMA from https://github.com/TurkuNLP/finnish-instructions
34
+ - Dolly from https://github.com/TurkuNLP/finnish-instructions
35
+ - OASST from https://github.com/TurkuNLP/finnish-instructions
36
+ - Ultrafeedback https://huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized/viewer/default/train_sft translated with deepl
37
+ - facebook/belebele Finnish subset
38
+ - google/boolq translated with deepl
39
+ - LDJnr/Capybara translated with deepl
40
+ - allenai/ai2_arc translated with deepl
41
+
42
+
43
+ ### How to use
44
+
45
+ Here is an example of using this model with Unsloth with some generation arguments you can modify:
46
+
47
+ ```python
48
+ import torch
49
+ from unsloth import FastLlamaModel
50
+
51
+ max_seq_length = 2048
52
+ dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
53
+ load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
54
+
55
+
56
+ use_unsloth = True
57
+ # use_transformers = True
58
+
59
+ # LOADING MODEL USIINIG TRANSFORMERS assumes at least 16GB of memory. Tested with this configuration
60
+ # If you have less memory use load_in_4bit or load_in_8_bit as needed
61
+ if use_transformers:
62
+ major_version, minor_version = torch.cuda.get_device_capability()
63
+ model = AutoModelForCausalLM.from_pretrained("Finnish-NLP/llama-7b-finnish-instruct-v0.2", device_map='cuda:0', torch_dtype = torch.bfloat16 if major_version >=8 else torch.float16)
64
+ tokenizer = AutoTokenizer.from_pretrained("Finnish-NLP/llama-7b-finnish-instruct-v0.2")
65
+
66
+ # USING UNSLOTH, tested with load_in_4bit
67
+ if use_unsloth:
68
+ model, tokenizer = FastLlamaModel.from_pretrained(
69
+ model_name = "Finnish-NLP/llama-7b-finnish-instruct-v0.2"
70
+ max_seq_length = max_seq_length,
71
+ dtype = dtype,
72
+ load_in_4bit = load_in_4bit
73
+ )
74
+
75
+ alpaca_prompt = """<|alku|> Olet tekoälyavustaja. Seuraavaksi saat kysymyksen tai tehtävän. Kirjoita vastaus parhaasi mukaan siten että se täyttää kysymyksen tai tehtävän vaatimukset.
76
+ <|ihminen|> Kysymys/Tehtävä:
77
+ {}
78
+ <|avustaja|> Vastauksesi:
79
+ """
80
+
81
+ sample_questions = ["Ketkä ovat Aku Ankan luona asuvat kolme ankanpoikaa?",\
82
+ "Mikä on Suomen korkein tunturi?",\
83
+ "Suomi soti Neuvostoliittoa vastaan talvisodan 1939-1940. Kuinka monta päivää sota kesti?",\
84
+ "Luettele viisi yleistä Suomessa yleisesti käytettyä pojan nimeä. Nimet:",\
85
+ "Luettele lyhyt, maksimissaan 50 sanan mittainen runo Suomesta. Runo:",\
86
+ ]
87
+
88
+ from transformers import GenerationConfig
89
+
90
+ generation_config = GenerationConfig(
91
+ pad_token_id=tokenizer.eos_token_id,
92
+ eos_token_id=tokenizer.convert_tokens_to_ids("<|loppu|>"),
93
+ )
94
+
95
+
96
+ for sample_question in sample_questions:
97
+
98
+ model.eval()
99
+
100
+ inputs = tokenizer(
101
+ [
102
+ alpaca_prompt.format(
103
+ sample_question, # instruction
104
+ )
105
+ ]*1, return_tensors = "pt").to("cuda")
106
+
107
+ with torch.no_grad():
108
+ generated_ids = model.generate(
109
+ input_ids=inputs["input_ids"],
110
+ attention_mask=inputs["attention_mask"],
111
+ generation_config=generation_config, **{
112
+ "temperature": 0.1,
113
+ "penalty_alpha": 0.6,
114
+ "top_k": 3,
115
+ "do_sample": True,
116
+ "repetition_penalty": 1.28,
117
+ "min_length": 10,
118
+ "max_new_tokens": 200
119
+ })
120
+
121
+ generated_text = tokenizer.batch_decode(generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True)[0]
122
+ print(len(generated_ids[0]))
123
+ print("KYSYMYS:")
124
+ print(generated_text.split('<|avustaja|>')[0])
125
+ print("VASTAUS:")
126
+ print(generated_text.split('<|avustaja|> Vastauksesi:')[1])
127
+ print('##################################')
128
+
129
+ '''
130
+ -->
131
+ <s><|alku|> Olet tekoälyavustaja. Seuraavaksi saat kysymyksen tai tehtävän. Kirjoita vastaus parhaasi mukaan siten että se täyttää kysymyksen tai tehtävän vaatimukset.
132
+ <|ihminen|> Kysymys/Tehtävä:
133
+ Aku Ankan luona asuu kolme ankanpoikaa. Mitkä ovat heidän nimet?
134
+ VASTAUS:
135
+ Ankka Akun kanssa asuvat pojat ovat nimeltään Tupu, Hupu ja Lupu <|loppu|>
136
+ ##################################
137
+
138
+ KYSYMYS:
139
+ <s><|alku|> Olet tekoälyavustaja. Seuraavaksi saat kysymyksen tai tehtävän. Kirjoita vastaus parhaasi mukaan siten että se täyttää kysymyksen tai tehtävän vaatimukset.
140
+ <|ihminen|> Kysymys/Tehtävä:
141
+ Mikä on Suomen korkein tunturi?
142
+ VASTAUS:
143
+ Suomen korkein tunturihuippu on Haltitunturi (1 324 metriä). <|loppu|>
144
+ ##################################
145
+
146
+ KYSYMYS:
147
+ <s><|alku|> Olet tekoälyavustaja. Seuraavaksi saat kysymyksen tai tehtävän. Kirjoita vastaus parhaasi mukaan siten että se täyttää kysymyksen tai tehtävän vaatimukset.
148
+ <|ihminen|> Kysymys/Tehtävä:
149
+ Suomi soti Neuvostoliittoa vastaan talvisodan 1939-1940. Kuinka monta päivää sota kesti?
150
+ VASTAUS:
151
+ Talvisodan aikana Neuvostoliitto hyökkäsi Suomeen 30. marraskuuta ja 13. maaliskuuta välisenä aikana. Tämä tarkoittaa, että talvisota kesti 105 päivää. <|loppu|>
152
+ ##################################
153
+
154
+ KYSYMYS:
155
+ <s><|alku|> Olet tekoälyavustaja. Seuraavaksi saat kysymyksen tai tehtävän. Kirjoita vastaus parhaasi mukaan siten että se täyttää kysymyksen tai tehtävän vaatimukset.
156
+ <|ihminen|> Kysymys/Tehtävä:
157
+ Luettele viisi yleistä Suomessa yleisesti käytettyä pojan nimeä. Nimet:
158
+ VASTAUS:
159
+ Yleisiä suomalaisia poikien nimiä ovat Eino, Onni, Olavi, Väinö ja Ilmari. <|loppu|>
160
+ ##################################
161
+
162
+ KYSYMYS:
163
+ <s><|alku|> Olet tekoälyavustaja. Seuraavaksi saat kysymyksen tai tehtävän. Kirjoita vastaus parhaasi mukaan siten että se täyttää kysymyksen tai tehtävän vaatimukset.
164
+ <|ihminen|> Kysymys/Tehtävä:
165
+ Luettele lyhyt, maksimissaan 50 sanan mittainen runo Suomesta. Runo:
166
+ VASTAUS:
167
+ Olipa kerran kaunis maa,
168
+ jossa ihmiset elivät sopusoinnussa.
169
+ Se oli täynnä metsiä ja järviä,
170
+ ja siellä asui onnellisia ja ystävällisiä ihmisiä. <|loppu|>
171
+ ```
172
+
173
+ ### Limitations and bias
174
+
175
+ The training data used for this model contains a lot of content from the internet, which is far from neutral.
176
+ Therefore, the model can have biased predictions. This bias will also affect all fine-tuned versions of this model.
177
+ To reduce toxic content, the pretrained version of thiis model was trained with dataset filtered with a toxicity classifier but it cannot truly eliminate all toxic text.
178
+
179
+ ### Finetuning
180
+
181
+ Training was conducted on RTX 4080 using Unsloth framework https://github.com/unslothai/unsloth \
182
+ Training script is available in this repo.
183
+
184
+
185
+ ## Evaluation results
186
+
187
+ This model was evaluated using [FIN-bench by TurkuNLP](https://github.com/TurkuNLP/FIN-bench) with zero-shot setting, but \
188
+ the evaluation script had some problems running succesfully, so the results reported below should perhaps be viewed with some caution.
189
+
190
+ [llama-7b-finnish-instruct-v0.2](https://huggingface.co/Finnish-NLP/llama-7b-finnish-instruct-v0.2):
191
+
192
+ | Task |Version| Metric |Value | |Stderr|
193
+ |------------------------------------------------|------:|---------------------|-----:|---|-----:|
194
+ |bigbench_analogies | 0|multiple_choice_grade|0.5385|± |0.0439|
195
+ |bigbench_arithmetic_1_digit_addition | 0|multiple_choice_grade|0.3400|± |0.0476|
196
+ |bigbench_arithmetic_1_digit_division | 0|multiple_choice_grade|0.4783|± |0.1065|
197
+ |bigbench_arithmetic_1_digit_multiplication | 0|multiple_choice_grade|0.5200|± |0.0502|
198
+ |bigbench_arithmetic_1_digit_subtraction | 0|multiple_choice_grade|0.3400|± |0.0476|
199
+ |bigbench_arithmetic_2_digit_addition | 0|multiple_choice_grade|0.3200|± |0.0469|
200
+ |bigbench_arithmetic_2_digit_division | 0|multiple_choice_grade|0.3400|± |0.0476|
201
+ |bigbench_arithmetic_2_digit_multiplication | 0|multiple_choice_grade|0.2200|± |0.0416|
202
+ |bigbench_arithmetic_2_digit_subtraction | 0|multiple_choice_grade|0.2800|± |0.0451|
203
+ |bigbench_arithmetic_3_digit_addition | 0|multiple_choice_grade|0.3000|± |0.0461|
204
+ |bigbench_arithmetic_3_digit_division | 0|multiple_choice_grade|0.2500|± |0.0435|
205
+ |bigbench_arithmetic_3_digit_multiplication | 0|multiple_choice_grade|0.2200|± |0.0416|
206
+ |bigbench_arithmetic_3_digit_subtraction | 0|multiple_choice_grade|0.4000|± |0.0492|
207
+ |bigbench_arithmetic_4_digit_addition | 0|multiple_choice_grade|0.3500|± |0.0479|
208
+ |bigbench_arithmetic_4_digit_division | 0|multiple_choice_grade|0.2600|± |0.0441|
209
+ |bigbench_arithmetic_4_digit_multiplication | 0|multiple_choice_grade|0.2100|± |0.0409|
210
+ |bigbench_arithmetic_4_digit_subtraction | 0|multiple_choice_grade|0.4400|± |0.0499|
211
+ |bigbench_arithmetic_5_digit_addition | 0|multiple_choice_grade|0.4500|± |0.0500|
212
+ |bigbench_arithmetic_5_digit_division | 0|multiple_choice_grade|0.1800|± |0.0386|
213
+ |bigbench_arithmetic_5_digit_multiplication | 0|multiple_choice_grade|0.2000|± |0.0402|
214
+ |bigbench_arithmetic_5_digit_subtraction | 0|multiple_choice_grade|0.5000|± |0.0503|
215
+ |bigbench_cause_and_effect_one_sentence | 0|multiple_choice_grade|0.5294|± |0.0706|
216
+ |bigbench_cause_and_effect_one_sentence_no_prompt| 0|multiple_choice_grade|0.8627|± |0.0487|
217
+ |bigbench_cause_and_effect_two_sentences | 0|multiple_choice_grade|0.4314|± |0.0700|
218
+ |bigbench_emotions | 0|multiple_choice_grade|0.4750|± |0.0396|
219
+ |bigbench_empirical_judgments | 0|multiple_choice_grade|0.4141|± |0.0498|
220
+ |bigbench_general_knowledge | 0|multiple_choice_grade|0.4429|± |0.0598|
221
+ |bigbench_hhh_alignment_harmless | 0|multiple_choice_grade|0.3793|± |0.0643|
222
+ |bigbench_hhh_alignment_helpful | 0|multiple_choice_grade|0.3220|± |0.0614|
223
+ |bigbench_hhh_alignment_honest | 0|multiple_choice_grade|0.3898|± |0.0640|
224
+ |bigbench_hhh_alignment_other | 0|multiple_choice_grade|0.5581|± |0.0766|
225
+ |bigbench_intent_recognition | 0|multiple_choice_grade|0.2717|± |0.0169|
226
+ |bigbench_misconceptions | 0|multiple_choice_grade|0.5373|± |0.0432|
227
+ |bigbench_paraphrase | 0|multiple_choice_grade|0.5000|± |0.0354|
228
+ |bigbench_sentence_ambiguity | 0|multiple_choice_grade|0.5333|± |0.0649|
229
+ |bigbench_similarities_abstraction | 0|multiple_choice_grade|0.5921|± |0.0567|
230
+
231
+
232
+
233
+ ## Team Members
234
+
235
+ - Aapo Tanskanen, [Hugging Face profile](https://huggingface.co/aapot), [LinkedIn profile](https://www.linkedin.com/in/aapotanskanen/)
236
+ - Rasmus Toivanen, [Hugging Face profile](https://huggingface.co/RASMUS), [LinkedIn profile](https://www.linkedin.com/in/rasmustoivanen/)
237
+
238
+ Feel free to contact us for more details 🤗
config.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "model_merged_v0.2_option2",
3
+ "architectures": [
4
+ "LlamaForCausalLM"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "bos_token_id": 1,
9
+ "eos_token_id": 64260,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 4096,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 11008,
14
+ "max_position_embeddings": 2048,
15
+ "model_type": "llama",
16
+ "num_attention_heads": 32,
17
+ "num_hidden_layers": 32,
18
+ "num_key_value_heads": 32,
19
+ "pretraining_tp": 1,
20
+ "rms_norm_eps": 1e-06,
21
+ "rope_scaling": null,
22
+ "rope_theta": 10000.0,
23
+ "tie_word_embeddings": false,
24
+ "torch_dtype": "float16",
25
+ "transformers_version": "4.37.1",
26
+ "use_cache": true,
27
+ "vocab_size": 64262,
28
+ "quantization_config": {
29
+ "quant_method": "exl2",
30
+ "version": "0.0.16",
31
+ "bits": 4.0,
32
+ "head_bits": 6,
33
+ "calibration": {
34
+ "rows": 100,
35
+ "length": 2048,
36
+ "dataset": "(default)"
37
+ }
38
+ }
39
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "transformers_version": "4.37.1"
6
+ }
job_new.json ADDED
The diff for this file is too large to render. See raw diff
 
measurement.json ADDED
The diff for this file is too large to render. See raw diff
 
output.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6878949cb84a7c215d00c357994429248986eaf9dccfefecd6a1c1610526e12
3
+ size 3973772368
special_tokens_map.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|loppu|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "<PAD>",
18
+ "lstrip": false,
19
+ "normalized": true,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<unk>",
25
+ "lstrip": false,
26
+ "normalized": true,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "added_tokens_decoder": {
5
+ "0": {
6
+ "content": "<unk>",
7
+ "lstrip": false,
8
+ "normalized": true,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "1": {
14
+ "content": "<s>",
15
+ "lstrip": false,
16
+ "normalized": true,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "2": {
22
+ "content": "</s>",
23
+ "lstrip": false,
24
+ "normalized": true,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "64256": {
30
+ "content": "<|alku|>",
31
+ "lstrip": false,
32
+ "normalized": true,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": false
36
+ },
37
+ "64257": {
38
+ "content": "<PAD>",
39
+ "lstrip": false,
40
+ "normalized": true,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "64258": {
46
+ "content": "<|ihminen|>",
47
+ "lstrip": false,
48
+ "normalized": true,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": false
52
+ },
53
+ "64259": {
54
+ "content": "<|avustaja|>",
55
+ "lstrip": false,
56
+ "normalized": true,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": false
60
+ },
61
+ "64260": {
62
+ "content": "<|loppu|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "64261": {
70
+ "content": "\n",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ }
77
+ },
78
+ "bos_token": "<s>",
79
+ "clean_up_tokenization_spaces": true,
80
+ "eos_token": "<|loppu|>",
81
+ "model_max_length": 2048,
82
+ "pad_token": "<PAD>",
83
+ "sp_model_kwargs": {},
84
+ "tokenizer_class": "LlamaTokenizer",
85
+ "unk_token": "<unk>",
86
+ "use_default_system_prompt": false
87
+ }