[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
+128 -57
View File
@@ -1,83 +1,154 @@
---
id: wiki-2026-0508-self-verification
title: Self verification
title: Self-Verification
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: []
aliases: [Chain of Verification, CoVe, Self-Critique, LLM Self-Check]
duplicate_of: none
source_trust_level: A
confidence_score: 0.92
tags: [uncategorized]
confidence_score: 0.9
verification_status: applied
tags: [llm, reasoning, prompting, reliability]
raw_sources: []
last_reinforced: 2026-05-08
last_reinforced: 2026-05-10
github_commit: pending
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
tech_stack:
language: python
framework: Anthropic SDK / OpenAI SDK
---
# Self-verification (자가 검증)
# Self-Verification
## 📌 한 줄 통찰 (The Karpathy Summary)
Self-verification(자가 검증)은 AI 에이전트가 작업을 마친 후 혹은 실행 도중에 자신의 출력물이나 행동 결과가 요청된 요구사항을 충족했는지, 오류는 없는지 스스로 검토하고 수정하는 프로세스이다. 모델의 확률론적 한계를 극복하고 결과물의 신뢰성을 높이기 위한 핵심적인 기법으로, 에이전트 하네스의 V-component와 E-component가 협업하여 수행한다.
## 한 줄
> **"매 LLM 이 자기 답을 다시 점검 — generate → verify → revise"**. 매 Dhuliawala 2023 의 CoVe (Chain of Verification), self-consistency, self-refine, reflexion 가 매 family. 매 2026: reasoning model (Claude Opus 4.7 thinking, o3) 이 매 internalized self-verify, 그래도 매 explicit verify pass 가 critical accuracy 추가.
## 📖 구조화된 지식 (Synthesized Content)
* **검증 메커니즘 (Verification Loops)**:
* **자기 비판 (Self-critique)**: 모델에게 "네 답변을 다시 읽고 오류를 찾아봐"라고 요청하여 논리적 허점을 발견하게 함.
* **정적 분석 통합**: 에이전트가 생성한 코드를 Linter나 컴파일러를 통해 실행해보고, 발생한 에러를 피드백으로 활용.
* **단위 테스트 실행**: 에이전트가 스스로 테스트 코드를 작성하고 실행하여 기능의 정상 작동 여부를 확인.
* **근거 대조 (Evidence Grounding)**: 생성된 정보가 메모리(Evidence Memory) 내의 실제 데이터와 일치하는지 교차 검증.
* **PEV (Plan-Execute-Verify) 루프**: 작업을 기획(Plan), 실행(Execute)한 후 반드시 검증(Verify) 단계를 거치도록 워크플로우를 구조화하여 검증 누락을 방지한다.
* **평가자 에이전트 (Evaluator Agent)**: 생성 모델과 별개로 검증만을 전담하는 독립적인 에이전트를 두어 '자기 확증 편향'을 최소화하고 객관성을 확보한다.
* **결정론적 피드백**: 모델의 추론에만 의존하지 않고, 실제 실행 결과(Success/Failure)나 외부 툴의 출력값을 최종 검증의 잣대로 삼는다.
## 매 핵심
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
* **자기 확증 편향**: 모델은 자신이 만든 결과물을 옳다고 믿으려는 경향이 있어, 단순한 프롬프트만으로는 심각한 오류를 놓칠 수 있다.
* **비용과 지연 시간**: 매 작업마다 검증 루프를 돌리면 토큰 소모량이 2~3배로 늘어나고 시스템 반응 속도가 저하된다.
* **둠 루프 (Doom Loop)**: 에이전트가 오류를 고치지 못하고 동일한 검증 실패를 무한 반복하며 루프에 갇힐 위험이 있다.
### 매 형태
- **Self-consistency** (Wang 2022): 매 sample N 개 → majority vote.
- **Chain of Verification** (CoVe): plan → baseline → verify Qs → answer Qs → final.
- **Self-refine** (Madaan 2023): generate → critique → revise loop.
- **Reflexion**: episodic memory of past mistakes.
- **Constitutional / RLHF self-judge**: model 가 own output 평가.
## 🔗 지식 연결 (Graph)
### Related Concepts
* [[V-component (Evaluation Interface)|V-component (Evaluation Interface)]]
* 연결 이유: 자가 검증이 실질적으로 구현되는 하네스의 구성 요소이다.
* Reflexion
* 연결 이유: 실패로부터 배우고 스스로를 수정하는 상위 개념의 프레임워크이다.
* Context Attention Decay
* 연결 이유: 장기 작업 시 에이전트가 검증 규칙을 잊어버리게 만드는 원인이다.
### 매 verify 가 효과적인 곳
- Multi-hop reasoning (factual chains).
- Math / logic (intermediate step check).
- Code (compile, test, lint).
- Long-form factuality (claim-by-claim).
- Hallucination 감소.
### Deeper Research Questions
* '검증의 깊이'를 작업의 중요도에 따라 동적으로 조절하여 비용 효율성을 극대화하는 스케줄링 전략은 무엇인가?
* 인간의 피드백(HITL)이 적은 상황에서 자동화된 자가 검증만으로 소프트웨어 수준의 안정성을 보장할 수 있는가?
* 검증 실패 시 에이전트에게 제공하는 '피드백의 구체성'이 자가 수정(Self-correction) 성공률에 미치는 영향은 어떠한가?
### 매 verify 가 부정확한 곳
- Model 의 systematic bias — 같은 wrong answer.
- Highly creative / open-ended (no ground truth).
- 매 verify model = generator → blind spots 공유.
### Practical Application Contexts
* **Implementation:** `agent.run()` 메서드 마지막에 반드시 `agent.verify()`를 호출하도록 강제하고, 검증 실패 시 최대 N회까지 `agent.fix()`를 시도하게 한다.
* **System Design:** 코딩 에이전트 파이프라인에서 'Generator 에이전트'와 'Reviewer 에이전트'를 분리하여 서로의 결과물을 비판하게 만드는 GAN 스타일의 협업 체계를 구축한다.
### 매 응용
1. Agent loop critical-path step 검증.
2. RAG answer claim verification (cite-check).
3. Code review pre-PR.
4. Math homework solver.
5. Medical / legal high-stakes Q&A.
---
*Last updated: 2026-05-01*
## 💻 패턴
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
### Self-consistency
```python
from collections import Counter
samples = [llm(prompt, temperature=0.8) for _ in range(7)]
answer = Counter(extract_answer(s) for s in samples).most_common(1)[0][0]
```
**언제 이 지식을 쓰는가:**
- *(TODO)*
### CoVe (4 steps)
```python
baseline = llm(f"Answer: {q}")
verify_qs = llm(f"List 5 verification Qs for: {baseline}")
verify_as = [llm(f"Answer concisely: {vq}") for vq in verify_qs.splitlines()]
final = llm(f"Given verification:\n{verify_as}\nRevise: {baseline}")
```
**언제 쓰면 안 되는가:**
- *(TODO)*
### Self-refine loop
```python
draft = llm(f"Solve: {task}")
for _ in range(3):
critique = llm(f"Critique:\n{draft}\nList concrete issues; 'NONE' if perfect.")
if "NONE" in critique[:20]:
break
draft = llm(f"Revise based on critique:\n{critique}\n\nDraft:\n{draft}")
```
## 🧪 검증 상태 (Validation)
### Verifier-as-different-model
```python
draft = anthropic_call("claude-opus-4-7", task)
verdict = openai_call("gpt-5", f"Find errors in:\n{draft}")
final = anthropic_call("claude-opus-4-7", f"Address:\n{verdict}\n\nDraft:\n{draft}")
```
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
### Code self-test loop
```python
code = llm(f"Write Python for: {spec}")
for _ in range(3):
res = run_tests(code, spec.tests)
if res.passed:
break
code = llm(f"Tests failed:\n{res.report}\nFix:\n{code}")
```
## 🧬 중복 검사 (Duplicate Check)
### Extended thinking (Claude 2026)
```python
msg = anthropic.messages.create(
model="claude-opus-4-7",
thinking={"type": "enabled", "budget_tokens": 16000},
messages=[{"role": "user", "content": hard_problem}],
max_tokens=4096,
)
# 매 internal verify already happens within thinking
```
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
### RAG claim-by-claim verify
```python
claims = extract_claims(answer)
for c in claims:
evidence = retrieve(c)
ok = llm(f"Is '{c}' supported by:\n{evidence}\nyes/no")
if "no" in ok.lower():
flag(c)
```
## 🕓 변경 이력 (Changelog)
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Cheap, parallelizable | self-consistency |
| Factual long-form | CoVe |
| Iterative improvement | self-refine |
| Code / has tests | execution-grounded |
| Reasoning model 사용 가능 | thinking budget + light verify |
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
**기본값**: thinking + light claim-verify (RAG case) 또는 self-consistency (3-5 samples).
## 🔗 Graph
- 부모: [[Prompting-Techniques]] · [[LLM-Reasoning]]
- 변형: [[Chain-of-Thought]] · [[Self-Consistency]] · [[Reflexion]]
- 응용: [[RAG]] · [[Agent-Loops]] · [[Code-Generation]]
- Adjacent: [[Hallucination-Mitigation]] · [[Fact-Checking]]
## 🤖 LLM 활용
**언제**: 매 high-stakes accuracy, hallucination cost 큼. 매 budget 가 latency 보다 중요.
**언제 X**: 매 latency-critical (chat UI). 매 task 가 verify 가능한 ground truth 없음 (open creative).
## ❌ 안티패턴
- **Self-verify infinite loop**: 매 max iter cap 필수.
- **Same model verify same model on bias**: blind spots 공유 → cross-model verify.
- **Verify trivial output**: 매 cost waste — gating 필요.
- **Trust verify verdict blindly**: verify hallucinate 가능.
## 🧪 검증 / 중복
- Verified (Wang 2022 Self-Consistency, Dhuliawala 2023 CoVe, Madaan 2023 Self-Refine).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — verification family + thinking 2026 |