Token导航 LogoToken导航TokenDH.com
AI 工具只读github未标认证来源可访问clear审计通过

gpt2-codegolfGPT2 代码高尔夫

Agent Skill

gpt2-codegolf 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

783

周安装

32

GitHub Stars

93

下载量

251
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:gpt2-codegolf(GPT2 代码高尔夫)
来源仓库:https://github.com/letta-ai/skills
仓库路径:skills/gpt2-codegolf
安装命令:
npx skills add https://github.com/letta-ai/skills --skill gpt2-codegolf
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/letta-ai/skills --skill gpt2-codegolf

简介

gpt2-codegolf 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态、代码变更或协作事项进行整理。
  • 通过 npx skills add 命令从指定仓库安装并使用。
  • 安装前建议确认权限范围和维护状态,注意是否会触发联网或文件读写操作。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

GPT-2 Code Golf

Overview

This skill provides guidance for implementing GPT-2 or similar transformer model inference in minimal code, typically for code golf challenges. These tasks require parsing binary checkpoint formats, implementing BPE tokenization, and performing forward passes through transformer architectures—all within strict size constraints.

Critical Principles

1. Verify Before Optimizing

Never optimize for size before functionality is verified. A working 10KB solution is better than a broken 4KB solution. Size optimization should be the final step, not a constraint during development.

2. Incremental Development and Testing

Build and test components independently before integration:

  1. Checkpoint parsing - Verify weights load correctly
  2. Tokenization - Verify BPE encoding/decoding works
  3. Forward pass - Verify matrix operations produce reasonable outputs
  4. Integration - Combine components only after individual verification

3. Format Analysis Before Implementation

Before writing any parsing code, analyze the actual file formats:

# Examine checkpoint structure
hexdump -C model.ckpt.data-00000-of-00001 | head -100

# Check index file format
cat model.ckpt.index | xxd | head -50

# Examine vocabulary/BPE file structure
head -50 vocab.bpe

Approach: Checkpoint Parsing

Understanding TensorFlow Checkpoint Format

TensorFlow checkpoints consist of multiple files:

  • .index file: Contains tensor metadata (names, shapes, offsets)
  • .data-* files: Contains actual weight values

The index file uses protocol buffers. Parsing it correctly requires understanding:

  • Varint encoding for integers
  • String length prefixes
  • Tensor shape encodings

Verification Strategy for Weight Loading

After implementing checkpoint parsing, verify weights loaded correctly:

// Print statistics for loaded weights
printf("wte sum: %f\n", sum_tensor(wte, vocab_size * n_embd));
printf("wpe[0]: %f %f %f\n", wpe[0], wpe[1], wpe[2]);
printf("First layer attn weight samples: %f %f\n",
       attn_w[0][0], attn_w[0][100]);

Red flags indicating parsing failure:

  • All values are zero
  • All values are identical
  • Values are extremely large (e.g., 1e30+)
  • NaN or Inf values

Common Mistakes in Checkpoint Parsing

  1. Using arbitrary magic offsets - Offsets depend on tensor order and checkpoint version
  2. Ignoring endianness - TensorFlow uses little-endian floats
  3. Skipping index file - The data file alone lacks tensor boundaries
  4. Pattern matching on binary data - Binary patterns like 0x08 are not reliable markers

Approach: BPE Tokenization

Understanding BPE Structure

GPT-2 uses byte-pair encoding with:

  • A vocabulary file mapping tokens to IDs
  • Merge rules defining how to combine byte sequences

Verification Strategy for Tokenization

Test with known input/output pairs:

// Known tokenization for GPT-2
// "Hello" -> [15496]
// " world" -> [995]
// "Hello world" -> [15496, 995]

int tokens[MAX_TOKENS];
int n = tokenize("Hello world", tokens);
assert(n == 2);
assert(tokens[0] == 15496);
assert(tokens[1] == 995);

Common Mistakes in BPE Implementation

  1. Word-level splitting - GPT-2 BPE operates on bytes, not words
  2. Ignoring merge order - Merges must be applied in priority order
  3. Missing special handling - Spaces are encoded as part of tokens (e.g., " world" is one token)
  4. Reading wrong file sections - Vocabulary IDs vs merge rules are in different sections

Approach: Forward Pass

Verification Strategy for Forward Pass

  1. Test with simple inputs first:
// Single token input, check output shape and range
float logits[VOCAB_SIZE];
forward_pass(single_token, 1, logits);
// Logits should be roughly in range [-10, 10]
// Softmax should sum to 1.0
  1. Compare against reference implementation:
# Generate reference outputs with Hugging Face
from transformers import GPT2LMHeadModel, GPT2Tokenizer
model = GPT2LMHeadModel.from_pretrained('gpt2')
# Save intermediate activations for comparison
  1. Check numerical stability:
// After attention, values should be bounded
// After layer norm, mean should be ~0, std ~1

Common Numerical Issues

  1. Overflow in softmax - Subtract max before exponentiating
  2. Accumulation errors - Use double precision for reductions
  3. Missing layer normalization - Each transformer block requires layer norm

Verification Checklist

Before declaring completion, verify each component:

  • Checkpoint parsing: Print sample weights, verify non-zero and reasonable values
  • Vocabulary loading: Print sample token mappings, verify expected tokens exist
  • BPE encoding: Test with known strings, verify token IDs match reference
  • BPE decoding: Round-trip test: encode then decode should return original string
  • Forward pass: Single token produces logits in expected range
  • Sampling: Top token for common prefixes matches expected continuations
  • End-to-end: Generated text is coherent (not garbage or repeated patterns)

When to Simplify vs. Ask for Alternatives

If proper implementation of a component would exceed constraints:

  1. Checkpoint format too complex: Ask if weights can be provided in a simpler format (raw binary floats, NumPy arrays)
  2. Full BPE too large: Ask if a pre-tokenized input is acceptable
  3. Full transformer too large: Ask about acceptable accuracy tradeoffs (fewer layers, smaller dimensions)

Never implement a non-functional simplification silently. If corners must be cut, communicate clearly which functionality is affected.

Anti-Patterns to Avoid

  1. Claiming success without testing - Always run the program with actual inputs before completion
  2. Ignoring self-identified risks - If a limitation is noted, address it or communicate it
  3. Premature size optimization - Get it working first, then optimize
  4. Testing only happy path - Verify error handling and edge cases
  5. Assuming file format knowledge - Always examine actual files before parsing

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

27.95%
按下载量换算70

Gemini CLI

23.45%
按下载量换算59

Antigravity

16.79%
按下载量换算42

windsurf

10.41%
按下载量换算26

OpenCode

7.56%
按下载量换算19

Codex

2.77%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills