"매 모델이 자기 출력을 다시 읽고 평가/수정". 철학에서는 1인칭 자기 의식 접근을 의미하고, LLM에서는 self-critique → revise loop로 정확도/정합성을 끌어올리는 핵심 prompting pattern.
매 핵심
매 두 가지 의미
철학 (Locke, Kant): mind 자체를 관찰하는 1인칭 access. qualia, self-model.
LLM: 자기 응답을 input 으로 다시 받아 비판/개선. Reflexion, Self-Refine, CoVe 계열.
매 동작 원리
Generate: 초안 응답 produce.
Critique: 같은 모델이 초안을 평가 (오류, 누락, 가정).
Revise: critique 반영 재생성.
(선택) 수렴할 때까지 반복.
매 응용
Reasoning 정확도 향상 (math, code).
Hallucination 검출 (CoVe — Chain of Verification).
Agent 환경: tool 호출 결과 self-evaluate 후 재시도.
RLHF reward modeling 대안 (constitutional AI).
💻 패턴
Self-Refine (single-model loop)
defself_refine(prompt,model,max_iters=3):answer=model.invoke(f"Answer: {prompt}")for_inrange(max_iters):feedback=model.invoke(f"Critique this answer (errors, gaps):\n{answer}")if"no issues"infeedback.lower():breakanswer=model.invoke(f"Original: {prompt}\nDraft: {answer}\nFeedback: {feedback}\nRevised:")returnanswer
Reflexion (verbal RL)
classReflexionAgent:def__init__(self,llm):self.llm=llmself.memory=[]# past reflectionsdefact(self,task):ctx="\n".join(self.memory)result=self.llm(f"{ctx}\nTask: {task}")ifnotself.evaluate(result):reflection=self.llm(f"Why did this fail?\n{result}")self.memory.append(reflection)returnresult
PRINCIPLES=["harmless","honest","helpful"]defconstitutional_revise(response,llm):forpinPRINCIPLES:critique=llm(f"Critique by '{p}':\n{response}")response=llm(f"Revise per critique:\n{critique}")returnresponse