微信扫码
添加专属顾问
我要投稿
在进行文本嵌入时,尤其是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-07-30
优化 AI 问答准确率:知识库实践与避坑指南
2025-07-30
RAG召回优化完全指南:从理论到实践的三大核心策略!
2025-07-30
RAG 检索四件套全解析:模型、向量库、检索方式、排序器,一文选型不踩坑
2025-07-30
从0到1,彻底搞懂 RAG 分块的艺术(附开源代码)
2025-07-30
大规模RAG实施蓝图
2025-07-29
一小时内构建基于Gemma与Bright Data的生产级RAG应用
2025-07-28
做RAG系统到底是选MaxKB还是FastGPT
2025-07-28
企业RAG之构建 FastMCP 服务:基于模型上下文协议的智能服务体系搭建实践
2025-06-06
2025-05-30
2025-06-05
2025-05-19
2025-05-08
2025-05-10
2025-06-05
2025-05-20
2025-06-05
2025-05-09
2025-07-28
2025-07-09
2025-07-04
2025-07-01
2025-07-01
2025-07-01
2025-07-01
2025-06-30