AI Research Skills 引文管理指南:基于 API 验证的 BibTeX 工作流与幻觉预防实战

原创2026-09-23 20:55:512,244 阅读
文章标签:人工智能AI 技能AI 插件大模型机器学习深度学习

AI Research Skills 引文管理指南:基于 API 验证的 BibTeX 工作流与幻觉预防实战

本篇技术指南面向使用 ml-paper-writing 技能撰写 NeurIPS、ICML、ICLR、ACL、AAAI、COLM 等顶会论文的研究者与 AI Agent,系统讲解如何通过 Semantic Scholar、CrossRef、arXiv、OpenAlex 等学术 API 以编程方式检索、验证、抓取文献并生成干净可用的 BibTeX 参考文献库,彻底杜绝 AI 生成引文的幻觉(hallucination)问题。读完本文,你将掌握一套可复制、可落地的"搜索 → 双源验证 → DOI 内容协商取 BibTeX → 声明核验 → 入库"五步引文流水线,以及配套的 CitationManager 类、批量引文工具和投稿前检查清单。


为什么引文验证如此重要

幻觉问题:AI 引文的真实风险

随着 LLM 深度介入学术写作,"AI 生成引文"已成为学术不端的高发区。根据文档中记录的研究数据,AI 生成的引文错误率约为 40%,NeurIPS 2025 审稿中甚至发现 100+ 条幻觉引文溜过了评审环节。常见错误类型包括:

  • 伪造论文标题:真实作者配上并不存在的论文标题;
  • 出版信息错误:期刊名、年份、卷期号张冠李戴;
  • 凭空捏造文献:元数据看似合理但论文根本不存在;
  • DOI / arXiv ID 错误:标识符无法解析或指向无关文献。

后果

  • 部分会议直接 desk rejection(桌面拒稿);
  • 审稿人视角下的可信度崩塌;
  • 若已发表可能面临 撤稿(retraction);
  • 研究人员为追查不存在的文献浪费大量时间。

解决方案

永远不要凭记忆生成引文——必须通过编程方式验证。 这正是本技能在 SKILL.md 中列为 "CRITICAL: Never Hallucinate Citations" 最高优先级规则的原因:AI 辅助学术写作时,引文幻觉是"可能导致 desk rejection 或 retraction 的严重学术不端形式"。


引文 API 全景概览

主要 API 对比

API 覆盖范围 速率限制 最佳用途
Semantic Scholar 2.14 亿篇论文 免费 key 约 1 RPS ML/AI 论文检索、引文图谱
CrossRef 1.4 亿+ DOI Polite pool(需 mailto) DOI 查询、BibTeX 内容协商获取
arXiv 预印本 请求间隔约 3 秒 ML 预印本、PDF 获取
OpenAlex 2.4 亿+ 作品 10 万/天、10 RPS MAG 的开源替代、批量访问

API 选型指南

需要 ML 论文检索?       → Semantic Scholar
有 DOI 需要 BibTeX?    → CrossRef content negotiation
在找预印本?            → arXiv API
需要开放数据、批量访问?  → OpenAlex

关于 Google Scholar 的重要提醒

Google Scholar 没有官方 API。爬取其页面违反其服务条款(ToS),不建议使用。只有在 Semantic Scholar 覆盖不足时才考虑 SerpApi(付费 $75–275/月)这类第三方聚合服务。


验证引文五步工作流

这是本指南的核心方法论,也是 SKILL.md 中 "Workflow 2: Adding Citations" 的完整展开:

1. SEARCH   → 用具体关键词查询 Semantic Scholar
     ↓
2. VERIFY   → 在 2 个以上来源确认论文真实存在
     ↓
3. RETRIEVE → 通过 DOI 内容协商获取 BibTeX
     ↓
4. VALIDATE → 确认被引用的论断确实出现在该文献中
     ↓
5. ADD      → 将验证过的条目写入 .bib 文件

Step 1: 检索(Search)

针对 ML/AI 论文,首选 Semantic Scholar 官方 Python 客户端:

from semanticscholar import SemanticScholar

sch = SemanticScholar()
results = sch.search_paper("transformer attention mechanism", limit=10)

for paper in results:
    print(f"Title: {paper.title}")
    print(f"Year: {paper.year}")
    print(f"DOI: {paper.externalIds.get('DOI', 'N/A')}")
    print(f"arXiv: {paper.externalIds.get('ArXiv', 'N/A')}")
    print(f"Citation count: {paper.citationCount}")
    print("---")

externalIds 字段会同时返回 DOI 与 ArXiv ID,这两者正是后续交叉验证与 BibTeX 抓取的关键入口。

