微信扫码
添加专属顾问
我要投稿
在进行文本嵌入时,尤其是RAG系统,有一个快速高效的文本嵌入工具是非常有必要的。因此,FastEmbed设计目标是提升计算效率,同时保持嵌入表示的质量。此外,FastEmbed还支持一些图像嵌入模型。
特点:
# CPU版
pip install fastembed
# GPU版
pip install fastembed-gpu
from fastembed import TextEmbedding
from typing import List
# Example list of documents
documents: List[str] = [
"This is built to be faster and lighter than other embedding libraries e.g. Transformers, Sentence-Transformers, etc.",
"fastembed is supported by and maintained by Qdrant.",
]
# This will trigger the model download and initialization
embedding_model = TextEmbedding()
print("The model BAAI/bge-small-en-v1.5 is ready to use.")
embeddings_generator = embedding_model.embed(documents) # reminder this is a generator
embeddings_list = list(embedding_model.embed(documents))
# you can also convert the generator to a list, and that to a numpy array
print(len(embeddings_list[0]) ) # Vector of 384 dimensions
from fastembed import TextEmbedding
model = TextEmbedding(model_name="BAAI/bge-small-en-v1.5")
embeddings = list(model.embed(documents))
# [
# array([-0.1115, 0.0097, 0.0052, 0.0195, ...], dtype=float32),
# array([-0.1019, 0.0635, -0.0332, 0.0522, ...], dtype=float32)
# ]
SPLADE++
from fastembed import SparseTextEmbedding
model = SparseTextEmbedding(model_name="prithivida/Splade_PP_en_v1")
embeddings = list(model.embed(documents))
# [
# SparseEmbedding(indices=[ 17, 123, 919, ... ], values=[0.71, 0.22, 0.39, ...]),
# SparseEmbedding(indices=[ 38, 12, 91, ... ], values=[0.11, 0.22, 0.39, ...])
# ]
from fastembed import ImageEmbedding
images = [
"./path/to/image1.jpg",
"./path/to/image2.jpg",
]
model = ImageEmbedding(model_name="Qdrant/clip-ViT-B-32-vision")
embeddings = list(model.embed(images))
# [
# array([-0.1115, 0.0097, 0.0052, 0.0195, ...], dtype=float32),
# array([-0.1019, 0.0635, -0.0332, 0.0522, ...], dtype=float32)
# ]
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2025-09-12
Meta如何给RAG做Context Engineering,让模型上下文增加16倍
2025-09-12
检索器江湖:那些让RAG神功大成的武林绝学
2025-09-12
Dify + Oracle + MCP:轻松构建 RAG 与 MCP Agent 智能应用
2025-09-11
做好 RAG 落地最后环节 —— 评估 RAG 应用
2025-09-10
企业级RAG系统实战心得:来自10多个项目的深度总结
2025-09-10
您应该为您的 RAG 系统使用哪种分块技术?
2025-09-10
关于多模态应用的几个疑问,以及多模态应该怎么应用于RAG?
2025-09-10
MiniMax RAG 技术:从推理、记忆到多模态的演进与优化
2025-06-20
2025-06-20
2025-07-15
2025-06-24
2025-06-24
2025-07-16
2025-06-23
2025-07-09
2025-06-15
2025-06-20
2025-09-10
2025-09-10
2025-09-03
2025-08-28
2025-08-25
2025-08-20
2025-08-11
2025-08-05