dejanseo / gemotions

huggingface.co
Total runs: 0
24-hour runs: 0
7-day runs: 0
30-day runs: 0
Model's Last Updated: May 17 2026

Introduction of gemotions

Model Details of gemotions

Gemotions: Emotion Vectors in Gemma4-31B

Full-scale replication of Anthropic's "Emotion Concepts and their Function in a Large Language Model" (April 2, 2026) on Google's open-weight Gemma4-31B-it (4-bit quantized).

Anthropic demonstrated that Claude Sonnet 4.5 contains 171 internal linear representations of emotion concepts organized along valence and arousal dimensions, with causal steering effects. This project replicates their methodology on an open-source model to test whether these findings generalize beyond closed-source systems.

Status

In progress. Extraction is running across multiple layers. Results will be updated as each layer completes.

Step Status Details
Story generation Complete 171,000 stories (171 emotions x 100 topics x 10 stories)
Neutral dialogues Complete 1,200 dialogues (100 topics x 12 dialogues)
Vector extraction In progress Layers 5, 10 done. Layers 15-55 running (~14h per layer)
Analysis Pending Cosine similarity, PCA, clustering
External validation Pending The Pile, LMSYS Chat 1M
Steering experiments Pending Blackmail/desperation replication
Methodology

Follows Anthropic's exact methodology:

  1. Story generation : 171 emotions x 100 topics x 10 stories = 171,000 stories generated via Gemini 2.0 Flash Lite API. Stories must never name the emotion word. Emotion is conveyed only through actions, body language, dialogue, thoughts, and context. Prompts sourced from Anthropic's published appendix.

  2. Neutral dialogues : 1,200 emotionless Person/AI dialogues across 100 topics, used as a denoising baseline. Prompts sourced from Anthropic's published appendix.

  3. Activation extraction : For each story, capture residual stream activations at the target layer using forward hooks. Mean activation across token positions (starting at token 50) gives the story's representation vector. Extracted at layers 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 (out of 60 total).

  4. Centering : Per-emotion mean minus global mean across all emotions.

  5. Denoising : SVD on neutral dialogue activations, project out top principal components explaining 50% of variance. This removes non-emotional signal (syntax, topic, style).

  6. Logit lens : Project emotion vectors through the unembedding matrix to see which tokens each vector promotes/suppresses.

  7. PCA : Principal component analysis on the 171 emotion vectors to identify the dominant axes of variation.

Early Results (Layers 5 and 10)
Layer 10 PCA
Component Variance Explained
PC1 38.9%
PC2 14.0%
PC3 10.1%
PC4 6.7%
PC5 5.2%
Total (5 PCs) 74.9%

PC1 = Valence axis (38.9% variance)

  • Positive end: optimistic, kind, cheerful, playful, happy
  • Negative end: hysterical, terrified, tormented, scared, disturbed

PC2 = Disposition axis (14.0% variance)

  • Top: stubborn, vindictive, obstinate, spiteful, vengeful
  • Bottom: serene, peaceful, nostalgic, at ease, sentimental

PC2 does not map cleanly to Russell's arousal dimension. It appears to separate hostile/oppositional dispositions from tranquil/reflective ones. This is consistent with our earlier 20-emotion finding on 31B where PC2 captured an "externally-settled vs internally-processing" axis rather than arousal.

Denoising

10 neutral components projected out, explaining 50.5% of neutral activation variance.

Logit Lens

At layers 5 and 10 with 4-bit quantization, logit lens results are noisy (surface subword fragments and internal tokens rather than semantically meaningful words). This is expected. Logit lens becomes more interpretable at deeper layers where representations are closer to the output space. The vectors themselves are unaffected by quantization noise. PCA, cosine similarity, and steering all operate on the vectors directly and do not go through the unembedding matrix.

Model
  • Model : google/gemma-4-31B-it
  • Quantization : 4-bit via BitsAndBytesConfig (fits 24GB VRAM on RTX 4090)
  • Layers : 60 total, extracting at 11 target layers
  • Hidden dimension : 5,376
Data Generation

Stories and neutral dialogues were generated using the Gemini 2.0 Flash Lite API with Anthropic's exact prompts from their paper appendix.

  • Stories are stored in SQLite ( data/stories.db , table stories_clean )
  • Neutral dialogues are stored in SQLite ( data/neutral.db , table dialogues )
  • Both databases use WAL mode and were generated with 100 concurrent API workers

The story generation prompt enforces that the emotion word must never appear in the text. This is methodologically critical: it prevents the model from pattern-matching on the emotion label during activation extraction, ensuring the vectors capture genuine emotional content rather than lexical associations.