Step 2: 验证存在性(Verify)

铁律:一篇论文至少要在两个独立来源中确认存在。 从源码结构看,验证逻辑通常按 DOI → CrossRef → arXiv 的优先级逐层探测:

import requests

def verify_paper(doi=None, arxiv_id=None, title=None):
    """Verify paper exists in multiple sources."""
    sources_found = []

    # Check Semantic Scholar
    sch = SemanticScholar()
    if doi:
        paper = sch.get_paper(f"DOI:{doi}")
        if paper:
            sources_found.append("Semantic Scholar")

    # Check CrossRef (via DOI)
    if doi:
        resp = requests.get(f"https://api.crossref.org/works/{doi}")
        if resp.status_code == 200:
            sources_found.append("CrossRef")

    # Check arXiv
    if arxiv_id:
        resp = requests.get(
            f"http://export.arxiv.org/api/query?id_list={arxiv_id}"
        )
        if "<entry>" in resp.text:
            sources_found.append("arXiv")

    return len(sources_found) >= 2, sources_found

只要 sources_found 达到 2 个及以上即判定验证通过。

Step 3: 通过 DOI 获取 BibTeX(Retrieve)

不要手写 BibTeX,用 DOI 内容协商(content negotiation)保证准确率。 这是整个流程中最关键的防幻觉机制——BibTeX 条目由 DOI 注册机构(CrossRef)权威返回:

import requests

def doi_to_bibtex(doi: str) -> str:
    """Get verified BibTeX from DOI via CrossRef content negotiation."""
    response = requests.get(
        f"https://doi.org/{doi}",
        headers={"Accept": "application/x-bibtex"},
        allow_redirects=True
    )
    response.raise_for_status()
    return response.text

# Example: "Attention Is All You Need"
bibtex = doi_to_bibtex("10.48550/arXiv.1706.03762")
print(bibtex)

Accept: application/x-bibtex 请求头触发 DOI 解析服务的内容协商机制,直接返回规范 BibTeX。

Step 4: 核验论断(Validate)

引用一篇论文支撑某个论断之前,必须确认该论断确实出自该论文。最轻量的做法是拉取摘要做关键词匹配:

def get_paper_abstract(doi):
    """Get abstract to verify claims."""
    sch = SemanticScholar()
    paper = sch.get_paper(f"DOI:{doi}")
    return paper.abstract if paper else None

# Verify claim appears in abstract
abstract = get_paper_abstract("10.48550/arXiv.1706.03762")
claim = "attention mechanism"
if claim.lower() in abstract.lower():
    print("Claim appears in paper")

更严格的场景应进一步定位到具体段落、公式或表格,尤其是方法章节的核心贡献。

Step 5: 写入参考文献库(Add)

将验证过的条目写入 .bib 文件,并采用一致的键格式 author_year_firstword:

def generate_citation_key(bibtex: str) -> str:
    """Generate consistent citation key: author_year_firstword."""
    import re

    # Extract author
    author_match = re.search(r'author\s*=\s*\{([^}]+)\}', bibtex, re.I)
    if author_match:
        first_author = author_match.group(1).split(',')[0].split()[-1]
    else:
        first_author = "unknown"

    # Extract year
    year_match = re.search(r'year\s*=\s*\{?(\d{4})\}?', bibtex, re.I)
    year = year_match.group(1) if year_match else "0000"

    # Extract title first word
    title_match = re.search(r'title\s*=\s*\{([^}]+)\}', bibtex, re.I)
    if title_match:
        first_word = title_match.group(1).split()[0].lower()
        first_word = re.sub(r'[^a-z]', '', first_word)
    else:
        first_word = "paper"

    return f"{first_author.lower()}_{year}_{first_word}"

键的示例:vaswani_2017_attention、devlin_2019_bert、brown_2020_language。一致的键命名让后续 LaTeX 引用、批量去重和人工审计都更加容易。


完整 Python 实现:CitationManager

把五步工作流封装成一个可复用的 CitationManager 类,即可在任意论文写作流程中直接调用:

"""
Citation Manager - Verified citation workflow for ML papers.
"""

import requests
import time
from typing import Optional, List, Dict, Tuple
from dataclasses import dataclass

try:
    from semanticscholar import SemanticScholar
except ImportError:
    print("Install: pip install semanticscholar")
    SemanticScholar = None

@dataclass
class Paper:
    title: str
    authors: List[str]
    year: int
    doi: Optional[str]
    arxiv_id: Optional[str]
    venue: Optional[str]
    citation_count: int
    abstract: Optional[str]

