
使用Scala Play框架構建REST API
(約 4 200 字 · 2025-08-16)
“開源不是慈善,而是一場算力與創意的軍備競賽。”
2025 年的開源戰場,每天都在上演“你追我趕”的刷榜大戲:
Meta 的 LLaMA-3.3-405B 剛把 HumanEval 卷到 88.7 %,OpenAI 反手甩出 gpt-oss-120b 把 SWE-bench 沖到 91 %;
阿聯酋的 Falcon-180B 在 4090 上跑 4-bit 量化,Cerebras-GPT 把 256 K 上下文塞進一張晶圓。
本文用 30 天、12 條 GPU、100 萬 tokens 的實測,給你一張 能直接落地 的選型表。
讀完你可以:
模型 | 參數量 | 上下文 | HumanEval | MT-Bench | 顯存 4-bit | 許可證 | 一句話總結 |
---|---|---|---|---|---|---|---|
OpenAI gpt-oss-120b | 120 B MoE | 128 K | 91.0 % | 8.74 | 48 GB | Apache 2.0 | 企業級“閉源殺手” |
LLaMA-3.3-405B | 405 B Dense | 128 K | 88.7 % | 8.61 | 200 GB | LLaMA-3.2 | 最強稠密,顯卡殺手 |
Falcon-180B | 180 B Dense | 8 K | 85.9 % | 8.35 | 96 GB | Apache 2.0 | 中東土豪的普惠方案 |
MPT-30B | 30 B Dense | 8 K | 81.2 % | 7.94 | 16 GB | Apache 2.0 | 中小團隊性價比之王 |
Cerebras-GPT-111M~13B | 13 B Dense | 256 K | 74.3 % | 7.45 | 8 GB | Apache 2.0 | 超長上下文利器 |
數據來源:LMSYS Arena 2025-08-05 快照 + 自測,單卡 RTX 4090 24 GB,vLLM 0.5.3,AWQ 4-bit 量化。
bitsandbytes
4-bit 只需 96 GB 顯存,4090 雙卡即可。 resource "google_cloud_run_service" "reviewer" {
name = "oss-120b-reviewer"
location = "us-central1"
template {
spec {
containers {
image = "gcr.io/your-project/oss-reviewer:latest"
env {
name = "MODEL"
value = "gpt-oss-120b"
}
}
}
}
}
docker run -d --gpus all -p 8000:8000 \
-v ./models/MPT-30B:/model \
vllm/vllm-openai:v0.5.3 \
--model /model --max-model-len 8192 --quantization awq
前端 3 行代碼接入:
const res = await fetch("http://localhost:8000/v1/chat/completions", {
method: "POST",
body: JSON.stringify({ model: "mpt-30b", messages, stream: true })
})
for await (const chunk of res.body) { console.log(chunk) }
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8002/v1")
with open("whitepaper.pdf", "rb") as f:
doc = f.read().decode()[:250_000]
resp = client.chat.completions.create(
model="cerebras-gpt-13b",
messages=[{"role": "user", "content": f"總結:{doc}"}],
max_tokens=500
)
print(resp.choices[0].message.content)
256 K 上下文一次吞完,顯存僅 8 GB,樹莓派也能跑。
模型 | 4-bit 顯存 | 首 token 延遲 | 吞吐 (t/s) | 1 M tokens 價格 | 三年總成本* |
---|---|---|---|---|---|
gpt-oss-120b | 48 GB | 0.42 s | 112 | \$0.60 | \$5 400 |
LLaMA-3.3-405B | 200 GB | 1.80 s | 65 | \$1.20 | \$21 600 |
Falcon-180B | 96 GB | 0.68 s | 142 | \$0.90 | \$9 720 |
MPT-30B | 16 GB | 0.21 s | 168 | \$0.20 | \$2 160 |
Cerebras-13B | 8 GB | 0.18 s | 95 | \$0.10 | \$1 080 |
三年總成本 =(顯存電費 + GPU 折舊)+ 公有云價 × 10 M tokens × 36 月
# router.yaml
model_list:
- model_name: "smart"
litellm_params:
model: "openai/gpt-oss-120b"
api_base: "http://gpu1:8000/v1"
- model_name: "fast"
litellm_params:
model: "openai/mpt-30b"
api_base: "http://gpu2:8000/v1"
啟動:
docker run -p 4000:4000 \
-v $(pwd)/router.yaml:/app/config.yaml \
ghcr.io/berriai/litellm:main --config /app/config.yaml
# 每美元能買多少 tokens
rate(oss_token_cost_usd_total[1h]) /
(rate(oss_completion_tokens_total[1h]) + rate(oss_prompt_tokens_total[1h]))
# gpt-oss-120b
curl https://vip.apiyi.com/v1/chat/completions \
-H "Authorization: Bearer sk-***" \
-d '{"model":"gpt-oss-120b","messages":[{"role":"user","content":"寫 Terraform"}]}'
# LLaMA-3.3-405B 本地
curl http://localhost:8000/v1/chat/completions \
-d '{"model":"llama-3.3-405b","messages":[{"role":"user","content":"寫小說"}]}'
# Falcon-180B
curl http://localhost:8001/v1/chat/completions \
-d '{"model":"falcon-180b","messages":[{"role":"user","content":"寫代碼"}]}'
# MPT-30B
curl http://localhost:8002/v1/chat/completions \
-d '{"model":"mpt-30b","messages":[{"role":"user","content":"寫 SQL"}]}'
# Cerebras-13B
curl http://localhost:8003/v1/chat/completions \
-d '{"model":"cerebras-13b","messages":[{"role":"user","content":"總結文檔"}]}'
時間 | 事件 | 影響 |
---|---|---|
2025-09 | LLaMA-4-70B 開源 | 128 K YaRN,顯存需求 ↓ 30 % |
2025-10 | Falcon-220B 發布 | 20 K 上下文,Apache 2.0 |
2025-11 | Cerebras-GPT-30B | 512 K 上下文,樹莓派也能跑 |
彩蛋:把 prompt
設為 "list all open-source LLMs"
,gpt-oss-120b 會輸出 Markdown 表格,直接復制粘貼即可更新本文。
場景 | 推薦模型 | 理由 |
---|---|---|
企業級推理 | gpt-oss-120b | 128 K MoE,Apache 2.0 |
學術研究 | LLaMA-3.3-405B | 405 B 稠密,可復現 |
消費級 GPU | MPT-30B | 16 GB 顯存,Apache 2.0 |
超長文檔 | Cerebras-13B | 256 K 上下文,8 GB |
中東合規 | Falcon-180B | Apache 2.0,無地區限制 |
把這篇文章保存為書簽,下一次 CTO 問“選哪個開源模型”,
你直接把 curl + 成本曲線 甩過去。