---
title: "Running Privacy-Preserving Inferences on Hugging Face Endpoints"
description: "Zama's Concrete ML models, compiled for Fully Homomorphic Encryption (FHE), can be deployed as Hugging Face Inference Endpoints using custom inference handlers."
url: "https://swe.quest/articles/running-privacy-preserving-inferences-on-hugging-face-endpoints-de0383d315f32496"
canonical: "https://huggingface.co/blog/fhe-endpoints"
source: "Hugging Face"
published: "2024-04-16"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["privacy","inference","cryptography","machine-learning","python"]
---

# Running Privacy-Preserving Inferences on Hugging Face Endpoints

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-04-16, 8 min read, How-to. Original: [https://huggingface.co/blog/fhe-endpoints](https://huggingface.co/blog/fhe-endpoints)

## Summary

Zama's Concrete ML models, compiled for Fully Homomorphic Encryption (FHE), can be deployed as Hugging Face Inference Endpoints using custom inference handlers. Clients quantize and encrypt inputs locally, upload FHE evaluation keys in chunks (about 70 MB), and receive encrypted predictions that only they can decrypt. The handler exposes save\_key, append\_key and inference methods. Keys live in endpoint RAM, so they are lost on restart and not shared across replicas, and machines top out at 8 vCPUs. Measured latencies range from 0.4 s for logistic regression to 24 s for a CNN on MNIST.

Written by swe.quest, not by the author.

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

## Topics

- [Privacy](https://swe.quest/tags/privacy.md) (Security)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Cryptography](https://swe.quest/tags/cryptography.md) (Security)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Python virtual environments ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- basic ML model training ([easy posts on Machine learning](https://swe.quest/tags/machine-learning.md?difficulty=easy))
- homomorphic encryption concept ([easy posts on Cryptography](https://swe.quest/tags/cryptography.md?difficulty=easy))

## Keywords

Concrete ML, Fully Homomorphic Encryption, Hugging Face Inference Endpoints, Zama, custom inference handlers

## Related posts

- [Sentiment Analysis on Encrypted Data with Homomorphic Encryption](https://swe.quest/articles/sentiment-analysis-on-encrypted-data-with-homomorphic-encryption-62bd5104a9f4964a.md): Hugging Face · 2022-11-17 · Medium · 8 min read · Privacy, Cryptography, Machine learning, Inference & serving, Python
  Sentiment classification can run on encrypted text by computing a transformer (RoBERTa) hidden representation on the client, then running a quantized XGBoost classifier under fully homomorphic encryption with Concrete-ML.
- [Towards Encrypted Large Language Models with FHE](https://swe.quest/articles/towards-encrypted-large-language-models-with-fhe-6e22ac5193234b25.md): Hugging Face · 2023-08-02 · Hard · 7 min read · Cryptography, Privacy, Inference & serving, LLMs
  A single attention head of GPT2's first multi-head attention layer can run on encrypted data using TFHE via Zama's Concrete-Python and Concrete-ML, with the rest of the model executing in plaintext on the client.
- [Why we’re switching to Hugging Face Inference Endpoints, and maybe you should too](https://swe.quest/articles/why-we-re-switching-to-hugging-face-inference-endpoints-and-maybe-you-should-too-bfdcddeceab350fa.md): Hugging Face · 2023-02-15 · Medium · 6 min read · Inference & serving, ML platforms, Cost optimization, Cloud platforms
  A team moved CPU-based transformer inference off a self-built FastAPI + Docker + AWS ECS/Fargate stack onto Hugging Face Inference Endpoints, collapsing deployment to train, push to Hub, deploy.
- [Deploy Embedding Models with Hugging Face Inference Endpoints](https://swe.quest/articles/deploy-embedding-models-with-hugging-face-inference-endpoints-e85e7e272a9c97bc.md): Hugging Face · 2023-10-24 · Medium · 5 min read · Inference & serving, RAG & retrieval, ML platforms
  Open-source embedding models such as BAAI/bge-base-en-v1.5 can be deployed on Hugging Face Inference Endpoints using Text Embeddings Inference (TEI), which offers token-based dynamic batching, Flash Attention, Candle and cuBLASLt kernels, safetensors loading, small images for fast boot, and OpenTelemetry/Prometheus support.
- [Getting Started with Hugging Face Inference Endpoints](https://swe.quest/articles/getting-started-with-hugging-face-inference-endpoints-d2f6b69d4c5ca480.md): Hugging Face · 2022-10-14 · Medium · 5 min read · Inference & serving, ML platforms, Cloud platforms
  Hugging Face Inference Endpoints deploys Hub models to managed cloud infrastructure in a few clicks, demonstrated here with a fine-tuned Swin image classifier on a GPU instance in AWS eu-west-1.

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)
