# Learning from emojis

**URL:** <https://discuss.huggingface.co/t/learning-from-emojis/11573>\
**Category:** 🤗 Course Projects\
**Created:** [November 10, 2021, 4:46pm UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573 "2021-11-10T16:46:56Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [November 10, 2021, 4:46pm UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/1 "2021-11-10T16:46:56Z")

</div>

> 👋 Please read the topic category [description](https://discuss.huggingface.co/t/about-the-course-projects-category/11510) to understand what this is all about

### Description

Emoticons are often used as a proxy for emotional content in social media posts or instant messaging chats. As a result, emojis are often used as a label to train text classifiers. The goal of this project is to create a Transformer-based implementation of [DeepEmoji](https://deepmoji.mit.edu/), a research project from MIT that studied this task with LSTMs.

### Model(s)

Any BERT-like model would be a good candidate for fine-tuning on an emoji dataset and you can get inspiration from models like these:

- [cardiffnlp/twitter-roberta-base-emoji](https://huggingface.co/cardiffnlp/twitter-roberta-base-emoji)

### Datasets

- [tweet\_eval](https://huggingface.co/datasets/tweet_eval)

### Challenges

To get better performance, you may want to perform domain adaptation by fine-tuning the language model on in-domain data. We recommend trying this approach only after building a baseline classifier.

### Desired project outcomes

- Create a Streamlit or Gradio app on [🤗 Spaces](https://huggingface.co/spaces) that can predict the top 5 emojis associated with a piece of text
- Don’t forget to push all your models and datasets to the Hub so others can build on them!

### Additional resources

- [https://huggingface.co/spaces/ml6team/emoji\_predictor](https://huggingface.co/spaces/ml6team/emoji_predictor) (a Space for inspiration)

### Discord channel

To chat and organise with other people interested in this project, head over to our [Discord](http://xwo7x.mjt.lu/lnk/CAAAAkdkZwAAAAAAAAAAALG-MTEAAYCr4H8AAAAAAAyFyQBhjpnimM4rcE5DT5ibCUtRT96tWwAMh8Y/15/U6BYNMNDksyyGG4jgtzPKQ/aHR0cHM6Ly9odWdnaW5nZmFjZS5jby9qb2luL2Rpc2NvcmQ) and:

- Follow the instructions on the `#join-course` channel
- Join the `learning-from-emojis` channel

Just make sure you comment here to indicate that you’ll be contributing to this project 🙂

---

<div class="post-metadata">

**Author:** ![saldera](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@saldera](https://discuss.huggingface.co/u/saldera)\
**Post date:** [November 14, 2021, 5:31am UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/2 "2021-11-14T05:31:25Z")

</div>

This project sounds interesting. I would like to work on something like this.

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [November 14, 2021, 10:51am UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/3 "2021-11-14T10:51:56Z")

</div>

Hey @saldera, I’ve added some details about the Discord channel associated with this project in case you and others wish to coordinate over there 🙂

---

<div class="post-metadata">

**Author:** ![adorkin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/adorkin/32/2704_2.png) [@adorkin](https://discuss.huggingface.co/u/adorkin)\
**Post date:** [November 15, 2021, 10:28am UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/4 "2021-11-15T10:28:54Z")

</div>

Hi,

I would like to participate, but I want to add a slight twist to the idea. So basically I’m thinking about fine-tuning a multilingual model (or bilingual for that matter) on tweet\_eval, and then performing sort of cross-lingual zero-shot classification on the other language(s) (it’s just Russian in my case). This works surprisingly well on MNLI which is, arguably, more difficult, so it’s worth a shot, I think.

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [November 15, 2021, 12:50pm UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/5 "2021-11-15T12:50:14Z")

</div>

Hey @adorkin, this sounds like a really nice idea!

---

<div class="post-metadata">

**Author:** ![adorkin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/adorkin/32/2704_2.png) [@adorkin](https://discuss.huggingface.co/u/adorkin)\
**Post date:** [November 16, 2021, 9:49am UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/6 "2021-11-16T09:49:20Z")

</div>

I made a really primitive [demo](https://huggingface.co/spaces/AlekseyDorkin/XlmRobertaTwitterEmoji). It seems to me that emojis in tweet eval are kind of same-ish, and, cosequently, predicted emojis are also similar for different texts. Any feedback?

---

<div class="post-metadata">

**Author:** ![adorkin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/adorkin/32/2704_2.png) [@adorkin](https://discuss.huggingface.co/u/adorkin)\
**Post date:** [November 16, 2021, 9:51am UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/7 "2021-11-16T09:51:13Z")

</div>

What I mean is that there’s essentially only one kind of sentiment for every text, which seems boring.

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [November 16, 2021, 10:06am UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/8 "2021-11-16T10:06:35Z")

</div>

Wow, congrats on tuning the model / building the Space so fast 🥳 !

I think you’re right that the model seems to only predict positive sentiments - what I suggest is looking at the distribution of emojis in `tweet_eval` and perhaps consider filtering the dataset for a select number of emojis that capture various emotions

 ![Screen Shot 2021-11-16 at 11.04.12](https://us1.discourse-cdn.com/hellohellohello/original/2X/e/e84dea4eebeaad38a1feb5871ed86300c17edccc.png)

---

<div class="post-metadata">

**Author:** ![adorkin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/adorkin/32/2704_2.png) [@adorkin](https://discuss.huggingface.co/u/adorkin)\
**Post date:** [November 16, 2021, 11:15am UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/9 "2021-11-16T11:15:10Z")

</div>

It is an option, however I don’t think it will change the results dramatically because, again, all the emojis in this particular dataset are not really that different even if you do filter them a bit (it’s still going to remain positive, basically). For example, what exactly distinguishes several different kinds of heart emojis? What I mean is that keeping, let’s say, only a smiley, a heart and a tree won’t really make it more interesting, unfortunately. There’s not even a sad emoji ☹

Meanwhile, the DeepEmoji demo definitely offers a much larger range of emojis. I can’t figure out what data it was trained on though. It would be nice to use it.

I was thinking about maybe doing sort of augmentation by means of replacing emotion tags with emojis in the same dataset in combination with the aforementioned filtering. It’s not an _exact_ solution, but it should be okay for a fun project.

---

<div class="post-metadata">

**Author:** ![adorkin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/adorkin/32/2704_2.png) [@adorkin](https://discuss.huggingface.co/u/adorkin)\
**Post date:** [November 16, 2021, 11:34am UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/10 "2021-11-16T11:34:46Z")

</div>

For reference, [here’s](https://raw.githubusercontent.com/cardiffnlp/tweeteval/main/datasets/emoji/mapping.txt) the full set of emojis in tweet eval.

---

<div class="post-metadata">

**Author:** ![akshay7](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@akshay7](https://discuss.huggingface.co/u/akshay7)\
**Post date:** [November 16, 2021, 11:55am UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/11 "2021-11-16T11:55:56Z")

</div>

I am also working on this, helping Aleksey with the UI and stuff

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [November 16, 2021, 12:11pm UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/12 "2021-11-16T12:11:23Z")

</div>

Thanks for digging into the label set - you’re totally right that this is pretty biased! I think your approach of mapping emoji tags to emojis could work with some historical twitter datasets (like [this](https://archive.org/search.php?query=collection%3Atwitterstream&sort=-publicdate)) to collect more diverse labels.

I saw that the DeepEmoji team released some [_benchmark_ datasets](https://github.com/bfelbo/DeepMoji/tree/master/data), but haven’t checked their content as to their use

---

<div class="post-metadata">

**Author:** ![adorkin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/adorkin/32/2704_2.png) [@adorkin](https://discuss.huggingface.co/u/adorkin)\
**Post date:** [November 19, 2021, 11:45am UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/13 "2021-11-19T11:45:38Z")

</div>

Okay, so I tried diversifying the labels using the approach that I mentioned previously, and I also added class weights like you showed in your tutorial. The outputs are a bit more reasonable now, although there’s evidently still not enough non-positive emojis to fill five slots.

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/2X/3/3c0eaca168848cf2623d5ae4eaa6a011aee23db2.png)  
[Here](https://huggingface.co/spaces/learningfromemojis/TwitterEmojis)’s the demo made with [akshay7](https://discuss.huggingface.co/u/akshay7)’s help.

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [November 19, 2021, 1:45pm UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/14 "2021-11-19T13:45:18Z")

</div>

Cool to hear that you could use the tricks from the tutorial! The Space is really nice and I think the model does a decent job at capturing the top 1-2 emojis 🙂

---

<div class="post-metadata">

**Author:** ![adorkin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/adorkin/32/2704_2.png) [@adorkin](https://discuss.huggingface.co/u/adorkin)\
**Post date:** [November 19, 2021, 1:58pm UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/15 "2021-11-19T13:58:37Z")

</div>

I think the most interesting thing here is that it also works fairly well with a language it was never trained on. Apparently It’s even able to pick up on the usage of brackets (instead of fully-fledged emojis) to express emotions, which is not a thing on the English-speaking internet, as far as I’m aware. I added some examples from twitter datasets to demonstrate that.

On a separate note, maybe it’s not entirely fair to expect the model to predict the same emojis that one would expect it to, because in many cases it’s not really possible to figure the exact emotion being expressed without extratextual cues that are partially substitued by emojis (and brackets, I guess) in the first place.

---

<div class="post-metadata">

**Author:** ![saldera](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@saldera](https://discuss.huggingface.co/u/saldera)\
**Post date:** [November 19, 2021, 8:02pm UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/16 "2021-11-19T20:02:37Z")

</div>

@adorkin @akshay7 This is really cool. Good job!

Unfortunately I haven’t been able to participate due to exams. 😭

---

<div class="post-metadata">

**Author:** ![akshay7](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@akshay7](https://discuss.huggingface.co/u/akshay7)\
**Post date:** [November 21, 2021, 1:16pm UTC](https://discuss.huggingface.co/t/learning-from-emojis/11573/17 "2021-11-21T13:16:37Z")

</div>

Hey @saldera, not an issue. Please try out the app though as I think its ready now [TwitterEmojis - a Hugging Face Space by learningfromemojis](https://huggingface.co/spaces/learningfromemojis/TwitterEmojis)
