DeepMoji
State-of-the-art deep learning model for analyzing sentiment, emotion, sarcasm etc.
Install / Use
/learn @bfelbo/DeepMojiREADME
------ Update September 2023 ------
The online demo is no longer available as it's not possible for us to renew the certificate. The code in this repo still works, but you might have to make some changes for it to work in Python 3 (see the open PRs). You can also check out the PyTorch version of this algorithm called torchMoji made by HuggingFace.
DeepMoji

(click image for video demonstration)
DeepMoji is a model trained on 1.2 billion tweets with emojis to understand how language is used to express emotions. Through transfer learning the model can obtain state-of-the-art performance on many emotion-related text modeling tasks.
See the paper or blog post for more details.
Overview
- deepmoji/ contains all the underlying code needed to convert a dataset to our vocabulary and use our model.
- examples/ contains short code snippets showing how to convert a dataset to our vocabulary, load up the model and run it on that dataset.
- scripts/ contains code for processing and analysing datasets to reproduce results in the paper.
- model/ contains the pretrained model and vocabulary.
- data/ contains raw and processed datasets that we include in this repository for testing.
- tests/ contains unit tests for the codebase.
To start out with, have a look inside the examples/ directory. See score_texts_emojis.py for how to use DeepMoji to extract emoji predictions, encode_texts.py for how to convert text into 2304-dimensional emotional feature vectors or finetune_youtube_last.py for how to use the model for transfer learning on a new dataset.
Please consider citing our paper if you use our model or code (see below for citation).
Frameworks
This code is based on Keras, which requires either Theano or Tensorflow as the backend. If you would rather use pyTorch there's an implementation available here, which has kindly been provided by Thomas Wolf.
Installation
We assume that you're using Python 2.7 with pip installed. As a backend you need to install either Theano (version 0.9+) or Tensorflow (version 1.3+). Once that's done you need to run the following inside the root directory to install the remaining dependencies:
pip install -e .
This will install the following dependencies:
- Keras (the library was tested on version 2.0.5 but anything above 2.0.0 should work)
- scikit-learn
- h5py
- text-unidecode
- emoji
Ensure that Keras uses your chosen backend. You can find the instructions here, under the Switching from one backend to another section.
Run the included script, which downloads the pretrained DeepMoji weights (~85MB) from here and places them in the model/ directory:
python scripts/download_weights.py
Testing
To run the tests, install nose. After installing, navigate to the tests/ directory and run:
nosetests -v
By default, this will also run finetuning tests. These tests train the model for one epoch and then check the resulting accuracy, which may take several minutes to finish. If you'd prefer to exclude those, run the following instead:
nosetests -v -a '!slow'
Disclaimer
This code has been tested to work with Python 2.7 on an Ubuntu 16.04 machine. It has not been optimized for efficiency, but should be fast enough for most purposes. We do not give any guarantees that there are no bugs - use the code on your own responsibility!
Contributions
We welcome pull requests if you feel like something could be improved. You can also greatly help us by telling us how you felt when writing your most recent tweets. Just click here to contribute.
License
This code and the pretrained model is licensed under the MIT license.
Benchmark datasets
The benchmark datasets are uploaded to this repository for convenience purposes only. They were not released by us and we do not claim any rights on them. Use the datasets at your responsibility and make sure you fulfill the licenses that they were released with. If you use any of the benchmark datasets please consider citing the original authors.
Twitter dataset
We sadly cannot release our large Twitter dataset of tweets with emojis due to licensing restrictions.
Citation
@inproceedings{felbo2017,
title={Using millions of emoji occurrences to learn any-domain representations for detecting sentiment, emotion and sarcasm},
author={Felbo, Bjarke and Mislove, Alan and S{\o}gaard, Anders and Rahwan, Iyad and Lehmann, Sune},
booktitle={Conference on Empirical Methods in Natural Language Processing (EMNLP)},
year={2017}
}
Related Skills
claude-opus-4-5-migration
83.3kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
model-usage
337.7kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
TrendRadar
49.8k⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。
mcp-for-beginners
15.7kThis open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
