๐ DeBERTa Emotion Predictor
This package provides a DeBERTa-based model for predicting emotions in Japanese text. It uses fine-tuned DeBERTa models to estimate emotions in Japanese texts. You can easily obtain the predicted emotion labels and the confidence of the positive class for each text using models for eight emotions (Joy, Sadness, Anticipation, Surprise, Anger, Fear, Disgust, Trust).
๐ Quick Start
This package simplifies the process of emotion prediction in Japanese text. With the pre - trained DeBERTa models, you can quickly get emotion prediction results for your text.
โจ Features
- Eight - emotion Estimation: Utilize fine - tuned models for each emotion to perform emotion estimation on texts.
- Flexible Input Formats: Accept single texts, text lists, or pandas Series as input and return results in DataFrame format.
- Efficient Inference: Designed to load models to the GPU only when necessary to reduce GPU memory usage.
๐ฆ Installation
Use pip to install the package:
pip install deberta-emotion-predictor
Note that torch, transformers, and pandas are also required for the operation:
pip install torch
pip install transformers
pip install pandas
If you want to use a GPU, you need to install the NVIDIA GPU driver. Please refer to other materials for this.
๐ป Usage Examples
Basic Usage
from deberta_emotion_predictor import DeBERTaEmotionPredictor
predictor = DeBERTaEmotionPredictor()
result = predictor.predict_emotions("ไปๆฅใฏใจใฆใๅฌใใ๏ผ")
predictor.show_emotions(result)
Advanced Usage
Passing a list of texts
sample_texts = [
"ใใใ ไบฌ้ฝใ่กใใใ",
"ใใใฐใใฒใจใฎใใใใฐใใชใๆ้ใ"
]
result_df = predictor.predict_emotions(sample_texts)
predictor.show_emotions(result_df)
Passing a single text
result_single = predictor.predict_emotions("ๆฐใใๆใๆฅใใ")
print(result_single)
Output DataFrame
The output DataFrame contains eight columns representing the presence of each emotion and the probability values of each emotion.
print(result_df)
๐ Documentation
Directory Structure
deberta_emotion_predictor/
โโโ README.md # This description file
โโโ deberta_emotion_predictor.py # Implementation of the DeBERTaEmotionPredictor class
โ โโโ tokenizer_DeBERTa_v3_large/ # Tokenizer
โโโ setup.py
โโโ pyproject.toml
โโโ README.md
โโโ LICENSE
โโโ usage.py
Required Environment
- Python 3.6 or higher
- PyTorch
- transformers
- pandas
๐ License
This project is licensed under the Creative Commons Attribution - ShareAlike 4.0 International (CC BY - SA 4.0) License.
Copyright (c) 2025 Yoichi Takenaka
This work is licensed under the Creative Commons Attribution - ShareAlike 4.0 International License. To view a copy of this license, visit https://creativecommons.org/licenses/by - sa/4.0/.
This project is based on:
- DeBERTa (https://huggingface.co/microsoft/deberta - v3 - large), licensed under the MIT License.
- DeBERTa Japanese Model (https://huggingface.co/globis - university/deberta - v3 - japanese - large), licensed under the CC BY - SA 4.0 License.
Any modifications or derivative works must also be distributed under the same CC BY - SA 4.0 License.
โ ๏ธ Important Note
Since eight types of DeBERTa models are downloaded from Hugging - face, the first startup takes a long time. Subsequent executions will be faster.