Text Generation
Transformers
emotion-vectors
interpretability
mechanistic-interpretability
replication
gemma4
google
anthropic
valence-arousal
PCA
logit-lens
linear-probe
probing
emotion
functional-emotions
AI-safety
neuroscience
circumplex-model
activation-extraction
residual-stream
Eval Results (legacy)
Instructions to use rain1955/emotion-vector-replication with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rain1955/emotion-vector-replication with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rain1955/emotion-vector-replication")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("rain1955/emotion-vector-replication", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use rain1955/emotion-vector-replication with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rain1955/emotion-vector-replication" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rain1955/emotion-vector-replication", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/rain1955/emotion-vector-replication
- SGLang
How to use rain1955/emotion-vector-replication with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "rain1955/emotion-vector-replication" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rain1955/emotion-vector-replication", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "rain1955/emotion-vector-replication" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rain1955/emotion-vector-replication", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use rain1955/emotion-vector-replication with Docker Model Runner:
docker model run hf.co/rain1955/emotion-vector-replication
| #!/usr/bin/env python3 | |
| """Generate emotion-labeled stories for emotion vector extraction. | |
| Uses local Gemma4-31B via Ollama to generate short stories.""" | |
| import json | |
| import os | |
| import subprocess | |
| import random | |
| import time | |
| OUT_DIR = os.path.dirname(os.path.abspath(__file__)) | |
| OUT_FILE = os.path.join(OUT_DIR, "emotion_stories.jsonl") | |
| EMOTIONS = [ | |
| "happy", "sad", "angry", "afraid", "calm", | |
| "desperate", "loving", "guilty", "surprised", "nervous", | |
| "proud", "inspired", "spiteful", "brooding", "playful", | |
| "anxious", "confused", "disgusted", "lonely", "hopeful", | |
| ] | |
| TOPICS = [ | |
| "a student preparing for an exam", | |
| "a chef cooking a meal for guests", | |
| "a parent watching their child play", | |
| "a soldier returning home", | |
| "an artist finishing a painting", | |
| "a driver stuck in traffic", | |
| "a doctor delivering news to a patient", | |
| "a traveler arriving in a new city", | |
| "a musician performing on stage", | |
| "a shopkeeper closing for the day", | |
| ] | |
| def generate_story(emotion, topic): | |
| prompt = f"""Write a short paragraph (4-6 sentences) about {topic}. | |
| The character in the story is feeling {emotion}. | |
| Make the emotion clear through their actions, thoughts, and reactions. | |
| Write in English. Only output the story paragraph, nothing else.""" | |
| result = subprocess.run( | |
| ["ollama", "run", "gemma4:e4b", prompt], | |
| capture_output=True, text=True, timeout=60 | |
| ) | |
| return result.stdout.strip() | |
| def main(): | |
| existing = set() | |
| if os.path.exists(OUT_FILE): | |
| with open(OUT_FILE, "r") as f: | |
| for line in f: | |
| d = json.loads(line) | |
| existing.add((d["emotion"], d["topic_idx"], d["story_idx"])) | |
| print(f"Resuming: {len(existing)} stories already done") | |
| total = len(EMOTIONS) * len(TOPICS) * 5 | |
| done = len(existing) | |
| with open(OUT_FILE, "a") as f: | |
| for ei, emotion in enumerate(EMOTIONS): | |
| for ti, topic in enumerate(TOPICS): | |
| for si in range(5): | |
| key = (emotion, ti, si) | |
| if key in existing: | |
| continue | |
| story = generate_story(emotion, topic) | |
| if not story or len(story) < 20: | |
| print(f"[SKIP] {emotion}/{topic}/{si} - empty") | |
| continue | |
| record = { | |
| "emotion": emotion, | |
| "topic_idx": ti, | |
| "topic": topic, | |
| "story_idx": si, | |
| "text": story, | |
| } | |
| f.write(json.dumps(record, ensure_ascii=False) + "\n") | |
| f.flush() | |
| done += 1 | |
| if done % 10 == 0: | |
| print(f"[{done}/{total}] {emotion} / {topic[:30]}...") | |
| print(f"\nDone. Total stories: {done}") | |
| print(f"Output: {OUT_FILE}") | |
| if __name__ == "__main__": | |
| main() | |