Dataset Viewer
Auto-converted to Parquet Duplicate
Search is not available for this dataset
input_ids
listlengths
4.1k
4.1k
attention_mask
listlengths
4.1k
4.1k
labels
listlengths
4.1k
4.1k
[ 248045, 846, 198, 5328, 28508, 279, 16905, 12654, 5148, 748, 421, 424, 5469, 264, 359, 3361, 6, 6136, 4598, 1056, 279, 6149, 359, 1891, 6, 6136, 11, 864, 5199, 942, 1472, 279, 3470, 314, 449, 7308, 1103, 13, 271, 760, 5148, 4862, 68...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
[ 248045, 846, 198, 3886, 264, 29812, 709, 303, 7693, 421, 54004, 279, 1727, 2943, 5255, 303, 279, 76938, 27929, 1238, 264, 2574, 1857, 11, 1973, 1608, 866, 28782, 466, 26678, 3555, 41053, 25536, 23689, 8240, 2663, 303, 449, 1287, 13, 248...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
[ 248045, 8678, 198, 7525, 3364, 430, 449, 17313, 17077, 25522, 23218, 4602, 1472, 264, 35234, 1248, 7047, 1817, 1518, 7984, 279, 1534, 22825, 321, 12995, 9611, 13, 1061, 7225, 21870, 303, 264, 15352, 10458, 314, 6157, 11, 27367, 4694, 11, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
[ 248045, 846, 198, 35421, 682, 2677, 264, 19548, 506, 264, 21128, 21117, 321, 628, 4992, 310, 5640, 310, 2892, 21128, 357, 466, 21128, 417, 13, 11342, 357, 682, 264, 220, 17, 15, 4, 5823, 314, 10849, 18861, 7728, 279, 19548, 1345, 2112...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
[248045,846,198,40,599,220,20,15,15,795,3387,364,2136,2046,7336,864,2020,494,220,17,15,15,11,15,15,1(...TRUNCATED)
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1(...TRUNCATED)
[-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100(...TRUNCATED)
[248045,8678,198,7525,3364,430,449,17313,17077,25522,23218,4602,1472,264,35234,1248,7047,1817,1518,7(...TRUNCATED)
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1(...TRUNCATED)
[-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100(...TRUNCATED)
[248045,846,198,9764,393,87,3,321,393,88,3,381,24959,1680,421,393,3994,283,220,22,17,2339,220,7145,2(...TRUNCATED)
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1(...TRUNCATED)
[-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100(...TRUNCATED)
[248045,846,198,2523,513,49110,440,24141,264,999,1752,32570,709,303,264,15019,3992,314,678,5576,13,5(...TRUNCATED)
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1(...TRUNCATED)
[-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100(...TRUNCATED)
[248045,846,198,2523,513,49110,440,6611,264,1957,421,82243,264,3061,5545,999,310,8385,3050,1928,13,5(...TRUNCATED)
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1(...TRUNCATED)
[-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100(...TRUNCATED)
[248045,8678,198,7525,3364,430,449,17313,17077,25522,23218,4602,1472,264,35234,1248,7047,1817,1518,7(...TRUNCATED)
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1(...TRUNCATED)
[-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100(...TRUNCATED)
End of preview. Expand in Data Studio

KapInstruct-100M: Curated 100-Million Token Instruction Tuning Dataset

KapInstruct-100M Banner

License Tokens Dialogue Format Loss Policy Associated Model Kaggle Dataset Starter Notebook Builder Notebook

KapInstruct-100M is a high-fidelity, 100-million-token instruction-tuning dataset engineered for Supervised Fine-Tuning (SFT) and alignment of compact language models (under 1 billion parameters). Formatted with the Qwen ChatML chat template and tokenized using Qwen/Qwen3.5-0.8B-Base, the dataset enforces strict assistant-only loss masking (masking user prompts and structural delimiters to -100) to maximize training efficiency.

KapInstruct-100M unifies 12 balanced, high-signal instruction sources spanning programming synthesis, step-by-step mathematical reasoning (Chain-of-Thought), technical STEM QA, multi-turn dialogue, strict constraint following, and interactive code debugging/repair.


Dataset Overview

  • Hugging Face Repository: kaptaan45/KapInstruct-100M
  • Kaggle Dataset: kaptaan45/kapinstruct-100m
  • Total Usable Tokens: 100,000,000 tokens post-filtering, normalization, and deduplication
  • Packed Sequence Length: 4096 tokens per packed sequence
  • Tokenizer: Qwen/Qwen3.5-0.8B-Base (248,044 BPE vocabulary)
  • Loss Masking Policy: assistant_only (prompts, system messages, and <|im_start|> headers have labels = -100; loss is computed strictly on assistant response spans)
  • Primary Storage Formats: Memory-mapped Apache Arrow IPC (.arrow) and Apache Parquet (.parquet)
  • Primary Use Case: SFT / Instruction Tuning for compact code and reasoning models such as QaptaanLM-0.75B.

Motivation & Design Principles

Supervised fine-tuning of compact models (0.5B to 1.5B parameters) is highly sensitive to data quality and token loss allocation:

  1. Assistant-Only Loss Masking: Standard causal LM training over unmasked instruction data wastes gradient updates predicting user prompts and static system headers. By masking all non-assistant tokens to -100, 100% of gradient updates focus on assistant reasoning, syntax accuracy, and answer generation.
  2. Deficit-Weighted Balanced Scheduling: Rather than concatenating disparate dumps, KapInstruct-100M uses a deficit-driven sampling scheduler that measures exact tokenizer tokens post-filtering, guaranteeing precise representation across all 12 domains.
  3. Cross-Source Global Deduplication: Full multi-turn dialogues are canonicalized and indexed via SHA-256 to eliminate prompt leaks, dataset overlaps, and synthetic duplicates across independent upstream sources.
  4. Rich Reasoning Traces (Chain-of-Thought): Mathematics and STEM partitions retain detailed step-by-step reasoning solutions, empowering compact models to learn structured problem breakdown.

Dataset Composition & Source Mixture

KapInstruct-100M is composed of 12 verified upstream sources sampled according to strict token budgets:

Source Domain / Category Share Tokens License
Smol-Magpie-Ultra General reasoning & conversation 18% 18,000,000 Apache-2.0
Magicoder-Evol Complex programming instructions 13% 13,000,000 Apache-2.0
OpenMathInstruct-2 Math problem solving & synthesis 11% 11,000,000 CC-BY-4.0
CodeFeedback-Filtered Bug fixing & code repair 10% 10,000,000 Apache-2.0
OpenHermes-2.5 Broad conversational QA 9% 9,000,000 MIT
Magicoder-OSS Open-source code generation 8% 8,000,000 MIT
OpenThoughts-114k General & STEM reasoning 7% 7,000,000 Apache-2.0
NuminaMath-CoT Competition math reasoning 6% 6,000,000 Apache-2.0
Tulu-3 SFT High-fidelity instruction following 6% 6,000,000 ODC-By
Self-OSS StarCoder2 Execution-validated code 5% 5,000,000 ODC-By
WebInstructSub Science & technical QA 4% 4,000,000 Apache-2.0
Smol-Constraints Strict constraint adherence 3% 3,000,000 Apache-2.0
Total 100% 100,000,000

Domain Allocation Breakdown

+-------------------------------------------------------------+
|             KapInstruct-100M Domain Allocation              |
+-------------------------------------------------------------+
|  [================]  Code Generation (31% - 31M tokens)     |
|  [==============]    General Reasoning (27% - 27M tokens)   |
|  [=========]         Mathematics CoT (17% - 17M tokens)     |
|  [======]            STEM QA & Science (11% - 11M tokens)   |
|  [=====]             Debugging & Repair (10% - 10M tokens)  |
|  [==]                Constraint Adherence (4% - 4M tokens)  |
+-------------------------------------------------------------+

ChatML Formatting & Loss Masking

Each conversation is formatted strictly following the Qwen ChatML schema:

<|im_start|>system
You are a helpful and harmless assistant.<|im_end|>
<|im_start|>user
Write a function in Python to compute the Levenshtein distance.<|im_end|>
<|im_start|>assistant
def levenshtein_distance(s1: str, s2: str) -> int:
    ...<|im_end|>

Token-Level Alignment & Masking Verification

Turn Component Rendered Token Span Loss Label (labels) Masking Status
System Turn `< im_start >system\n...<
User Turn `< im_start >user\n...<
Assistant Header `< im_start >assistant\n`
Assistant Content `response text...< im_end >\n`
Sequence Padding `< endoftext >` infilling

In multi-turn dialogues [User 1 -> Assistant 1 -> User 2 -> Assistant 2], loss is computed strictly across Assistant 1 and Assistant 2 response spans.


Quality Filtering & Deduplication

  1. Natural Language Filtering: FastText language identification and English confidence scoring (min_confidence = 0.65), with automatic preservation of code-mixed technical dialogues.
  2. Programming Language Normalization: Canonical alias mapping across 16 core languages (Python, TypeScript, JavaScript, C++, C, C#, Java, Rust, Go, Ruby, PHP, SQL, Shell, HTML, CSS, Dockerfile).
  3. Secret & Key Stripping: Regex scanning and complete rejection of leaked API keys (OpenAI sk-, AWS AKIA, GitHub ghp_, Slack, JWTs, and private RSA/SSH keys).
  4. LaTeX & Math Integrity: Rejection of unbalanced LaTeX delimiters ($$, \begin{...}) and OCR noise artifacts.
  5. Prompt Injection & Repetition Removal: Scanning and removal of injection jailbreaks, infinite loops, and degenerative repetition.
  6. Global Cross-Source Deduplication: Exact SHA-256 fingerprinting on normalized dialogue turns across all 12 constituent datasets.

Dataset Loading and Usage

1. Zero-Copy Memory-Mapped PyArrow Loading (Fastest)

import glob
import pyarrow as pa
from datasets import load_dataset

# Load Arrow shards directly
shard_files = sorted(glob.glob("data/kapinstruct/*.arrow"))
dataset = load_dataset("arrow", data_files=shard_files, split="train", keep_in_memory=False)

print(f"Total packed sequences: {len(dataset):,}")
sample = dataset[0]
print(f"Sequence length: {len(sample['input_ids'])} tokens")
print(f"Trainable tokens: {sum(1 for l in sample['labels'] if l != -100)}")

2. Hugging Face Datasets Streaming

from datasets import load_dataset

dataset = load_dataset("kaptaan45/KapInstruct-100M", split="train", streaming=True)
sample = next(iter(dataset))
print("Loaded sequence keys:", list(sample.keys()))

3. PyTorch Training Loop Integration

import torch
from torch.utils.data import DataLoader

def collate_fn(batch):
    return {
        "input_ids": torch.tensor([b["input_ids"] for b in batch], dtype=torch.long),
        "attention_mask": torch.tensor([b["attention_mask"] for b in batch], dtype=torch.long),
        "labels": torch.tensor([b["labels"] for b in batch], dtype=torch.long),
    }

loader = DataLoader(dataset, batch_size=8, shuffle=True, collate_fn=collate_fn)
for batch in loader:
    # Forward pass computes cross-entropy loss ONLY on labels != -100
    outputs = model(
        input_ids=batch["input_ids"],
        attention_mask=batch["attention_mask"],
        labels=batch["labels"]
    )
    loss = outputs.loss
    loss.backward()
    break

Licensing and Provenance

KapInstruct-100M is a curated composite dataset. Each constituent subset retains its upstream license terms as documented in licenses.json:

Subset / Source Upstream License Attribution & Commercial Use
smol_magpie_ultra, smol_constraints Apache-2.0 / Open HuggingFaceTB / SmolTalk
magicoder_evol, code_debugging Apache-2.0 ISE UIUC / M-A-P
magicoder_oss, openhermes_2_5 MIT ISE UIUC / Teknium
openmathinstruct2 CC-BY-4.0 NVIDIA Corporation
numinamath_cot, openthoughts_reasoning Apache-2.0 AI-MO / Open-Thoughts
tulu3_sft, self_oss_starcoder2 ODC-By Allen AI / BigCode Project
stem_qa (WebInstructSub) Apache-2.0 TIGER-Lab

Users and researchers must comply with the individual licenses of each constituent source.


Citation

To cite the KapInstruct-100M dataset in research:

@misc{kapinstruct100m2026,
  title   = {{KapInstruct-100M}: A Curated 100-Million Token Multi-Source Instruction Tuning Dataset for Compact Models},
  author  = {Kaptaan, Rudy and Contributors},
  year    = {2026},
  publisher = {Hugging Face},
  url     = {https://huggingface.co/datasets/kaptaan45/KapInstruct-100M}
}
@misc{qaptaanlm2026,
  title   = {{QaptaanLM-0.75B}: Efficient Hybrid-Attention Foundation Language Model},
  author  = {Kaptaan, Rudy and Contributors},
  year    = {2026},
  publisher = {GitHub},
  url     = {https://github.com/rudy-07/QaptaanLM-0.75B}
}
Downloads last month
78

Models trained or fine-tuned on kaptaan45/KapInstruct-100M