欣淇
发布于 2026-05-17 / 0 阅读
0
0

📄 paper2code:1.3k Stars 的 Agent 技能,贴个 arxiv 链接就能拿到带论文引用的可运行代码

📄 paper2code:1.3k Stars 的 Agent 技能,贴个 arxiv 链接就能拿到带论文引用的可运行代码

论文看完还得自己写实现?这玩意儿把你从侦探变回程序员。

为啥这玩意儿值得关心

搞 ML 的人都有这个痛:读完一篇论文觉得牛逼,写实现的时候发现——"标准配置"是啥?那个关键超参数在哪?公式里的符号对应哪行代码?

老实说,我试过让 Claude Code 直接"帮我实现这篇论文"。结果是:它愉快地生成了能跑的代码,但跟论文一对照——好的,模型结构自己改了,学习率瞎猜的,连损失函数都用了不对的变体。代码能跑,但跟论文说的人话不是一回事。

paper2code 不是另一个 AI 编码助手,而是一个专门处理论文实现的 Agent Skill。 它的核心逻辑就一句话:实现里的每一行代码,都要能追溯到论文里具体的章节和公式。

核心思路:Citation Anchoring

这个项目并不是简单地把论文丢给 LLM 让它写代码。它的流程是:

  1. 抓取论文 — 从 arxiv 拉全文(包括附录、脚注)
  2. 歧义审计 — 在写任何代码前,先把所有实现选择标出来:哪些是论文明确说的(SPECIFIED),哪些是部分说的(PARTIALLY_SPECIFIED),哪些根本没提(UNSPECIFIED)
  3. 引用锚定生成 — 每一段生成的代码都带着 §3.2, Eq. 4 这种引用
  4. 诚实标注 — 不确定的地方直接写 [UNSPECIFIED] 注释,列几个常见替代

安装

npx skills add PrathamLearnsToCode/paper2code/skills/paper2code

安装完在 Claude Code 里直接呼:

基本用法

# 用 arxiv URL
/paper2code https://arxiv.org/abs/1706.03762

# 用 arxiv ID 也行
/paper2code 1706.03762

# 指定框架
/paper2code https://arxiv.org/abs/2006.11239 --framework jax

# 完整模式(含训练循环)
/paper2code 2106.09685 --mode full

# 教学模式(额外注释和 notebook)
/paper2code https://arxiv.org/abs/2010.11929 --mode educational

输出结构

attention_is_all_you_need/
├── README.md                    # 快速开始
├── REPRODUCTION_NOTES.md        # 歧义审计 + 已知偏差
├── requirements.txt
├── src/
   ├── model.py                 # 每行代码都引用了论文章节
   ├── loss.py                  # 损失函数带公式引用
   ├── train.py
   └── evaluate.py
├── configs/
   └── base.yaml                # 每个超参数要么有引用要么标 [UNSPECIFIED]
└── notebooks/
    └── walkthrough.ipynb        # 论文段落到代码到 shape 检查

代码长啥样

# §3.2, §3.2, Eq. 2 — attention_weights = softmax(QK^T / sqrt(d_k))
class TransformerBlock(nn.Module):
    def forward(self, x):
        attn_out = self.attention(self.norm1(x))  # (batch, seq_len, d_model)
        x = x + attn_out  # §3.2 — residual connection

遇到论文没说的参数,直接标:

# [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

它不做什么

这个 Skill 设计得很克制。它不会:

  • 保证代码完全正确(论文写错代码就错)
  • 瞎编细节(没说的参数就标 [UNSPECIFIED]
  • 下数据集、搞分布式训练、实现 baseline
  • 重新实现标准组件(注意力机制这种会直接复用已有实现)

这比那些"一口气生成整个项目"的方案靠谱多了。少即是多,诚实比什么都重要。

总结

  • 1.3k Stars,刚出来不久,理念极正
  • 核心创新是 Citation Anchoring:每行代码都绑定论文具体章节
  • 歧义审计确保不会瞎编参数
  • 装在 Agent 上就能用,适合 论文实现 + 代码审查 + 教学场景

说实话,这玩意儿才 1.3k Stars 说明知道它的人还不多。如果你经常需要把论文转代码,装一个试试,哪怕只是用它生成 REPRODUCTION_NOTES.md 来对照自己的实现是否偏离了原文。


📄 paper2code: 1.3k Stars Agent Skill — Paste an arxiv URL, Get Citation-Anchored Implementations

No more guessing what "standard settings" means. This skill makes every line of generated code traceable to the exact paper section.

If you've ever tried implementing an ML paper from scratch, you know the pain: "standard configuration" means nothing, critical hyperparameters are buried in appendices (or missing entirely), and LLMs confidently invent details that don't match the paper.

paper2code is an Agent Skill that implements papers with full citation anchoring. Every line of code references the exact section and equation it came from.

Install

npx skills add PrathamLearnsToCode/paper2code/skills/paper2code

Usage

/paper2code https://arxiv.org/abs/1706.03762
/paper2code 1706.03762
/paper2code https://arxiv.org/abs/2006.11239 --framework jax
/paper2code 2106.09685 --mode full
/paper2code https://arxiv.org/abs/2010.11929 --mode educational

Output structure

attention_is_all_you_need/
├── README.md
├── REPRODUCTION_NOTES.md        # Ambiguity audit
├── requirements.txt
├── src/
   ├── model.py                 # Every line cited to paper section
   ├── loss.py                  # Loss with equation references
   ├── train.py
   └── evaluate.py
├── configs/
   └── base.yaml                # Every param cited or [UNSPECIFIED]
└── notebooks/
    └── walkthrough.ipynb

What it won't do

  • Won't guarantee correctness (if the paper is wrong, the code is wrong)
  • Won't invent details — every unspecified param gets [UNSPECIFIED]
  • Won't download datasets, set up distributed training, or reimplement standard components

Key takeaway

1.3k Stars and growing. The core innovation is Citation Anchoring — code you can verify because every decision is traceable. Install it on your coding agent, and the next time you need to implement a paper, you'll spend less time detective-working and more time actually coding.


评论