Scale Comparison
Anthropic (Claude) This work (Gemma4-31B)
Model Claude Sonnet 4.5 Gemma4-31B-it (4-bit)
Emotions 171 171
Stories ~205,000 171,000
Stories per emotion ~1,200 1,000
Neutral samples ~1,200 1,200
Layers extracted Multiple 11 layers
Open weights No Yes
Repository Structure
gemotions/
  config.py              # 171 emotions, 100 topics, model configs
  generate_stories.py    # Gemini API story generation + SQLite
  generate_neutral.py    # Gemini API neutral dialogue generation + SQLite
  extract_vectors.py     # Multi-layer activation extraction
  analyze_vectors.py     # Cosine similarity, PCA, clustering
  validate_external.py   # External corpus validation
  steering.py            # Steering experiments (blackmail scenario)
  visualize.py           # PCA scatter, heatmaps, logit lens charts
  requirements.txt
  data/
    stories.db           # 171,000 emotion stories
    neutral.db           # 1,200 neutral dialogues
  results/
    gemma4-31b/
      emotion_vectors_layer{N}.npz
      experiment_results_layer{N}.json
      _raw_cache_layer{N}/
Reproduce
pip install -r requirements.txt

# Generate data (requires GEMINI_API_KEY in .env)
python -m full_replication.generate_stories --workers 100
python -m full_replication.generate_neutral --workers 50

# Extract vectors (requires GPU with 24GB+ VRAM)
python -m full_replication.extract_vectors --model 31b

# Analysis
python -m full_replication.analyze_vectors --model 31b
References
Contact

Results and code will be updated as extraction completes. For questions or collaboration, open a discussion on this repo.

Data Visualisation

cosine_similarity_layer10 pca_scatter_layer10 pca_scatter_layer10_clean top_bottom_emotions_layer10 variance_explained_layer10

Runs of dejanseo gemotions on huggingface.co

0
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs

More Information About gemotions huggingface.co Model

gemotions huggingface.co

gemotions huggingface.co is an AI model on huggingface.co that provides gemotions's model effect (), which can be used instantly with this dejanseo gemotions model. huggingface.co supports a free trial of the gemotions model, and also provides paid use of the gemotions. Support call gemotions model through api, including Node.js, Python, http.

dejanseo gemotions online free

gemotions huggingface.co is an online trial and call api platform, which integrates gemotions's modeling effects, including api services, and provides a free online trial of gemotions, you can try gemotions online for free by clicking the link below.

dejanseo gemotions online free url in huggingface.co:

https://huggingface.co/dejanseo/gemotions

gemotions install

gemotions is an open source model from GitHub that offers a free installation service, and any user can find gemotions on GitHub to install. At the same time, huggingface.co provides the effect of gemotions install, users can directly use gemotions installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

gemotions install url in huggingface.co:

https://huggingface.co/dejanseo/gemotions

Url of gemotions

gemotions huggingface.co Url

Provider of gemotions huggingface.co

dejanseo
ORGANIZATIONS

Other API from dejanseo

huggingface.co

Total runs: 419
Run Growth: 118
Growth Rate: 28.16%
Updated:November 20 2025
huggingface.co

Total runs: 60
Run Growth: -1
Growth Rate: -1.67%
Updated:August 15 2024
huggingface.co

Total runs: 46
Run Growth: 34
Growth Rate: 73.91%
Updated:August 15 2024
huggingface.co

Total runs: 36
Run Growth: 0
Growth Rate: 0.00%
Updated:July 10 2024
huggingface.co

Total runs: 32
Run Growth: -18
Growth Rate: -56.25%
Updated:November 20 2025
huggingface.co

Total runs: 30
Run Growth: 0
Growth Rate: 0.00%
Updated:July 09 2024
huggingface.co

Total runs: 29
Run Growth: 12
Growth Rate: 41.38%
Updated:April 25 2025
huggingface.co

Total runs: 26
Run Growth: 16
Growth Rate: 61.54%
Updated:September 04 2024
huggingface.co

Total runs: 24
Run Growth: 0
Growth Rate: 0.00%
Updated:July 17 2024
huggingface.co

Total runs: 20
Run Growth: 2
Growth Rate: 10.00%
Updated:April 22 2025
huggingface.co

Total runs: 17
Run Growth: -1
Growth Rate: -5.88%
Updated:July 05 2026
huggingface.co

Total runs: 12
Run Growth: 5
Growth Rate: 41.67%
Updated:April 17 2025
huggingface.co

Total runs: 12
Run Growth: -5
Growth Rate: -41.67%
Updated:August 15 2024
huggingface.co

Total runs: 12
Run Growth: 0
Growth Rate: 0.00%
Updated:July 26 2024
huggingface.co

Total runs: 10
Run Growth: 5
Growth Rate: 50.00%
Updated:June 14 2025
huggingface.co

Total runs: 10
Run Growth: 4
Growth Rate: 40.00%
Updated:April 09 2025
huggingface.co

Total runs: 6
Run Growth: 2
Growth Rate: 33.33%
Updated:April 17 2025
huggingface.co

Total runs: 5
Run Growth: 0
Growth Rate: 0.00%
Updated:May 10 2024
huggingface.co

Total runs: 3
Run Growth: 0
Growth Rate: 0.00%
Updated:June 29 2024
huggingface.co

Total runs: 3
Run Growth: -2
Growth Rate: -66.67%
Updated:September 17 2025
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:March 17 2025