Update README.md
Browse files
README.md
CHANGED
@@ -14,4 +14,69 @@ tags:
|
|
14 |
- schaapje
|
15 |
inference: false
|
16 |
license: apache-2.0
|
17 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
- schaapje
|
15 |
inference: false
|
16 |
license: apache-2.0
|
17 |
+
---
|
18 |
+
|
19 |
+
# Schaapje-2B-Pretrained
|
20 |
+
|
21 |
+
## Model description
|
22 |
+
|
23 |
+
This continual pretrained model is pretrained on roughly 2.4 Billion tokens of Dutch language data based on Wikipedia and MC4.
|
24 |
+
|
25 |
+
As a base model the IBM Granite 3.0 2B Instruct model was used.
|
26 |
+
|
27 |
+
See [ibm-granite/granite-3.0-2b-instruct](https://huggingface.co/ibm-granite/granite-3.0-2b-instruct) for all information about the IBM Granite foundation model.
|
28 |
+
|
29 |
+
## Model usage
|
30 |
+
|
31 |
+
A basic example of how to use this continual pretrained model.
|
32 |
+
|
33 |
+
!! IMPORTANT NOTE !!
|
34 |
+
As this is an instruct model that was continual pretrained on dutch data there is some degredation in the performance regarding instruction-following. This custom pretrained model should be further finetuned with SFT in which the embedding and lm_head layer are also trained. Given a proper SFT dataset in dutch this will restore the instruction following/EOS token functionality.
|
35 |
+
See the SFT training notebook for Schaapje on one of the ways on how to do this.
|
36 |
+
|
37 |
+
```
|
38 |
+
import torch
|
39 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
40 |
+
|
41 |
+
device = 'cuda'
|
42 |
+
model_name = 'robinsmits/Schaapje-2B-Pretrained'
|
43 |
+
|
44 |
+
model = AutoModelForCausalLM.from_pretrained(model_name,
|
45 |
+
device_map = "auto",
|
46 |
+
torch_dtype = torch.bfloat16)
|
47 |
+
|
48 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
49 |
+
|
50 |
+
messages = [{"role": "user", "content": "Hoi hoe gaat het ermee?"}]
|
51 |
+
|
52 |
+
chat = tokenizer.apply_chat_template(messages,
|
53 |
+
tokenize = False,
|
54 |
+
add_generation_prompt = True)
|
55 |
+
|
56 |
+
input_tokens = tokenizer(chat, return_tensors = "pt").to('cuda')
|
57 |
+
|
58 |
+
output = model.generate(**input_tokens,
|
59 |
+
max_new_tokens = 512,
|
60 |
+
do_sample = True)
|
61 |
+
|
62 |
+
output = tokenizer.decode(output[0], skip_special_tokens = False)
|
63 |
+
print(output)
|
64 |
+
```
|
65 |
+
|
66 |
+
## Intended uses & limitations
|
67 |
+
|
68 |
+
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.
|
69 |
+
|
70 |
+
## Datasets and Licenses
|
71 |
+
|
72 |
+
The datasets used for the continual pretraining had different licenses:
|
73 |
+
- [wikimedia/wikipedia](https://huggingface.co/datasets/wikimedia/wikipedia): cc-by-sa-3.0
|
74 |
+
- [yhavinga/mc4_nl_cleaned](https://huggingface.co/datasets/yhavinga/mc4_nl_cleaned): ODB-BY
|
75 |
+
|
76 |
+
## Model Training
|
77 |
+
|
78 |
+
The continual pretraining notebook is available at the following link: [Schaapje_2B_Pretrained](https://github.com/RobinSmits/Schaapje/blob/main/Schaapje_2B_Pretrained.ipynb)
|
79 |
+
|
80 |
+
Training was performed with Google Colab PRO on a A100 - 40GB in multiple sessions. As the amount of data was more than would fit within the maximum 24 hour session that Google Colab PRO allows I split the dataset in 5 roughly equal parts. Training for each part lasted around 18 to 24 hours. The 'resume_from_checkpoint' was used to continue pretraining in a proper way.
|
81 |
+
|
82 |
+
Continual Pretraining dataset was created with the script: [prepare_pretraining_datasets](https://github.com/RobinSmits/Schaapje/blob/main/prepare_pretraining_datasets.py)
|