From 617c51ca53cf6c9d4d6427d12d28517bdd1f5a5c Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Sat, 7 Mar 2026 12:52:08 +0900 Subject: [PATCH] =?UTF-8?q?perf:=20RAG=20Q&A=20=EC=86=8D=EB=8F=84=20?= =?UTF-8?q?=EC=B5=9C=EC=A0=81=ED=99=94=20=EB=B0=8F=20=ED=94=84=EB=A1=AC?= =?UTF-8?q?=ED=94=84=ED=8A=B8=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 검색 건수 15건 → 7건으로 축소 (컨텍스트 경량화) - 프롬프트: 500자 이내 간결 답변 유도, 마크다운 포맷 지시 Co-Authored-By: Claude Opus 4.6 --- ai-service/prompts/rag_qa.txt | 13 ++++++------- ai-service/services/rag_service.py | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ai-service/prompts/rag_qa.txt b/ai-service/prompts/rag_qa.txt index a84dcd5..7c3fa74 100644 --- a/ai-service/prompts/rag_qa.txt +++ b/ai-service/prompts/rag_qa.txt @@ -1,4 +1,4 @@ -당신은 공장 품질관리(QC) 데이터 분석가입니다. 아래 질문에 대해 과거 부적합 데이터를 기반으로 답변하세요. +당신은 공장 품질관리(QC) 전문가입니다. 과거 부적합 데이터를 기반으로 질문에 답변하세요. [질문] {question} @@ -6,9 +6,8 @@ [관련 부적합 데이터] {retrieved_cases} -위 데이터를 근거로 질문에 답변하세요. -- 제공된 데이터를 적극적으로 활용하여 답변하세요 -- 관련 사례를 구체적으로 인용하며 분석하세요 -- 패턴이나 공통점이 있다면 정리하세요 -- 숫자나 통계가 있다면 포함하세요 -- 간결하되 유용한 답변을 하세요 \ No newline at end of file +답변 규칙: +- 핵심을 먼저 말하고 근거 사례를 인용하세요 +- 500자 이내로 간결하게 답변하세요 +- 마크다운 사용: **굵게**, 번호 목록, 소제목(###) 활용 +- 데이터에 없는 내용은 추측하지 마세요 \ No newline at end of file diff --git a/ai-service/services/rag_service.py b/ai-service/services/rag_service.py index df5cb20..56883b2 100644 --- a/ai-service/services/rag_service.py +++ b/ai-service/services/rag_service.py @@ -79,7 +79,7 @@ async def rag_ask(question: str, project_id: int = None) -> dict: """부적합 데이터를 기반으로 자연어 질문에 답변""" # 프로젝트 필터 없이 전체 데이터에서 검색 (과거 미지정 데이터 포함) results = await search_similar_by_text( - question, n_results=15, filters=None + question, n_results=7, filters=None ) context = _format_retrieved_issues(results)