장점
단점
| 항목 | LSA | LDA |
|---|---|---|
| 방식 | SVD 기반 차원 축소 | 베이지안 확률 모델 |
| 의미 기반 | 수치적 근접 | 확률 기반 해석 가능 |
| 입력 | DTM, TF-IDF | DTM, TF-IDF |
| 출력 | 잠재 의미 벡터 | 토픽-단어 / 문서-토픽 분포 |
| 단점 | 업데이트 불가 | 복잡한 계산, 느림 |
from sklearn.decomposition import LatentDirichletAllocation
from sklearn.feature_extraction.text import CountVectorizer
CountVectorizer로 DTM 생성LatentDirichletAllocation 모델 학습vectorizer = CountVectorizer(max_df=0.9, min_df=10, stop_words='english')
X = vectorizer.fit_transform(docs)
lda = LatentDirichletAllocation(n_components=10, random_state=42)
lda.fit(X)
from keybert import KeyBERT
kw_model = KeyBERT('distilbert-base-nli-mean-tokens')
doc = "BERT is a powerful model for extracting keyphrases from documents."
keywords = kw_model.extract_keywords(doc, top_n=5)
print(keywords)
klue/bert-base, skt/kobert-base-v1, snunlp/KR-SBERT-...konlpy, mecab, soynlppip install keybert transformers
from keybert import KeyBERT
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("snunlp/KR-SBERT-V40K-klueNLI-augSTS")
kw_model = KeyBERT(model)
doc_ko = "기후 변화는 지구의 생태계와 인류에 중대한 영향을 미치고 있다."
keywords = kw_model.extract_keywords(doc_ko, top_n=5)
print(keywords)
| 항목 | 설명 |
|---|---|
| LSA | SVD 기반 차원 축소, 문서/단어 의미 추출 |
| LDA | 확률 분포 기반 토픽 모델링 |
| Sklearn LDA | 사이킷런 기반 확률적 모델 |
| KeyBERT | 문맥 임베딩 기반 키워드 추출 |
| 한국어 키버트 | 한국어 전용 BERT + 형태소 분석 |