A DeBERTa-based emotion predictor for Japanese text.
Project description
DeBERTa Emotion Predictor
This package provides a DeBERTa-based model for predicting emotions in Japanese text.
DeBERTa Emotion Predictor は、ファインチューニング済みの DeBERTa モデルを用いて日本語テキストの感情推定を行う Python パッケージです。8 つの感情(Joy, Sadness, Anticipation, Surprise, Anger, Fear, Disgust, Trust)に対するそれぞれのモデルを利用し、各テキストに対する感情の予測ラベルと肯定クラスの確信度を簡単に取得できます。
Install(インストール)
pip を使います。
pip install deberta-emotion-predictor
## Usage (おためし利用)
from deberta_emotion_predictor import DeBERTaEmotionPredictor
predictor = DeBERTaEmotionPredictor()
result = predictor.predict_emotions("今日はとても嬉しい!")
print(result)
注)Hugging-face から8種類のDeBERTaをダウンロードするため、初回起動に大変時間がかかります。二回目以降の実行から速くなります。
サンプル実行ファイル usage.py もご覧ください
python usage.py
なお、動作には torch, transformers, pandas が必要です。
pip install torch
pip install transformers
pip install pandas
また、GPUを使用するには、NVIDIA GPUドライバー等のインストールが必要です。 こちらは、他の資料を参照してください。
特徴
-
8感情の推定
各感情ごとにファインチューニング済みのモデルを利用し、テキストの感情推定を行います。 -
柔軟な入力形式
単一のテキスト、テキストのリスト、または pandas Series を入力として受け付け、結果を DataFrame 形式で返します。 -
効率的な推論
GPU メモリの使用量を抑えるため、必要なときだけモデルを GPU にロードする設計になっています。
使用方法
以下は、パッケージの基本的な使い方の例です:
テキストの渡し方(リスト)
sample_texts = [
"そうだ 京都、行こう。",
"がんばるひとの、がんばらない時間。"
]
result_df = predictor.predict_emotions(sample_texts)
print(result_df)
単一のテキストの場合
result_single = predictor.predict_emotions("新しい朝が来た。")
print(result_single)
ディレクトリ構成
deberta_emotion_predictor/
├── README.md # この説明ファイル
├── deberta_emotion_predictor.py # DeBERTaEmotionPredictor クラスの実装
│ └── tokenizer_DeBERTa_v3_large/ #トークナイザー
├── setup.py
├── pyproject.toml
├── README.md
├── LICENSE
└── usage.py
必要環境
- Python 3.6 以上
- PyTorch
- transformers
- pandas
License
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deberta_emotion_predictor-1.0.0.tar.gz.
File metadata
- Download URL: deberta_emotion_predictor-1.0.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
230e67e83de4452ffddd47233c84a0868a22e6df40a883587b6be884310cf32d
|
|
| MD5 |
f96ec7461fbd9232d2ed247b90c7d60d
|
|
| BLAKE2b-256 |
5a978f63f6b3c3728c73801c52979a97a1df8e9dba9e245040d6101d0480b109
|
File details
Details for the file deberta_emotion_predictor-1.0.0-py3-none-any.whl.
File metadata
- Download URL: deberta_emotion_predictor-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcd5107c312947183fab2498f2f95f4fcaf347b93906f5e9d2834c631b67614e
|
|
| MD5 |
b130f705eddf416f67d0290f8d9d1dd4
|
|
| BLAKE2b-256 |
71418c4e7226ed57345912d40f6a3229462f7285b1a97358ad529d5e392ed5b2
|