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,135 @@
|
||||
---
|
||||
id: wiki-2026-0508-latent-semantic-analysis-lsa
|
||||
title: Latent Semantic Analysis (LSA)
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [LSA, LSI, Latent Semantic Indexing]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.85
|
||||
verification_status: applied
|
||||
tags: [nlp, ir, svd, tfidf, topic-modeling, embeddings]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack: { language: Python, framework: scikit-learn/gensim }
|
||||
---
|
||||
|
||||
# Latent Semantic Analysis (LSA)
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 LSA = TF-IDF 행렬에 truncated SVD"**. term-document을 저차원 latent semantic 공간에 투영해 동의어/다의어 부분 해소.
|
||||
|
||||
## 매 핵심
|
||||
### 매 수학
|
||||
- A (m×n) = U Σ Vᵀ. truncated rank-k → A_k = U_k Σ_k V_kᵀ.
|
||||
- 행 = term embedding, 열 = document embedding.
|
||||
- Cosine similarity in k-dim space → semantic similarity.
|
||||
|
||||
### 매 절차
|
||||
1. Tokenize, stopword/lemma
|
||||
2. TF-IDF 행렬 구축
|
||||
3. Truncated SVD (k=100~300)
|
||||
4. 쿼리도 동일 공간 투영: q_k = qᵀ U_k Σ_k⁻¹
|
||||
5. cosine으로 유사 문서 검색
|
||||
|
||||
### 매 강점/한계
|
||||
- ✅ 작은 corpus, 빠름, 해석 가능
|
||||
- ✅ 동의어 부분 처리 (synonymy)
|
||||
- ❌ 다의어 약함 (polysemy): 한 단어 = 한 벡터
|
||||
- ❌ 비음수성 X → 토픽 해석 어려움 (→ NMF, LDA)
|
||||
- ❌ Out-of-vocabulary 학습 불가
|
||||
- ❌ contextual 의미 X (→ BERT)
|
||||
|
||||
### 매 vs 동족
|
||||
- **NMF**: 비음수, 해석 ↑
|
||||
- **LDA**: 확률적 토픽 모델
|
||||
- **word2vec/GloVe**: 단어 단위 dense embedding
|
||||
- **BERT/SBERT**: contextual, SoTA
|
||||
|
||||
## 💻 패턴
|
||||
### scikit-learn LSA
|
||||
```python
|
||||
from sklearn.feature_extraction.text import TfidfVectorizer
|
||||
from sklearn.decomposition import TruncatedSVD
|
||||
from sklearn.pipeline import make_pipeline
|
||||
from sklearn.preprocessing import Normalizer
|
||||
|
||||
vec = TfidfVectorizer(stop_words="english", max_df=0.95, min_df=2)
|
||||
svd = TruncatedSVD(n_components=200, random_state=0)
|
||||
lsa = make_pipeline(vec, svd, Normalizer(copy=False))
|
||||
doc_emb = lsa.fit_transform(corpus) # (n_docs, 200)
|
||||
```
|
||||
|
||||
### Query → semantic search
|
||||
```python
|
||||
import numpy as np
|
||||
q_emb = lsa.transform(["machine learning algorithms"])
|
||||
sims = doc_emb @ q_emb.T # already L2-normed
|
||||
top = np.argsort(-sims.ravel())[:10]
|
||||
```
|
||||
|
||||
### gensim LSI
|
||||
```python
|
||||
from gensim import corpora, models
|
||||
dictionary = corpora.Dictionary(tokenized_docs)
|
||||
bow = [dictionary.doc2bow(d) for d in tokenized_docs]
|
||||
tfidf = models.TfidfModel(bow)
|
||||
lsi = models.LsiModel(tfidf[bow], id2word=dictionary, num_topics=200)
|
||||
print(lsi.print_topics(5)) # 토픽별 top words
|
||||
```
|
||||
|
||||
### Topic 해석
|
||||
```python
|
||||
terms = vec.get_feature_names_out()
|
||||
for i, comp in enumerate(svd.components_[:5]):
|
||||
top_terms = [terms[j] for j in comp.argsort()[-10:][::-1]]
|
||||
print(f"Topic {i}: {top_terms}")
|
||||
```
|
||||
|
||||
### Modern: BERT 대체
|
||||
```python
|
||||
from sentence_transformers import SentenceTransformer
|
||||
model = SentenceTransformer("all-MiniLM-L6-v2")
|
||||
doc_emb = model.encode(corpus, normalize_embeddings=True)
|
||||
# 문맥 의미 반영, OOV 자유. LSA 대비 SoTA.
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| 빠른 baseline, 적은 자원 | LSA |
|
||||
| 해석 가능 토픽 | NMF, LDA |
|
||||
| 단어 의미 (sparse 분포) | word2vec/GloVe |
|
||||
| Production semantic search | SBERT + FAISS |
|
||||
| 도메인 한정 corpus | LSA fine-tune or domain SBERT |
|
||||
|
||||
**기본값**: 신규 시스템은 SBERT. LSA는 baseline / 교육용 / 자원 제약.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Information Retrieval]], [[NLP]], [[Dimensionality-Reduction]]
|
||||
- 변형: [[LDA]], [[PCA]]
|
||||
- 응용: [[Semantic Search|Semantic-Search]]
|
||||
- Adjacent: [[TF-IDF]], [[Word-Embeddings]], [[SVD]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 빠른 baseline 구현, SVD 직관 설명.
|
||||
**언제 X**: 현대 production 시스템 — SBERT/LLM embedding이 대부분 우수.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- 매우 큰 corpus에 dense SVD (메모리) — truncated/randomized 사용
|
||||
- TF-IDF 없이 raw count → 빈도 단어 dominate
|
||||
- k 너무 작거나 큼 (k=50~300, perplexity/downstream으로 튜닝)
|
||||
- BERT 시대에 LSA 단독 production
|
||||
- Query 정규화/stopword 학습과 다름
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Deerwester 1990 LSI, scikit-learn/gensim docs). 신뢰도 A.
|
||||
- 중복: 없음.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — 매 prefix, BERT 대체 비교 추가 |
|
||||
Reference in New Issue
Block a user