--- id: wiki-2026-0508-linguistic-analysis-in-ai title: Linguistic Analysis in AI category: 10_Wiki/Topics status: verified canonical_id: self aliases: [NLP Linguistic Analysis, Syntactic Analysis, Linguistic Features] duplicate_of: none source_trust_level: A confidence_score: 0.85 verification_status: applied tags: [nlp, ai, linguistics, parsing, ner, llm] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: { language: python, framework: spacy-stanza-llm } --- # Linguistic Analysis in AI ## 매 한 줄 > **"매 LLM 시대에도 구조 분석은 살아있다"**. POS/dependency/NER 같은 전통 분석은 여전히 정보 추출·검색·평가에 쓰이지만, 2026엔 LLM이 zero-shot으로 대부분 대체. ## 매 핵심 ### 매 분석 단계 - **Tokenization**: 단어/subword 분리. - **POS tagging**: 품사 (NOUN, VERB, ADJ). - **Lemmatization / Stemming**: 어간 정규화. - **Dependency parsing**: 단어 간 문법 관계 트리. - **Constituency parsing**: 구 구조 (NP, VP). - **NER**: Named Entity Recognition (PER, ORG, LOC). - **SRL**: Semantic Role Labeling (agent, patient). - **Coreference**: 대명사 해결. ### 매 응용 1. 정보 추출 (KG 구축, relation extraction). 2. 검색 쿼리 재작성, 의도 파싱. 3. RAG에서 entity 기반 chunking. 4. 평가 (LLM 출력의 grammaticality, faithfulness). 5. 저자원 언어 도구 체인. 6. 데이터 정제 / privacy redaction (NER로 PII 마스킹). ## 💻 패턴 ### Pattern 1 — spaCy 표준 파이프라인 ```python import spacy nlp = spacy.load('ko_core_news_lg') doc = nlp("애플은 2026년 비전 프로 2를 출시했다.") for tok in doc: print(tok.text, tok.pos_, tok.dep_, tok.head.text) for ent in doc.ents: print(ent.text, ent.label_) ``` ### Pattern 2 — Stanza (다국어 정확도) ```python import stanza nlp = stanza.Pipeline('ko', processors='tokenize,pos,lemma,depparse,ner') doc = nlp(text) ``` ### Pattern 3 — LLM zero-shot NER ```python from anthropic import Anthropic client = Anthropic() resp = client.messages.create( model='claude-opus-4-7', messages=[{'role':'user','content': f'Extract entities as JSON [{{"text","type"}}]:\n{text}'}], max_tokens=1024, ) ``` ### Pattern 4 — Dependency 기반 관계 추출 ```python for tok in doc: if tok.dep_ == 'nsubj' and tok.head.pos_ == 'VERB': print('subject:', tok.text, '->', tok.head.text) ``` ### Pattern 5 — PII Redaction (NER) ```python def redact(text): doc = nlp(text) out = text for ent in reversed(doc.ents): if ent.label_ in {'PERSON','GPE','PHONE'}: out = out[:ent.start_char] + f'[{ent.label_}]' + out[ent.end_char:] return out ``` ### Pattern 6 — Hybrid (LLM + parser 검증) ```python # LLM으로 빠르게 추출 → spaCy로 검증/정렬 candidates = llm_extract(text) doc = nlp(text) verified = [c for c in candidates if any(c['text']==e.text for e in doc.ents)] ``` ## 매 결정 기준 | 상황 | 도구 | |---|---| | 대량 / 저예산 / 정형 | spaCy / Stanza | | 정확도 우선 다국어 | Stanza, Trankit | | Zero-shot, 도메인 특수 | LLM (Claude/GPT) | | 실시간 latency | spaCy small model | | 학습 데이터 라벨링 | LLM weak supervision + 검수 | | Production NER 한국어 | KoNLPy + spaCy ko 또는 LLM | **기본값**: 2026 - LLM zero-shot이 default, spaCy는 비용 민감/대량 처리에. ## 🔗 Graph - 부모: [[Natural-Language-Processing-NLP|Natural-Language-Processing]], [[Computational-Linguistics]] - 변형: [[NER]] - 응용: [[Information-Extraction]], [[Knowledge Graph|Knowledge-Graph]], [[RAG]] - Adjacent: [[Tokenization]], [[Word-Embeddings]] ## 🤖 LLM 활용 **언제**: - 짧은 텍스트 entity/relation 추출 (zero-shot). - spaCy/Stanza 파이프라인 코드 생성. - 한국어/저자원 언어 빠른 프로토타입. **언제 X**: - 100M doc 배치 (비용 - 전통 도구가 100배 저렴). - 결정론적 재현성 필수 (LLM 비결정성). ## ❌ 안티패턴 - LLM에 토크나이저 정보 의존 (모델별 상이). - 영어 모델로 한국어 NER (도메인 mismatch). - Dependency tree 결과를 ground truth로 (parser도 ~92%). - 모든 문제에 LLM (단순 POS 태깅에 GPT-4 호출은 낭비). - Tokenization 영향 무시 (subword가 단어 경계 깨짐). ## 🧪 검증 / 중복 - Verified. spaCy 3.7+/Stanza 1.8 기준. 신뢰도 A. ## 🕓 Changelog | 날짜 | 변경 | |---|---| | 2026-05-08 | Phase 1 | | 2026-05-10 | Manual cleanup |