leire-corpus
收藏资源简介:
Leire Corpus 是一个专为巴西葡萄牙语语言模型 Leire(343.7M 参数)设计的预训练语料库,模型从零开始训练于 Kaggle T4 GPU。该语料库包含约 150 亿个 token,由四个子集混合而成:70% 的葡萄牙语高质量文本(来自 GigaVerbo-v2)、15% 的 Python 代码(来自 Stack-Edu 镜像)、8% 的数学内容(来自 FineMath 的 finemath-4plus 子集)、7% 的教育性英语内容(来自 FineWeb-Edu 的 sample-10BT 子集)。数据使用自定义的 32,768 词表字节级 BPE 分词器进行分词,该分词器基于混合数据的分层抽样训练。数据以 uint16 小端序二进制分片形式存储,每个分片包含 250M token,文档由 eos 分隔。每 1000 个文档中有一个被分配到验证集。该语料库并非通用葡萄牙语语料,而是为特定实验(递归、条件记忆与诚实性相关研究)准备的燃料。各子集继承其上游来源的许可证,本仓库不添加额外限制。
The Leire Corpus is a pretraining corpus designed specifically for the Brazilian Portuguese language model Leire (343.7M parameters), trained from scratch on Kaggle T4 GPU. It contains approximately 15 billion tokens, composed of four subsets: 70% high-quality Portuguese text (from GigaVerbo-v2), 15% Python code (from Stack-Edu mirror), 8% mathematical content (from FineMaths finemath-4plus subset), and 7% educational English content (from FineWeb-Edus sample-10BT subset). The data is tokenized using a custom byte-level BPE tokenizer with a vocabulary of 32,768, trained on a stratified sample of the mixed data. The data is stored as uint16 little-endian binary shards, each containing 250M tokens, with documents separated by eos. One out of every 1000 documents is assigned to the validation set. This corpus is not a general-purpose Portuguese corpus but a fuel for specific experiments (related to recursion, conditional memory, and honesty). Subsets inherit their upstream source licenses, and this repository adds no additional restrictions.
Leire Corpus 数据集详情
基本信息
- 数据集名称:Leire Corpus
- 语言:葡萄牙语(主要)与英语
- 许可证:混合上游许可(mixed-upstream),各数据切片继承其上游来源的许可证
- 任务类型:文本生成
- 数据规模:100亿至1000亿 tokens(约15B tokens)
- 用途:用于训练 Leire 模型——一个 343.7M 参数的巴西葡萄牙语语言模型,从零开始在 Kaggle T4 GPU 上训练
数据构成(混合比例)
| 切片 | 占比 | 来源 | 配置 |
|---|---|---|---|
| 葡萄牙语(高质量) | 70% | Polygl0t/gigaverbo-v2 | 默认 |
| 代码(Python) | 15% | zaydzuhri/stack-edu-python | 默认,download_success=True |
| 数学 | 8% | HuggingFaceTB/finemath | finemath-4plus |
| 教育类英语 | 7% | HuggingFaceFW/fineweb-edu | sample-10BT |
说明:代码来源原本计划使用 HuggingFaceTB/stack-edu(仅提供元数据),实际使用了上述带文本内容的镜像,该镜像包含与 Stack-Edu 相同的 25,300,000 行 Python 代码。
Tokenizer 信息
- 采用 byte-level BPE,词表大小为 32,768
- 基于数据混合物的 2GB 分层抽样进行训练(并非仅使用葡萄牙语)
- 特殊标记:
bos、eos、pad以及 8 个保留标记 - 压缩效率对比:
- Leire tokenizer:葡萄牙语 1.692 tokens/词,代码 3.125 tokens/词
- SmolLM2(49,152 词表):葡萄牙语 2.511,代码 3.137
- Tucano(32,000 词表):葡萄牙语 1.620,代码 4.698
- 该 tokenizer 在代码处理上比纯葡萄牙语 tokenizer 高效 50%
数据格式
- 每个分片文件命名格式:
{切片名}_train_{编号}.bin或{切片名}_val_{编号}.bin - 内容为 uint16 小端序 token ID 二进制文件,文档间以
eos分隔 - 每个分片文件名唯一,不会被覆盖
- 每 1000 个文档中约 1 个进入验证集(val),绝不进入训练集(train)
- 同时提供
progress_{切片名}.json文件记录可恢复的流水线进度
复现方法
位于项目仓库的 scripts/fase1_corpus.py 中提供完整流程:流式读取数据源 → 过滤(长度 ≥200)→ tokenization → 生成 2.5 亿 tokens 的分片 → 上传。
许可证详情
各切片的数据许可证继承自其上游来源:
- GigaVerbo-v2 → other
- Stack-Edu(源自 The Stack v2)→ other
- FineMath 和 FineWeb-Edu → odc-by
- 本仓库本身不附加额外限制
重要声明
该数据集并非通用葡萄牙语语料库,而是为特定语言模型实验(343.7M 参数规模下的递归、条件记忆与诚实性研究)专门准备的训练数据。其中代码数据的价值在于其推理能力的迁移,而非教授编程技能。




