A web research agent that refuses to guess, on an AMD GPU

A web research agent that refuses to guess, on an AMD GPU

Why I wrote this I have loved technology since I was a kid. I was the one who opened every menu in the phone settings, played with JavaScript, and showed people Google’s satellite maps when nobody around me had seen them. I once put a Samsung ROM on a Huawei phone just to see if I could. I studied architecture at Unity University, but AI is where my curiosity kept taking me. About three years ago I was already generating images and music with AI, and telling my friends that one day everyone would have their own agents, each with a profession, working for them. They started calling me “the AI guy”. Since then I have taken the 5 Million Ethiopian Coders course, built automations, made videos with ComfyUI, run models offline on my own PC, and tried almost every AI assistant I could find. I joined the AMD AI League for two honest reasons: the prize money, and the skills. I want to work as an AI engineer, and one day start a tech company in Ethiopia.

我为什么写这篇文章 我从小就热爱科技。我曾是那个会打开手机设置里每一个菜单、摆弄 JavaScript,并在周围没人见过谷歌卫星地图时向他们展示的人。我曾经为了看看自己能否做到,给一部华为手机刷入了三星的 ROM。我在 Unity 大学学习建筑学,但人工智能始终是我好奇心所在的方向。大约三年前,我就已经开始用 AI 生成图像和音乐,并告诉朋友们,总有一天每个人都会拥有属于自己的、各司其职的 AI 代理。他们开始叫我“AI 达人”。从那时起,我参加了“500 万埃塞俄比亚程序员”课程,构建自动化流程,用 ComfyUI 制作视频,在自己的电脑上离线运行模型,并尝试了我能找到的几乎每一个 AI 助手。我加入 AMD AI 联盟有两个诚实的原因:奖金和技能。我想成为一名 AI 工程师,并希望有一天能在埃塞俄比亚创办一家科技公司。

The challenge Match 4 of the AMD AI League, run by lablab and AMD, asks for an agent that takes a plain question, goes out on the live web, and comes back with the exact answer and the page that proves it. It runs as a Docker image on AMD’s ROCm base, graded on an AMD GPU. Here is how I built mine, and what I learned.

挑战 由 lablab 和 AMD 举办的 AMD AI 联盟第四场比赛,要求开发一个代理程序:它接收一个简单的问题,在实时网络上进行搜索,并返回准确的答案以及证明该答案的页面。它以 Docker 镜像的形式在 AMD 的 ROCm 基础上运行,并在 AMD GPU 上进行评分。以下是我构建它的过程以及我的心得。

The real problem is not the model My first instinct was to pick the biggest model that fits. That was the wrong place to start. A model can only answer from what you put in front of it, so most of the work is getting the right 1,500 words onto the page.

真正的问题不在于模型 我的第一直觉是选择能装下的最大模型。这是一个错误的起点。模型只能根据你提供给它的内容进行回答,所以大部分工作在于如何将正确的 1500 个单词呈现在页面上。

Step 1: never depend on one search engine From inside a container, any single search engine may block you. So the agent asks several at once (DuckDuckGo, Bing, Wikipedia, Mojeek, Yahoo) and merges the results. If the question includes a starting URL, it also crawls that site, following the links whose text best matches the question first.

第一步:永远不要依赖单一搜索引擎 在容器内部,任何单一的搜索引擎都可能封锁你。因此,代理程序会同时询问多个引擎(DuckDuckGo、Bing、Wikipedia、Mojeek、Yahoo)并合并结果。如果问题包含起始 URL,它还会抓取该网站,优先跟踪那些文本与问题匹配度最高的链接。

Step 2: clean pages properly It fetches up to 8 pages in parallel, HTML and PDF. Menus, footers and cookie banners are thrown away. The detail that mattered most: tables are flattened into label: value lines. Many answers live in infoboxes and spec tables, and plain text extraction turns those into soup.

第二步:正确清理页面 它并行抓取最多 8 个页面(HTML 和 PDF 格式)。菜单、页脚和 Cookie 横幅会被丢弃。最关键的细节是:表格被扁平化为“标签:数值”行。许多答案存在于信息框和规格表中,而纯文本提取会将这些内容变成乱码。

