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 IpexLLM From Model Id

From Leeroopedia


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

Overview

Concrete tool for loading an IPEX-LLM-optimized LLM as a LangChain LLM for use in chains and agents.

Description

The IpexLLM.from_model_id class method loads a HuggingFace model with IPEX-LLM low-bit optimization and wraps it as a LangChain-compatible LLM. It supports model_kwargs for configuring temperature, max_length, device, and trust_remote_code.

Usage

Use to create a LangChain LLM backed by an IPEX-LLM-optimized model on Intel XPU.

Code Reference

Source Location

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

Signature

from langchain_community.llms import IpexLLM

llm = IpexLLM.from_model_id(
    model_id: str,
    model_kwargs: dict = {
        "temperature": 0,
        "max_length": 512,
        "trust_remote_code": True,
        "device": "xpu",
    },
) -> IpexLLM

Import

from langchain_community.llms import IpexLLM

I/O Contract

Inputs

Name Type Required Description
model_id str Yes HuggingFace model ID or local path
temperature float No Sampling temperature (0 for greedy)
max_length int No Max generation length (default 512)
device str No Compute device ("xpu" for Intel GPU)
trust_remote_code bool No Allow custom model code

Outputs

Name Type Description
llm IpexLLM LangChain LLM instance backed by IPEX-LLM

Usage Examples

from langchain_community.llms import IpexLLM

# Initialize LLM on XPU
llm = IpexLLM.from_model_id(
    model_id="/path/to/Llama-2-7b-chat-hf",
    model_kwargs={
        "temperature": 0,
        "max_length": 512,
        "trust_remote_code": True,
        "device": "xpu",
    },
)

# Use in LangChain
result = llm.invoke("What is IPEX-LLM?")
print(result)

Related Pages

Implements Principle

Requires Environment

Page Connections

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