chrisociepa
commited on
Commit
•
85170cd
1
Parent(s):
8ab7056
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,195 @@
|
|
1 |
---
|
2 |
license: cc-by-nc-4.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: cc-by-nc-4.0
|
3 |
+
datasets:
|
4 |
+
- chrisociepa/wikipedia-pl-20230401
|
5 |
+
language:
|
6 |
+
- pl
|
7 |
+
library_name: transformers
|
8 |
+
tags:
|
9 |
+
- llama
|
10 |
+
- ALLaMo
|
11 |
+
inference: false
|
12 |
---
|
13 |
+
|
14 |
+
# APT3-1B-Base
|
15 |
+
|
16 |
+
## Introduction
|
17 |
+
|
18 |
+
At [Azurro](https://azurro.pl), we consistently place importance on using the Open Source technologies, both while working on the projects and in our everyday lives. We have decided to share a base language model trained by us. We are confident that smaller language models have great potential, and direct access to them for all people that are interested in such models democratizes this significant and dynamically changing field even more.
|
19 |
+
|
20 |
+
## Statements
|
21 |
+
|
22 |
+
Training large language models requires a lot of computing power and it is meant for the major players on the market. However, does it mean that individuals or small companies cannot train language models capable of performing specific tasks? We decided to answer this question and train our own language model from scratch.
|
23 |
+
|
24 |
+
We have made the following statements:
|
25 |
+
|
26 |
+
* we use 1 consumer graphic card
|
27 |
+
* we train the model only with the Polish corpus
|
28 |
+
* we use manually selected, high quality texts for training the model.
|
29 |
+
|
30 |
+
Why have we made such statements?
|
31 |
+
It is worth noting that training a model requires several times more resources than using it. To put it simply, it can be assumed that it is about 3-4 times more. Therefore, if a model can be run with a graphic card that has 6 GB VRAM, then training this model requires about 24 GB VRAM (this is the minimum value).
|
32 |
+
|
33 |
+
Many consumer computers are equipped with good quality graphic cards that can be used for training a model at one’s own home. This is why we have decided to use a top consumer graphic card - Nvidia’s RTX 4090 24GB VRAM.
|
34 |
+
|
35 |
+
All the currently available language models have been trained mainly with English corpora with a little bit of other languages, including Polish. The effect is that these models are not the best at dealing with the Polish texts. Even the popular GPT models from OpenAI and Bard from Google often have issues with correct forms. Therefore we have decided to prepare a model based only on the Polish corpus. An additional advantage of using only the Polish corpus is the size of the model - it is better to focus on one language in the case of smaller models.
|
36 |
+
|
37 |
+
It is important to remember that models are only as good as the data with which they are trained. Given the small size of the model, we trained it with carefully selected texts. This is why we have not used corpora such as Common Crawl that contain a lot of poor-quality data. With close collaboration and advice from the [Speakleash](https://speakleash.org) team, our team has prepared over 300GB of Polish language text corpus that has then been processed and used for training the model. Additionally, the unique feature of our model is that it has been trained on the largest amount of text among all available models for the Polish language.
|
38 |
+
|
39 |
+
## Model
|
40 |
+
|
41 |
+
APT3-1B-Base has been trained with the use of an original open source framework called [ALLaMo](https://github.com/chrisociepa/allamo). This framework allows the user to train language models similar to the Meta AI’s LLaMA models quickly and efficiently.
|
42 |
+
|
43 |
+
APT3-1B-Base is an autoregressive language model based on the architecture of a transformer. It has been trained with data collected before the end of December 2023.
|
44 |
+
|
45 |
+
The training dataset (the Polish corpus) has over 60 billion tokens, and we use all of them for training with one epoch.
|
46 |
+
|
47 |
+
A special tokenizer has been prepared and trained for the purpose of training the models in the APT3 series.
|
48 |
+
|
49 |
+
### Model description:
|
50 |
+
|
51 |
+
* **Developed by:** [Azurro](https://azurro.pl)
|
52 |
+
* **Language:** Polish
|
53 |
+
* **Model type:** causal decoder-only
|
54 |
+
* **License:** CC BY NC 4.0 (non-commercial use)
|
55 |
+
|
56 |
+
|
57 |
+
### Model details:
|
58 |
+
|
59 |
+
| **Hyperparameter** | **Value** |
|
60 |
+
|--------------------|-------------|
|
61 |
+
| Model Parameters | 1041M |
|
62 |
+
| Sequence Length | 2048 |
|
63 |
+
| Vocabulary Size | 31980 |
|
64 |
+
| Layers | 18 |
|
65 |
+
| Heads | 32 |
|
66 |
+
| d_head | 64 |
|
67 |
+
| d_model | 2048 |
|
68 |
+
| Dropout | 0.0 |
|
69 |
+
| Bias | No |
|
70 |
+
| Positional Encoding | RoPE |
|
71 |
+
| Activation Function | SwiGLU |
|
72 |
+
| Normalizing Function | RMSNorm |
|
73 |
+
| Intermediate Size | 5504 |
|
74 |
+
| Norm Epsilon | 1e-06 |
|
75 |
+
|
76 |
+
### Tokenizer details:
|
77 |
+
|
78 |
+
* type: BPE
|
79 |
+
* special tokens: 8 (`<unk>`, `<s>`, `</s>`, `<pad>`, `[INST]`, `[/INST]`, `<<SYS>>`, `<</SYS>>`)
|
80 |
+
* alphabet size: 113
|
81 |
+
* vocabulary size: 31980
|
82 |
+
|
83 |
+
## Training
|
84 |
+
|
85 |
+
* Framework: [ALLaMo](https://github.com/chrisociepa/allamo)
|
86 |
+
* Visualizations: [W&B](https://wandb.ai)
|
87 |
+
|
88 |
+
<p align="center">
|
89 |
+
<img src="https://huggingface.co/Azurro/APT3-1B-Base/raw/main/apt3-1b-base.jpg">
|
90 |
+
</p>
|
91 |
+
|
92 |
+
### Training hyperparameters:
|
93 |
+
|
94 |
+
| **Hyperparameter** | **Value** |
|
95 |
+
|-----------------------------|------------------|
|
96 |
+
| Micro Batch Size | 1 |
|
97 |
+
| Gradient Accumulation Steps | 1024 |
|
98 |
+
| Batch Size | 2097152 |
|
99 |
+
| Learning Rate (cosine) | 2e-04 -> 2e-05 |
|
100 |
+
| Warmup Iterations | 1000 |
|
101 |
+
| All Iterations | 28900 |
|
102 |
+
| Optimizer | AdamW |
|
103 |
+
| β1, β2 | 0.9, 0.95 |
|
104 |
+
| Adam_eps | 1e−8 |
|
105 |
+
| Weight Decay | 0.1 |
|
106 |
+
| Grad Clip | 1.0 |
|
107 |
+
| Precision | bfloat16 |
|
108 |
+
|
109 |
+
### Dataset
|
110 |
+
|
111 |
+
Collecting a large amount of high quality training data is a great challenge. Over the past years at Azurro, we have done a lot of projects connected with processing Big Data. Therefore, with our extensive experience, we have been able to prepare carefully selected training dataset quickly and efficiently.
|
112 |
+
|
113 |
+
Our close collaboration with the Speakleash team has resulted in the creation of over 300GB of the Polish language text corpus. The process of preparing the training dataset involved transforming documents by applying various cleaning and repairing rules, followed by selecting documents of appropriate quality.
|
114 |
+
|
115 |
+
Our training dataset contains:
|
116 |
+
|
117 |
+
* 150 datasets from [Speakleash](https://speakleash.org) - 93%
|
118 |
+
* other publicly available and crawled web data - 6%
|
119 |
+
* Polish Wikipedia - 1%
|
120 |
+
|
121 |
+
### Quickstart
|
122 |
+
|
123 |
+
This model can be easily loaded using the AutoModelForCausalLM functionality.
|
124 |
+
|
125 |
+
```python
|
126 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
127 |
+
|
128 |
+
model_name = "Azurro/APT3-1B-Base"
|
129 |
+
|
130 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
131 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
132 |
+
```
|
133 |
+
|
134 |
+
In order to reduce the memory usage, you can use smaller precision (`bfloat16`).
|
135 |
+
|
136 |
+
```python
|
137 |
+
import torch
|
138 |
+
|
139 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16)
|
140 |
+
```
|
141 |
+
|
142 |
+
And then you can use Hugging Face Pipelines to generate text:
|
143 |
+
|
144 |
+
```python
|
145 |
+
import transformers
|
146 |
+
|
147 |
+
text = "Najważniejszym celem człowieka na ziemi jest"
|
148 |
+
|
149 |
+
pipeline = transformers.pipeline("text-generation", model=model, tokenizer=tokenizer)
|
150 |
+
sequences = pipeline(max_new_tokens=100, do_sample=True, top_k=50, eos_token_id=tokenizer.eos_token_id, text_inputs=text)
|
151 |
+
for seq in sequences:
|
152 |
+
print(f"Result: {seq['generated_text']}")
|
153 |
+
```
|
154 |
+
Generated output:
|
155 |
+
> Najważniejszym celem człowieka na ziemi jest życie w pokoju, harmonii i miłości. Dla każdego z nas bardzo ważne jest, aby otaczać się kochanymi osobami.
|
156 |
+
|
157 |
+
## Limitations and Biases
|
158 |
+
|
159 |
+
APT3-1B-Base is not intended for deployment without fine-tuning. It should not be used for human-facing interactions without further guardrails and user consent.
|
160 |
+
|
161 |
+
APT3-1B-Base can produce factually incorrect output, and should not be relied on to produce factually accurate information. APT3-1B-Base was trained on various public datasets. While great efforts have been taken to clean the pretraining data, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
|
162 |
+
|
163 |
+
## License
|
164 |
+
|
165 |
+
Because of an unclear legal situation, we have decided to publish the model under CC BY NC 4.0 license - it allows for non-commercial use. The model can be used for scientific purposes and privately, as long as the license conditions are met.
|
166 |
+
|
167 |
+
## Disclaimer
|
168 |
+
|
169 |
+
The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model.
|
170 |
+
|
171 |
+
## Citation
|
172 |
+
Please cite this model using the following format:
|
173 |
+
|
174 |
+
```
|
175 |
+
@online{AzurroAPT3Base1B,
|
176 |
+
author = {Krzysztof Ociepa, Azurro},
|
177 |
+
title = {Introducing APT3-1B-Base: Polish Language Model},
|
178 |
+
year = {2023},
|
179 |
+
url = {www.azurro.pl/apt3-1b-base-en},
|
180 |
+
note = {Accessed: 2024-01-04}, % change this date
|
181 |
+
urldate = {2024-01-04} % change this date
|
182 |
+
}
|
183 |
+
```
|
184 |
+
|
185 |
+
## Special thanks
|
186 |
+
|
187 |
+
We would like to especially thank the [Speakleash](https://speakleash.org) team for collecting and sharing texts in Polish, and for the support we could always count on while preparing the training set for our model. Without you, it would not have been possible to train this model. Thank you!
|
188 |
+
|
189 |
+
## The Azurro Team
|
190 |
+
|
191 |
+
Please find more information on the Azurro [homepage](https://azurro.pl).
|
192 |
+
|
193 |
+
## Contact Us
|
194 |
+
|
195 |
+
If you have any questions or suggestions, please use the discussion tab. If you want to contact us directly, drop an email to [[email protected]](mailto:[email protected]).
|