---
title: "Blazing Fast SetFit Inference with 🤗 Optimum Intel on Xeon"
description: "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."
url: "https://swe.quest/articles/blazing-fast-setfit-inference-with-optimum-intel-on-xeon-804c53c4c80ba1a3"
canonical: "https://huggingface.co/blog/setfit-optimum-intel"
source: "Hugging Face"
published: "2024-04-03"
difficulty: "medium"
kind: "How-to"
reading_minutes: 6
tags: ["inference","performance","hardware","python"]
---

# Blazing Fast SetFit Inference with 🤗 Optimum Intel on Xeon

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-04-03, 6 min read, How-to. Original: [https://huggingface.co/blog/setfit-optimum-intel](https://huggingface.co/blog/setfit-optimum-intel)

## Summary

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%.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- PyTorch basics
- Hugging Face Transformers
- model quantization concepts ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))

## Keywords

SetFit, Optimum Intel, Intel Neural Compressor, Intel Extension for PyTorch, Intel Xeon, Intel AMX, bge-small-en-v1.5

## Related posts

- [CPU Optimized Embeddings with 🤗 Optimum Intel and fastRAG](https://swe.quest/articles/cpu-optimized-embeddings-with-optimum-intel-and-fastrag-e206611a492390e0.md): Hugging Face · 2024-03-15 · Medium · 11 min read · Inference & serving, RAG & retrieval, Performance engineering, Hardware, Python
  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.
- [Intel and Hugging Face Partner to Democratize Machine Learning Hardware Acceleration](https://swe.quest/articles/intel-and-hugging-face-partner-to-democratize-machine-learning-hardware-0de59c0019e6704c.md): Hugging Face · 2022-06-15 · Medium · 7 min read · Inference & serving, Machine learning, Performance engineering, Hardware
  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.
- [Introducing Optimum: The Optimization Toolkit for Transformers at Scale](https://swe.quest/articles/introducing-optimum-the-optimization-toolkit-for-transformers-at-scale-a074b17981960e1a.md): Hugging Face · 2021-09-14 · Easy · 4 min read · Inference & serving, Machine learning, Open source, Hardware
  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.
- [Accelerate your models with 🤗 Optimum Intel and OpenVINO](https://swe.quest/articles/accelerate-your-models-with-optimum-intel-and-openvino-6481f69a8bf224aa.md): Hugging Face · 2022-11-02 · Medium · 5 min read · Inference & serving, Python, Hardware, Computer vision
  Optimum Intel now integrates OpenVINO, letting Transformers models run on OpenVINO Runtime across Intel processors and be quantized with the Neural Network Compression Framework (NNCF).
- [Smaller is better: Q8-Chat, an efficient generative AI experience on Xeon](https://swe.quest/articles/smaller-is-better-q8-chat-an-efficient-generative-ai-experience-on-xeon-67e9bd0a15445b38.md): Hugging Face · 2023-05-16 · Easy · 5 min read · Inference & serving, LLMs, Hardware
  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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
