六周前,我收到 Gorgias 的 $300 账单——他们的 AI 客服自信地告诉我的客户一个根本不存在的退货政策。那一刻我决定自己写一个 AI 客服:不幻觉、可解释、成本可控。

客户提问
↓
[BM25 检索] ← 知识库(产品页 chunks)
↓
Top-K 相关 chunks + 分数
↓
[置信度检查] → 分数太低?→ "我不确定,转人工"
↓
[LLM 生成] ← "只根据上下文回答"
↓
回答(基于真实产品数据)产品页 = 短、结构化、关键词密集。BM25 在这种场景下:
Pinecone 起步 $70/月,对早期独立开发者是负担。
def should_answer(retrieved):
if not retrieved:
return False # 无相关上下文
top1 = retrieved[0][1]
if top1 < MIN_TOP_SCORE: # 阈值 1.0
return False # 最佳匹配太弱
if len(retrieved) >= 2:
gap = retrieved[0][1] - retrieved[1][1]
if gap < SCORE_GAP_THRESHOLD: # 阈值 0.5
return False # 多个弱匹配 = 歧义
return True如果 should_answer 返回 False,AI 说:
"I am not confident I know the answer to that. Let me connect you with a human agent who can help."
这是商家最需要的功能。 他们不要 AI 永远正确——他们要 AI 知道什么时候自己错了。置信度评分比回答质量更重要。
只有当置信度高时 LLM 才介入:
system_prompt = (
"You are a customer support agent. "
"Answer the customer question using ONLY the information in the "
"## Product Information section below. "
"If the answer is not in the product information, say "
"I am not sure, let me connect you to a human agent. "
"Do not invent policies, shipping times, or return rules."
)LLM(DeepSeek,OpenAI 兼容)温度 0.3(低创造性,高忠实度)。每对话 $0.003(DeepSeek)vs $0.50+(GPT-4),是 1/170。
# 客户用中文问,KB 是英文
translated = await translate_query("你们的退货政策是什么?", target_lang="en")
# → "What is your return policy?"
# 用翻译后的 query 搜英文 KB
results = index.search(translated, top_k=4)
# 用英文生成答案,再翻译回中文
answer_en = await llm_generate(results, translated)
answer_zh = await translate_query(answer_en, target_lang="zh")支持 7 种语言(en/zh/ja/fr/de/es/ko)。一个 KB,不重复造轮子。
| 商家 | 类型 | 答率 | 备注 |
|---|---|---|---|
| Allbirds | 鞋类 | 71% | 跨语言 zh→en |
| Kith | 街头 | 100% | CNY 变体复杂库存 |
| Cascadia Roasters | 订阅 | 83% | 暂停/跳过/烘焙度 |
| Peak Design | 摄影 | 100% | 丰富 JSON-LD |
| Loop Earplugs | 健康 | 88% | 选哪款 |
| Beardbrand | 美妆 | 50% | 其余正确转人工 |
| 平均 | 82% | 跨语言 |
那 18% 没答的?正确转人工,不编造。
前 10 个订阅者 50% off forever ($24.5/月),用码 EARLY10。
Building in public. Day 47/90. 8 个商家,0 个付费用户,但架构稳定 funnel 打开. 在评论里问我任何问题。