GitHub - huggingface/torchMoji: A pyTorch implementation of the DeepMoji model:...
source link: https://github.com/huggingface/torchMoji
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
------ Update September 2018 ------
It's been a year since TorchMoji and DeepMoji were released. We're trying to understand how it's being used such that we can make improvements and design better models in the future.
You can help us achieve this by answering this 4-question Google Form. Thanks for your support!
TorchMoji
Read our blog post about the implementation process here.
TorchMoji is a pyTorch implementation of the DeepMoji model developped by Bjarke Felbo, Alan Mislove, Anders Søgaard, Iyad Rahwan and Sune Lehmann.
This 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.
Try the online demo of DeepMoji http://deepmoji.mit.edu! See the paper, blog post or FAQ for more details.
Overview
- torchmoji/ contains all the underlying code needed to convert a dataset to the vocabulary and use the model.
- examples/ contains short code snippets showing how to convert a dataset to the 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 the paper of DeepMoji if you use the model or code (see below for citation).
Installation
We assume that you're using Python 2.7-3.5 with pip installed.
First you need to install pyTorch (version 0.2+), currently by:
conda install pytorch -c pytorch
At the present stage the model can't make efficient use of CUDA. See details in the Hugging Face blog post.
When pyTorch is installed, run the following in the root directory to install the remaining dependencies:
pip install -e .
This will install the following dependencies:
Then, run the download script to downloads the pretrained torchMoji weights (~85MB) from here and put 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:
cd tests 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:
cd tests nosetests -v -a '!slow'
Disclaimer
This code has been tested to work with Python 2.7 and 3.5 on Ubuntu 16.04 and macOS Sierra machines. 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.
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}
}
Recommend
-
262
RetinaNet An implementation of RetinaNet in PyTorch.
-
173
PyTorch implementation of the YOLO (You Only Look Once) v2 The YOLOv2 is one of the most popular one-stage o...
-
127
README.md Max-Pooling Loss Loss Max-Pooling for Semantic Image Segmentation Installation Requirements To...
-
342
README.md PyTorch implementation of OpenAI's Finetuned Transformer Language Model This is a PyTorch implementation of the TensorFlow...
-
98
README.md PyTorch implementation of Google AI's BERT model with a script to load Google's pre-trained models Introduction This repository cont...
-
116
README.md PyTorch pretrained BigGAN An op-for-op PyTorch reimplementation of DeepMind's BigGAN model with the pre-trained weights from DeepMind.
-
12
Run your *raw* PyTorch training script on any kind of device Easy to integrate Accelerate was created for PyTorch users who like to...
-
6
Attention is all you need: A Pytorch Implementation This is a PyTorch implementation of the Transformer model in "Attention is All You Need" (Ashish Vaswani, Noam Shazeer, Niki Parmar, J...
-
2
This article was published as a part of the Data Science Blogathon. Introduction
-
2
本教程假定你已经对于 PyToch 训练一个简单模型有一定的基础理解。本教程将展示使用 3 种封装层级不同的方法调用 DDP (DistributedDataParallel) 进程,在多个 GPU 上训练同一个模型: 使用 pytorch.distributed 模块的原生 PyTorch DDP...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK