feat(retrieval): 답변 프롬프트 위생 v2 — faithfulness/conciseness 누수 차단#68
Merged
TaskerJang merged 4 commits intoMay 30, 2026
Merged
Conversation
…nti-leak) v1 진단: 페르소나가 'subgraph 결과 전달자'라 답변에 그래프/관계타입/라벨/청크ID 같은 내부 용어가 새어 faithfulness가 깎이고(80-QA AC≥4인데 Not Faithful 다수), '명시적 관계 최우선·청크는 약한 보완' 지침이 GPT-5.2의 conservative grounding bias와 맞물려 원문에 답이 있어도 거부하게 만듦(over-refusal). v2 변경: - 페르소나: 그래프 결과 전달자 → 자료 근거로 답하는 금융 분석가 - 진실 소스 역전: sample_chunks.text = 1차 답변 근거, 관계/라벨/co-mention/chunk_id = 내부 힌트(노출 금지) - over-refusal 차단: 명시적 관계가 없어도 원문에 답이 있으면 단정해서 답함 - 기계어 금지어 리스트 + 원문에 없는 종목코드 금지 - padding 금지(GPT-5.2 §3.2), 깔끔한 N/A(negative AC 5.0 보존), 길이 2~4문장(§3.1) - 출력 전 self-check(§3.4 high_risk_self_check) + few-shot 전면 재작성(누수 예시 제거) ref: GPT-5.2 Prompting Guide, MS GraphRAG local search grounding rules
…leak) v1 진단: 페르소나가 '조회 결과 전달자'라 답변에 Cypher/그래프/라벨/group_size 같은 내부 용어가 새어 faithfulness가 깎임. 예시들이 "Company 라벨 상위 5개", "19 청크 언급", "entity 추출 라벨 품질 보강" 식 기계어를 모범답안으로 학습시킴. v2 변경: - 페르소나: 결과 전달자 → 자료 근거로 답하는 금융 분석가 - LangChain Cypher-QA 골든룰 이식: result는 권위 근거, 의심·보정 금지, 질문에 대한 답처럼 말하되 "결과/쿼리에 근거했다는 사실은 언급하지 말 것", 빈 결과→모름 - 기계어 금지(도메인 질문) + padding 금지 + 깔끔한 N/A + 길이 2~4문장 - 조건부 예외: 질문 자체가 분류/라벨링/문서구성을 묻는 메타 질문일 때만 '회사로 분류' 같은 분류 표현 허용(단 내부 라벨명·실행 디테일은 비노출). → filter_agg·limitation 류(GraphRAG가 BM25 이기는 영역) 정확도 보존 - 출력 전 self-check + few-shot 전면 재작성 ref: GPT-5.2 Prompting Guide, LangChain GraphCypherQAChain CYPHER_QA_TEMPLATE
ANSWER_PROMPT_PATH 만 local_retriever_answer_v2.md 로 변경 (위생 프롬프트 활성화). v1.md 는 롤백용으로 보존. 코드 로직 변경 없음.
ANSWER_PROMPT_PATH 만 text2cypher_answer_v2.md 로 변경 (위생 프롬프트 활성화). v1.md 는 롤백용으로 보존. 코드 로직 변경 없음.
This was referenced May 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
배경 — 측정이 짚어준 1순위 레버
gpt52_p1clean 80-QA 측정에서 가장 비용 대비 효과 큰 병목으로 답변 생성 프롬프트의 기계어 누수가 나왔다.
그래프 / HAS_METRIC / RECOMMENDED_FOR / 두산밥캣(247560) / Layer B / subgraph / 청크 c0001 / (p.정보 없음)같은 내부 시스템 용어가 답변 본문에 새어 원문에 없는 내용으로 판정됐기 때문.retrieval을 한 글자도 안 건드리고 답변 프롬프트만 고쳐도 faithfulness·conciseness가 오를 수 있는 영역이라 먼저 착수.
v1 진단
두 답변 프롬프트(
local_retriever_answer_v1.md,text2cypher_answer_v1.md) 공통:FACES_RISK 관계 / Company 라벨 상위 5개 / 19 청크 언급 / entity 추출 라벨 품질 보강같은 기계어를 모범답안으로 학습시킴.layer_b_relations를 "가장 신뢰도 높음",sample_chunks를 "약한 보완"으로 못 박음 → GPT-5.2의 conservative grounding bias와 맞물려 관계가 없으면 답을 거부.변경 내용
신규 v2 프롬프트 2개 + 로더 상수 2개 전환 (v1.md는 롤백용 보존, 코드 로직 변경 없음):
retrieval/prompts/local_retriever_answer_v2.mdretrieval/prompts/text2cypher_answer_v2.mdretrieval/local_retriever.pyANSWER_PROMPT_PATH→ v2 (1줄)retrieval/text2cypher.pyANSWER_PROMPT_PATH→ v2 (1줄)v2 공통 설계
sample_chunks.text(원문)·result(조회값) = 1차 답변 근거 / 관계·라벨·co-mention·chunk_id·group_size = 내부 힌트(답변 노출 금지).(247560)) 금지.text2cypher v2 — 조건부 예외
질문 자체가 분류/라벨링/문서구성을 묻는 메타 질문(예: graph_040 "회사로 분류된 게 실제 회사명인가", doc_type 집계)일 때만 '회사로 분류' 같은 분류 표현을 허용(내부 라벨명·실행 디테일은 비노출). 이 영역(filter_agg·limitation)이 GraphRAG가 BM25를 이기는 구간이라 정확도 보존을 위해 무조건 금지하지 않음.
레퍼런스
output_verbosity_spec(§3.1), scope drift 금지(§3.2),high_risk_self_check(§3.4) 차용.CYPHER_QA_TEMPLATE: "result는 권위 근거, 의심·보정 금지, 답처럼 말하되 근거 언급 금지, 빈 결과→모름" 골든룰 이식.검증 계획
동일 #61 커맨드로 재측정 후
gpt52_p1clean과 비교:기대: Faithfulness↑(기계어 누수 제거) · Conciseness↑ · AC 소폭↑(over-refusal 감소). → 블로그 3편 소재.
롤백
두 로더의
ANSWER_PROMPT_PATH를_v1.md로 되돌리면 즉시 원복.base가
feat/p1-extractor-hardening인 이유: 측정·클린그래프·#66/#67 수정이 그 브랜치에 있고 dev엔 아직 없음.