gpt2-codegolf

Implement minimal GPT-2 inference with checkpoint parsing and BPE tokenization.

134|21|Updated Nov 12, 2025
One-click install
npx skills add https://github.com/letta-ai/skills --skill gpt2-codegolf
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gpt2-codegolf
Source: https://github.com/letta-ai/skills/tree/main/ai/benchmarks/letta/terminal-bench-2/trajectory-feedback/gpt2-codegolf
Command: npx skills add https://github.com/letta-ai/skills --skill gpt2-codegolf

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides implementing GPT-2 style inference under tight code-size constraints, including checkpoint parsing and tokenization within code golfing challenges.

Core Features & Use Cases

  • Checkpoint parsing: Extract and validate weights from compact formats.
  • BPE tokenization: Implement or adapt byte-pair encoding to map tokens to IDs.
  • Forward pass basics: Achieve a minimal viable inference step within size limits.

Quick Start

Example: create a minimal GPT-2-like inference snippet that processes a single token and outputs a plausible next-token distribution.

Frequently Asked Questions about gpt2-codegolf

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement GPT-2 inference under code-size constraints?

GPT-2 inference in constrained environments requires implementing three core components: parsing binary checkpoints to extract weights, building a BPE tokenizer to convert text to token IDs, and executing minimal transformer forward passes. Start by validating checkpoint loading, then verify tokenization accuracy, and finally test numerical stability of the forward pass within your size budget.

What is byte-pair encoding tokenization and why does GPT-2 use it?

Byte-pair encoding (BPE) tokenization maps text into token IDs by iteratively merging frequent byte pairs into subword units. GPT-2 uses BPE to balance vocabulary size and compression efficiency, allowing it to handle any Unicode text while keeping the token space manageable and enabling efficient inference in resource-constrained settings.

Can I parse GPT-2 checkpoint files in a code-golf environment?

Yes. Checkpoint parsing extracts and validates weights from compact binary formats into usable tensors. In code-golf constraints, this means implementing minimal parsing logic that verifies weight shapes and data types, then loads them into memory—prioritizing correctness over compactness, then optimizing for size after validation passes.

What are the limitations of running GPT-2 inference with tight code-size budgets?

Tight size constraints force trade-offs: you must omit advanced features like attention caching, quantization, or multi-layer parallelism. Correctness verification becomes harder to demonstrate within limited lines. Use component-wise validation—test checkpoint loading, tokenization, and forward-pass numerics independently—before optimizing for size.

How do I verify GPT-2 tokenization matches the original implementation?

Validate your BPE tokenizer against known token sequences from standard GPT-2 checkpoints. Test edge cases: special tokens, Unicode boundaries, and repeated subwords. Component-wise validation ensures your token IDs align with the model's expectations before running inference, catching tokenization bugs early.

Do I need external dependencies to build GPT-2 inference from scratch?

No external dependencies are required. GPT-2 inference can be built from first principles—checkpoint parsing uses only binary I/O, BPE tokenization uses only string manipulation and frequency counting, and forward passes use only basic matrix operations—making it viable for code-golf and verification-driven workflows.