跳转到内容

使用 Optimum-Intel 优化的嵌入模型

LlamaIndex 支持使用 Optimum-Intel 库 为英特尔加载量化嵌入模型。

优化后的模型更小更快,精度损失极小,请参阅文档以及使用IntelLabs/fastRAG库的优化指南

优化基于至强®第四代或更新处理器中的数学指令。

为了能够加载和使用量化模型,请安装所需的依赖项 pip install optimum[exporters] optimum-intel neural-compressor intel_extension_for_pytorch

加载过程使用类 IntelEmbedding 完成;使用方法与任何 HuggingFace 本地嵌入模型类似;参见示例:

%pip install llama-index-embeddings-huggingface-optimum-intel
from llama_index.embeddings.huggingface_optimum_intel import IntelEmbedding
embed_model = IntelEmbedding("Intel/bge-small-en-v1.5-rag-int8-static")
embeddings = embed_model.get_text_embedding("Hello World!")
print(len(embeddings))
print(embeddings[:5])
384
[-0.0032782123889774084, -0.013396517373621464, 0.037944991141557693, -0.04642259329557419, 0.027709005400538445]