mpasila commited on
Commit
5744952
1 Parent(s): 4e3a1e9

Added weights

Browse files
README.md ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.1](https://huggingface.co/Finnish-NLP/llama-7b-finnish-instruct-v0.1) 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.1 for Finnish
25
+
26
+
27
+ - This is an early v0.1 version release of our Instruct finetuned model from https://huggingface.co/Finnish-NLP/llama-7b-finnish
28
+ - Model was trained for 2 epochs using 11014 samples and for this release we chose checkpoint at 2500/4048 steps.
29
+ - Future DPO/SFT+DPO variants are in the pipeline.
30
+
31
+ For finetuning we used mix of the following datasets:
32
+ - LIMA from https://github.com/TurkuNLP/finnish-instructions
33
+ - Dolly from https://github.com/TurkuNLP/finnish-instructions
34
+ - OASST from https://github.com/TurkuNLP/finnish-instructions
35
+ - Heavily filtered version of Ultrachat https://huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized/viewer/default/train_sft + deepl translations by writing
36
+ samples to file and uploading to deepl.com to filetranslation and then parsinig the translated files back to samples
37
+
38
+
39
+
40
+ ### How to use
41
+
42
+ Here is an example of using this model with Unsloth with some generation arguments you can modify:
43
+
44
+ ```python
45
+ import torch
46
+ from unsloth import FastLlamaModel
47
+
48
+ max_seq_length = 2048
49
+ dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
50
+ load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
51
+
52
+
53
+ use_unsloth = True
54
+ # use_transformers = True
55
+
56
+ # LOADING MODEL USIINIG TRANSFORMERS assumes at least 16GB of memory. Tested with this configuration
57
+ # If you have less memory use load_in_4bit or load_in_8_bit as needed
58
+ if use_transformers:
59
+ major_version, minor_version = torch.cuda.get_device_capability()
60
+ model = AutoModelForCausalLM.from_pretrained("Finnish-NLP/llama-7b-finnish-instruct-v0.1", device_map='cuda:0', torch_dtype = torch.bfloat16 if major_version >=8 else torch.float16)
61
+ tokenizer = AutoTokenizer.from_pretrained("Finnish-NLP/llama-7b-finnish-instruct-v0.1")
62
+
63
+ # USING UNSLOTH, tested with load_in_4bit
64
+ if use_unsloth:
65
+ model, tokenizer = FastLlamaModel.from_pretrained(
66
+ model_name = "Finnish-NLP/llama-7b-finnish-instruct-v0.1"
67
+ max_seq_length = max_seq_length,
68
+ dtype = dtype,
69
+ load_in_4bit = load_in_4bit
70
+ )
71
+
72
+ 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.
73
+ <|ihminen|> Kysymys/Tehtävä:
74
+ {}
75
+ <|avustaja|> Vastauksesi:
76
+ """
77
+
78
+ sample_questions = ["Ketkä ovat Aku Ankan luona asuvat kolme ankanpoikaa?",\
79
+ "Mikä on Suomen korkein tunturi?",\
80
+ "Suomi soti Neuvostoliittoa vastaan talvisodan 1939-1940. Kuinka monta päivää sota kesti?",\
81
+ "Luettele viisi yleistä Suomessa yleisesti käytettyä pojan nimeä. Nimet:",\
82
+ "Luettele lyhyt, maksimissaan 50 sanan mittainen runo Suomesta. Runo:",\
83
+ ]
84
+
85
+ from transformers import GenerationConfig
86
+
87
+ generation_config = GenerationConfig(
88
+ pad_token_id=tokenizer.eos_token_id,
89
+ eos_token_id=tokenizer.convert_tokens_to_ids("<|loppu|>"),
90
+ )
91
+
92
+
93
+ for sample_question in sample_questions:
94
+
95
+ model.eval()
96
+
97
+ inputs = tokenizer(
98
+ [
99
+ alpaca_prompt.format(
100
+ sample_question, # instruction
101
+ )
102
+ ]*1, return_tensors = "pt").to("cuda")
103
+
104
+ with torch.no_grad():
105
+ generated_ids = model.generate(
106
+ input_ids=inputs["input_ids"],
107
+ attention_mask=inputs["attention_mask"],
108
+ generation_config=generation_config, **{
109
+ "temperature": 0.1,
110
+ "penalty_alpha": 0.6,
111
+ "top_k": 3,
112
+ "do_sample": True,
113
+ "repetition_penalty": 1.28,
114
+ "min_length": 10,
115
+ "max_new_tokens": 200
116
+ })
117
+
118
+ generated_text = tokenizer.batch_decode(generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True)[0]
119
+ print(len(generated_ids[0]))
120
+ print("KYSYMYS:")
121
+ print(generated_text.split('<|avustaja|>')[0])
122
+ print("VASTAUS:")
123
+ print(generated_text.split('<|avustaja|> Vastauksesi:')[1])
124
+ print('##################################')
125
+
126
+ '''
127
+ -->
128
+ 79
129
+ KYSYMYS:
130
+ <|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.<|ihminen|> Kysymys/Tehtävä: Aku Ankan luona asuu kolme ankanpoikaa. He ovat nimeltään:
131
+ VASTAUS:
132
+ Ankkalinnan asukkaat ovat Aku Ankka, hänen vaimonsa Iines ja heidän lapsensa Tupu, Hupu ja Lupu
133
+ ##################################
134
+ 65
135
+ KYSYMYS:
136
+ <|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.<|ihminen|> Kysymys/Tehtävä: Mikä on Suomen korkein tunturi?
137
+ VASTAUS:
138
+ Suomen korkeimmat tunturit ovat Halti (1 324 metriä) ja Saana (1 029 metriä).
139
+ ##################################
140
+ 80
141
+ KYSYMYS:
142
+ <|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.<|ihminen|> Kysymys/Tehtävä: Suomi soti Neuvostoliittoa vastaan talvisodan 1939-1940. Kuinka monta päivää sota kesti?
143
+ VASTAUS:
144
+ Talvisodan aikana Neuvostoliitto hyökkäsi Suomeen 30. marraskuuta ja 13. maaliskuuta välisenä aikana. Tämä oli lyhyt sota, joka kesti 105 päivää.
145
+ ##################################
146
+ 87
147
+ KYSYMYS:
148
+ <|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.<|ihminen|> Kysymys/Tehtävä: Luettele viisi yleistä Suomessa yleisesti käytettyä pojan nimeä. Nimet:
149
+ VASTAUS:
150
+ Suomessa on monia yleisiä poikien nimiä, mutta tässä on muutamia suosittuja: 1. Eemeli 2 Onni 3 Eino 4 Väinö 5 Artturi
151
+ ##################################
152
+ 63
153
+ KYSYMYS:
154
+ <|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.<|ihminen|> Kysymys/Tehtävä: Luettele lyhyt, maksimissaan 50 sanan mittainen runo Suomesta. Runo:
155
+ VASTAUS:
156
+ Suomen talvi on kylmä, kesä on lyhyt, mutta luonto on kaunis.
157
+ '''
158
+
159
+ ```
160
+
161
+ ### Limitations and bias
162
+
163
+ The training data used for this model contains a lot of content from the internet, which is far from neutral.
164
+ Therefore, the model can have biased predictions. This bias will also affect all fine-tuned versions of this model.
165
+ 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.
166
+
167
+ ### Finetuning
168
+
169
+ Training was conducted on RTX 4080 using Unsloth framework https://github.com/unslothai/unsloth \
170
+ Training script is available in this repo.
171
+
172
+
173
+ ## Evaluation results
174
+
175
+ This model was evaluated using [FIN-bench by TurkuNLP](https://github.com/TurkuNLP/FIN-bench) with zero-shot setting, but \
176
+ the evaluation script had some problems running succesfully, so the results reported below should perhaps be viewed with some caution.
177
+
178
+ [llama-7b-finnish-instruct-v0.1](https://huggingface.co/Finnish-NLP/llama-7b-finnish-instruct-v0.1):
179
+
180
+ | Task |Version| Metric |Value | |Stderr|
181
+ |------------------------------------------------|------:|---------------------|-----:|---|-----:|
182
+ |bigbench_analogies | 0|multiple_choice_grade|0.5000|± |0.0440|
183
+ |bigbench_arithmetic_1_digit_addition | 0|multiple_choice_grade|0.4800|± |0.0502|
184
+ |bigbench_arithmetic_1_digit_division | 0|multiple_choice_grade|0.5652|± |0.1057|
185
+ |bigbench_arithmetic_1_digit_multiplication | 0|multiple_choice_grade|0.5000|± |0.0503|
186
+ |bigbench_arithmetic_1_digit_subtraction | 0|multiple_choice_grade|0.6700|± |0.0473|
187
+ |bigbench_arithmetic_2_digit_addition | 0|multiple_choice_grade|0.4000|± |0.0492|
188
+ |bigbench_arithmetic_2_digit_division | 0|multiple_choice_grade|0.5400|± |0.0501|
189
+ |bigbench_arithmetic_2_digit_multiplication | 0|multiple_choice_grade|0.2700|± |0.0446|
190
+ |bigbench_arithmetic_2_digit_subtraction | 0|multiple_choice_grade|0.4800|± |0.0502|
191
+ |bigbench_arithmetic_3_digit_addition | 0|multiple_choice_grade|0.4100|± |0.0494|
192
+ |bigbench_arithmetic_3_digit_division | 0|multiple_choice_grade|0.2800|± |0.0451|
193
+ |bigbench_arithmetic_3_digit_multiplication | 0|multiple_choice_grade|0.2600|± |0.0441|
194
+ |bigbench_arithmetic_3_digit_subtraction | 0|multiple_choice_grade|0.5300|± |0.0502|
195
+ |bigbench_arithmetic_4_digit_addition | 0|multiple_choice_grade|0.3400|± |0.0476|
196
+ |bigbench_arithmetic_4_digit_division | 0|multiple_choice_grade|0.3300|± |0.0473|
197
+ |bigbench_arithmetic_4_digit_multiplication | 0|multiple_choice_grade|0.2100|± |0.0409|
198
+ |bigbench_arithmetic_4_digit_subtraction | 0|multiple_choice_grade|0.6000|± |0.0492|
199
+ |bigbench_arithmetic_5_digit_addition | 0|multiple_choice_grade|0.5600|± |0.0499|
200
+ |bigbench_arithmetic_5_digit_division | 0|multiple_choice_grade|0.2300|± |0.0423|
201
+ |bigbench_arithmetic_5_digit_multiplication | 0|multiple_choice_grade|0.2500|± |0.0435|
202
+ |bigbench_arithmetic_5_digit_subtraction | 0|multiple_choice_grade|0.5600|± |0.0499|
203
+ |bigbench_cause_and_effect_one_sentence | 0|multiple_choice_grade|0.4902|± |0.0707|
204
+ |bigbench_cause_and_effect_one_sentence_no_prompt| 0|multiple_choice_grade|0.9020|± |0.0421|
205
+ |bigbench_cause_and_effect_two_sentences | 0|multiple_choice_grade|0.3922|± |0.0690|
206
+ |bigbench_emotions | 0|multiple_choice_grade|0.2313|± |0.0334|
207
+ |bigbench_empirical_judgments | 0|multiple_choice_grade|0.3535|± |0.0483|
208
+ |bigbench_general_knowledge | 0|multiple_choice_grade|0.3857|± |0.0586|
209
+ |bigbench_hhh_alignment_harmless | 0|multiple_choice_grade|0.3966|± |0.0648|
210
+ |bigbench_hhh_alignment_helpful | 0|multiple_choice_grade|0.3220|± |0.0614|
211
+ |bigbench_hhh_alignment_honest | 0|multiple_choice_grade|0.3898|± |0.0640|
212
+ |bigbench_hhh_alignment_other | 0|multiple_choice_grade|0.5814|± |0.0761|
213
+ |bigbench_intent_recognition | 0|multiple_choice_grade|0.2211|± |0.0158|
214
+ |bigbench_misconceptions | 0|multiple_choice_grade|0.5149|± |0.0433|
215
+ |bigbench_paraphrase | 0|multiple_choice_grade|0.5400|± |0.0353|
216
+ |bigbench_sentence_ambiguity | 0|multiple_choice_grade|0.4500|± |0.0648|
217
+ |bigbench_similarities_abstraction | 0|multiple_choice_grade|0.5789|± |0.0570|
218
+
219
+
220
+
221
+ ## Team Members
222
+
223
+ - Aapo Tanskanen, [Hugging Face profile](https://huggingface.co/aapot), [LinkedIn profile](https://www.linkedin.com/in/aapotanskanen/)
224
+ - Rasmus Toivanen, [Hugging Face profile](https://huggingface.co/RASMUS), [LinkedIn profile](https://www.linkedin.com/in/rasmustoivanen/)
225
+
226
+ Feel free to contact us for more details 🤗
config.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "new_model_merged_vitun_hyva_2",
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.15",
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:4e883256daa658041efa335e555a5d39749893b06b11683fff6961c47eb86df3
3
+ size 3973591240
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
+ }