Run a Natural Language Processing (NLP) model from Hugging Face on Arm servers

Who is this for?

This is an introductory topic for software developers who want to learn how to run a natural language processing (NLP) model from Hugging Face using PyTorch on Arm based servers.

What will you learn?

After completing this Learning Path, you'll be able to perform the following tasks:

  • Deploy a PyTorch NLP model from Hugging Face on an Arm AArch64 CPU
  • Use the PyTorch profiler to analyze the execution time of the model

Prerequisites

Before starting, you'll need the following prerequisites:

Summary

AI-assisted

This summary was drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.

Close
?
You’ll run and profile a Hugging Face NLP model with PyTorch on an Arm AArch64 CPU. First, you’ll prepare an Ubuntu 22.04 LTS Arm server and install PyTorch, Transformers, and SciPy. You’ll then run a RoBERTa sentiment-analysis model and inspect its ranked labels and confidence scores. Finally, you’ll add the PyTorch Profiler and review the CPU execution time for individual operators.

Frequently asked questions

AI-assisted

These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.

Close
?
How can I analyze my own text with the example?
Replace the string assigned to text in sentiment-analysis.py, save the file, and run python sentiment-analysis.py again. The script preprocesses your text before passing it to the tokenizer and model.
How does the example handle usernames and links?
When you run the script, its preprocess function replaces words that start with @ and contain more than one character with @user. It replaces words that start with http with http before tokenization.
Which Hugging Face model should I use?
Use the cardiffnlp/twitter-roberta-base-sentiment-latest model.
What result should I expect when I run the model?
A successful run prints three ranked sentiment labels with confidence scores. The scores should sum to 1. The first line is the model’s strongest prediction.
How do I know that the PyTorch profiler captured my run?
You should see a table of CPU operators and their execution times before the classification output. The model_inference row summarizes the profiled inference region.
Next