class CitationManager:
    """Manage citations with verification."""

    def __init__(self, api_key: Optional[str] = None):
        self.sch = SemanticScholar(api_key=api_key) if SemanticScholar else None
        self.verified_papers: Dict[str, Paper] = {}

    def search(self, query: str, limit: int = 10) -> List[Paper]:
        """Search for papers using Semantic Scholar."""
        if not self.sch:
            raise RuntimeError("Semantic Scholar not available")

        results = self.sch.search_paper(query, limit=limit)
        papers = []

        for r in results:
            paper = Paper(
                title=r.title,
                authors=[a.name for a in (r.authors or [])],
                year=r.year or 0,
                doi=r.externalIds.get('DOI') if r.externalIds else None,
                arxiv_id=r.externalIds.get('ArXiv') if r.externalIds else None,
                venue=r.venue,
                citation_count=r.citationCount or 0,
                abstract=r.abstract
            )
            papers.append(paper)

        return papers

    def verify(self, paper: Paper) -> Tuple[bool, List[str]]:
        """Verify paper exists in multiple sources."""
        sources = []

        # Already found in Semantic Scholar via search
        sources.append("Semantic Scholar")

        # Check CrossRef if DOI available
        if paper.doi:
            try:
                resp = requests.get(
                    f"https://api.crossref.org/works/{paper.doi}",
                    timeout=10
                )
                if resp.status_code == 200:
                    sources.append("CrossRef")
            except:
                pass

        # Check arXiv if ID available
        if paper.arxiv_id:
            try:
                resp = requests.get(
                    f"http://export.arxiv.org/api/query?id_list={paper.arxiv_id}",
                    timeout=10
                )
                if "<entry>" in resp.text and "<title>" in resp.text:
                    sources.append("arXiv")
            except:
                pass

        return len(sources) >= 2, sources

    def get_bibtex(self, paper: Paper) -> Optional[str]:
        """Get BibTeX for verified paper."""
        if paper.doi:
            try:
                resp = requests.get(
                    f"https://doi.org/{paper.doi}",
                    headers={"Accept": "application/x-bibtex"},
                    timeout=10,
                    allow_redirects=True
                )
                if resp.status_code == 200:
                    return resp.text
            except:
                pass

        # Fallback: generate from paper data
        return self._generate_bibtex(paper)

    def _generate_bibtex(self, paper: Paper) -> str:
        """Generate BibTeX from paper metadata."""
        # Generate citation key
        first_author = paper.authors[0].split()[-1] if paper.authors else "unknown"
        first_word = paper.title.split()[0].lower().replace(',', '').replace(':', '')
        key = f"{first_author.lower()}_{paper.year}_{first_word}"

        # Format authors
        authors = " and ".join(paper.authors) if paper.authors else "Unknown"

        bibtex = f"""@article{{{key},
  title = {{{paper.title}}},
  author = {{{authors}}},
  year = {{{paper.year}}},
  {'doi = {' + paper.doi + '},' if paper.doi else ''}
  {'eprint = {' + paper.arxiv_id + '},' if paper.arxiv_id else ''}
  {'journal = {' + paper.venue + '},' if paper.venue else ''}
}}"""
        return bibtex

    def cite(self, query: str) -> Optional[str]:
        """Full workflow: search, verify, return BibTeX."""
        # Search
        papers = self.search(query, limit=5)
        if not papers:
            return None

        # Take top result
        paper = papers[0]

        # Verify
        verified, sources = self.verify(paper)
        if not verified:
            print(f"Warning: Could only verify in {sources}")

        # Get BibTeX
        bibtex = self.get_bibtex(paper)

        # Cache
        if bibtex:
            self.verified_papers[paper.title] = paper

        return bibtex


# Usage example
if __name__ == "__main__":
    cm = CitationManager()

    # Search and cite
    bibtex = cm.cite("attention is all you need transformer")
    if bibtex:
        print(bibtex)

类设计要点

  • Paper 数据类:统一承载标题、作者、年份、DOI、arXiv ID、venue、引用数与摘要,是后续所有流程的数据契约;
  • verify() 的多源验证:Semantic Scholar 命中即为第一来源,CrossRef / arXiv 再各补充一票,达到 2 票即通过;
  • get_bibtex() 的双通道:优先走 DOI 内容协商拿权威 BibTeX;当 DOI 不可用或请求失败时,降级为 _generate_bibtex() 基于元数据生成——注意这是降级兜底,而非默认路径,且元数据全部来自已验证的 API 返回而非模型记忆;
  • cite() 一站式入口:搜索 → 验证 → 抓取 → 缓存,一次调用返回 BibTeX 字符串,未通过验证时打印警告。