Step 3: rank before you read The text is cut into chunks of about 90 words and ranked with BM25, an old keyword method with no GPU cost. Only the best 1,500 words or so go to the model.

第三步:先排序,后阅读 文本被切分成约 90 个单词的块,并使用 BM25(一种无需 GPU 成本的旧式关键词方法)进行排序。只有最好的 1500 个左右的单词会被送入模型。

Step 4: a small model, kept warm The model is Qwen3-4B-Instruct in bf16 on the AMD GPU through PyTorch on ROCm. A small server inside the container loads the weights once at start. Each question then costs web time plus one short request, not a model load. The model must return strict JSON: the shortest exact answer, its source and a supporting quote.

第四步:一个小模型,保持热启动 该模型是通过 ROCm 上的 PyTorch 在 AMD GPU 上运行的 bf16 格式的 Qwen3-4B-Instruct。容器内的一个小型服务器在启动时加载一次权重。之后每个问题仅消耗网络时间和一次简短的请求,无需重新加载模型。模型必须返回严格的 JSON 格式:最短的准确答案、来源以及支持性引文。

Step 5: check the answer against the page This is the part I am proudest of. The answer has to literally appear on a page the agent actually fetched. If it does not, the agent follows the best links one level deeper, searches again with a rewritten question, and if that fails it returns an empty answer. An honest blank beats a confident wrong answer.

第五步:对照页面核实答案 这是我最引以为豪的部分。答案必须确实出现在代理程序实际抓取的页面上。如果没有,代理程序会深入一层跟踪最佳链接,用重写的问题再次搜索;如果仍然失败,它会返回空答案。诚实的空白胜过自信的错误答案。

My favourite moment One slow search engine was quietly breaking everything. The agent waited so long for it that it had about one second left to actually read pages. Finding that, and fixing it so that no single engine can hold up the others, was the best moment of the whole build. There is now a test for it.

我最喜欢的时刻 一个缓慢的搜索引擎在暗中破坏了一切。代理程序为了等待它耗费了太多时间,以至于只剩下一秒钟来阅读页面。发现这一点并进行修复,确保没有任何单一引擎能拖累其他引擎,这是整个构建过程中最棒的时刻。现在已经为此添加了测试。

Lessons from running on ROCm Build for linux/amd64 and leave the ROCm base layers untouched. The base is about 29 GiB, too big for a hosted CI runner to unpack, so I append my layers on top of it with crane without ever pulling it apart. Keep stdout clean. Graders parse it. My logs go to a file. Give every question one shared deadline, and always write an output file, even on failure.

在 ROCm 上运行的经验教训 针对 linux/amd64 进行构建,并保持 ROCm 基础层不动。基础镜像大约 29 GiB,对于托管的 CI 运行器来说太大而无法解压,所以我使用 crane 将我的层附加在它上面,而无需将其拆解。保持标准输出(stdout)整洁,因为评分系统会解析它。我的日志会写入文件。为每个问题设置一个共享的截止时间,并且即使失败也要始终写入输出文件。

Test without a GPU first I built a fake web and a fake model so I could run seven tricky questions offline: decoy years in a footer, a PDF, a rumour page that disagrees with the spec table, and a question with no answer.

先在没有 GPU 的情况下测试 我构建了一个虚假的网络和一个虚假的模型,以便离线运行七个棘手的问题:页脚中的诱饵年份、PDF 文件、与规格表不符的谣言页面,以及一个没有答案的问题。

If you are a student Just start. Use the free credits. You do not need a computer science degree. Compete anyway. Ask me anything in the comments. I will answer.

如果你是一名学生 直接开始吧。使用免费额度。你不需要计算机科学学位。无论如何都要去参赛。在评论区问我任何问题,我会回答。

The source is on GitHub: https://github.com/abrsh43210/amd-league-mc4-web-public Built for the AMD AI League (lablab x AMD): https://lablab.build/ai-hackathons/amd-lablab-ai-academy-challenge (I used an AI coding assistant while building this.)

源代码在 GitHub 上:https://github.com/abrsh43210/amd-league-mc4-web-public 为 AMD AI 联盟(lablab x AMD)构建:https://lablab.build/ai-hackathons/amd-lablab-ai-academy-challenge (我在构建过程中使用了 AI 编程助手。)