Dataset Viewer
Auto-converted to Parquet Duplicate
messages
listlengths
3
3
metadata
unknown
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# The La...
{ "source": "goodwiki", "token_count": 1632, "heading_count": 9, "max_depth": 3, "min_depth": 1, "max_level_gap": 1, "title": "The Last Ringbearer", "pageid": 15773551, "categories": [ "1999 novels", "Fan fiction works", "High fantasy novels", "Parallel literature", "Parody novels"...
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# Change...
{ "source": "github_code", "token_count": 6977, "heading_count": 39, "max_depth": 2, "min_depth": 1, "max_level_gap": 1, "repo": "taiebb/bearded", "path": "themes/bearded/node_modules/shelljs/CHANGELOG.md", "license": "gpl-2.0", "is_priority_path": false }
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# Louis ...
{ "source": "goodwiki", "token_count": 1597, "heading_count": 12, "max_depth": 3, "min_depth": 1, "max_level_gap": 1, "title": "Louis Ngwat-Mahop", "pageid": 8467684, "categories": [ "1987 births", "2. Bundesliga players", "2. Liga (Austria) players", "Austrian Football Bundesliga play...
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# Pseudo...
{ "source": "goodwiki", "token_count": 1096, "heading_count": 7, "max_depth": 3, "min_depth": 1, "max_level_gap": 1, "title": "Pseudoplectania nigrella", "pageid": 24551515, "categories": [ "Fungi described in 1801", "Fungi of Asia", "Fungi of Europe", "Fungi of New Zealand", "Fung...
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# Change...
{ "source": "github_code", "token_count": 232, "heading_count": 9, "max_depth": 4, "min_depth": 1, "max_level_gap": 2, "repo": "renjujv/MeOr", "path": "CHANGELOG.md", "license": "gpl-3.0", "is_priority_path": false }
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# Change...
{ "source": "github_code", "token_count": 232, "heading_count": 9, "max_depth": 4, "min_depth": 1, "max_level_gap": 2, "repo": "renjujv/MeOr", "path": "CHANGELOG.md", "license": "gpl-3.0", "is_priority_path": false }
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# David ...
{ "source": "goodwiki", "token_count": 5536, "heading_count": 26, "max_depth": 3, "min_depth": 1, "max_level_gap": 1, "title": "David Irving", "pageid": 87585, "categories": [ "1938 births", "20th-century British biographers", "20th-century English writers", "21st-century British biogr...
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# Greece...
{ "source": "goodwiki", "token_count": 847, "heading_count": 5, "max_depth": 2, "min_depth": 1, "max_level_gap": 1, "title": "Greece at the 2014 Winter Paralympics", "pageid": 41971042, "categories": [ "2014 in Greek sport", "Greece at the Paralympics", "Nations at the 2014 Winter Paralymp...
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# Operat...
{ "source": "goodwiki", "token_count": 1858, "heading_count": 8, "max_depth": 3, "min_depth": 1, "max_level_gap": 1, "title": "Operation PBFortune", "pageid": 1218219, "categories": [ "Central Intelligence Agency operations", "Covert operations", "False flag operations", "Guatemalan Re...
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# Stavro...
{ "source": "goodwiki", "token_count": 2171, "heading_count": 10, "max_depth": 4, "min_depth": 1, "max_level_gap": 1, "title": "Stavros Niarchos Foundation Library", "pageid": 64427755, "categories": [ "1970 establishments in New York City", "Bryant Park buildings", "Fifth Avenue", "Li...
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# Stavro...
{ "source": "goodwiki", "token_count": 2171, "heading_count": 10, "max_depth": 4, "min_depth": 1, "max_level_gap": 1, "title": "Stavros Niarchos Foundation Library", "pageid": 64427755, "categories": [ "1970 establishments in New York City", "Bryant Park buildings", "Fifth Avenue", "Li...
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# Blue W...
{ "source": "goodwiki", "token_count": 923, "heading_count": 7, "max_depth": 3, "min_depth": 1, "max_level_gap": 1, "title": "Blue Wing Blitz", "pageid": 12349135, "categories": [ "2001 video games", "Japan-exclusive video games", "Square (video game company) games", "Tactical role-pla...
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# Coors ...
{ "source": "goodwiki", "token_count": 2947, "heading_count": 14, "max_depth": 3, "min_depth": 1, "max_level_gap": 1, "title": "Coors strike and boycott", "pageid": 67878603, "categories": [ "1966 protests", "1970s in LGBT history", "1970s strikes in the United States", "1977 in Colora...
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# sprite...
{ "source": "github_code", "token_count": 3963, "heading_count": 24, "max_depth": 4, "min_depth": 1, "max_level_gap": 1, "repo": "AlexanderDolgan/sputnik", "path": "wp-content/themes/node_modules/gulp.spritesmith/node_modules/spritesmith/README.md", "license": "gpl-2.0", "is_priority_path": false }
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# sprite...
{ "source": "github_code", "token_count": 3963, "heading_count": 24, "max_depth": 4, "min_depth": 1, "max_level_gap": 1, "repo": "AlexanderDolgan/sputnik", "path": "wp-content/themes/node_modules/gulp.spritesmith/node_modules/spritesmith/README.md", "license": "gpl-2.0", "is_priority_path": false }
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# Dál Ri...
{ "source": "goodwiki", "token_count": 2766, "heading_count": 13, "max_depth": 3, "min_depth": 1, "max_level_gap": 1, "title": "Dál Riata", "pageid": 43782, "categories": [ "6th-century establishments in Scotland", "840s disestablishments", "9th-century disestablishments in Europe", "F...
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# What i...
{ "source": "github_code", "token_count": 2197, "heading_count": 38, "max_depth": 4, "min_depth": 1, "max_level_gap": 1, "repo": "eea/eea.rancher.catalog", "path": "templates/matomo/4/README.md", "license": "gpl-2.0", "is_priority_path": false }
[ { "role": "system", "content": "You are a markdown document structure expert. Given a markdown document with incorrect or flattened heading levels, output each heading with its correct markdown prefix (# for level 1, ## for level 2, etc.), one per line." }, { "role": "user", "content": "# What i...
{ "source": "github_code", "token_count": 2197, "heading_count": 38, "max_depth": 4, "min_depth": 1, "max_level_gap": 1, "repo": "eea/eea.rancher.catalog", "path": "templates/matomo/4/README.md", "license": "gpl-2.0", "is_priority_path": false }
End of preview. Expand in Data Studio

md-reheader Dataset

Training data for md-reheader, a model that restores heading hierarchy in markdown documents.

Dataset Description

Each example is a ChatML conversation with three messages:

  1. System: Instructions for heading level prediction
  2. User: A markdown document with all headings flattened to # (level 1) and body text stripped to first 128 + last 128 tokens per section
  3. Assistant: The correct headings with proper # prefixes (e.g., ## Methods, ### Data)

Example

{
  "messages": [
    {"role": "system", "content": "You are a markdown document structure expert..."},
    {"role": "user", "content": "# Introduction\n\nFirst 128 tokens...\n\n# Background\n\n..."},
    {"role": "assistant", "content": "# Introduction\n## Background"}
  ],
  "metadata": {
    "source": "goodwiki",
    "token_count": 1632,
    "heading_count": 9,
    "max_depth": 3
  }
}

Dataset Structure

Split Examples Notes
train 196,949 Includes 2-8x oversampling of deep-structure documents
validation 7,321
test 7,321

Metadata fields

  • source: github_code or goodwiki
  • token_count: Token count of the stripped document (Qwen3 tokenizer)
  • heading_count: Number of headings in the document
  • max_depth: Maximum heading depth (1-6)
  • min_depth: Minimum heading depth
  • max_level_gap: Largest gap between adjacent heading levels

Sources

codeparrot/github-code (~105k documents)

Markdown files from GitHub repositories, loaded from the codeparrot/github-code dataset. Filtered by .md/.markdown file extension. Bucket-targeted download ensures representation across document lengths (< 4k, 4k-8k, 8k-16k, 16k-32k characters).

Split by repository name to prevent data leakage.

euirim/goodwiki (~45k documents)

High-quality Wikipedia articles from euirim/goodwiki. Article titles prepended as # {title} since Wikipedia's title serves as the H1 heading.

Split by article title to prevent data leakage.

Processing Pipeline

  1. Download raw markdown documents from HuggingFace
  2. Filter by character length (300-150k), heading count (3-120), distinct levels (≥2), token count (100-31k)
  3. Split by source key (repo name / article title) into 90% train / 5% val / 5% test
  4. Oversample deep-structure documents in the training split (depth 4: 2x, depth 5: 4x, depth 6: 8x)
  5. Strip body text to first 128 + last 128 tokens per section
  6. Flatten all headings to # (level 1)
  7. Truncate documents exceeding 7,500 tokens
  8. Format as ChatML conversations

Heading Level Distribution (training set)

Level Count Percentage
H1 211,673 8.5%
H2 911,437 36.8%
H3 922,695 37.3%
H4 335,052 13.5%
H5 78,761 3.2%
H6 16,345 0.7%

License

This dataset is released under CC-BY-SA 4.0 because it contains derivative content from Wikipedia.

Author

Built by Joel Barmettler.

Citation

@software{barmettler2026mdreheader,
  author = {Barmettler, Joel},
  title = {md-reheader: Restoring Heading Hierarchy in Markdown Documents},
  year = {2026},
  url = {https://github.com/joelbarmettlerUZH/md-reheader}
}
Downloads last month
21

Models trained or fine-tuned on joelbarmettler/md-reheader-dataset