[Feature] 向量语义搜索 — 让 AI 搜索真正理解语义 #227
AmintaCCCP
started this conversation in
Ideas
Replies: 1 comment
-
完整技术方案一、背景与目标现状: 当前 AI 搜索流程:LLM 提取关键词/同义词 → 本地子串匹配。本质上仍是关键词搜索。 目标: 引入向量语义搜索作为可选增强功能:
设计原则:
二、架构总览关键设计决策:Worker 不负责 Embedding,只做 Vectorize 代理。
三、Embedding 配置设计Embedding 配置与现有 AI 分析配置结构类似但完全独立: export type EmbeddingApiType =
| 'openai' // OpenAI /v1/embeddings
| 'openai-compatible' // 任意兼容端点
| 'gemini' // Google Gemini
| 'cohere' // Cohere
| 'ollama'; // Ollama 本地
export interface EmbeddingConfig {
id: string;
name: string;
apiType: EmbeddingApiType;
baseUrl: string;
apiKey: string; // Ollama 可为空
model: string;
dimensions: number; // 必须与 Vectorize 索引一致
isActive: boolean;
}各渠道配置示例:
核心:用户填什么就用什么,不限制渠道。 四、Worker 设计(极简化,约120行)Worker 完全不知道 Embedding 模型的存在,只做三件事: Worker 完整代码仅约 120 行,没有任何 AI 相关逻辑,没有环境变量持有 API Key。只是一个带认证的 Vectorize 代理。 Vectorize 索引创建: npx wrangler vectorize create github-stars --dimensions=1536 --metric=cosine五、搜索流程六、同步流程
文本拼接策略: 七、成本分析Cloudflare 免费额度:
Embedding API 成本:
八、实现计划
九、风险与限制
附录:Embedding 模型参考
欢迎提出意见和建议!🙏 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
🎯 要解决的问题
当前的 AI 搜索本质上仍是关键词搜索:LLM 提取关键词/同义词 → 本地子串匹配。它无法理解语义关系:
管理 Docker 的工具→ ❌ 无法匹配描述为 "container orchestration platform" 的仓库好看的终端→ ❌ 无法匹配 "beautiful terminal emulator with GPU acceleration"轻量级数据库→ ❌ 无法匹配 "embedded key-value store written in Rust"💡 方案概述
引入向量语义搜索作为可选增强功能,基于 Cloudflare Vectorize:
核心设计
架构
📋 具体内容
Embedding 配置(独立于 AI 分析配置)
text-embedding-3-small, 1536维, $0.02/M tokens/v1/embeddings的端点text-embedding-004, 768维, 免费nomic-embed-text, 768维, 完全免费Cloudflare 免费额度够用吗?
搜索流程
🤔 讨论点
Beta Was this translation helpful? Give feedback.
All reactions