为什么 Regex 在 Google Taxonomy 中失效:构建 98% 准确的 RAG Agent

发布: (2025年12月15日 GMT+8 14:42)
3 min read
原文: Dev.to

Source: Dev.to

问题

在 Google Merchant Center 中,分类至关重要。如果你把产品分类错误,广告会被停止投放。大多数 feed 工具使用关键词匹配(Regex)。

规则: 如果标题包含 “Dog” → 类别:Animals > Pets > Dogs
输入: “Hot Dog Costume”
结果: Animals > Pets > Dogs ❌(错误!)

这就是为什么在大型目录中,15‑20 % 的产品常常停留在 “Disapproved” 的灰色地带。

解决方案:基于向量的分类

我构建了 CatMap AI 来使用向量而非关键词解决此问题。我们不是使用规则,而是将整个 Google 产品分类(5,500+ 节点)使用 OpenAI 的 text-embedding-3-small 转换为向量索引。

当一个产品进来时(例如 “Pallash Casual Women’s Kurti”),我们不去寻找单词 “Kurti”。我们在向量空间中寻找该产品的数学概念。

处理文化术语

标准向量搜索在面对特定文化术语时可能失效。

输入: “Kurri”
向量匹配: 通用服装(置信度:低)

代理循环

  1. 尝试 1: 标准搜索 → 结果:未分类。

  2. 触发: 代理检测到失败。

  3. 行动: 代理调用 LLM(gpt-5-nano)来 “扩展” 查询。

    提示: “What is a Kurti? Give me synonyms.”

    响应: “Tunic, Blouse, Shirt”。

  4. 尝试 2: 使用 “Tunic Blouse Shirt” 进行向量搜索。

  5. 结果: Apparel > Clothing > Shirts & Tops

结果

  • 覆盖率: 100 %(从 85 % 提升)。
  • 准确率: 98.3 %。
  • 延迟: 每行约 200 ms。

简化逻辑

// Simplified categorization flow
if (result.status === "Uncategorized") {
    const synonyms = await expandQuery(product.name); // AI call
    const newContext = await VectorStore.search(synonyms);
    return categorizeWithContext(product, newContext);
}

试用

我正在为开发者开放 免费 BetaLink to CatMap AI

关注获取更多 AI 代理的工程深度解析。

Back to Blog

相关文章

阅读更多 »