快速函数

面向脚本化、批量化的便捷封装:

def quick_cite(query: str) -> str:
    """One-liner citation."""
    cm = CitationManager()
    return cm.cite(query)

def batch_cite(queries: List[str], output_file: str = "references.bib"):
    """Cite multiple papers and save to file."""
    cm = CitationManager()
    bibtex_entries = []

    for query in queries:
        print(f"Processing: {query}")
        bibtex = cm.cite(query)
        if bibtex:
            bibtex_entries.append(bibtex)
        time.sleep(1)  # Rate limiting

    with open(output_file, 'w') as f:
        f.write("\n\n".join(bibtex_entries))

    print(f"Saved {len(bibtex_entries)} citations to {output_file}")

注意 batch_cite 中的 time.sleep(1) 是刻意的速率控制,用于规避 API 限流。


依赖安装与运行前提

CitationManager 依赖以下 Python 库,这也与 SKILL.md 元数据中声明的 dependencies 字段一致:

pip install semanticscholar arxiv habanero requests
  • semanticscholar:Semantic Scholar 官方客户端;
  • arxiv:arXiv API 的 Python 封装;
  • habanero:CrossRef REST API 客户端;
  • requests:HTTP 基础库(用于 DOI 内容协商等)。

若未安装 semanticscholar,类初始化会打印 "Install: pip install semanticscholar" 提示并将 self.sch 置为 None,此时调用 search() 会抛出 RuntimeError,这是设计上对依赖缺失的显式暴露。


BibTeX 管理与 LaTeX 集成

BibTeX vs BibLaTeX

特性 BibTeX BibLaTeX
Unicode 支持 有限 完整
条目类型 标准类型 扩展类型(@online、@dataset)
可定制性 有限 高度灵活
后端 bibtex Biber(推荐)

推荐:新论文一律使用 BibLaTeX + Biber。

LaTeX 前置设置

% In preamble
\usepackage[
    backend=biber,
    style=numeric,
    sorting=none
]{biblatex}
\addbibresource{references.bib}

% In document
\cite{vaswani_2017_attention}

% At end
\printbibliography

常用引文命令

\cite{key}      % Numeric: [1]
\citep{key}     % Parenthetical: (Author, 2020)
\citet{key}     % Textual: Author (2020)
\citeauthor{key} % Just author name
\citeyear{key}  % Just year

一致的引文键格式

统一采用 author_year_firstword:

vaswani_2017_attention
devlin_2019_bert
brown_2020_language

常见引文格式模板

无论通过 API 抓取还是手动补录,都应确保条目类型与字段符合以下规范:

会议论文(@inproceedings)

@inproceedings{vaswani_2017_attention,
  title = {Attention Is All You Need},
  author = {Vaswani, Ashish and Shazeer, Noam and Parmar, Niki and
            Uszkoreit, Jakob and Jones, Llion and Gomez, Aidan N and
            Kaiser, Lukasz and Polosukhin, Illia},
  booktitle = {Advances in Neural Information Processing Systems},
  volume = {30},
  year = {2017},
  publisher = {Curran Associates, Inc.}
}

期刊论文(@article)

