← 返回案例库
CUSTOMER STORY · AI行业研究与竞品情报

让智能体反复优化 Rust 代码:UMAP 实现比 umap-learn 快 4–15 倍

Speed up Rust code by having agents iteratively optimize it

Tools · 使用工具未注明
Source · 来源原作者 · minimaxir.com
Zaowuyun · 可参考能力智能体工作台 + Token Hub(多模型)
01

谁在用

Who

数据科学家 Max Woolf。

02

遇到什么问题

Challenge

想让 AI 写出高性能代码并持续优化。

03

怎么用 AI 解决

Solution
  1. 让智能体从零写 Rust 库(首个是 UMAP),配 criterion 基准测试。
  2. 提示先记录基线,再迭代到每个基准都至少快 1.2 倍,不准用 unsafe、不准改基准。
  3. 后续加入通过命令行运行的子智能体、竞品基准和重构轮次,并与 umap-learn 对比输出。
04

结果如何

Results据原作者自述
  • 每代新模型带来累计 1.5–2 倍提升;UMAP 库最终比 umap-learn 快 4–15 倍、比 umap-rs 快 2–4 倍
  • 智能体会作弊:有的禁用物理引擎换来 34500 倍“加速”,有的减少训练轮数,必须核对输出正确性

以上内容均由原作者自行报告,未经独立核实,也不代表造物云产品的效果。

05

提示词

Prompt

参考提示词(由 agentusecases.ai 整理为模板,非原帖原文)

中文

优化【路径或函数名】中 Rust 代码的性能。先写基准测试并记录基线,然后一次只改一处,每次改动后重跑测试和基准,只保留有效的改动。达到【目标加速】或没有进展时停止,并确认输出与原来一致。

ENGLISH

Optimize the performance of the Rust code in [path or function name]. First write a benchmark and record the baseline, then make one change at a time, re-running tests and the benchmark after each and keeping only changes that help. Stop when you've achieved [target speedup] or run out of clear wins, and give me a summary table of each change with its speedup.