RAG中为什么要做Embedding?嵌入模型如何选?

1.基础知识

python 复制代码
from sentence_transformers import SentenceTransformer

# 加载 embedding 模型
model = SentenceTransformer('all-MiniLM-L6-v2')

# 文本转向量
texts = ["如何煮奶茶", "奶茶制作步骤", "Python 入门教程"]
embeddings = model.encode(texts)

# 计算相似度
from sklearn.metrics.pairwise import cosine_similarity
similarity = cosine_similarity([embeddings[0]], [embeddings[1]])
# 输出约 0.85,说明"如何煮奶茶"和"奶茶制作步骤"语义相近

2.为什么需要Embedding

3.常见嵌入模型

一句话:中文选BGE或M3E、英文选OpenAI或Cohere、轻量级选Sentence-BERT

https://huggingface.co/spaces/mteb/leaderboard

4.如何选嵌入模型

https://huggingface.co/models?library=sentence-transformers

5.追问

相关推荐
志尊宝21 小时前
AI原生前端开发(018):端侧AI性能优化:模型加载、推理加速
人工智能·性能优化·ai-native
志尊宝1 天前
AI原生前端开发(019):端侧AI安全与隐私:数据保护、权限控制
人工智能·安全·ai-native
AI产品测评官2 天前
2026企业AI招聘选型指南:四类技术路线与硬科技场景适配方案
大数据·人工智能·科技·求职招聘·ai-native
金仓社区的KK2 天前
Agent Skill 没按预期执行?用请求、调用记录和产物排查
人工智能·软件构建·ai-native
志尊宝2 天前
AI原生前端开发(016):端侧AI与React 19结合实战
人工智能·react.js·ai-native
志尊宝3 天前
AI原生前端开发(013):端侧文本生成实战:智能提示、自动补全
人工智能·prompt·ai-native
志尊宝3 天前
AI原生前端开发(011):Chrome 148+内置Gemini Nano入门
前端·chrome·ai-native
志尊宝3 天前
AI原生前端开发(012):Prompt API详解:如何优雅调用本地AI模型
人工智能·prompt·ai-native
志尊宝3 天前
AI原生前端开发(010):AI时代的开发者工作流重构
人工智能·重构·ai-native