Sentiment Analysis on Encrypted Data with Homomorphic Encryption

📰 Hugging Face Blog

Perform sentiment analysis on encrypted data using homomorphic encryption with the Concrete-ML library

advanced Published 17 Nov 2022
Action Steps
  1. Setup the environment with Concrete-ML library
  2. Use a public dataset for sentiment analysis
  3. Represent text using a transformer
  4. Classify with XGBoost
  5. Predict over encrypted data with Concrete-ML
  6. Deploy the model to the cloud
Who Needs to Know This

Data scientists and machine learning engineers can benefit from this tutorial to build privacy-preserving sentiment analysis models, while software engineers and devops teams can learn about deployment to the cloud

Key Insight

💡 Homomorphic encryption enables computation on encrypted data without decryption, making it suitable for privacy-sensitive applications

Share This
🔒 Perform sentiment analysis on encrypted data with Concrete-ML library! #homomorphicencryption #sentimentanalysis

Key Takeaways

Perform sentiment analysis on encrypted data using homomorphic encryption with the Concrete-ML library

Full Article

Published Time: 2022-11-17T00:00:00.146Z

# Sentiment Analysis on Encrypted Data with Homomorphic Encryption

[![Image 1: Hugging Face's logo](https://huggingface.co/front/assets/huggingface_logo-noborder.svg)Hugging Face](https://huggingface.co/)

* [Models](https://huggingface.co/models)
* [Datasets](https://huggingface.co/datasets)
* [Spaces](https://huggingface.co/spaces)
* [Buckets new](https://huggingface.co/storage)
* [Docs](https://huggingface.co/docs)
* [Enterprise](https://huggingface.co/enterprise)
* [Pricing](https://huggingface.co/pricing)
*
*
* * *

* [Log In](https://huggingface.co/login)
* [Sign Up](https://huggingface.co/join)

[Back to Articles](https://huggingface.co/blog)

# [](https://huggingface.co/blog/sentiment-analysis-fhe#sentiment-analysis-on-encrypted-data-with-homomorphic-encryption) Sentiment Analysis on Encrypted Data with Homomorphic Encryption

Published November 17, 2022

[Update on GitHub](https://github.com/huggingface/blog/blob/main/sentiment-analysis-fhe.md)

[- [x] Upvote 3](https://huggingface.co/login?next=%2Fblog%2Fsentiment-analysis-fhe)
* [![Image 2](https://huggingface.co/avatars/b2725bb163fa15d6c5856121780d52eb.svg)](https://huggingface.co/Csplk "Csplk")
* [![Image 3](https://cdn-avatars.huggingface.co/v1/production/uploads/1658840143259-62dad700f8148e3d4b514343.png)](https://huggingface.co/binoua "binoua")
* [![Image 4](https://huggingface.co/avatars/e780c8c836ef4d8bc87d9819c1334f1e.svg)](https://huggingface.co/bhosalemahesh899 "bhosalemahesh899")

[![Image 5: Jordan Frery's avatar](https://huggingface.co/avatars/81a6dd1b89dd988827a2eb944f233000.svg)](https://huggingface.co/jfrery-zama)

[Jordan Frery jfrery-zama Follow](https://huggingface.co/jfrery-zama)

guest

* [Setup the environment](https://huggingface.co/blog/sentiment-analysis-fhe#setup-the-environment "Setup the environment")

* [Using a public dataset](https://huggingface.co/blog/sentiment-analysis-fhe#using-a-public-dataset "Using a public dataset")

* [Text representation using a transformer](https://huggingface.co/blog/sentiment-analysis-fhe#text-representation-using-a-transformer "Text representation using a transformer")

* [Classifying with XGBoost](https://huggingface.co/blog/sentiment-analysis-fhe#classifying-with-xgboost "Classifying with XGBoost")

* [Predicting over encrypted data](https://huggingface.co/blog/sentiment-analysis-fhe#predicting-over-encrypted-data "Predicting over encrypted data")

* [Deployment](https://huggingface.co/blog/sentiment-analysis-fhe#deployment "Deployment")

* [Full example in a Hugging Face Space](https://huggingface.co/blog/sentiment-analysis-fhe#full-example-in-a-hugging-face-space "Full example in a Hugging Face Space")

* [Conclusion](https://huggingface.co/blog/sentiment-analysis-fhe#conclusion "Conclusion")

It is well-known that a sentiment analysis model determines whether a text is positive, negative, or neutral. However, this process typically requires access to unencrypted text, which can pose privacy concerns.
Homomorphic encryption is a type of encryption that allows for computation on encrypted data without needing to decrypt it first. This makes it well-suited for applications where user's personal and potentially sensitive data is at risk (e.g. sentiment analysis of private messages).

This blog post uses the [Concrete-ML library](https://github.com/zama-ai/concrete-ml), allowing data scientists to use machine learning models in fully homomorphic encryption (FHE) settings without any prior knowledge of cryptography. We provide a practical tutorial on how to use the library to build a sentiment analysis model on encrypted data.

The post covers:

* transformers
* how to use transformers with XGBoost to perform sentiment analysis
* how to do the training
* how to use Concrete-ML to turn predictions into predictions over encrypted data
* how to [deploy to the cloud](https://docs.zama.ai/concrete-ml/getting-star
Read full article → ← Back to Reads

Related Videos

5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Customize NotebookLM Banners & Notebook Summaries
Customize NotebookLM Banners & Notebook Summaries
Growth Learner
NotebookLM Power User Tip: Validate & Improve Deep Research
NotebookLM Power User Tip: Validate & Improve Deep Research
Growth Learner
Gemini Project Notebooks: Way Better Than Expected! (NotebookLM Syncing)
Gemini Project Notebooks: Way Better Than Expected! (NotebookLM Syncing)
Growth Learner
Generate Free AI Infographics with Gemini & Nano Banana in 30 Seconds!
Generate Free AI Infographics with Gemini & Nano Banana in 30 Seconds!
Growth Learner
Gemini Creates Progress Bars For You Without Typing Formulas
Gemini Creates Progress Bars For You Without Typing Formulas
Growth Learner