File size: 8,466 Bytes
3e9c8f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9442b05
3e9c8f2
 
 
 
 
 
 
 
 
 
9442b05
3e9c8f2
 
 
 
 
 
 
 
 
9442b05
 
3e9c8f2
9442b05
 
3e9c8f2
9442b05
 
 
3e9c8f2
9442b05
3e9c8f2
 
39f4412
3e9c8f2
 
 
39f4412
3e9c8f2
 
 
9442b05
3e9c8f2
39f4412
3e9c8f2
 
 
 
 
 
39f4412
3e9c8f2
 
 
 
 
39f4412
3e9c8f2
 
 
39f4412
3e9c8f2
 
 
39f4412
3e9c8f2
 
 
 
 
 
39f4412
3e9c8f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9442b05
3e9c8f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
---
language: ne
license: other
task_categories:
  - text-generation
tags:
  - nepali
  - devanagari
  - pretraining
  - llm
  - text-corpus
  - neBrahma
size_categories:
  - 10M<n<100M
---

# neBrahma Nepali Pretrain Corpus P2b

## Dataset Summary

The **neBrahma Nepali Pretrain Corpus P2b** is a large-scale, production-grade Nepali text
corpus assembled and certified for language model pretraining.
It contains **20,321,968 documents** and **1.845 billion tokens** of clean, verified
Devanagari Nepali text, drawn from four diverse sources and processed through an
eight-stage cleaning and quality pipeline.

