Dataset Viewer
The dataset viewer is not available for this dataset.
Unexpected token '<', "<html> <h"... is not valid JSON

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

Gleam Code Corpus

A structured, attributed corpus of 22,581 Gleam source files collected from 1,528 GitHub repositories for continued pre-training and code generation research.

Overview

This dataset contains .gleam source files from the Gleam programming language ecosystem. Every file includes full attribution — repo owner, name, URL, license, star count, and Hex.pm package metadata where available.

What this is for:

  • Continued pre-training (CPT) of code-focused language models
  • Fine-tuning models for Gleam code generation
  • Research on small programming language ecosystems
  • Reference corpus for Gleam idioms and patterns

What this is NOT:

  • Instruction/response pairs (see the companion gleam-sft dataset, coming later)
  • Documentation (language tour, hexdocs — separate dataset, coming later)
  • Raw/unfiltered data (generated files, unlicensed code, and duplicates have been removed)

Dataset Configs

Config Files Size Description
all 22,581 27 MB Full filtered corpus
official 296 422 KB Official repos only (gleam-lang, gleam-wisp, lustre-labs)
community_top 6,702 8 MB Community repos with stars ≥ 10 or Hex downloads ≥ 1,000

All configs contain only permissively licensed, deduplicated code.

Schema

Each record is a single .gleam file with full attribution:

Field Type Description
id string {owner}/{repo}/{file_path} — unique identifier
source string Always "github"
code string Raw file contents
file_path string Path within the repository
repo_url string GitHub repository URL
repo_owner string Repository owner/organization
repo_name string Repository name
repo_description string Repository description from GitHub
stars int GitHub star count at collection time
is_official bool True if owner is gleam-lang, gleam-wisp, or lustre-labs
license string Normalized SPDX license identifier
license_raw string Original license string from source
authors list[string] Repository authors/contributors
hex_package string? Hex.pm package name (null if not on Hex)
hex_downloads int? Hex.pm download count (null if not on Hex)
fork bool Whether the repo is a fork (unreliable — see notes)
archived bool Whether the repo is archived
collected_at string ISO 8601 timestamp of collection
commit_sha string Git commit SHA of the snapshot
schema_version int Schema version (currently 1)

Collection Methodology

  1. Discovery: GitHub search API with language:gleam, using star-range + date-range chunking to bypass the 1,000-result-per-query limit. Discovered 4,660 unique repositories across 17 query chunks.

  2. Enrichment: Cross-referenced with Hex.pm search=gleam (1,035 packages) to add package names and download counts.

  3. Collection: Shallow-cloned each repo (git clone --depth 1), extracted all .gleam files. 4,489 repos processed, 0 clone failures.

  4. Filtering: Applied a multi-stage quality pipeline:

    Filter Removed Reason
    Generated files (>50K chars) 666 Auto-generated schemas, lookup tables, data dumps
    Stub files (<20 chars) 316 Empty/placeholder files
    Unlicensed repos 42,368 No license and no Hex package
    Non-permissive licenses 0 GPL, AGPL removed
    Exercism repos 840 Same exercises solved repeatedly — low diversity
    Content deduplication 2,642 Identical code from different repos (kept highest-starred)

    69,413 raw files → 22,581 clean files (67% reduction)

Statistics

Corpus

  • 22,581 files from 1,528 repos
  • 4.3M lines, 121M characters
  • Median file: 2,692 chars; Mean: 5,352 chars; Max: 49,945 chars

License Distribution

  • MIT: 57% (13,068 files)
  • Apache-2.0: 40% (8,723 files)
  • Other permissive: 3% (MPL-2.0, BSD, ISC, Unlicense, 0BSD, CC0-1.0)

Source Distribution

  • src/ files: 48%
  • test/ files: 24%
  • examples/ files: 6%
  • Other: 22%

Star Distribution

Stars Files %
0 6,904 31%
1–4 6,842 30%
5–9 3,432 15%
10–49 3,602 16%
50–99 757 3.4%
100–999 918 4.1%
1000+ 126 0.6%

Known Limitations

  • fork field is unreliable: GitHub search API doesn't consistently mark forks. All records show fork=false. Some near-duplicate fork content may be present (content dedup catches exact copies only).
  • Near-duplicate forks: Diverged forks (e.g., Ivan-Vakhula07/lustre vs lustre-labs/lustre) survived dedup because their files differ slightly. These are valid Gleam code and not harmful for training.
  • Semi-generated content: dusty-phillips/monks_of_style contributes 496 files (2.2%) of auto-generated CSS property wrappers from MDN documentation. Each file is valid Gleam but follows an identical template.
  • Hex.pm enrichment incomplete: Only 44% of files (10,015) have Hex package metadata. The rest are from repos not published on Hex.
  • Collection snapshot: Data was collected on 2026-05-28. Repositories may have changed since.

Licensing

This dataset aggregates code from many repositories, each with their own license. The license field in each record contains the normalized SPDX identifier. All included code is under permissive licenses:

  • MIT
  • Apache-2.0
  • MPL-2.0
  • BSD-3-Clause
  • BSD-2-Clause
  • ISC
  • Unlicense
  • 0BSD
  • CC0-1.0

The dataset card and curation scripts are released under the same license terms as the underlying code. See individual records for specific license attribution.

How to Use

from datasets import load_dataset

# Load full corpus
ds = load_dataset("kasuboski/gleam-code-corpus", config="all")

# Load only official Gleam repos
ds = load_dataset("kasuboski/gleam-code-corpus", config="official")

# Load community top (stars >= 10 or hex_downloads >= 1000)
ds = load_dataset("kasuboski/gleam-code-corpus", config="community_top")

# Access a record
record = ds["train"][0]
print(record["code"])           # the Gleam source code
print(record["repo_url"])       # GitHub URL for attribution
print(record["license"])        # SPDX license identifier

Acknowledgments

  • The Gleam language team and community
  • Hex.pm for package metadata
  • All the repository authors whose code is included in this corpus
Downloads last month
32