IPEX-LLM is a PyTorch library for running LLM on Intel CPU and GPU (e.g., local PC with iGPU, discrete GPU such as Arc, Flex and Max) with very low latency.This example goes over how to use LangChain to conduct embedding tasks with
ipex-llm
optimizations on Intel GPU. This would be helpful in applications such as RAG, document QA, etc.
Note It is recommended that only Windows users with Intel Arc A-Series GPU (except for Intel Arc A300-Series or Pro A60) run this Jupyter notebook directly. For other cases (e.g. Linux users, Intel iGPU, etc.), it is recommended to run the code with Python scripts in terminal for best experiences.
Install Prerequisites
To benefit from IPEX-LLM on Intel GPUs, there are several prerequisite steps for tools installation and environment preparation. If you are a Windows user, visit the Install IPEX-LLM on Windows with Intel GPU Guide, and follow Install Prerequisites to update GPU driver (optional) and install Conda. If you are a Linux user, visit the Install IPEX-LLM on Linux with Intel GPU, and follow Install Prerequisites to install GPU driver, Intel® oneAPI Base Toolkit 2024.0, and Conda.Setup
After the prerequisites installation, you should have created a conda environment with all prerequisites installed. Start the jupyter service in this conda environment:sentence-transformers
.
Note
You can also use https://pytorch-extension.intel.com/release-whl/stable/xpu/cn/
as the extra-indel-url.
Runtime Configuration
For optimal performance, it is recommended to set several environment variables based on your device:For Windows Users with Intel Core Ultra integrated GPU
For Windows Users with Intel Arc A-Series GPU
Note For the first time that each model runs on Intel iGPU/Intel Arc A300-Series or Pro A60, it may take several minutes to compile. For other GPU type, please refer to here for Windows users, and here for Linux users.
Basic Usage
Settingdevice
to "xpu"
in model_kwargs
when initializing IpexLLMBgeEmbeddings
will put the embedding model on Intel GPU and benefit from IPEX-LLM optimizations: