neshkatrapati commited on
Commit
3f80d0c
·
verified ·
1 Parent(s): 8da140c

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +9 -7
  2. tokenizer_class.py +19 -0
  3. tokenizer_config.json +6 -0
README.md CHANGED
@@ -16,7 +16,7 @@ pipeline_tag: text-generation
16
 
17
  # Pothana Base 300M
18
 
19
- A **726M parameter** LLaMA-style language model trained **from scratch** on Telugu text.
20
 
21
  Named after [Bammera Pothana](https://en.wikipedia.org/wiki/Bammera_Pothana), the celebrated 15th-century Telugu poet who authored the *Andhra Maha Bhagavatamu*.
22
 
@@ -28,9 +28,9 @@ Developed by **[Dvitva AI](https://dvitva.ai)**.
28
  |---|---|
29
  | **Model** | pothana-base-300M |
30
  | **Architecture** | LLaMA (RoPE + SwiGLU + RMSNorm + GQA) |
31
- | **Parameters** | 726M |
32
  | **Hidden size** | 1024 |
33
- | **Layers** | 60 |
34
  | **Attention heads** | 16 Q / 4 KV (Grouped Query Attention) |
35
  | **Intermediate size** | 2816 |
36
  | **Context length** | 2048 |
@@ -46,11 +46,13 @@ Developed by **[Dvitva AI](https://dvitva.ai)**.
46
  ```python
47
  from transformers import pipeline
48
 
49
- pipe = pipeline("text-generation", model="dvitvaai/pothana-base-300M")
50
  result = pipe("తెలుగు భాష", max_new_tokens=50, do_sample=True, temperature=0.8)
51
  print(result[0]["generated_text"])
52
  ```
53
 
 
 
54
  ### Manual loading
55
 
56
  ```python
@@ -58,7 +60,7 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
58
  import torch
59
 
60
  model = AutoModelForCausalLM.from_pretrained("dvitvaai/pothana-base-300M")
61
- tokenizer = AutoTokenizer.from_pretrained("dvitvaai/pothana-base-300M")
62
 
63
  text = "తెలుగు భాష చాలా అందమైనది"
64
  inputs = tokenizer(text, return_tensors="pt")
@@ -88,7 +90,7 @@ This model uses a **SentencePiece Unigram** tokenizer with a 48K vocabulary, tra
88
 
89
  Key features:
90
  - **Grouped Query Attention (GQA)**: 16 query heads, 4 KV heads — 4x KV cache reduction
91
- - **Block-wise Weight Sharing**: 60 HF layers mapped from 30 unique blocks (each used twice), following MobileLLM-LS
92
  - **SwiGLU MLP** with 2816 intermediate size
93
  - **RoPE** positional encoding (theta=10000.0)
94
  - **RMSNorm** (no bias in any linear layer)
@@ -106,7 +108,7 @@ Key features:
106
 
107
  - This is a **base model** (not instruction-tuned) — it performs text completion, not instruction following
108
  - Trained primarily on Telugu text; limited multilingual capability
109
- - Small model size (726M) limits reasoning and knowledge capacity
110
 
111
  ## License
112
 
 
16
 
17
  # Pothana Base 300M
18
 
19
+ A **387M parameter** LLaMA-style language model trained **from scratch** on Telugu text.
20
 
21
  Named after [Bammera Pothana](https://en.wikipedia.org/wiki/Bammera_Pothana), the celebrated 15th-century Telugu poet who authored the *Andhra Maha Bhagavatamu*.
22
 
 
28
  |---|---|
29
  | **Model** | pothana-base-300M |
30
  | **Architecture** | LLaMA (RoPE + SwiGLU + RMSNorm + GQA) |
31
+ | **Parameters** | 387M (unique) |
32
  | **Hidden size** | 1024 |
33
+ | **Layers** | 30 unique (60 effective via weight sharing) |
34
  | **Attention heads** | 16 Q / 4 KV (Grouped Query Attention) |
35
  | **Intermediate size** | 2816 |
36
  | **Context length** | 2048 |
 
46
  ```python
47
  from transformers import pipeline
48
 
49
+ pipe = pipeline("text-generation", model="dvitvaai/pothana-base-300M", trust_remote_code=True)
50
  result = pipe("తెలుగు భాష", max_new_tokens=50, do_sample=True, temperature=0.8)
51
  print(result[0]["generated_text"])
52
  ```
53
 
54
+ > **Note**: `trust_remote_code=True` is required for the custom tokenizer that cleans up SentencePiece word boundary markers for readable output.
55
+
56
  ### Manual loading
57
 
58
  ```python
 
60
  import torch
61
 
62
  model = AutoModelForCausalLM.from_pretrained("dvitvaai/pothana-base-300M")
63
+ tokenizer = AutoTokenizer.from_pretrained("dvitvaai/pothana-base-300M", trust_remote_code=True)
64
 
65
  text = "తెలుగు భాష చాలా అందమైనది"
66
  inputs = tokenizer(text, return_tensors="pt")
 
90
 
91
  Key features:
92
  - **Grouped Query Attention (GQA)**: 16 query heads, 4 KV heads — 4x KV cache reduction
93
+ - **Block-wise Weight Sharing**: 30 unique blocks, each used twice = 60 effective layers (MobileLLM-LS)
94
  - **SwiGLU MLP** with 2816 intermediate size
95
  - **RoPE** positional encoding (theta=10000.0)
96
  - **RMSNorm** (no bias in any linear layer)
 
108
 
109
  - This is a **base model** (not instruction-tuned) — it performs text completion, not instruction following
110
  - Trained primarily on Telugu text; limited multilingual capability
111
+ - Small model size (387M) limits reasoning and knowledge capacity
112
 
113
  ## License
114
 
tokenizer_class.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Custom Telugu SentencePiece tokenizer with clean decode output."""
2
+ from transformers import LlamaTokenizer
3
+
4
+
5
+ class TeluguSPTokenizer(LlamaTokenizer):
6
+ """Telugu SentencePiece tokenizer that produces clean decoded text.
7
+
8
+ Extends LlamaTokenizer to clean up SentencePiece's ▁ (U+2581) word
9
+ boundary markers, producing natural text output.
10
+ """
11
+
12
+ def decode(self, token_ids, skip_special_tokens=False, **kwargs):
13
+ text = super().decode(token_ids, skip_special_tokens=skip_special_tokens, **kwargs)
14
+ # SentencePiece uses ▁ (U+2581) as word boundary marker
15
+ # Replace with space, then clean up
16
+ text = text.replace("\u2581", " ")
17
+ # Clean up extra whitespace
18
+ text = " ".join(text.split())
19
+ return text
tokenizer_config.json CHANGED
@@ -1,5 +1,11 @@
1
  {
2
  "tokenizer_class": "LlamaTokenizer",
 
 
 
 
 
 
3
  "model_max_length": 2048,
4
  "bos_token": "<bos>",
5
  "eos_token": "<eos>",
 
1
  {
2
  "tokenizer_class": "LlamaTokenizer",
3
+ "auto_map": {
4
+ "AutoTokenizer": [
5
+ "tokenizer_class.TeluguSPTokenizer",
6
+ "tokenizer_class.TeluguSPTokenizer"
7
+ ]
8
+ },
9
  "model_max_length": 2048,
10
  "bos_token": "<bos>",
11
  "eos_token": "<eos>",