1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[pip install emotionics]Pythonライブラリ"emotionics"公開

Posted at

Pythonライブラリ"emotionics"公開

先日、Pythonライブラリ"emotionics"を公開しました。
本記事は、日本語での解説記事です。
emotionics

Emotionicsとは?

Emotionicsとは、人類の感情をAIが扱いやすいように構造化する技術です。
(ちなみに造語です。)
Emotionicsのスコープは、下図が示すように、「意識と無意識」と「ロジックとアルゴリズム」の間にある人間の感情層の領域です。
scopeofemotionics.png

仕組み

Pythonライブラリ"emotionics"は、LLM×Emotionicsを組み合わせて使用します。
emotionicsは、テキストを特定の感情ラベルに分類する分類器ではありません。
LLMが文脈として理解した感情的ニュアンスを、あらかじめ定義された感情要素(Trust / Joy / Fear / Surprise など)の「強度分布」として構造化して出力します。

LLM自体は、文章の意味理解や文脈把握を担当します。
emotionicsは、その結果をそのまま返すのではなく、感情的な反応を「人間が後から扱いやすい形」に再構成する役割を持ちます。

つまり、

  • 意味理解:LLM
  • 感情構造化:emotionics
    という役割分担になっています。

pip install emotionics

使い方

必要なものは、OpenAIのAPIキーとOpenAIライブラリです。
Emotionics自体はLLM依存が無いはずですが、emotionicsライブラリは、OpenAIにしか今のところ対応していないです。
まずは、

pip install emotionics

でインストールし、下記のように使用します。

import os
import emotionics

emotionics.activate(
    llm="openai",
    api_key=os.environ["OPENAI_API_KEY"],
    model="gpt-5.2",
)

result = emotionics.estimate(
    text="今日も頑張る",
    mode="lite",
)

print(result)

というような感じで使うと、

{
  "mode": "lite",
  "version": "0.1.0",
  "trust": 0.6,
  "surprise": 0.1,
  "joy": 0.7,
  "fear": 0.1,
  "confidence": 0.75
}

というような出力が出ます。

各感情値は確率や診断結果ではなく、そのテキストに含まれる感情的シグナルの「相対的な強さ」を表します。
confidenceは、LLMがその推定をどれくらい安定して行えたかの目安です。

emotionics自体は言語に依存せず、LLMの多言語理解能力を前提として動作するため、LLMが対応している言語であれば同様に利用できます。
なお、診断などの目的には使用しないで下さい。

コードなど

コードなどの資産は、GitHubに置いてあります。
Kouhei-Takagiのemotionics

おまけ

開発したfastAPI(バックエンド)+SwiftUI(フロントエンド)

もっと高機能なバージョンを初期に開発していて、あまり公開するべきじゃ無いなと感じたために基本非公開にしたのが、fastAPIをバックエンドにし、SwiftUIアプリをフロントエンドにしたスタイルです。

動画

sample2.gif

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?