This corpus serves as the training data for
[neBrahma-llm](https://github.com/ToniBirat7/neBrahma-llm) - a Nepali multimodal LLM
(text + ASR + TTS) built from scratch in C++/CUDA.
The corpus is certified **FIT TO TRAIN** with zero warnings and a 300-document human
spot-check confirming linguistic quality.

| Source | Raw Docs | Kept Docs | Keep Rate | License |
|--------|----------|-----------|-----------|---------|
| IndicCorp v2 | 21,836,879 | 17,147,383 | 78.52% | CC0 |
| FineWeb-2 | 2,381,855 | 1,583,002 | 66.46% | ODC-By |
| IRIIS Nepali | 1,878,927 | 1,563,850 | 83.23% | Research use |
| Sagarmatha ASR text | 50,790 | 27,733 | 54.60% | Author's own |
| **Total** | **26,148,451** | **20,321,968** | **77.72%** | - |

---

## EDA Visualizations

### Pipeline Overview

The corpus was constructed through an eight-stage pipeline:

1. **Fetch** - stream raw documents from source APIs (HuggingFace datasets, IRIIS, ASR text)
2. **Clean** - Unicode NFC normalization, Devanagari font conversion (Preeti/Kantipur → Unicode),
   script-ratio pre-filter
3. **Exact dedup** - SHA-1 hash deduplication within each source
4. **Language ID** - GlotLID filtering: keep `npi_Deva` (Nepali Devanagari) with score >= 0.6;
   line-level filtering for mixed-language documents
5. **Cross-source exact dedup** - SHA-1 deduplication across all sources (merged)
6. **Near-dedup** - MinHash LSH at Jaccard >= 0.8; removes near-duplicate paragraphs
7. **Quality annotation + filter** - 25+ signal gates: word count, Devanagari ratio, digit ratio,
   Latin ratio, KenLM perplexity, n-gram repetition, stopword ratio, and more
8. **Split + pack** - deterministic hash-keyed train/val/test split, then SentencePiece BPE
   tokenization into packed uint16 shards for training

![Pipeline Funnel](https://huggingface.co/datasets/tonibirat/neBrahma-Nepali-Pretrain-Corpus/resolve/main/images/pipeline_funnel.png)

### Source Composition and Keep Rates

![Source Keep Rates](https://huggingface.co/datasets/tonibirat/neBrahma-Nepali-Pretrain-Corpus/resolve/main/images/source_keep_rates.png)

### Quality Filter Gate Analysis

The chart below shows the top rejection gates (gates overlap - a document may fail multiple).

![Quality Gates](https://huggingface.co/datasets/tonibirat/neBrahma-Nepali-Pretrain-Corpus/resolve/main/images/quality_gates.png)

### Document Length Distribution

Distribution of document lengths (in characters) across the quality-filtered corpus
(sampled from 200K documents).

![Document Length Distribution](https://huggingface.co/datasets/tonibirat/neBrahma-Nepali-Pretrain-Corpus/resolve/main/images/doc_length_dist.png)

### Devanagari Ratio Distribution

All retained documents have Devanagari ratio = 1.0 (pure script, no Latin contamination).

![Devanagari Ratio](https://huggingface.co/datasets/tonibirat/neBrahma-Nepali-Pretrain-Corpus/resolve/main/images/devanagari_ratio_dist.png)

### Character Category Breakdown

![Character Categories](https://huggingface.co/datasets/tonibirat/neBrahma-Nepali-Pretrain-Corpus/resolve/main/images/char_categories.png)

### Top-100 Nepali Words by Frequency

![Top 100 Nepali Words](https://huggingface.co/datasets/tonibirat/neBrahma-Nepali-Pretrain-Corpus/resolve/main/images/word_freq_top100.png)

### Token Zipf Distribution

Vocabulary frequency distribution follows the expected Zipfian curve.
32,000-token BPE vocabulary with 97.16% coverage (31,091 of 32,000 tokens seen in corpus).

![Token Zipf Distribution](https://huggingface.co/datasets/tonibirat/neBrahma-Nepali-Pretrain-Corpus/resolve/main/images/token_zipf.png)

---

## Dataset Structure

### Data Fields

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Unique document identifier (format: `{source}:{original_id}`) |
| `text` | string | Cleaned, NFC-normalized Nepali text in Devanagari script |
| `source` | string | Data source: `indiccorp`, `fineweb2`, `iriis`, or `sagarmatha` |

### Example Record

```json
{
  "id": "indiccorp:npi_Deva_2847193",
  "text": "नेपाल सरकारले नयाँ शिक्षा नीति लागू गर्ने घोषणा गरेको छ। यो नीतिले प्राथमिक विद्यालयदेखि विश्वविद्यालय तहसम्मका विद्यार्थीहरूलाई प्रभाव पार्नेछ।",
  "source": "indiccorp"
}
```

---

## Statistics

### Corpus-Level

| Metric | Value |
|--------|-------|
| Total documents | 20,321,968 |
| Raw input documents | 26,148,451 |
| Overall keep rate | 77.72% |
| Total tokens (BPE 32k) | 1,845,781,044 |
| Training tokens | 1,827,236,028 |
| Validation tokens | 9,320,924 |
| Test tokens | 9,224,092 |
| Total shards | 21 (19 train / 1 val / 1 test) |
| Vocab size | 32,000 (SentencePiece BPE) |
| Unique token types seen | 31,091 / 32,000 (97.16%) |
| Mean Devanagari ratio | 1.00 (pure script) |
| Halant density | 7.87% of Devanagari chars |
| Chandrabindu per 1K Devanagari | 4.92 |
| Anusvara per 1K Devanagari | 4.78 |
| Font conversion applied | 0% (all native Unicode) |

### Per-Source Document Counts

| Source | Kept Docs | % of Total | Est. Tokens |
|--------|-----------|------------|-------------|
| IndicCorp v2 | 17,147,383 | 84.4% | ~1.556B |
| FineWeb-2 | 1,583,002 | 7.8% | ~144M |
| IRIIS | 1,563,850 | 7.7% | ~142M |
| Sagarmatha ASR | 27,733 | 0.1% | ~2.5M |

### Quality Certification

```
Verdict   : FIT TO TRAIN
hard_ok   : true
warnings  : [] (zero)
spot_check: 300 documents - all pass
binary_checks: PASS (SHA-256 integrity, shard contract)
reversible: true (kept ∪ rejected == raw input)
```

---

## Usage

```python
from datasets import load_dataset

# Load the full corpus (~8GB parquet download)
ds = load_dataset("tonibirat/neBrahma-Nepali-Pretrain-Corpus")
print(ds)
# DatasetDict({'train': Dataset({features: ['id', 'text', 'source'], num_rows: 20321968})})

# Filter by source
indiccorp_only = ds["train"].filter(lambda x: x["source"] == "indiccorp")

# Iterate (streaming for large-scale use)
ds_stream = load_dataset("tonibirat/neBrahma-Nepali-Pretrain-Corpus", streaming=True)
for example in ds_stream["train"]:
    text = example["text"]   # Nepali Devanagari text
    src  = example["source"] # "indiccorp" | "fineweb2" | "iriis" | "sagarmatha"
    break
```

---

## Limitations

- **IRIIS crowd-source noise**: The IRIIS subset relies on crowd-sourced transcriptions which
  may contain latent inaccuracies despite passing the quality filter.
- **No demographic metadata**: No speaker, regional dialect, or domain metadata is included.
  Source provenance is available via the `source` field.
- **Sagarmatha ASR fraction is small**: The Sagarmatha ASR text subset (27,733 docs, 0.1%)
  consists of short utterance-level transcriptions and has a lower keep rate (54.6%) due to
  the minimal-sentence nature of ASR transcripts.
- **EDA sample**: Document-level EDA visualizations (length distribution, character breakdown,
  word frequency) were computed on a 200K-document sample, not the full 20.3M.
  Shard-level token statistics are exact (computed from all 21 shards).
- **Per-source license**: IndicCorp v2 is CC0; FineWeb-2 is ODC-By (attribution required);
  IRIIS is distributed for research use. Verify compliance with your use case.

---

## Citation

If you use this dataset, please cite:

```bibtex
@misc{neBrahma2026,
  title        = {neBrahma-llm: A Nepali Multimodal Language Model Trained from Scratch},
  author       = {Gautam, Toni Birat},
  year         = {2026},
  institution  = {Final Year Project},
  howpublished = {\url{https://github.com/ToniBirat7/neBrahma-llm}},
  note         = {Corpus: neBrahma Nepali Pretrain Corpus P2b --
                  20.3M docs / 1.845B tokens / 4 sources / FIT TO TRAIN}
}
```