一份关于“小型构建”黑客松的实地报告,探讨一个拥有30亿参数的交易者委员会能做什么、不能做什么。先来试试看:访问这个Space,以及开放的智能体运行轨迹。
我为“小型构建”黑客松构建了“千木之森”。这是一个微型经济体:五个森林生物,每个都是基于Qwen2.5-3B的独立智能体,它们用五种商品交换鹅卵石、闲聊、囤积和恐慌。你戳一戳这片森林,就能看到泡沫、崩盘和不断扩大的贫富差距自行出现。该模型通过Modal上的vLLM提供服务;一个Gradio应用则是观察这片森林的窗口。
这是一份关于工程实现的实地报告,写给那些使用小型模型进行构建的人。简而言之:一个3B模型是一个可靠的格式生成器,但推理能力不可靠;涌现系统需要设计好的稀缺性;而最佳演示往往出现在技术约束与你深刻理解的某个事物相交汇的地方。
为什么“小”是设计,而非限制
一个鲜活的经经济体需要许多智能体在每次运行中进行多次思考。这正是前沿模型成为错误工具的地方:每轮运行一个交易者委员会都太慢、太昂贵。而小型模型使得实时的多智能体模拟成为可能。每个生物每轮只需通过一次批处理的GPU调用就能做出决策。
第一个经济体在诞生之初就死了
那个天真的版本什么也没发生。生产超过了消费,所以每个生物都能自给自足,完全没有理由进行交易。市场清空一次后就沉寂了。解决办法是人为制造稀缺性:
- 饮食多样化:每个生物每餐只能吃任何一种食物的一个单位,因此为了生存,它必须购买自己不种植的食物。
- 食物腐败:易腐烂的食物如果囤积就会变质,迫使生物在食物仍有价值时出售盈余。
- 冬季燃料危机:每个生物每轮都必须燃烧木柴,需求会随时间增长,而只有一种生物生产木柴。
最后这个机制是戏剧性的来源。一个供应商无法满足不断增长的需求,于是樵夫变得富有,而其他生物则为了取暖而竞争。
有效的JSON,薄弱的判断力
在资源稀缺的设定下,小型模型的真实教训浮现了出来。3B 模型在 100% 的调用中都输出了合法的 JSON,但其经济判断力很差:一个生产橡果的生物会发布购买橡果的订单,而橡果恰恰是它过剩的东西。
解决办法不是换用更大的模型,而是给出更精准的提示词。我告诉每个智能体它生产什么、绝对不能买什么,计算出它具体短缺的商品清单,并给出了一个示例。决策质量大幅提升,生物们开始按照各自的角色进行交易。整个循环被包裹在一个容错的 JSON 解析与修复层中,因此格式错误的响应会降级为空操作,而不会导致模拟崩溃。
第二个教训来自“福祉”系统。我最初将其建模为一个累加器,任何长期的短缺都会在运行过程中让每个生物的值归零,形成一种不好看的死亡螺旋,并惩罚了智能体不完美的优化。我将其重新定义为一种均值回归的情绪状态,当生物吃饱穿暖时就会恢复,并且永远不会降到零。风险应该体现在石子、价格和地位上,而不是饥饿。
然后,它开始讲故事了
我最满意的功能是将这个项目与市场历史联系了起来。玩家可以绘制一张“森林传奇”:将著名的历史事件重新包装成林地民间传说。郁金香狂热变成了“大橡果狂热”。南海泡沫变成了“空心圆木贸易公司”。1929 年的银行挤兑变成了“乌娜宝库挤兑”。
这些并非只是装饰性文字。每个传奇都会触发真实的冲击,而智能体会做出反应。在一次运行中,我绘制了“乌娜宝库挤兑”,即猫头鹰的宝库是空的这一谣言。乌娜开始抛售她的蜂蜜以换取石子,蜂蜜的供应过剩导致其价格在接下来的几个回合中从 10 暴跌至 3。一个被重新包装的银行挤兑事件,让一个智能体抛售资产,并改变了市场价格。这一切都不是预设脚本。
为了让这一切可见,价格必须能够变动。价格之前是冻结的,因为智能体们报出的价格就是我展示给他们的参考价。解决办法是让市场参考价随着每轮交易后的剩余供需关系而浮动:大量未成交的买单推高价格,供应过剩则压低价格。现在,价格在稀缺时期会形成趋势,在均衡交易中则保持平稳。
实际发生的情况是
一个具有代表性的十五轮运行,中途注入了干旱和冬季传闻:
| 指标 | 结果 |
|---|---|
| 有效的 JSON 动作 | 100%(75 次调用中 75 次) |
| 每轮交易次数 | 维持在 3 到 9 之间,从未静默 |
| 蜂蜜价格 | 在银行挤兑传闻期间从 10 暴跌至 3 |
| 木柴价格 | 随着冬季短缺加剧,从 4 上涨至 7 |
| 财富差距(基尼系数) | 从 0.14 扩大至 0.38 |
| 结果 | 樵夫最终成为最富有的人,囤积者破产 |
这些每一步行动背后的推理过程都包含在公开的追踪数据集中:每一行都是一个智能体的完整提示词、原始响应、解析后的动作以及私有思考。
使用小模型构建的启示
大部分工程工作在于通过结构和提示词而非规模,来弥合小模型可靠格式与其不可靠推理之间的差距。涌现系统需要设计稀缺性;富足是无聊的。而最引人注目的小模型演示并不需要人为制造的戏剧性。三个世纪的市场历史已经为此做好了准备,一个由 3B 参数智能体组成的议会就足以将其演绎出来。
小模型,大冒险。试试这个 Space。
最初发布于 Medium。
A Build Small Hackathon field report on what a 3-billion-parameter council of traders can and cannot do. Try it first: the Space, and the open agent traces.
I built Thousand Token Wood for the Build Small Hackathon. It is a tiny economy: five woodland creatures, each its own agent on Qwen2.5-3B, trade five goods for pebbles, gossip, hoard, and panic. You poke the wood and watch bubbles, crashes, and a widening wealth gap appear on their own. The model is served with vLLM on Modal; a Gradio app is the window onto the wood.
This is a field report on the engineering, written for people who build with small models. The short version: a 3B model is a reliable format generator and an unreliable reasoner, emergent systems need designed scarcity, and the best demos sit where a technical constraint meets something you already understand deeply.
Why small is the design, not the limit
A living economy needs many agents thinking many times per run. That is exactly where a frontier model is the wrong tool: too slow and too costly to run a council of traders every tick. A small model is what makes a real-time multi-agent simulation feasible. Every creature decides in a single batched GPU call per turn.
The first economy was dead on arrival
The naive version did nothing. Production outran consumption, so every creature was self-sufficient and never had a reason to trade. The market cleared once and went silent. The fix was to engineer scarcity:
- Diet variety: a creature can eat only one unit of any single food per meal, so surviving means buying foods it does not grow.
- Spoilage: perishable food rots if hoarded, forcing surplus to be sold while it still has value.
- A winter fuel crisis: every creature must burn firewood each turn, the need rises over time, and only one creature makes firewood.
That last mechanic drives the drama. One supplier cannot meet rising demand, so the woodcutter gets rich and everyone else competes for warmth.
Valid JSON, weak judgment
With scarcity in place, the honest small-model lesson surfaced. The 3B emitted valid JSON on 100% of calls, but its economic judgment was poor: a creature that produced acorns would post an order to buy acorns, the one thing it had in surplus.
The fix was not a bigger model, it was a sharper prompt. I told each agent what it produced and must never buy, computed the exact list of goods it was short on, and gave it one worked example. Decision quality jumped and the creatures began trading to their roles. The whole loop is wrapped in a tolerant JSON parse-and-repair layer, so a malformed response degrades to a no-op instead of crashing the simulation.
A second lesson came from wellbeing. I first modeled it as an accumulator, and any chronic shortfall ground every creature to zero over a run, a death spiral that was no fun to watch and that punished the agents' imperfect optimization. I reframed it as a mean-reverting mood that recovers when a creature is fed and warm and never hits zero. Stakes belong in pebbles, prices, and status, not starvation.
Then it started telling stories
The feature I am most pleased with ties the project to market history. The player can draw a Wood Legend: a famous episode reskinned as woodland folklore. Tulip Mania becomes the Great Acorn Mania. The South Sea Bubble becomes the Hollow Log Trading Company. The 1929 bank runs become the Run on Oona's Hoard.
These are not flavor text. Each legend fires real shocks, and the agents react. In one run I drew the Run on Oona's Hoard, the rumor that the owl's vault was empty. Oona began liquidating her honey to raise pebbles, and the flood of supply crashed the honey price from 10 to 3 over the next turns. A reskinned bank run made an agent dump assets and moved a market price. None of it was scripted.
For that to be visible, prices had to move. They were frozen because the agents quoted back the reference price I showed them. The fix was to let the market reference drift with residual supply and demand after each round: heavy unfilled buying pushes a price up, a glut pushes it down. Prices now trend during scarcity and stay calm in balanced trade.
What actually happened
A representative fifteen-turn run, with a drought and a winter rumor injected partway:
| Metric | Result |
|---|---|
| Valid JSON actions | 100% (75 of 75 calls) |
| Trades per turn | sustained 3 to 9, never silent |
| Honey price | crashed 10 to 3 during the bank-run legend |
| Firewood price | rose 4 to 7 as winter scarcity bit |
| Wealth gap (Gini) | widened 0.14 to 0.38 |
| Outcome | the woodcutter ended richest, the hoarder broke |
The reasoning behind every one of those moves is in the open traces dataset: each row is a creature's full prompt, raw response, parsed actions, and private thought.
Takeaways for building with small models
Most of the engineering is closing the gap between a small model's reliable formatting and its unreliable reasoning, with structure and prompting rather than scale. Emergent systems need designed scarcity; abundance is boring. And the most compelling small-model demos do not need invented drama. Three centuries of market history had it ready, and a council of 3B agents was enough to play it out.
Small models, big adventures. Try the Space.
Originally published on Medium.