spitfire4794 commited on
Commit
39ac623
·
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,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ - instruction-tuning
13
+ - sft
14
+ datasets:
15
+ - spitfire4794/Bangla-SFT-50k
16
+ metrics:
17
+ - accuracy
18
+ ---
19
+
20
+ # Alo-70M (Instruct)
21
+
22
+ ## Model Summary
23
+ **Alo-70M** is the instruction-tuned version of the ultra-lightweight 69-million parameter Bengali language model, [Alo-70M-Base](https://huggingface.co/spitfire4794/Alo-70M-Base). Built on a scaled-down LLaMA architecture, it is designed to act as a highly efficient, edge-deployable localized AI assistant.
24
+
25
+ Fine-tuned on a curated dataset of instruction-response pairs using the **ChatML** format, Alo-70M is aligned for tasks such as summarization, entity extraction, text editing, and question answering in native Bengali. Despite its compact footprint, it offers a viable path for edge AI deployment on standard CPUs and mobile hardware.
26
+
27
+ * **Developer:** Fahad Hossain
28
+ * **Language:** Bengali (Bangla)
29
+ * **Model Type:** Causal Language Model (Instruction-Tuned Autoregressive Transformer)
30
+ * **Parameter Count:** 69 Million
31
+ * **License:** Apache 2.0
32
+
33
+ ## Related Resources
34
+ * **Base Model:** [spitfire4794/Alo-70M-Base](https://huggingface.co/spitfire4794/Alo-70M-Base)
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
+ Alo-70M was trained using the ChatML template. The chat template is built directly into the Jinja template of the tokenizer (`spitfire4794/beng_bpe`). You can leverage it using Hugging Face's `apply_chat_template` interface:
41
+
42
+ ```python
43
+ from transformers import AutoTokenizer, AutoModelForCausalLM
44
+
45
+ model_id = "spitfire4794/Alo-70M"
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
+ # Define the instruction in ChatML format
53
+ messages = [
54
+ {"role": "user", "content": "নিচের অনুচ্ছেদটি সংক্ষেপে সারসংক্ষেপ করুন: [এখানে আপনার টেক্সট লিখুন]"}
55
+ ]
56
+
57
+ # Apply the pre-configured ChatML template
58
+ inputs = tokenizer.apply_chat_template(
59
+ messages,
60
+ add_generation_prompt=True,
61
+ return_tensors="pt"
62
+ ).to(model.device)
63
+
64
+ # Generate text
65
+ outputs = model.generate(
66
+ **inputs,
67
+ max_new_tokens=150,
68
+ repetition_penalty=1.1,
69
+ do_sample=True,
70
+ temperature=0.6,
71
+ top_p=0.9
72
+ )
73
+
74
+ # Decode response (omitting user prompt)
75
+ response = outputs[0][inputs.shape[-1]:]
76
+ print(tokenizer.decode(response, skip_special_tokens=True))
77
+ ```
78
+
79
+ ## Supervised Fine-Tuning (SFT) Details
80
+ Alo-70M was aligned using a curated subset of the **Bangla-SFT-50k** dataset formatted using **ChatML**.
81
+ * **Dataset Pruning:** Initial SFT experiments revealed that forcing a sub-100M parameter model to learn complex markdown syntax/tables caused severe representation crowding. Thus, the 12,517-sample *Structured Formatting* category was excluded. The final active training mixture consisted of **37,536** aligned pairs.
82
+ * **Engineering Properties:** The training data strictly forbade conversational prefaces (e.g., "নিশ্চয়ই, আমি এটি করে দিচ্ছি") so that responses begin immediately with the target output, optimizing inference speeds.
83
+ * **Hardware:** NVIDIA T4 and L4 GPUs.
84
+ * **Hyperparameters:**
85
+ * Optimizer: Fused AdamW (`adamw_torch_fused`) with $\beta_1 = 0.9, \beta_2 = 0.999, \epsilon = 10^{-8}$
86
+ * Weight Decay: 0.0
87
+ * Learning Rate Schedule: Cosine decay, peaking at $3 \times 10^{-4}$ with a 10% linear warmup.
88
+ * Epochs: 3
89
+ * Effective Batch Size: 32 (per-device 8 with gradient accumulation of 4).
90
+ * Precision: Native Automatic Mixed Precision (AMP).
91
+
92
+ ## Model Architecture details
93
+ Like its base model, Alo-70M utilizes a parameter-efficient architecture:
94
+ * **Layers:** 12
95
+ * **Hidden Dimension ($d_{model}$):** 512 | **Intermediate FFN:** 1408
96
+ * **Attention:** Grouped-Query Attention (GQA) with 8 query heads / 4 KV heads.
97
+ * **Positional Embeddings:** RoPE (Base freq: 10,000)
98
+ * **Word Embeddings:** Untied (`tie_word_embeddings = False`).
99
+ * **Context Window:** 1024 tokens.
100
+
101
+ ## Evaluation Results
102
+ The model was evaluated zero-shot across Bengali reasoning and knowledge benchmarks (continuation-based log-probability evaluation):
103
+
104
+ | Benchmark | Alo-70M (SFT) | Alo-70M-Base | Gemma-3-270M-IT | TigerLLM-1B-IT |
105
+ | :--- | :---: | :---: | :---: | :---: |
106
+ | **bangla_mmlu_bn** | 26.29% | 26.31% | 26.81% | 27.66% |
107
+ | **bangla_commonsenseqa_bn** | **25.88%** | 28.42% | 22.77% | 25.14% |
108
+ | **indicbench_arc_bn_challenge** | 24.15% | 22.70% | 25.34% | 27.13% |
109
+ | **boolqa_bn** | 48.70% | 48.42% | 51.30% | 52.40% |
110
+ | **openbookqa_bn** | 30.58% | 31.39% | 31.99% | 34.21% |
111
+ | **piqa_bn** | **50.05%** | 50.49% | 49.51% | 49.51% |
112
+ | **hellaswag_bn** | 26.89% | 27.27% | 27.85% | 31.01% |
113
+
114
+ *Note: The 69M instruction-tuned model outperforms the larger Gemma-3-270M-IT baseline on tasks like CommonsenseQA and PIQA.*
115
+
116
+ ## Limitations and Biases
117
+ * **Alignment Tax (Catastrophic Forgetting):** While SFT successfully aligned the model for text generation stability and instruction following, it introduced a measurable degradation in pure zero-shot reasoning compared to the Base model (e.g., dropping from 28.42% to 25.88% on CommonsenseQA). This happens because applying instructions to a highly capacity-constrained 69M model over-indexes weights toward output formatting at the expense of some pre-trained logical representations.
118
+ * **Knowledge Retrieval:** With under 100M parameters, the model physically lacks the capacity to serve as a comprehensive encyclopedic knowledge base. It is better suited for text processing tasks (editing, summarizing) than fact-retrieval.
119
+ * **Context Length:** The model is optimized for a 1024-token context window. Prompts exceeding this length will be truncated or result in degraded quality.
120
+
121
+ ## Citation
122
+ *Technical paper out soon.*
chat_template.jinja ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {{- bos_token }}
2
+ {%- for message in messages %}
3
+ {{- '<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>\n' }}
4
+ {%- endfor %}
5
+ {%- if add_generation_prompt %}
6
+ {{- '<|im_start|>assistant\n' }}
7
+ {%- 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.0.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.0.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:25fd7e5fabea1d37b72b63686dd7954b961f5bdcd9eb13b77d4e8fbd2ff635e4
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
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c7d45d39aa5dfcde0fc617983ffca808cc137529610a96125bf0c9efb52b251a
3
+ size 5201