Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Intel Ipex llm IpexLLMBgeEmbeddings And Chroma

From Leeroopedia


Knowledge Sources
Domains NLP, RAG, Embeddings
Last Updated 2026-02-09 00:00 GMT

Overview

Concrete tools for XPU-accelerated BGE embeddings and Chroma vector store creation in the IPEX-LLM RAG pipeline.

Description

IpexLLMBgeEmbeddings is the IPEX-LLM integration for LangChain that runs BAAI BGE embedding models on Intel XPU with low-bit optimization. Chroma.from_texts creates an in-memory vector store from text chunks and their embeddings, returning a retriever for similarity search.

Usage

Use after document chunking to create the retrieval component of a RAG chain.

Code Reference

Source Location

  • Repository: IPEX-LLM
  • File: python/llm/example/GPU/LangChain/rag.py
  • Lines: 60-65

Signature

from langchain_community.embeddings import IpexLLMBgeEmbeddings
from langchain_chroma import Chroma

# Initialize embeddings
embeddings = IpexLLMBgeEmbeddings(
    model_name: str,                      # Path to BGE model
    model_kwargs: dict = {"device": "xpu"},
    encode_kwargs: dict = {"normalize_embeddings": True},
)

# Create vector store and retriever
retriever = Chroma.from_texts(
    texts: List[str],
    embedding: Embeddings,
    metadatas: List[dict] = None,
).as_retriever() -> VectorStoreRetriever

Import

from langchain_community.embeddings import IpexLLMBgeEmbeddings
from langchain_chroma import Chroma

I/O Contract

Inputs

Name Type Required Description
model_name str Yes Path to BGE embedding model
device str No Compute device (default "xpu")
normalize_embeddings bool No L2-normalize embeddings (default True)
texts List[str] Yes Text chunks to embed and store
metadatas List[dict] No Metadata for each chunk

Outputs

Name Type Description
retriever VectorStoreRetriever Retriever for similarity search over the vector store

Usage Examples

from langchain_community.embeddings import IpexLLMBgeEmbeddings
from langchain_chroma import Chroma

# Initialize XPU-accelerated BGE embeddings
embeddings = IpexLLMBgeEmbeddings(
    model_name="/path/to/bge-base-en-v1.5",
    model_kwargs={"device": "xpu"},
    encode_kwargs={"normalize_embeddings": True},
)

# Create vector store from text chunks
texts = ["IPEX-LLM is an LLM acceleration library...",
         "It supports 70+ models including Llama, Phi..."]
retriever = Chroma.from_texts(
    texts, embeddings,
    metadatas=[{"source": str(i)} for i in range(len(texts))]
).as_retriever()

# Query the retriever
docs = retriever.invoke("What is IPEX-LLM?")

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment