主题
LlamaIndex 支持使用 FastEmbed 生成嵌入。
如果你在 Colab 中打开这个 Notebook,可能需要先安装 LlamaIndex 🦙。
%pip install llama-index-embeddings-fastembed1
%pip install llama-index1
要使用该提供商,需要安装 fastembed 包。
%pip install fastembed1
支持的模型列表可在此处找到。
from llama_index.embeddings.fastembed import FastEmbedEmbedding
embed_model = FastEmbedEmbedding(model_name="BAAI/bge-small-en-v1.5")1
2
3
2
3
100%|██████████| 76.7M/76.7M [00:18<00:00, 4.23MiB/s]1
embeddings = embed_model.get_text_embedding("Some text to embed.")
print(len(embeddings))
print(embeddings[:5])1
2
3
2
3
384
[-0.04166769981384277, 0.0018720313673838973, 0.02632238157093525, -0.036030545830726624, -0.014812108129262924]1
2
2