@article{hochreiter_1997_long,
  title = {Long Short-Term Memory},
  author = {Hochreiter, Sepp and Schmidhuber, J{\"u}rgen},
  journal = {Neural Computation},
  volume = {9},
  number = {8},
  pages = {1735--1780},
  year = {1997},
  publisher = {MIT Press}
}

arXiv 预印本(@misc)

@misc{brown_2020_language,
  title = {Language Models are Few-Shot Learners},
  author = {Brown, Tom and Mann, Benjamin and Ryder, Nick and others},
  year = {2020},
  eprint = {2005.14165},
  archiveprefix = {arXiv},
  primaryclass = {cs.CL}
}

仓库模板中也有同构的实战样本可参考:aaai2026.bib(含 @article、@inproceedings、@misc 多种条目及 arXiv 预印本写法)、ACL 模板 custom.bib(含 DOI 字段、@book、@techreport 等类型)。选错条目类型(@inproceedings 写成 @article)是审稿人常见扣分点,务必核对。


与 AI 写作流程的深度集成

黄金法则:无法验证就标记占位符

SKILL.md 将引文规则总结为一张决策表,这里完整展开:

情形 正确动作
找到论文、拿到 DOI、成功抓取 BibTeX ✅ 直接使用
找到论文但没有 DOI ✅ 用 arXiv BibTeX 或根据论文元数据手工补录
论文存在但无法抓取 BibTeX ⚠️ 标记占位符并告知研究者
不确定论文是否存在 ❌ 标记 [CITATION NEEDED] 并告知研究者
"我记得好像有篇论文讲 X" ❌ 绝对不要引用——先搜索或标记占位符

当无法编程验证引文时,必须在文档中留下显式占位符并要求人工复核:

% EXPLICIT PLACEHOLDER - requires human verification
\cite{PLACEHOLDER_author2024_verify_this}  % TODO: Verify this citation exists

同时必须向研究者明确汇报:"我已将 [X] 条无法确认存在的引文标记为占位符,需要人工验证。" 类似地,PLACEHOLDER_smith2023_verify 与 [CITATION NEEDED - could not verify Smith et al. 2023] 也是 SKILL.md 中给出的标准写法。

用 Exa MCP 做首轮检索(可选增强)

SKILL.md 推荐安装 Exa MCP 提供实时学术搜索:

claude mcp add exa -- npx -y mcp-remote "https://mcp.exa.ai/mcp"

Cursor / VS Code 则在 MCP settings 中配置:

{
  "mcpServers": {
    "exa": {
      "type": "http",
      "url": "https://mcp.exa.ai/mcp"
    }
  }
}

Exa 支持自然语言检索(如 "Find papers on RLHF for language models published after 2023"),但检索结果仍必须回到 Semantic Scholar / CrossRef 做双源验证、再走 DOI 抓取 BibTeX——Exa 只是检索入口,不能替代验证环节。

从研究仓库起步时如何复用已有引文

写作流程的第一步是从研究仓库中提取已引用的文献(SKILL.md 的 Workflow 0),这是 Related Work 的"高信号"起点:

# 找出代码库中已有引文
grep -r "arxiv\|doi\|cite" --include="*.md" --include="*.bib" --include="*.py"
find . -name "*.bib"

仓库内现成的引文样例还包括 NeurIPS 2025 模板主文件 中预留的 \bibliographystyle{plainnat} / \bibliography{bibliography} 结构,以及 AAAI 2026 模板 的编译流程(pdflatex → bibtex → pdflatex → pdflatex)。


故障排查

常见问题与解法

问题:Semantic Scholar 返回空结果

  • 尝试更具体的关键词;
  • 检查作者姓名拼写;
  • 对精确短语使用引号包裹。

问题:DOI 无法解析为 BibTeX

  • DOI 可能已注册但未挂接 CrossRef;
  • 如有 arXiv ID 可改用 arXiv 条目;
  • 或基于元数据手动生成 BibTeX(走 _generate_bibtex 兜底路径)。

问题:速率限制(Rate limiting)错误

  • 在请求之间增加 1–3 秒延迟;
  • 有 API key 时务必使用(SemanticScholar(api_key=...));
  • 缓存结果,避免重复查询同一文献(CitationManager.verified_papers 正是为此设计)。

问题:BibTeX 编码问题

  • 使用正确的 LaTeX 转义:如 {\"u} 表示 ü;
  • 确保文件为 UTF-8 编码;
  • 换用 BibLaTeX + Biber 以获得更好的 Unicode 支持。

投稿前验证检查清单

每一条引文在进入参考文献表之前,都应通过以下核验(本清单与 checklists.md 中 "Universal Pre-Submission Checklist" 的 References complete and verified 项呼应):

  • [ ] 论文至少在 2 个来源中验证存在
  • [ ] DOI 或 arXiv ID 已验证可解析
  • [ ] BibTeX 是通过接口抓取获得(而非凭记忆生成)
  • [ ] 条目类型正确(@inproceedings 与 @article 不混用)
  • [ ] 作者姓名完整且格式正确
  • [ ] 年份与发表 venue 已验证
  • [ ] 引文键遵循统一格式(author_year_firstword)

小结

本指南给出的核心纪律可以浓缩为一句话:AI 写作场景下,引文永远是"验证过的数据",而不是"生成出来的文本"。 通过 Semantic Scholar + CrossRef + arXiv 的多源交叉验证、DOI 内容协商获取权威 BibTeX、以及"无法验证即标记占位符"的显式失败处理,可以在根源上消除 AI 引文幻觉,保住论文通过 desk rejection 与审稿人审视的底线。配合 ml-paper-writing 技能中的写作方法论、LaTeX 模板 与 投稿检查清单,即可形成从"检索文献"到"提交 camera-ready"的完整闭环。

登录后查看全文
AI-Research-SKILLs