refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,232 @@
|
||||
---
|
||||
id: wiki-2026-0508-emotional-ai-affective-computing
|
||||
title: Emotional AI (Affective Computing)
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [affective computing, emotion AI, sentiment analysis, emotion recognition, FER]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.95
|
||||
verification_status: applied
|
||||
tags: [ai, affective-computing, emotional-ai, sentiment, fer, multimodal, hci]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: Python
|
||||
framework: PyTorch / Transformers / DeepFace
|
||||
---
|
||||
|
||||
# Emotional AI (Affective Computing)
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 emotion 의 sense + 매 generate"**. Picard MIT (1997). 매 facial, voice, text, physiological. 매 modern: 매 multimodal LLM + valence-arousal regression. 매 ethical: 매 surveillance + cultural bias.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 emotion model
|
||||
- **Discrete** (Ekman): 매 6 basic — anger, fear, disgust, surprise, sadness, joy.
|
||||
- **Dimensional** (Russell): 매 valence × arousal.
|
||||
- **Plutchik wheel**: 매 8 + intensity.
|
||||
- **Appraisal** (Scherer): 매 cognitive evaluation.
|
||||
|
||||
### 매 modality
|
||||
- **Facial** (FER): 매 AU (action unit).
|
||||
- **Voice**: 매 prosody, pitch.
|
||||
- **Text**: 매 lexicon + transformer.
|
||||
- **Physiological**: 매 HRV, GSR, EEG.
|
||||
- **Body**: 매 posture, gait.
|
||||
- **Multimodal**: 매 fuse.
|
||||
|
||||
### 매 응용
|
||||
1. **Customer service**: 매 sentiment.
|
||||
2. **Mental health**: 매 mood track.
|
||||
3. **Education**: 매 engagement.
|
||||
4. **Auto**: 매 driver drowsiness.
|
||||
5. **Marketing**: 매 ad reaction.
|
||||
6. **Robot**: 매 emotional support.
|
||||
7. **Game**: 매 dynamic difficulty.
|
||||
|
||||
### 매 ethical
|
||||
- **Privacy**: 매 emotion 의 surveil.
|
||||
- **Cultural bias**: 매 Ekman universality 의 contested.
|
||||
- **Inaccuracy**: 매 expression ≠ feeling.
|
||||
- **Manipulation**: 매 ad / dark pattern.
|
||||
- **Regulation**: 매 EU AI Act 의 emotion 의 high-risk.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### Text sentiment (transformers)
|
||||
```python
|
||||
from transformers import pipeline
|
||||
pipe = pipeline('sentiment-analysis', model='cardiffnlp/twitter-roberta-base-sentiment')
|
||||
print(pipe("I love this!"))
|
||||
# 매 [{'label': 'POSITIVE', 'score': 0.99}]
|
||||
```
|
||||
|
||||
### Emotion classification (text, 7-class)
|
||||
```python
|
||||
classifier = pipeline('text-classification', model='j-hartmann/emotion-english-distilroberta-base', top_k=None)
|
||||
result = classifier("I'm worried about tomorrow")
|
||||
# 매 [{'label': 'fear', 'score': 0.7}, ...]
|
||||
```
|
||||
|
||||
### Facial emotion (DeepFace)
|
||||
```python
|
||||
from deepface import DeepFace
|
||||
result = DeepFace.analyze('selfie.jpg', actions=['emotion'])
|
||||
print(result[0]['dominant_emotion']) # 매 'happy'
|
||||
```
|
||||
|
||||
### Voice emotion (audio + Wav2Vec2)
|
||||
```python
|
||||
import librosa
|
||||
import torch
|
||||
from transformers import Wav2Vec2ForSequenceClassification, Wav2Vec2FeatureExtractor
|
||||
|
||||
model = Wav2Vec2ForSequenceClassification.from_pretrained('superb/wav2vec2-base-superb-er')
|
||||
fe = Wav2Vec2FeatureExtractor.from_pretrained('superb/wav2vec2-base-superb-er')
|
||||
|
||||
def predict_emotion(audio_path):
|
||||
audio, sr = librosa.load(audio_path, sr=16000)
|
||||
inputs = fe(audio, sampling_rate=16000, return_tensors='pt')
|
||||
with torch.no_grad():
|
||||
logits = model(**inputs).logits
|
||||
return model.config.id2label[logits.argmax().item()]
|
||||
```
|
||||
|
||||
### Valence-Arousal regression
|
||||
```python
|
||||
class VARegressor(nn.Module):
|
||||
def __init__(self, backbone):
|
||||
super().__init__()
|
||||
self.backbone = backbone
|
||||
self.va_head = nn.Linear(backbone.hidden_dim, 2) # 매 valence, arousal
|
||||
|
||||
def forward(self, x):
|
||||
feat = self.backbone(x)
|
||||
va = torch.tanh(self.va_head(feat)) # 매 [-1, 1]
|
||||
return va # 매 [batch, (valence, arousal)]
|
||||
```
|
||||
|
||||
### Multimodal fusion
|
||||
```python
|
||||
class MultiModalEmotion(nn.Module):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.face_enc = FacialEncoder()
|
||||
self.audio_enc = AudioEncoder()
|
||||
self.text_enc = TextEncoder()
|
||||
self.fusion = nn.Linear(768 * 3, 7)
|
||||
|
||||
def forward(self, face, audio, text):
|
||||
ff = self.face_enc(face)
|
||||
fa = self.audio_enc(audio)
|
||||
ft = self.text_enc(text)
|
||||
return self.fusion(torch.cat([ff, fa, ft], dim=-1))
|
||||
```
|
||||
|
||||
### Physiological (HRV stress)
|
||||
```python
|
||||
import neurokit2 as nk
|
||||
def stress_from_ecg(ecg_signal, sr=1000):
|
||||
signals, info = nk.ecg_process(ecg_signal, sampling_rate=sr)
|
||||
hrv = nk.hrv_time(signals, sampling_rate=sr)
|
||||
rmssd = hrv['HRV_RMSSD'].iloc[0]
|
||||
return 'stressed' if rmssd < 30 else 'calm'
|
||||
```
|
||||
|
||||
### Cultural-aware (avoid bias)
|
||||
```python
|
||||
def culturally_aware_predict(image, region):
|
||||
base_pred = model.predict(image)
|
||||
# 매 cultural calibration
|
||||
if region == 'east_asia':
|
||||
# 매 East Asian 의 less expressive baseline
|
||||
base_pred['happy'] *= 0.8
|
||||
base_pred['neutral'] *= 1.2
|
||||
return normalize(base_pred)
|
||||
```
|
||||
|
||||
### LLM-based emotion (modern)
|
||||
```python
|
||||
def llm_emotion(text):
|
||||
prompt = f"""Classify the emotion in this text. Output JSON.
|
||||
Text: "{text}"
|
||||
Output: {{"primary": "...", "secondary": "...", "valence": -1 to 1, "arousal": 0 to 1}}"""
|
||||
return json.loads(llm.generate(prompt))
|
||||
```
|
||||
|
||||
### Real-time engagement (online learning)
|
||||
```python
|
||||
class EngagementTracker:
|
||||
def __init__(self, baseline=0.5):
|
||||
self.engagement = baseline
|
||||
self.history = []
|
||||
|
||||
def update(self, frame):
|
||||
emotion = analyze_face(frame)
|
||||
self.engagement = 0.9 * self.engagement + 0.1 * emotion['attention_score']
|
||||
self.history.append(self.engagement)
|
||||
|
||||
def is_disengaged(self):
|
||||
return np.mean(self.history[-30:]) < 0.3
|
||||
```
|
||||
|
||||
### Affective response (chatbot)
|
||||
```python
|
||||
def empathic_response(user_msg):
|
||||
emotion = classify(user_msg)
|
||||
if emotion in ('sad', 'fear'):
|
||||
return llm.generate(f"User feels {emotion}. Respond with validation first, then gentle reframe.\nUser: {user_msg}")
|
||||
return llm.generate(f"Respond to: {user_msg}")
|
||||
```
|
||||
|
||||
### Privacy-aware (on-device)
|
||||
```python
|
||||
# 매 raw frame 의 server 의 send X
|
||||
def on_device_emotion(frame, local_model):
|
||||
emotion = local_model(frame)
|
||||
# 매 only summary 의 send
|
||||
return {'emotion': emotion, 'confidence': ...}
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Customer support text | Sentiment + LLM |
|
||||
| Driver drowsiness | Facial + on-device |
|
||||
| Mental health | Multimodal + clinician |
|
||||
| Marketing | A/B + reaction |
|
||||
| Robot pet | Multimodal real-time |
|
||||
| Education | Engagement (eye + face) |
|
||||
|
||||
**기본값**: 매 task-specific modality + 매 cultural calibration + 매 privacy on-device + 매 LLM augment + 매 ethical disclosure.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[AI]] · [[Human Computer Interaction]]
|
||||
- 변형: [[Sentiment-Analysis]] · [[FER]] · [[Emotional-AI (Affective Computing)|Empathy-in-AI]]
|
||||
- Adjacent: [[Multimodal-LLM]] · [[Drama Management Systems]] · [[Dynamic Difficulty Adjustment (DDA)]] · [[EU-AI-Act]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 customer experience. 매 health (with clinician). 매 robot interaction.
|
||||
**언제 X**: 매 surveillance. 매 manipulation. 매 EU high-risk.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Single-modality trust**: 매 noisy.
|
||||
- **Universal Ekman 의 assume**: 매 cultural bias.
|
||||
- **Express ≠ feel**: 매 mask.
|
||||
- **No consent**: 매 surveillance.
|
||||
- **Manipulate emotion**: 매 dark pattern.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Picard 1997, Russell circumplex, Barrett constructionist).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-04-26 | EMOTION-AI auto |
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — emotion model + 매 text/voice/face/VA/multimodal code |
|
||||
Reference in New Issue
Block a user