SuperAPI AI 工具集

ai-scientist-v2-guide

智能体与模型

查看项目

更新于 10-16 06:01

技能介绍

用途

AI-Scientist-v2 是 Sakana AI 开发的开源系统,用于自动化完整的科学研究流程——从想法生成、实验设计与运行,到结果分析和论文写作,尽量减少人工干预。它适用于希望把科研流程中较机械的部分自动化的研究者,以及需要系统化探索机器学习子领域实验空间的研究场景。

主要能力

  • 想法生成:分析现有文献,识别空白或可扩展方向,生成研究想法,并给出新颖性评分与可行性评分。
  • 智能体树搜索:维护一棵研究轨迹树。根节点为初始想法与基线实现;每个节点扩展出 2-4 个修改方案(超参数调整、架构改动、新训练策略等);对每个修改进行实现与实验评估;使用 UCB(上限置信界)等策略选择值得继续探索的分支;性能低于基线或收益递减的分支被剪除。
  • 实验执行:在隔离环境中运行实验,自动处理随机种子管理、指标记录、检查点保存与结果可视化;每个实验用多个种子运行以保证统计显著性。
  • 论文生成:搜索结束后生成科学论文,包含摘要、引言、相关工作(带引用)、方法(含公式)、实验(含表格与图)、结果分析与消融研究、结论与未来方向;支持 LaTeX 编译为 PDF。
  • 自动论文评审:按顶级机器学习会议标准(新颖性、重要性、清晰度、正确性、可复现性)对生成的论文评分,并输出优点、缺点与问题。
  • 研究模板:内置 NanoGPT、扩散模型等模板,也支持自定义研究领域模板。

使用方式

安装:

git clone https://github.com/SakanaAI/AI-Scientist-v2.git
cd AI-Scientist-v2

conda create -n ai-scientist python=3.11
conda activate ai-scientist

pip install -r requirements.txt

前置条件:需要 LLM API 访问(用于想法生成、分析与写作),可设置 OPENAI_API_KEY 或 ANTHROPIC_API_KEY;需要 GPU 运行机器学习实验(推荐至少一张 24GB 以上显存的 NVIDIA GPU);需要 LaTeX 用于论文编译(Ubuntu/Debian 用 sudo apt-get install texlive-full,macOS 用 brew install --cask mactex)。

配置示例(config.yaml):

llm:
  provider: "openai"
  model: "gpt-4o"
  temperature: 0.7

search:
  max_depth: 5          # Maximum tree depth
  branching_factor: 3   # Number of branches per node
  pruning_threshold: 0.3  # Prune branches below this score

experiment:
  gpu_ids: [0, 1]       # Available GPUs
  timeout_hours: 2      # Max time per experiment
  num_seeds: 3          # Random seeds per experiment

paper:
  template: "icml"      # Paper template (icml, neurips, iclr)
  max_pages: 8          # Maximum paper length

使用想法生成器:

from ai_scientist import IdeaGenerator

generator = IdeaGenerator(
    research_area="efficient_transformers",
    seed_papers=[
        "path/to/related_paper_1.pdf",
        "path/to/related_paper_2.pdf",
    ],
    num_ideas=10,
)

ideas = generator.generate()
for idea in ideas:
    print(f"Title: {idea.title}")
    print(f"Hypothesis: {idea.hypothesis}")
    print(f"Novelty score: {idea.novelty_score}")
    print(f"Feasibility score: {idea.feasibility_score}")

运行树搜索:

from ai_scientist import TreeSearchResearcher

researcher = TreeSearchResearcher(
    idea=ideas[0],  # Start with the top-ranked idea
    base_code="templates/efficient_transformer/",
    config="config.yaml",
)

result = researcher.run()

print(f"Tree depth reached: {result.max_depth}")
print(f"Total experiments run: {result.total_experiments}")
print(f"Best result: {result.best_node.metrics}")

生成论文:

from ai_scientist import PaperWriter

writer = PaperWriter(
    research_result=result,
    template="neurips",
    sections=[
        "introduction",
        "related_work",
        "method",
        "experiments",
        "analysis",
        "conclusion",
    ],
)

paper = writer.write()
paper.compile_latex("output/paper.pdf")

运行内置模板:

python run_scientist.py \
  --template nanoGPT \
  --idea "Investigate the effect of rotary position embeddings on small-scale language model training" \
  --max_experiments 20
python run_scientist.py \
  --template diffusion \
  --idea "Compare noise schedules for conditional image generation"

自定义模板(templates/my_domain/template.py):

class MyDomainTemplate:
    name = "my_research_domain"
    base_metrics = ["accuracy", "f1_score", "inference_time"]

    def setup_baseline(self):
        """Set up the baseline experiment."""
        pass

    def evaluate(self, model, data):
        """Evaluate a model configuration."""
        pass

    def get_modification_space(self):
        """Define the space of possible modifications."""
        return {
            "architecture": ["transformer", "lstm", "mamba"],
            "learning_rate": [1e-4, 3e-4, 1e-3],
            "batch_size": [32, 64, 128],
        }

自动评审:

from ai_scientist import PaperReviewer

reviewer = PaperReviewer(
    venue="neurips",
    review_criteria=[
        "novelty",
        "significance",
        "clarity",
        "correctness",
        "reproducibility",
    ],
)

review = reviewer.review("output/paper.pdf")
print(f"Overall score: {review.overall_score}/10")

每个实验节点包含假设、具体代码修改、超参数变化、实验结果、LLM 生成的分析以及子分支实验。

适用场景

  • 在定义明确的实验框架内做增量式研究。
  • 机器学习子领域(如扩散模型、语言模型训练、优化)的实验探索与论文初稿生成。
  • 需要系统化探索大量实验变体、并用多随机种子验证统计显著性的研究流程。

限制与伦理注意事项

  • 生成论文目前处于研讨会接收水平;突破性的概念性贡献仍需人类创造力。
  • 必须人工审阅生成论文的正确性后再提交,系统可能产出看似合理但错误的分析。
  • 若在发表中使用其输出,应按会议指南披露使用了自动化研究工具。
  • 树搜索加多种子实验可能消耗大量 GPU 时间,应设置合适的预算与超时。
  • 所有实验均记录种子、配置与代码版本,以支持可复现性。

参考资料

仓库:https://github.com/SakanaAI/AI-Scientist-v2 原始 AI Scientist 论文:https://arxiv.org/abs/2408.06292 Sakana AI:https://sakana.ai/ AI Scientist v1:https://github.com/SakanaAI/AI-Scientist