Source-linked AI summary
TweetNLP: Cutting-Edge Natural Language Processing for Social Media
Jose Camacho-Collados, Kiamehr Rezaee, Talayeh Riahi, Asahi Ushio, Daniel Loureiro, Dimosthenis Antypas, Joanne Boisson, Luis Espinosa-Anke, Fangyu Liu, Eugenio Martínez-Cámara, Gonzalo Medina, Thomas Buhrmann, Leonardo Neves, Francesco Barbieri
TL;DR
NLP for social media must address noisy, multilingual, fast-changing text that can undermine traditional task performance. TweetNLP packages Twitter-specialized, relatively lightweight Transformer models with a Python library, online demo, and tutorial across many tasks. Its public tools support model use and inspection, while the authors note ongoing scope and bias limitations.
Problem
Social-media NLP must account for noise, multilinguality, slang, immediacy, limited context, and platform-specific constraints that make traditional NLP tasks suboptimal.
Source: §1 · p. 1Method
TweetNLP continually pre-trains base-sized RoBERTa- and XLM-R-based models on Twitter data, fine-tunes them for social-media tasks, and distributes them through a Python library and online demo.
Source: §1 · p. 1, §3.1 · p. 2, §3.2 · p. 3Results
TweetNLP provides a broad, accessible platform spanning popular social-media NLP tasks, with models designed to run on standard computers or free cloud services.
Source: §1 · p. 1, §3.1 · p. 2, §8 · p. 7Takeaways & Limitations
The Python library, online demo, and tutorial enable both programmers and non-programmers to use and inspect Twitter NLP models.
Source: §8 · p. 7
Abstract
from arXiv · showhide
In this paper we present TweetNLP, an integrated platform for Natural Language Processing (NLP) in social media. TweetNLP supports a diverse set of NLP tasks, including generic focus areas such as sentiment analysis and named entity recognition, as well as social media-specific tasks such as emoji prediction and offensive language identification. Task-specific systems are powered by reasonably-sized Transformer-based language models specialized on social media text (in particular, Twitter) which can be run without the need for dedicated hardware or cloud services. The main contributions of TweetNLP are: (1) an integrated Python library for a modern toolkit supporting social media analysis using our various task-specific models adapted to the social domain; (2) an interactive online demo for codeless experimentation using our models; and (3) a tutorial covering a wide variety of typical social media applications.
1 Introduction
Social media provides valuable behavioral data, but its noisy and fast-changing communication creates challenges for NLP. TweetNLP addresses this gap with Twitter-specialized models, accessible tools, and real-time analysis.
- Social media text includes noise, multilinguality, slang, immediacy, limited context, length restrictions, and emojis that standard NLP must handle.Source: §1 · p. 1
- TweetNLP integrates Twitter-trained Transformer models fine-tuned for social-media NLP tasks.Source: §1 · p. 1
- The platform provides a Python API, an interactive online demo, and real-time Twitter analysis.Source: §1 · pp. 1–2
- Over 15M downloads made TweetNLP’s sentiment model the most downloaded model in Hugging Face’s model hub in January 2022.Source: §1 · p. 1
2 Related Work
Existing NLP libraries are broad but generally not specialized for social media, while social-media-specific tools have focused mainly on lower-level linguistic tasks. TweetNLP is positioned as a broader Twitter-oriented alternative.
- General-purpose libraries such as CoreNLP, Stanza, spaCy, and Hugging Face Transformers are not specialized for social media or Twitter.Source: §2 · p. 2
- Earlier social-media libraries mainly addressed tokenization, part-of-speech tagging, and dependency parsing.Source: §2 · p. 2
- TweebankNLP provides Twitter-specific models for tokenization, lemmatization, NER, part-of-speech tagging, and dependency parsing.Source: §2 · p. 2
3 Models and Functionalities
TweetNLP combines Twitter-adapted Transformer models, task-specific fine-tuning, and embeddings across a broad set of social-media NLP functionalities. Its models use relatively small base architectures intended for standard hardware and free cloud tiers.
3.1 Language models
- TweetNLP uses RoBERTa and XLM-R checkpoints that are continually pre-trained on Twitter-specific corpora.Source: §3.1 · p. 2
- RoBERTa-base and XLM-R-base architectures support efficient execution on standard hardware and free cloud-computing tiers, including without GPU support.Source: §3.1 · p. 2
- The model family includes TweetEval, continually updated TimeLMs, and multilingual XLM-T trained on over thirty languages.Source: §3.1 · p. 2
3.2 Supported tasks
- TweetNLP fine-tunes its models for classification tasks and uses T-NER for named entity recognition.Source: §3.2 · p. 2
- Supported tasks include sentiment, emotion, emoji, irony, hate-speech, offensive-language, stance, topic classification, and named entity recognition.Source: §3.2 · p. 3
- Sentiment analysis predicts positive, neutral, or negative labels, while topic classification assigns one or more of 19 topics.Source: §3.2 · p. 3
3.3 Embeddings
- TweetNLP also releases word and tweet embeddings for applications including similarity analysis and tweet retrieval.Source: §3.3 · pp. 3–4
3.2 Supported tasks
- Topic-classification and named-entity-recognition datasets were internally annotated and were still being prepared for public release.Source: §3.3 · p. 3
4 TweetNLP Python library
The TweetNLP Python library provides pip-installable access to task-specific models through simple loading and prediction functions. It also supports custom fine-tuned models.
- TweetNLP is distributed through PyPI and can be installed with pip.Source: §4 · p. 4
- The library loads task-specific models in the background and exposes predefined functions for predictions on tweets or sentences.Source: §4 · p. 4
- Users can load sentiment, tweet-embedding, and masked-language models through the same simple API pattern.Source: §4 · p. 4
- Custom loading of existing fine-tuned language models not included in TweetNLP is also supported.Source: §4 · p. 4
5 Tutorials
TweetNLP provides instructive Google Colab tutorials that guide users through social-media NLP workflows, from using specialized models to retrieving data, fine-tuning, embeddings, and temporal language models.
Tutorial platform
- The tutorials provide starter code and examples for users with varying experience in NLP and social-media processing.They expose the underlying Python code alongside the TweetNLP library.Source: §5 · p. 4
Tutorials
- The introduction tutorial demonstrates specialized social-media models across tasks including sentiment analysis and named entity recognition.Source: §5 · p. 4
Data collection
- The data tutorial explains Twitter API interaction and retrieving tweets using hashtags or keywords.Source: §5 · p. 4
Model adaptation
- The custom fine-tuning tutorial covers adapting language models to specific tasks and evaluating them on TweetEval.It uses TweetEval data and its unified format.Source: §5 · p. 4
Representations
- The word-embeddings tutorial covers training embeddings on custom data and obtaining similarity scores or nearest-neighbor words.Source: §5 · p. 4
Temporal models
- The language-models-over-time tutorial uses TimeLMs to access models trained during short periods from 2019 onward.Source: §5 · p. 4
Representations
- The tweet-embeddings tutorial shows how vector representations support tweet similarity and retrieval.Source: §5 · p. 4
6 Demo
TweetNLP offers a web-based demo for codeless experimentation with its social-media models. Users can analyze tweets and hashtags, predict masked words, compare tweet similarity, and identify named entities.
Web demo
- The comprehensive web demo integrates TweetNLP models so users can test them and obtain predictions without writing code.Source: §6 · p. 4
Tweet classification
- Tweet classification accepts sentences, tweets, or tweet URLs and displays prediction confidence, including English tasks and multilingual sentiment analysis.Source: §6 · p. 5
Hashtag analysis
- Hashtag analysis retrieves tweets for a chosen keyword, date interval, task, and language, then computes aggregated results.Source: §6 · p. 5
Word prediction
- Word prediction ranks likely replacements for a masked word using a masked language model.Source: §6 · p. 5
Tweet similarity
- Tweet similarity displays a 0-100 cosine similarity score for two short text pieces using the default tweet-embedding model.Source: §6 · p. 5
Named Entity Recognition
- Named Entity Recognition locates named entities in a tweet or sentence and infers their types.Source: §6 · p. 5
7 Evaluation
TweetNLP is evaluated across nine Twitter-based tasks using default Twitter-specific language models and established comparison systems. Results show strong cross-task performance, multilingual gains from in-domain training, and mixed but competitive embedding behavior on standard benchmarks.
Experimental setting
- Evaluation uses TweetEval datasets for tweet classification tasks except topic classification, alongside the train/validation/test splits described for the supported tasks.Source: §7.1 · p. 5
- Default models use TimeLMs-21 for English and XLM-T for other languages and multilingual tasks, fine-tuned to each corresponding task.Source: §7.1 · p. 6
- Comparison systems include frequency-based SVM, fastText, BiLSTM, RoBERTa variants, the original TweetEval model, and BERTweet.Source: §7.1 · p. 6
Results
- The default TimeLMs-21 model achieves the overall results on most of the nine Twitter-based tasks, especially versus a comparable general-purpose RoBERTa model.Source: §7.2 · p. 6
Caveat
- BERTweet’s Irony result overlaps with its pre-training corpus and the Irony dataset, which was constructed using distant supervision.Source: §7.2 · p. 6
Results
- XLM-T achieves the best overall multilingual sentiment-analysis results in all evaluated languages against XLM-R and fastText.Source: §7.2 · p. 6
- 0.77 (WS-Sim), 0.72 (WS-Rel), 0.69 (SemEval), and 0.79 (MEN) are the Spearman correlations for the Twitter word embeddings, which outperform standard fastText on two datasets.Source: §7.2 · p. 6
- Tweet embeddings significantly outperform all-mpnet-base-v2 on tweet-reply retrieval, while all-mpnet-base-v2 performs best on the STS-Benchmark.Source: §7.2 · p. 7
8 Conclusion and Future Work
TweetNLP is an all-round social-media NLP platform powered by relatively lightweight Twitter-trained models adapted to multiple tasks. It provides an online demo, Python library, and tutorial, while future work targets new tasks, datasets, platforms, and languages.
- TweetNLP provides relatively lightweight language models trained on Twitter and adapted to popular social-media NLP tasks.Source: §8 · p. 7
- The platform combines an online demo, Python library, and tutorial for users with different levels of expertise.Source: §8 · p. 7
- TweetNLP supports inspection by non-programmers to help identify harmful biases or errors and improve models in the future.Source: §8 · p. 7
- Future work will add models and tasks, develop social-media datasets, extend beyond tweet classification, and support additional platforms and languages.Source: §8 · p. 7
9 Impact Statement
TweetNLP uses social-media data, particularly Twitter, while addressing privacy and content risks through anonymization and content removal efforts. The authors caution that models trained on this data may amplify existing platform biases.
A Languages supported
The sentiment-analysis demo, including hashtag analysis, supports English plus a broad set of additional languages. These languages use an XLM-T multilingual model and the Twitter API.
- The sentiment-analysis demo supports English and numerous additional languages, including Arabic, Chinese, French, German, Hindi, Japanese, Korean, Persian, and Vietnamese.Source: A Languages supported · p. 11
- The supported languages use both an XLM-T multilingual model and the Twitter API.Source: A Languages supported · p. 11