Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 11 min read How-to mediumAdept

CPU Optimized Embeddings with πŸ€— Optimum Intel and fastRAG

Post-training static int8 quantization of BGE embedding models (small, base, large) with Optimum Intel, Intel Neural Compressor and IPEX gives up to 4.5x lower latency and up to 4x higher throughput on 4th-gen Xeon CPUs compared with a bf16 PyTorch baseline. Accuracy loss stays small: under 0.3% on MTEB reranking and up to 1.55% on retrieval. The guide covers calibration with a qasper subset, loading the model with IPEXModel, and the benchmark setup (ipexrun, TCMalloc, single socket). It also shows how to plug the quantized models into fastRAG's QuantizedBiEncoderRetriever and QuantizedBiEncoderRanker for RAG indexing and reranking.

Assumes: text embedding modelsHugging Face Transformersmodel quantization basicsRAG pipelines

Related posts

  • Blazing Fast SetFit Inference with πŸ€— Optimum Intel on Xeon

    Hugging Face mediumAdept

    Post-training static int8 quantization of a SetFit model body with Optimum Intel and Intel Neural Compressor speeds up inference on Xeon CPUs by up to 7.8x in throughput with negligible accuracy loss. The walkthrough calibrates on 100 rotten_tomatoes samples, quantizes a bge-small SetFit model with the IPEX backend, and benchmarks it against fp32 Transformers and IPEX bf16 with TorchScript. At batch size 1, latency drops from 15.69 ms to 4.55 ms (3.45x), model size shrinks from 127 MB to 45 MB, and sst2 accuracy moves only from 88.4% to 88.1%.

  • Smaller is better: Q8-Chat, an efficient generative AI experience on Xeon

    Hugging Face easyNovice

    SmoothQuant enables accurate 8-bit (INT8) post-training quantization of LLMs by mathematically shifting activation outliers into the weights, which makes Transformer layers quantization-friendly. Intel applied it to OPT, LLaMA, Alpaca, Vicuna, BloomZ and MPT-7B-chat models, roughly halving model size. On many LM Evaluation Harness tasks the quantized models matched or slightly improved accuracy, and most remaining tasks degraded only marginally. Running on a single 32-core Sapphire Rapids Xeon socket at batch size 1, the quantized models deliver low per-token latency, demonstrated in the Q8-Chat Space, with Optimum Intel integration via Intel Neural Compressor planned.

  • Intel and Hugging Face Partner to Democratize Machine Learning Hardware Acceleration

    Hugging Face mediumAdept

    Intel has joined Hugging Face's Hardware Partner Program, and the two are collaborating on Optimum Intel, an open-source library built on Intel Neural Compressor that applies quantization, pruning and distillation to Transformer models on Xeon CPUs. A worked example applies post-training dynamic quantization to a DistilBERT review classifier with a 5% tolerable accuracy loss and up to 10 tuning trials. The run converts all 38 Linear and 2 Embedding operators to INT8, dropping accuracy from 0.574 to 0.546 while making evaluation 1.34x faster.

  • Accelerating PyTorch Transformers with Intel Sapphire Rapids - part 2

    Hugging Face mediumAdept

    Intel Sapphire Rapids CPUs with AMX instructions, combined with Hugging Face Optimum Intel running in bfloat16 with JIT compilation, cut p99 inference latency for DistilBERT, BERT and RoBERTa text classification by roughly 3x compared with vanilla Transformers on Ice Lake. The benchmark uses EC2 c6i.16xlarge and r7iz.16xlarge-metal instances, short (16-token) and long (128-token) inputs, single and batch-of-8 predictions, and libtcmalloc. Optimum needs only a small wrapper around the existing pipeline code, and the results show single-digit millisecond latency on long sequences without a GPU.

  • Introducing Optimum: The Optimization Toolkit for Transformers at Scale

    Hugging Face easyNovice

    Optimum is a new open source Hugging Face library that targets production performance for Transformer models by wrapping hardware-specific acceleration tooling built with hardware partners. Its first integration uses Intel Neural Compressor to quantize Transformers for Intel Xeon CPUs. Quantization is hard to do by hand: ops must be swapped for quantized kernels, quantize/dequantize nodes inserted, observers, schemes and int8/uint8/int16 types chosen, and accuracy loss balanced. Neural Compressor handles this through post-training, quantization-aware and dynamic quantization driven by a YAML config that can be stored on the Model Hub.

The quest for software engineering knowledge.

Look:
Layout: