@gyro_ai: 复现一篇机器学习论文,最痛苦的是论文写得含糊,关键参数藏在附录里甚至压根没写,你大半时间在当侦探而不是写代码 paper2code 是个 Agent 技能,丢给它一个 arxiv 链接,它生成一份能跑的实现代码,1308 star htt…
摘要
Paper2code 是一个 AI Agent 技能,输入 arxiv 论文链接即可生成带有引用锚定的可运行实现代码,自动审计论文中的模糊之处并标记未指定部分,帮助研究者和工程师高效复现机器学习论文。
查看缓存全文
缓存时间: 2026/05/23 10:08
复现一篇机器学习论文,最痛苦的是论文写得含糊,关键参数藏在附录里甚至压根没写,你大半时间在当侦探而不是写代码
paper2code 是个 Agent 技能,丢给它一个 arxiv 链接,它生成一份能跑的实现代码,1308 star
https://github.com/PrathamLearnsToCode/paper2code…
MIT 协议,论文链接进,可追溯到出处的代码出
核心特点:
- 每行代码标出处 - 生成的代码会标明它对应论文的哪一节哪个公式,比如这行是按第 3.2 节公式 4 写的,方便你逐条核对
- 先审模糊点再写 - 动笔前先把每个实现选择分成“论文写清了““写了一半”“完全没写“三类,不像普通 AI 那样默默瞎填
- 老实标不确定 - 论文没说清的地方,代码里直接打上标记并列出常见的几种做法,而不是假装它知道
- 连附录都挖 - 附录、脚注、图注都当正经资料来读,这些地方往往藏着关键参数
安装用 npx skills add 一条命令,装进 Claude Code 这类 Agent 后,敲 /paper2code 加论文链接就能用,还能选框架和详细程度
经常要复现论文的研究生和算法工程师,这个能帮你少做很多侦探活
PrathamLearnsToCode/paper2code
Source: https://github.com/PrathamLearnsToCode/paper2code
paper2code
arxiv URL in → citation-anchored implementation out
┌─────────────────────────────┐ ┌──────────────────────────────────────┐
│ │ │ {paper_slug}/ │
│ /paper2code │ │ ├── README.md │
│ https://arxiv.org/abs/ │ ───▶ │ ├── REPRODUCTION_NOTES.md │
│ 1706.03762 │ │ ├── requirements.txt │
│ │ │ ├── src/ │
│ │ │ │ ├── model.py # §3.2 cited │
│ │ │ │ ├── loss.py # §3.4 cited │
│ │ │ │ ├── train.py # §4.1 cited │
│ │ │ │ ├── data.py │
│ │ │ │ ├── evaluate.py │
│ │ │ │ └── utils.py │
│ │ │ ├── configs/ │
│ │ │ │ └── base.yaml # all params │
│ │ │ └── notebooks/ │
│ │ │ └── walkthrough.ipynb │
└─────────────────────────────┘ └──────────────────────────────────────┘
[placeholder: animated GIF showing the full pipeline — paper fetch → parsing → ambiguity audit → code generation → walkthrough notebook]
Why this exists
The problem: ML papers are vague. Critical hyperparameters are buried in appendices or omitted entirely. Prose contradicts equations. “Standard settings” refers to nothing specific. When you implement a paper, you spend more time detective-working than coding.
What LLMs get wrong: Naive code generation fills in every gap silently and confidently. You get something that runs but doesn’t match the paper. Worse, you can’t tell which parts are from the paper and which were invented by the model.
What paper2code does differently:
- Citation anchoring — every line of generated code references the exact paper section and equation it implements (
§3.2, Eq. 4) - Ambiguity auditing — before writing a single line of code, every implementation choice is classified as
SPECIFIED,PARTIALLY_SPECIFIED, orUNSPECIFIED - Honest uncertainty — unspecified choices are flagged with
[UNSPECIFIED]comments at the exact line where the choice is made, with common alternatives listed - Appendix mining — appendices, footnotes, and figure captions are treated as first-class sources, not ignored
The result: code you can trust because you can verify every decision against the paper.
Install
npx skills add PrathamLearnsToCode/paper2code/skills/paper2code
You’ll be prompted to:
- Select agents — pick the coding agents you want to use this skill with (e.g., Claude Code)
- Choose scope — Global (recommended) or project-level
- Choose method — Symlink (recommended) or copy
Once installed, open your agent and run the skill:
claude # or your preferred agent
Usage
Basic — generate a minimal implementation
/paper2code https://arxiv.org/abs/1706.03762
Specify framework
/paper2code https://arxiv.org/abs/2006.11239 --framework jax
Full mode — includes training loop and data pipeline
/paper2code 2106.09685 --mode full
Educational mode — extra comments and pedagogical notebook
/paper2code https://arxiv.org/abs/2010.11929 --mode educational
Using bare arxiv ID
/paper2code 1706.03762
What you get
attention_is_all_you_need/
├── README.md # Paper summary, contribution statement, quick-start
├── REPRODUCTION_NOTES.md # Ambiguity audit, unspecified choices, known deviations
├── requirements.txt # Pinned dependencies
├── src/
│ ├── model.py # Architecture — every layer cited to paper section
│ ├── loss.py # Loss functions with equation references
│ ├── data.py # Dataset class skeleton with preprocessing TODOs
│ ├── train.py # Training loop (if in scope)
│ ├── evaluate.py # Metric computation code
│ └── utils.py # Shared utilities (masking, positional encoding, etc.)
├── configs/
│ └── base.yaml # All hyperparams — each one cited or flagged [UNSPECIFIED]
└── notebooks/
└── walkthrough.ipynb # Pedagogical notebook linking paper sections → code → sanity checks
Key files explained
| File | Purpose |
|---|---|
model.py | Architecture only. Each class maps to a paper section. Variable names match paper notation. |
REPRODUCTION_NOTES.md | The ambiguity audit. Lists every choice, whether the paper specified it, and what alternatives exist. |
base.yaml | Single source of truth for all hyperparameters. |
walkthrough.ipynb | Runnable on CPU with toy dimensions. Quotes paper passages, shows corresponding code, runs shape checks. |
What this skill will NOT do
- Won’t guarantee correctness. The implementation matches what the paper describes. If the paper is wrong, the code is wrong. If the paper is vague, the code flags it.
- Won’t invent details. If the paper doesn’t specify a hyperparameter, the code uses a common default and marks it
[UNSPECIFIED]. It will never silently fill in gaps. - Won’t download datasets. The
data.pyprovides aDatasetclass skeleton with clear instructions on where to get the data and how to preprocess it. - Won’t set up training infrastructure. No distributed training, no experiment tracking, no checkpointing beyond what the paper’s contribution requires.
- Won’t implement baselines. Only the core contribution of the paper is implemented.
- Won’t reimplement standard components. If the paper says “standard transformer encoder,” the code imports it or notes the dependency — it doesn’t reimplement attention from scratch.
Design principles
Citation anchoring convention
Every non-trivial code decision is anchored to the paper:
# §3.2 — "We apply layer normalization before each sub-layer" (Pre-LN variant)
class TransformerBlock(nn.Module):
def forward(self, x):
# §3.2, Eq. 2 — attention_weights = softmax(QK^T / sqrt(d_k))
attn_out = self.attention(self.norm1(x)) # (batch, seq_len, d_model)
x = x + attn_out # §3.2 — residual connection
The UNSPECIFIED flag system
# [UNSPECIFIED] Paper does not state epsilon for LayerNorm — using 1e-6 (common default)
# Alternatives: 1e-5 (PyTorch default), 1e-8 (some implementations)
self.norm = nn.LayerNorm(d_model, eps=1e-6)
# [ASSUMPTION] Using pre-norm based on "we found pre-norm more stable" in §4.1
# The paper uses post-norm in Figure 1 but pre-norm in experiments — ambiguous
Ambiguity classification
| Tag | Meaning |
|---|---|
§X.Y | Directly specified in paper section X.Y |
§X.Y, Eq. N | Implements equation N from section X.Y |
[UNSPECIFIED] | Paper does not state this — our choice with alternatives listed |
[PARTIALLY_SPECIFIED] | Paper mentions this but is ambiguous — quote included |
[ASSUMPTION] | Reasonable inference from paper context — reasoning explained |
[FROM_OFFICIAL_CODE] | Taken from the authors’ official implementation |
Contributing
Adding worked examples
Worked examples are the most trust-building part of this project. To add one:
- Pick a well-known paper (people should be able to verify the output)
- Run the skill:
/paper2code https://arxiv.org/abs/XXXX.XXXXX - Save the full output to
skills/paper2code/worked/{paper_slug}/ - Write a
review.mdthat honestly evaluates:- What the skill got right
- What it correctly flagged as unspecified
- Any mistakes it made
- Any edge cases it handled well or poorly
- Submit a PR with all of the above
Improving guardrails
If you find a pattern where the skill hallucinates or makes a silent assumption, add it to the appropriate file in guardrails/.
Adding domain knowledge
If papers in your subfield consistently reference components that the skill doesn’t know about (e.g., graph neural network primitives, RL components), add a knowledge file in knowledge/.
Worked examples
This repo includes fully worked examples to demonstrate output quality:
| Paper | Type | Command |
|---|---|---|
| Attention Is All You Need (1706.03762) | Architecture | /paper2code https://arxiv.org/abs/1706.03762 |
| DDPM (2006.11239) | Training method | /paper2code https://arxiv.org/abs/2006.11239 |
Each includes the complete generated output plus an honest review.md evaluating what the skill got right and wrong.
相似文章
@akshay_pachaar: 将任何论文转化为可运行代码。只需在论文URL中将arxiv替换为autoarxiv,即可将论文交给AI代理……
autoarxiv 让你只需将 URL 改为 autoarxiv.org,就能将任何 arxiv 论文转换为可运行代码。来自 alphaXiv 的 AI 代理会阅读论文、克隆仓库、配置依赖项,并运行最小复现来验证声明,实时记录所有内容。
@vintcessun: 原来学术论文AI写作还能这么做:不是直接润色,而是先让agent学目标场景、读优秀样例,再记录每个段落为什么这么写。PaperSpine通过 writing rationale matrix 把写作变成了可审计的推理过程,而不是黑箱生成。…
PaperSpine 是一个面向 Codex、Claude Code 和 OpenClaw 的论文写作 skill suite,通过写作动机矩阵将 AI 写作变为可审计的推理过程,而非黑箱生成。
@nini_incrypto_: 论文写作Skill推荐 1 Research-Paper-Writing-Skills https://github.com/Master-cai/Research-Paper-Writing-Skills… 这是一个面向 机器学习/计算…
推荐了四个适用于机器学习/计算机视觉/NLP等领域的开源论文写作技能包,分别侧重结构规范、润色审查、完整科研流程和中文协作,支持Codex、Claude Code、Gemini等AI助手。
@Xudong07452910: 这可能是人类写给 AI 看的最后一篇论文了。 最近刷到Stanford、CMU、Michigan 等 37 位作者联名的论文:《The Last Human-Written Paper》。 核心观点很狠:沿用几百年的论文,在 AI 时代可…
来自Stanford、CMU、Michigan等37位作者联名的论文提出ARA(Agent原生研究工件)替代传统论文格式,旨在解决叙事税和工程税,让AI Agent能理解、复现和扩展研究。
@wsl8297: 用 AI 写论文最怕的不是写不出来,而是它看起来很完整,实际上研究空白、文献支撑、论证结构都站不住。Academic Paper Skills 解决的就是这个问题。 GitHub:https://github.com/lishix520/…
Academic Paper Skills 是一套用于 Claude Code 的论文写作技能框架,将写作流程分为策略和写作两个阶段,并内置文献支撑、审稿人模拟和质量检查等特性,帮助用户从研究想法生成初稿。