nicholasKluge commited on
Commit
2dfa794
·
verified ·
1 Parent(s): f9cb5e7

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +367 -0
README.md ADDED
@@ -0,0 +1,367 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - bn
4
+ - en
5
+ license: apache-2.0
6
+ library_name: transformers
7
+ tags:
8
+ - text-generation-inference
9
+ datasets:
10
+ - Polygl0t/bengali-corpus
11
+ - allenai/big-reasoning-traces
12
+ - HuggingFaceTB/smollm-corpus
13
+ - HuggingFaceTB/finemath
14
+ - HuggingFaceFW/fineweb-edu
15
+ - allenai/math-meta-reasoning-filtered
16
+ - nvidia/OpenScience
17
+ metrics:
18
+ - perplexity
19
+ pipeline_tag: text-generation
20
+ widget:
21
+ - text: "বাংলাদেশের রাজধানী হলো"
22
+ example_title: উদাহরণ
23
+ - text: "বাংলাদেশের প্রধান নদী হলো"
24
+ example_title: উদাহরণ
25
+ inference:
26
+ parameters:
27
+ repetition_penalty: 1.2
28
+ temperature: 0.1
29
+ top_k: 50
30
+ top_p: 1.0
31
+ max_new_tokens: 150
32
+ co2_eq_emissions:
33
+ emissions: 333000
34
+ source: CodeCarbon
35
+ training_type: pre-training
36
+ geographical_location: Germany
37
+ hardware_used: NVIDIA A100-SXM4-80GB
38
+ model-index:
39
+ - name: LilTii-v0.1
40
+ results:
41
+ - task:
42
+ type: text-generation
43
+ name: Text Generation
44
+ dataset:
45
+ name: Bangla MMLU
46
+ type: hishab/bangla-mmlu
47
+ split: test
48
+ args:
49
+ num_few_shot: 5
50
+ metrics:
51
+ - type: acc
52
+ value: 26.08
53
+ name: accuracy
54
+ source:
55
+ url: https://github.com/hishab-nlp/lm-evaluation-harness
56
+ name: Language Model Evaluation Harness (Bengali)
57
+ - task:
58
+ type: text-generation
59
+ name: Text Generation
60
+ dataset:
61
+ name: BoolQ-BN
62
+ type: hishab/boolq_bn
63
+ split: train
64
+ args:
65
+ num_few_shot: 5
66
+ metrics:
67
+ - type: acc
68
+ value: 60.64
69
+ name: accuracy
70
+ source:
71
+ url: https://github.com/hishab-nlp/lm-evaluation-harness
72
+ name: Language Model Evaluation Harness (Bengali)
73
+ - task:
74
+ type: text-generation
75
+ name: Text Generation
76
+ dataset:
77
+ name: CommonsenseQA-BN
78
+ type: hishab/commonsenseqa-bn
79
+ split: train
80
+ args:
81
+ num_few_shot: 5
82
+ metrics:
83
+ - type: acc
84
+ value: 32.43
85
+ name: accuracy
86
+ source:
87
+ url: https://github.com/hishab-nlp/lm-evaluation-harness
88
+ name: Language Model Evaluation Harness (Bengali)
89
+ - task:
90
+ type: text-generation
91
+ name: Text Generation
92
+ dataset:
93
+ name: OpenBookQA-BN
94
+ type: hishab/openbookqa-bn
95
+ split: train
96
+ args:
97
+ num_few_shot: 5
98
+ metrics:
99
+ - type: acc
100
+ value: 32.19
101
+ name: accuracy
102
+ source:
103
+ url: https://github.com/hishab-nlp/lm-evaluation-harness
104
+ name: Language Model Evaluation Harness (Bengali)
105
+ - task:
106
+ type: text-generation
107
+ name: Text Generation
108
+ dataset:
109
+ name: PIQA-BN
110
+ type: hishab/piqa-bn
111
+ split: train
112
+ args:
113
+ num_few_shot: 5
114
+ metrics:
115
+ - type: acc
116
+ value: 60.50
117
+ name: accuracy
118
+ source:
119
+ url: https://github.com/hishab-nlp/lm-evaluation-harness
120
+ name: Language Model Evaluation Harness (Bengali)
121
+ - task:
122
+ type: text-generation
123
+ name: Text Generation
124
+ dataset:
125
+ name: ARC-Challenge (BN)
126
+ type: arc_bn
127
+ args:
128
+ num_few_shot: 5
129
+ metrics:
130
+ - type: acc_norm
131
+ value: 26.17
132
+ name: normalized accuracy
133
+ source:
134
+ url: https://github.com/Nkluge-correa/lm-evaluation-harness-multilingual
135
+ name: Language Model Evaluation Harness (Multilingual)
136
+ - task:
137
+ type: text-generation
138
+ name: Text Generation
139
+ dataset:
140
+ name: HellaSwag (BN)
141
+ type: hellaswag_bn
142
+ args:
143
+ num_few_shot: 0
144
+ metrics:
145
+ - type: acc_norm
146
+ value: 32.20
147
+ name: normalized accuracy
148
+ source:
149
+ url: https://github.com/Nkluge-correa/lm-evaluation-harness-multilingual
150
+ name: Language Model Evaluation Harness (Multilingual)
151
+ - task:
152
+ type: text-generation
153
+ name: Text Generation
154
+ dataset:
155
+ name: MMLU (BN)
156
+ type: mmlu_bn
157
+ args:
158
+ num_few_shot: 5
159
+ metrics:
160
+ - type: acc_norm
161
+ value: 27.06
162
+ name: normalized accuracy
163
+ source:
164
+ url: https://github.com/Nkluge-correa/lm-evaluation-harness-multilingual
165
+ name: Language Model Evaluation Harness (Multilingual)
166
+ - task:
167
+ type: text-generation
168
+ name: Text Generation
169
+ dataset:
170
+ name: TruthfulQA (BN)
171
+ type: truthfulqa_bn
172
+ args:
173
+ num_few_shot: 0
174
+ metrics:
175
+ - type: mc1
176
+ value: 25.48
177
+ name: bleurt
178
+ source:
179
+ url: https://github.com/Nkluge-correa/lm-evaluation-harness-multilingual
180
+ name: Language Model Evaluation Harness (Multilingual)
181
+ ---
182
+ # LilTii-v0.2
183
+
184
+ <img src="./logo.png" alt="A round logo of a cartoon tiger in a hoodie, cap, and gold chain with the text 'LilTii' below." height="200">
185
+
186
+ ## Model Summary
187
+
188
+ **[LilTii-v0.2](https://huggingface.co/Polygl0t/LilTii-v0.2)** is a decoder-transformer natively pretrained in Bengali and English. LilTii is part of the [Polygl0t](https://huggingface.co/Polygl0t) initiative to advance language models for low-resource languages.
189
+
190
+ ## Details
191
+
192
+ - **Architecture:** a Transformer-based model pre-trained via causal language modeling
193
+ - **Size:** 670,127,616 parameters
194
+ - **Context length:** 4096 tokens
195
+ - **Dataset(s):**
196
+ - [Polygl0t/bengali-corpus](https://huggingface.co/datasets/Polygl0t/bengali-corpus)
197
+ - [allenai/big-reasoning-traces](https://huggingface.co/datasets/allenai/big-reasoning-traces)
198
+ - [HuggingFaceTB/smollm-corpus](https://huggingface.co/datasets/HuggingFaceTB/smollm-corpus)
199
+ - [HuggingFaceTB/finemath](https://huggingface.co/datasets/HuggingFaceTB/finemath)
200
+ - [HuggingFaceFW/fineweb-edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu)
201
+ - [allenai/math-meta-reasoning-filtered](https://huggingface.co/datasets/allenai/math-meta-reasoning-filtered)
202
+ - [nvidia/OpenScience](https://huggingface.co/datasets/nvidia/OpenScience)
203
+ - **Language(s):** Bengali, English
204
+ - **Batch size:** 2,097,152 tokens
205
+ - **Number of steps:** 110,000
206
+ - **GPU:** 8 NVIDIA A100-SXM4-80GB
207
+ - **Training time**: ~ 215 hours
208
+ - **Emissions:** 333 KgCO2 (Germany)
209
+ - **Total energy consumption:** 875 kWh
210
+
211
+ This repository has the [source code](https://github.com/Nkluge-correa/polyglot) used to train this model.
212
+
213
+ ### Learning Rate
214
+
215
+ This model was trained with a linear learning rate (i.e., warmup-stable-decay). Warmup was done over the first 2,000 steps to a peak learning rate of 7e-4, followed by a stable phase until step 98,000 (this revision is named `end-of-stable-ckpt`), and then a linear decay to 0 for the last 12,000 steps. Checkpoints were saved every 2,500 steps, which equates to approximately 5 billion tokens.
216
+
217
+ The main branch of this repository contains the final checkpoint saved at step 110,000. All other checkpoints are available as separate branches. To load a specific checkpoint, you can use the following code snippet:
218
+
219
+ ```python
220
+ from transformers import AutoModelForCausalLM, AutoTokenizer
221
+
222
+ model_id = "Polygl0t/LilTii-v0.2"
223
+ revision = "step-2500" # Change this to the desired checkpoint branch
224
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
225
+ model = AutoModelForCausalLM.from_pretrained(model_id, revision=revision)
226
+ ```
227
+
228
+ ## Intended Uses
229
+
230
+ The primary intended use LilTii is to serve as foundations for research and development involving native Bengali language modeling. Checkpoints saved during training are designed to provide a controlled setting for performing comparative experiments, specifically regarding the effects of active pretraining on the performance of currently available benchmarks. You may also fine-tune and adapt LilTii for deployment if your use follows the Apache 2.0 license. If you decide to use LilTii as a basis for your fine-tuned model, please conduct your own risk and bias assessment.
231
+
232
+ ## Out-of-scope Use
233
+
234
+ - LilTii is **not intended for deployment**. It is not an out-of-the-box product and should not be used for human-facing interactions.
235
+
236
+ - LilTii is for **the Bengali language only** and is unsuitable for text generation tasks in other languages.
237
+
238
+ - LilTii has **not been fine-tuned** for downstream tasks.
239
+
240
+ ## Basic usage
241
+
242
+ ### Via HuggingFace Transformers
243
+
244
+ Using the `pipeline`:
245
+
246
+ ```python
247
+ from transformers import pipeline
248
+
249
+ generator = pipeline("text-generation", model="Polygl0t/LilTii-v0.2")
250
+
251
+ completions = generator("বাংলাদেশের রাজধানী হলো", num_return_sequences=2, max_new_tokens=150)
252
+
253
+ for comp in completions:
254
+ print(f"🤖 {comp['generated_text']}")
255
+ ```
256
+
257
+ Using the `AutoTokenizer` and `AutoModelForCausalLM`:
258
+
259
+ ```python
260
+ from transformers import GenerationConfig, TextGenerationPipeline, AutoTokenizer, AutoModelForCausalLM
261
+ import torch
262
+
263
+ # Specify the model and tokenizer
264
+ model_id = "Polygl0t/LilTii-v0.2"
265
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
266
+ model = AutoModelForCausalLM.from_pretrained(model_id)
267
+
268
+ # Specify the generation parameters as you like
269
+ generation_config = GenerationConfig(
270
+ **{
271
+ "do_sample": True,
272
+ "max_new_tokens": 150,
273
+ "renormalize_logits": True,
274
+ "repetition_penalty": 1.2,
275
+ "temperature": 0.1,
276
+ "top_k": 50,
277
+ "top_p": 1.0,
278
+ "use_cache": True,
279
+ }
280
+ )
281
+
282
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
283
+ generator = TextGenerationPipeline(model=model, task="text-generation", tokenizer=tokenizer, device=device)
284
+
285
+ # Generate text
286
+ prompt = "বাংলাদেশের রাজধানী হলো"
287
+ completion = generator(prompt, generation_config=generation_config)
288
+ print(completion[0]['generated_text'])
289
+ ```
290
+
291
+ ### Via vLLM Inference
292
+
293
+ ```python
294
+ from vllm import LLM, SamplingParams
295
+ from transformers import AutoTokenizer
296
+ import torch
297
+
298
+ model_id = "Polygl0t/LilTii-v0.2"
299
+ prompt = "বাংলাদেশের রাজধানী হলো"
300
+
301
+ tokenizer = AutoTokenizer.from_pretrained(
302
+ model_id,
303
+ use_fast=True,
304
+ )
305
+
306
+ model = LLM(
307
+ model=model_id,
308
+ )
309
+
310
+ sampling_params = SamplingParams(
311
+ max_tokens=150,
312
+ stop=[tokenizer.eos_token],
313
+ stop_token_ids=[tokenizer.eos_token_id],
314
+ n=2,
315
+ temperature=0.1,
316
+ repetition_penalty=1.2,
317
+ top_k=50,
318
+ top_p=1.0
319
+ )
320
+
321
+ outputs = model.generate([prompt], sampling_params)
322
+
323
+ for output in outputs:
324
+ print(f"🤖 {output.outputs[0].text}")
325
+ ```
326
+
327
+ ## Limitations
328
+
329
+ Like almost all other language models trained on large text datasets scraped from the web, the LilTii shows behavior that does not make it an out-of-the-box solution to many real-world applications, especially those requiring factual, reliable, and nontoxic text generation. LilTii is subject to the following:
330
+
331
+ - **Hallucinations:** LilTii can produce content that can be mistaken as true facts, but are misleading or entirely false, i.e., hallucination.
332
+
333
+ - **Biases and Toxicity:** LilTii inherits the social and historical stereotypes from the data used to train it. Given these biases, the model can produce toxic content, i.e., harmful, offensive, or detrimental to individuals, groups, or communities.
334
+
335
+ - **Language Limitations:** LilTii is primarily designed to interact with Bengali. Other languages might challenge its comprehension, leading to potential misinterpretations or errors in response.
336
+
337
+ - **Repetition and Verbosity:** LilTii may get stuck on repetition loops (especially if the repetition penalty during generations is set to a meager value) or produce verbose responses unrelated to the prompt it was given.
338
+
339
+ Hence, even though LilTii is released with a permissive license, we urge users to perform their risk analysis on them if they intend to use them for real-world applications.
340
+
341
+ ## Evaluations
342
+
343
+ The table below compares our two versions of LilTii against other base models of similar size. The NPM (Normalized Performance Metric) is a metric designed to provide a balanced view of model performance across various tasks, accounting for the inherent difficulty of each task (Pires et al., [2023](https://arxiv.org/abs/2304.07880)). It normalizes the performance of each model on a given task by comparing it to a baseline performance, which represents a the performance of a random model.
344
+
345
+ | | NPM (mean) | ARC Challenge | HellaSwag | MMLU | TruthfulQA MC1 | Bangla MMLU | BoolQ-BN | CommonsenseQA-BN | OpenBookQA-BN | PIQA-BN |
346
+ |-----------------|------------|---------------|-----------|----------|----------------|-------------|----------|------------------|---------------|----------|
347
+ | LilTii-v0.2 | 9.62724 | 0.261762 | 0.322008 | 0.270631 | 0.254802 | 0.260881 | 0.606481 | 0.324324 | 0.321932 | 0.605005 |
348
+ | Qwen3-0.6B-Base | 8.0721 | 0.2284 | 0.286951 | 0.297865 | 0.271447 | 0.325695 | 0.657407 | 0.230139 | 0.305835 | 0.527203 |
349
+ | Qwen2.5-0.5B | 6.03669 | 0.229256 | 0.284246 | 0.283144 | 0.28169 | 0.308407 | 0.578704 | 0.22113 | 0.305835 | 0.535909 |
350
+ | LilTii-v0.1 | 5.81863 | 0.235244 | 0.303073 | 0.264088 | 0.240717 | 0.239525 | 0.520833 | 0.302211 | 0.327968 | 0.587051 |
351
+
352
+
353
+ ## Cite as 🤗
354
+
355
+ ```latex
356
+
357
+ ```
358
+
359
+ ## Aknowlegments
360
+
361
+ Polyglot is a project funded by the Federal Ministry of Education and Research (BMBF) and the Ministry of Culture and Science of the State of North Rhine-Westphalia (MWK) as part of TRA Sustainable Futures (University of Bonn) and the Excellence Strategy of the federal and state governments.
362
+
363
+ We also gratefully acknowledge the granted access to the [Marvin cluster](https://www.hpc.uni-bonn.de/en/systems/marvin) hosted by [University of Bonn](https://www.uni-bonn.de/en) along with the support provided by its High Performance Computing & Analytics Lab.
364
+
365
+ ## License
366
+
367
+ LilTii is licensed under the Apache License, Version 2.0. For more details, see the [LICENSE](LICENSE) file.