prolong-64k-qwen3
收藏资源简介:
# ProLong-64K Qwen3 (prolong-64k-qwen3) [princeton-nlp/prolong-data-64K](https://huggingface.co/datasets/princeton-nlp/prolong-data-64K) 的 Qwen3-tokenized 派生版,用于 Qwen3 系列模型的长上下文 continual pretraining。 基于 [fenghonghao/prolong-64k-text](https://modelscope.cn/datasets/fenghonghao/prolong-64k-text) 用 Qwen3-1.7B-Base tokenizer(vocab 151,643)重新分词,保留一行 = 一个原始文档的结构,同时存储 `text` 原文和 `input_ids` token 序列。 ## 数据规模 | 项目 | 值 | |---|---| | 行数(= 原始文档数) | ~20.3 M | | 子集数 | 10 | | Qwen3 tokens 总量 | 暂未统计 | | 存储 | parquet + zstd,每子集 64 shards,共 640 文件 | ## Schema | 列名 | 类型 | 含义 | |---|---|---| | `text` | string | 原始文档文本(UTF-8) | | `input_ids` | list[int32] | Qwen3 token IDs,无 BOS/EOS | | `length` | int32 | `len(input_ids)` | | `domain` | string | 子集名(10 个取值) | | `src_partition` | string | 上游 partition ID | | `src_sample_idx` | int32 | partition 内 sample 索引 | | `src_doc_idx` | int32 | packed sample 内文档索引 | ## 子集组成 | 子集 | 文档数 | 来源 | 形态 | |---|---|---|---| | book | 98,302 | SlimPajama Books | 长文档 | | thestackv1_concat_by_repo | 98,302 | GitHub 整 repo 拼接 | 长文档 | | textbooks | 3,755 | TextbookChapters | 长文档 | | fineweb-edu | 6,517,820 | FineWeb-Edu | 短文档 packed | | fineweb-2023-50 | 8,955,062 | FineWeb 2023-50 | 短文档 packed | | arxiv | 75,302 | SlimPajama ArXiv | 变长 packed | | stackexchange | 1,832,506 | SlimPajama StackExchange | 短文档 packed | | dolmawiki | 1,830,022 | Dolma Wikipedia | 短文档 packed | | openwebmath | 552,898 | OpenWebMath | 短文档 packed | | tuluv2 | 330,381 | Tulu-v2 短指令对话 | 短文档 packed | > ⚠️ 上游 dclm-baseline(5.28M docs)未包含在本仓库中。 ## 文档长度分布 长度统计基于 Llama-3 token 数(Qwen3 token 数通常比 Llama-3 低 0–15%,分布形态一致)。 - **完全填满 64K**:book, thestack(100% == 65,536 tokens) - **基本填满 64K**:textbooks(95% ≥ 64K) - **变长长尾**:arxiv(mean 14K)、openwebmath(mean 2K) - **全短文档**:其余 5 个子集(99%+ < 8K) 长文档(≥ 8K)仅占 ~1.5%,但贡献了大部分长上下文训练信号。完整分位数表见 [prolong-64k-text README](https://modelscope.cn/datasets/fenghonghao/prolong-64k-text)。 ## 训练注意事项 ### 直接按行采样的问题 按文档行 round-robin 采样会让 99% 训练步落在 < 8K 文档上,padding-heavy,长上下文能力练不出来。建议: 1. **Dataloader 层 packing**:短文档拼到 `max_seq_len` 后再 batch,需支持 cross-document attention masking(论文 §6.1) 2. **分阶段训练**:先用 long 子集做 warmup,再混入 short 数据微调 ### BOS/EOS 约定 `input_ids` **不含 BOS/EOS**。VeOmni `data_type: plaintext` 会自动在每 doc 末尾追加 EOS;走自定义 pretokenized 路径需自行添加。 ### 推荐 VeOmni 配置 ```yaml data: train_path: "ms://fenghonghao/prolong-64k-qwen3" data_type: plaintext # 读 text 列,自动加 EOS text_keys: text max_seq_len: 65536 datasets_type: iterable drop_last: true ``` > 为什么用 `plaintext` 而不是 `pretokenized`? 公开版 VeOmni 的 `process_pretokenized_example` 函数不存在(内部代码残留接口),开源训练必须走 `plaintext`。 ## ProLong 论文混合比例(Table 9) | 类别 | 子集 | 占比 | |---|---|---| | Long(63%) | thestackv1_concat_by_repo | 30% | | | book | 30% | | | textbooks | 3% | | Short(37%) | fineweb-edu | 10% | | | fineweb-2023-50 | 10% | | | dolmawiki | 4.1% | | | stackexchange | 4.1% | | | openwebmath | 3% | | | arxiv | 3% | | | tuluv2 | 3% | 论文同时要求训练时做 **cross-document attention masking**(`cu_seqlens` / FlexAttention 派生的 doc-boundary mask)。 <details> <summary>ProLong 训练 recipe 其他参数(Table 9)</summary> | 字段 | 值 | |---|---| | 初始化模型 | Llama-3-8B-Instruct | | RoPE base | Stage 1: 8e6 → Stage 2: 1.28e8 | | Attention | Full + cross-document masking | | Optimizer | AdamW (wd=0.1, β₁=0.9, β₂=0.95) | | LR | 1e-5, 10% warmup, cosine → 1e-6, 每 stage 重置 | | Batch | Stage 1: 4M tokens → Stage 2: 8M tokens | | Steps | 各 20B tokens | | Length curriculum | 64K → 512K | </details> ## 加载方式 ```python # ModelScope SDK from modelscope.msdatasets import MsDataset ds = MsDataset.load("fenghonghao/prolong-64k-qwen3", split="train", trust_remote_code=True) # 直接读 parquet import pyarrow.parquet as pq tbl = pq.read_table("data/book/train-00-of-64.parquet", columns=["text", "input_ids", "length"]) ``` 文件布局:`data/<subset>/train-XX-of-64.parquet`,64 shards × 10 subsets = 640 文件。 ## 派生数据集 | 数据集 | 说明 | |---|---| | [fenghonghao/prolong-64k-qwen3-cut16k](https://modelscope.cn/datasets/fenghonghao/prolong-64k-qwen3-cut16k) | 长度过滤 + 随机裁剪到 [1024, 16384],适合 16K 训练 | ## 数据血缘 ``` princeton-nlp/prolong-data-64K (MDS, Llama-3 tokens, 11 subsets) ↓ 反 tokenize fenghonghao/prolong-64k-text (纯文本, 10 subsets, ~20.3M docs) ↓ Qwen3 tokenize (add_special_tokens=False) fenghonghao/prolong-64k-qwen3 ← 本数据集 ↓ 长度过滤 + 16K 裁剪 fenghonghao/prolong-64k-qwen3-cut16k (4.7M rows, 17.3B tokens) ``` ## 引用 ```bibtex @article{gao2024prolong, title = {How to Train Long-Context Language Models (Effectively)}, author = {Gao, Tianyu and Wettig, Alexander and Yen, Howard and Chen, Danqi}, journal = {arXiv:2410.02660}, year = {2024}, } @inproceedings{feng2026inplace, title = {In-Place Test-Time Training}, author = {Feng, Guhao and Luo, Shengjie and Hua, Kai and Zhang, Ge and Huang, Wenhao and He, Di and Cai, Tianle}, booktitle = {ICLR}, year = {2026}, note = {Oral Presentation}, } ``` ## License Apache 2.0。各子集源数据保留原 license 条款,详见 [ProLong dataset card](https://huggingface.co/datasets/princeton-nlp/prolong-data-64K)。



