spitfire4794 commited on
Commit
616f6b1
·
0 Parent(s):

Squash history to single initial commit

Browse files
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - bn
4
+ license: apache-2.0
5
+ tags:
6
+ - bengali
7
+ - bangla
8
+ - causal-lm
9
+ - llama
10
+ - custom-tokenizer
11
+ - parameter-efficient
12
+ datasets:
13
+ - HuggingFaceFW/fineweb-2
14
+ - hishab/titulm-bangla-corpus
15
+ metrics:
16
+ - accuracy
17
+ ---
18
+
19
+ # Alo-70M-Base
20
+
21
+ ## Model Summary
22
+ **Alo-70M-Base** is a compact, 69-million parameter foundational Large Language Model (LLM) built exclusively for the Bengali (Bangla) language. Trained entirely from scratch, it aims to lower the compute barrier for Bengali NLP research and provide a viable path for deploying localized AI assistants on standard CPUs and resource-constrained edge devices.
23
+
24
+ Despite its ultra-lightweight footprint, Alo-70M-Base achieves competitive parity on localized reasoning tasks against significantly larger cross-lingual models (such as 270M and 1B parameter baselines).
25
+
26
+ * **Developer:** Fahad Hossain
27
+ * **Language:** Bengali (Bangla)
28
+ * **Model Type:** Causal Language Model (Autoregressive Transformer)
29
+ * **Parameter Count:** 69 Million
30
+ * **License:** Apache 2.0
31
+
32
+ ## Related Resources
33
+ This model is the **base** foundational model. We also release the instruction-tuned version, the synthetic dataset used for alignment, and the standalone tokenizer:
34
+ * **Instruction-Tuned Model:** [spitfire4794/Alo-70M](https://huggingface.co/spitfire4794/Alo-70M)
35
+ * **Alignment Dataset:** [spitfire4794/Bangla-SFT-50k](https://huggingface.co/datasets/spitfire4794/Bangla-SFT-50k)
36
+ * **Tokenizer:** [spitfire4794/beng_bpe](https://huggingface.co/spitfire4794/beng_bpe)
37
+
38
+ ## Usage
39
+
40
+ You can load and generate text with Alo-70M-Base using the `transformers` library.
41
+
42
+ ```python
43
+ from transformers import AutoTokenizer, AutoModelForCausalLM
44
+
45
+ model_id = "spitfire4794/Alo-70M-Base"
46
+ tokenizer_id = "spitfire4794/beng_bpe"
47
+
48
+ # Load the custom Bengali BPE tokenizer and model
49
+ tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
50
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
51
+
52
+ prompt = "বাংলাদেশের রাজধানী ঢাকা"
53
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
54
+
55
+ # Generate text
56
+ outputs = model.generate(
57
+ **inputs,
58
+ max_new_tokens=50,
59
+ repetition_penalty=1.1,
60
+ do_sample=True,
61
+ temperature=0.7
62
+ )
63
+
64
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
65
+ ```
66
+
67
+ ## Model Details
68
+ Alo-70M-Base is based on a scaled-down LLaMA transformer architecture optimized for hardware alignment and parameter efficiency.
69
+ * **Layers:** 12
70
+ * **Hidden Dimension ($d_{model}$):** 512
71
+ * **Intermediate FFN Dimension:** 1408
72
+ * **Attention Mechanism:** Grouped-Query Attention (GQA) with 8 query heads and 4 key-value heads.
73
+ * **Positional Embeddings:** Rotary Position Embeddings (RoPE) with a base frequency ($\theta$) of 10,000.
74
+ * **Activation Function:** SwiGLU (`silu`)
75
+ * **Word Embeddings:** Untied (`tie_word_embeddings = False`). The static lookup tables account for 48.6% (33.5M) of the total parameter budget.
76
+ * **Context Window:** 1024 tokens.
77
+ * **Tokenizer:** Custom Bengali Byte-Pair Encoding (BPE) tokenizer ([spitfire4794/beng_bpe](https://huggingface.co/spitfire4794/beng_bpe)) with a highly optimized vocabulary size of 32,768 ($2^{15}$) designed to maximize TPU efficiency.
78
+
79
+ ## Pre-Training Data
80
+ The model was pre-trained on a curated, strictly Bengali corpus containing approximately **19.25 billion tokens**. The dataset is a blend of:
81
+ 1. **FineWeb-2 (Bengali Split):** Providing diverse, web-scale filtered documents.
82
+ 2. **TituLM Bengali Corpus (CommonCrawl Split):** Introducing balanced, general-domain web data.
83
+
84
+ ## Training Procedure
85
+ Alo-70M-Base was initialized with completely randomized weights (no transfer learning) and trained from scratch.
86
+ * **Hardware:** Kaggle Tensor Processing Unit (TPU) v5e-8
87
+ * **Training Time:** 12.9 hours (wall time) across two sequential runs.
88
+ * **Optimizer:** AdamW (`adam_torch_xla`) with $\beta_1 = 0.9, \beta_2 = 0.95, \epsilon = 10^{-8}$
89
+ * **Weight Decay:** 0.1
90
+ * **Learning Rate Schedule:** Cosine Decay with a gradual warmup phase, peaking at $6 \times 10^{-4}$.
91
+ * **Precision & Optimization:** Mixed `bfloat16` (`bf16`) precision with gradient checkpointing enabled to maximize throughput.
92
+
93
+ ## Evaluation Results
94
+ The model was evaluated in a zero-shot setting across various Bengali reasoning and knowledge benchmarks using a continuation-based evaluation methodology (calculating conditional log-probabilities directly over raw Bengali text to avoid "pointer-reasoning" bottlenecks).
95
+
96
+ | Benchmark | Alo-70M-Base | Gemma-3-270M-IT | TigerLLM-1B-IT |
97
+ | :--- | :---: | :---: | :---: |
98
+ | **bangla_mmlu_bn** | 26.31% | 26.81% | 27.66% |
99
+ | **bangla_commonsenseqa_bn** | **28.42%** | 22.77% | 25.14% |
100
+ | **indicbench_arc_bn_challenge** | 22.70% | 25.34% | 27.13% |
101
+ | **boolqa_bn** | 48.42% | 51.30% | 52.40% |
102
+ | **openbookqa_bn** | 31.39% | 31.99% | 34.21% |
103
+ | **piqa_bn** | **50.49%** | 49.51% | 49.51% |
104
+ | **hellaswag_bn** | 27.27% | 27.85% | 31.01% |
105
+
106
+ *Note: Alo-70M-Base matches or outperforms both the 270M and 1B baselines on CommonsenseQA and PIQA despite having 4x to 14x fewer parameters.*
107
+
108
+ ## Limitations and Biases
109
+ * **Encyclopedic Knowledge:** Due to the severe parameter constraints (<100M parameters), the model physically lacks the parametric capacity to act as a deep encyclopedic knowledge base, which reflects in its performance on knowledge-intensive retrieval tasks like MMLU and ARC-Challenge.
110
+ * **Tokenizer Evaluation Bias:** During continuation-based log-likelihood evaluations, Alo-70M's highly efficient native tokenizer may possess a mathematical advantage over multilingual baselines (which heavily fragment Bengali text), contributing partially to its high performance margins on specific tasks.
111
+ * **Instruction Following:** This is a base model. It will attempt to complete text rather than follow conversational instructions. For chat and instruction-following, please use **Alo-70M**.
112
+
113
+ ## Citation
114
+ *Technical paper out soon.*
chat_template.jinja ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if messages[0]['role'] == 'system' and messages[0]['content'] -%}{{ '<|im_start|>system
2
+ ' + messages[0]['content'] + '<|im_end|>
3
+ ' }}{%- set loop_messages = messages[1:] -%}{%- else -%}{{ '<|im_start|>system
4
+ You are a helpful assistant.<|im_end|>
5
+ ' }}{%- set loop_messages = messages -%}{%- endif -%}{%- for message in loop_messages -%}{%- if message['role'] == 'tool' -%}{{ '<|im_start|>tool
6
+ ' + message['content'] + '<|im_end|>
7
+ ' }}{%- else -%}{{ '<|im_start|>' + message['role'] + '
8
+ ' + message['content'] + '<|im_end|>
9
+ ' }}{%- endif -%}{%- endfor -%}{%- if add_generation_prompt -%}{{ '<|im_start|>assistant
10
+ ' }}{%- endif -%}
config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 0,
8
+ "dtype": "float32",
9
+ "eos_token_id": 2,
10
+ "head_dim": 64,
11
+ "hidden_act": "silu",
12
+ "hidden_size": 512,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 1408,
15
+ "max_position_embeddings": 1024,
16
+ "mlp_bias": false,
17
+ "model_type": "llama",
18
+ "num_attention_heads": 8,
19
+ "num_hidden_layers": 12,
20
+ "num_key_value_heads": 4,
21
+ "pad_token_id": 0,
22
+ "pretraining_tp": 1,
23
+ "rms_norm_eps": 1e-06,
24
+ "rope_parameters": {
25
+ "rope_theta": 10000.0,
26
+ "rope_type": "default"
27
+ },
28
+ "tie_word_embeddings": false,
29
+ "transformers_version": "5.13.0",
30
+ "use_cache": false,
31
+ "vocab_size": 32768
32
+ }
generation_config.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": [
5
+ 2
6
+ ],
7
+ "output_attentions": false,
8
+ "output_hidden_states": false,
9
+ "pad_token_id": 0,
10
+ "transformers_version": "5.13.0",
11
+ "use_cache": false
12
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b07984f6f3be9a1299ea46f7781e009943da8594468beb37252b0a87076616f
3
+ size 275839008
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<|endoftext|>",
4
+ "clean_up_tokenization_spaces": false,
5
+ "eos_token": "<|im_end|>",
6
+ "extra_special_tokens": [
7
+ "<|im_start|>",
8
+ "<|im_end|>",
9
+ "<|tool_call|>",
10
+ "<|/tool_call|>",
11
+ "<|tool_response|>",
12
+ "<|begin_of_thought|>",
13
+ "<|end_of_thought|>",
14
+ "<|reserved_0|>",
15
+ "<|reserved_1|>"
16
+ ],
17
+ "is_local": false,
18
+ "local_files_only": false,
19
+ "model_max_length": 1000000000000000019884624838656,
20
+ "pad_token": "<|endoftext|>",
21
+ "tokenizer_class": "TokenizersBackend",
22
+ "unk_token": "<|endoftext|>"
23
+ }