Extract emotional information from embeddings.
When working with LLMs, various embedding models capture emotional information that might be useful to work with (or without!).
An emopoint is a simplified embedding with interpretable dimensions:
- joy vs sadness
- anger vs fear
- disgust vs surprise
So, for example OpenAI's text-embedding-3-small returns embeddings with 1536
dimensions. This library will convert those into 3 dimensions, losing most
information except for what directly relates to emotion.
This library enables two modes:
- Isolate emotion, converting it into 3D emopoint vectors
- Remove emotion, stay in original dimensionality
Install
Install using your language's package manager:
JavaScript/TypeScript via NPM
npm i emopoint
and then use it
const { MODELS } = require('emopoint');
console.log(MODELS.ADA_2);
Python via PyPi
pip install emopoint
and then use it
from emopoint import MODELS
embedding = get_embeddings("James was maaaaaad")
emopoint = MODELS.ADA_3_SMALL.emb_to_emo(embedding)
Go
go get github.com/tkellogg/emopoint/go/emopoint
and then use it
import (
emo "github.com/tkellogg/emopoint/go/emopoint"
)
func main() {
var embeding []float32 = getEmbeddings("James was maaaaaad")
var emopoint []float32 = emo.ADA_3_SMALL.EmbeddingToEmopoint(embedding)
}
Functions
All 3 languages have these capabilities:
- Convert embedding to emopoint — Convert an embedding (e.g. 1536 dimensions for
text-embedding-3-small) to 3-dimensional space, calledemopointspace that represents only emotion and nothing else. - Remove emotion — Take an embedding and keep it in the same dimensionality, but subtract emotional information
From these operations, there's a lot more you can do:
- Get the portion of emotional information in text — Calculate the magnitude of the embedding (should be always
1.0) and subtract the magnitude of the result ofremove_emotion(embedding). The result is a scalarfloatthat represents the portion of the meaning of the text that was dedicated to emotion, as the embedding model understood it. - Cluster on emotion — Convert to
emopointspace and run a K-Means clustering algorithm - Semantic search on emotion only — Convert to
emopointspace and store in a vector database. This matches text based only on the emotional content, ignoring all factual and subjective information. - Semantic search without emotion — Same as before, but store the result of
remove_emotion(embedding). This removes noise introduced by emotion, creating closer matches and potentially enhancing the search accuracy. - Analytics & visualizations on emotional magnitude — Calculate the magnitudes of emopoints for several texts, e.g. sections of a speech or tweets, and create visualizations on just the magnitude (portion of information dedicated to emotion).
- Analytics & visualizations on emotions — Same as before, but instead of calculating the magnitude, visualize the points in 3D emopoint space. Observe how some texts lean toward anger or joy. Analyze how emotions ebb & flow throughout a speech, and contrast that to the informational content (maybe use K-Means clustering on original content to classify the content and display those classifications as colors in a 3D scatter plot).
Release files for emopoint 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| emopoint-0.1.3.tar.gz | 197.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| emopoint-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 394.6 kB
Release files / emopoint-0.1.3.tar.gz
| Download URL | emopoint-0.1.3.tar.gz |
|---|---|
| Size | 197.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aafe82ddf60e3ec0918e8473a9b3d77df631766519f0703b5218a7df1d268df6
|
|
BLAKE2b-256 checksum How to use checksums |
74b8e735f09db94303bc21a54504893278b48bd906120c2ccd81c0d7ee2e435a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.4 Darwin/23.4.0
|
Release files / emopoint-0.1.3-py3-none-any.whl
| Download URL | emopoint-0.1.3-py3-none-any.whl |
|---|---|
| Size | 197.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53390bb0b0bb256f3be61697691364d926b7729e503bd5f7c9262916a2b5d656
|
|
BLAKE2b-256 checksum How to use checksums |
fdd618a044cd175f9a8c34bceafa30234bf262b8f9497a0f872c4b37e03296bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.4 Darwin/23.4.0
|