Skip to content

추출 프롬프트에 전역 grounding 규칙 추가 - #29

Merged
m-a-king merged 1 commit into
mainfrom
feat/prompt-grounding
Aug 11, 2026
Merged

추출 프롬프트에 전역 grounding 규칙 추가#29
m-a-king merged 1 commit into
mainfrom
feat/prompt-grounding

Conversation

@m-a-king

@m-a-king m-a-king commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Situation

Task

Action

  • 전역 규칙 서두 승격: 모든 출력 값은 제공된 HTML 에 존재해야 하고, 없으면 null(상품 자체가 없으면 isProductPage=false). 기억·유사 상품에서 회상한 값 생성을 명시 금지하고 "창작이 null 보다 엄격히 나쁘다" 는 우선순위를 박았다.
  • imageUrl 개별 강화: URL(또는 resolve 전 상대경로)이 HTML 에 실재해야 하며 조립·축약 금지. 사고에서 창작된 이미지 URL 이 전부 NXDOMAIN/403 이었던 것의 직접 대응이다.
  • 프롬프트 텍스트만 변경 - 스키마·코드 로직 무변경.

Result

  • 프롬프트는 확률적 방어라 보장이 아니다 - 효과는 dev 에서 병행 중인 모델 실험(extraction_models 에 gemini-3.6-flash 등록, 배포 없음)과 함께 via=llm 대비 UNTRUSTWORTHY_VALUE·INCOMPLETE_SNAPSHOT 비율 전후 비교로 측정한다.
  • 박스 1대를 전 환경이 공유하므로 머지(=자동 배포, 배포를 main push 자동 + blue-green 무중단 전환으로 개편 #27) 시 dev·prod 에 동시 적용된다. dev 는 모델+프롬프트, prod 는 프롬프트만 바뀌는 상태가 되어 두 효과를 어느 정도 분리 관찰할 수 있다.

연관 이슈

Summary by CodeRabbit

  • 개선 사항
    • 상품 정보 추출 시 제공된 HTML에 실제로 존재하는 내용만 사용하도록 정확도를 강화했습니다.
    • HTML에서 확인되지 않는 값은 null로 처리하고, 상품 페이지가 아니면 이를 명확히 표시합니다.
    • 이미지 URL을 임의로 생성하거나 축약하지 않고, HTML에 포함된 실제 URL만 사용합니다.

- 기존 "DO NOT GUESS" 는 Strategy 3(가격)에 국한돼 있었고, 빈 셸 환각 사고(에이블리 mobile.*, 15회 중 8회 창작)에서 flash-lite 가 이 지시를 절반가량만 따르는 것이 실측됐다. 극한(빈 입력)은 #26 게이트가 결정론으로 막았으므로, 이 규칙은 남은 표면 - 내용이 일부 있는 페이지에서 없는 필드를 채워 넣는 창작 - 을 겨냥한다
- 전역 규칙을 프롬프트 서두에 승격: 모든 출력 값은 제공된 HTML 에 존재해야 하고, 없으면 null(상품 자체가 없으면 isProductPage=false). 기억·유사 상품에서 회상한 값 생성을 명시적으로 금지하고 "창작이 null 보다 엄격히 나쁘다"는 우선순위를 박는다
- imageUrl 필드에도 개별 강화: URL(또는 resolve 전 상대경로)이 HTML 에 실재해야 하며 조립·축약 금지. 사고에서 창작된 이미지가 전부 NXDOMAIN/403 이었던 것의 직접 대응이며, 보류 중인 출력 대조(grounding 검증) PR 이 들어오기 전까지의 확률적 방어층이다
- 효과 측정은 dev 모델 실험(gemini-3.6-flash, extraction_models)과 함께 via=llm 대비 UNTRUSTWORTHY_VALUE·INCOMPLETE_SNAPSHOT 비율로 본다
@m-a-king m-a-king added the feat 외부 가시적 새 기능 label Aug 11, 2026
@m-a-king m-a-king self-assigned this Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

SYSTEM_PROMPT가 HTML 근거 우선 규칙을 사용하도록 변경되었습니다. 확인할 수 없는 값은 null 또는 isProductPage=false로 반환합니다. imageUrl은 HTML에 존재하는 URL만 사용합니다.

Changes

Gemini HTML 근거 규칙

Layer / File(s) Summary
HTML 근거 및 이미지 URL 검증
src/main/java/com/depromeet/piki/extractor/extraction/gemini/GeminiExtractionRequest.java
모든 출력값을 제공된 HTML에서 추출하도록 지정했습니다. 확인할 수 없는 값은 null로 반환하고, 추측이나 유사 상품 기반 생성을 금지합니다. imageUrl은 HTML의 원본 URL 또는 해석 가능한 상대 경로만 사용하며, 없으면 null을 반환합니다.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 추출 프롬프트에 전역 grounding 규칙을 추가한 주요 변경 사항을 정확하고 간결하게 설명합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/com/depromeet/piki/extractor/extraction/gemini/GeminiExtractionRequest.java`:
- Around line 59-65: Update the currency guidance in the GeminiExtractionRequest
prompt so it follows the highest-priority grounding rule: return null when the
HTML lacks an explicit currency code or unambiguous currency symbol, and remove
any permission to infer currency from page language or locale.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d8762f13-c04b-4225-8218-540c09c5fc0d

📥 Commits

Reviewing files that changed from the base of the PR and between f64be1b and 48fbdac.

📒 Files selected for processing (1)
  • src/main/java/com/depromeet/piki/extractor/extraction/gemini/GeminiExtractionRequest.java

Comment on lines +59 to +65
**Grounding rule (highest priority, applies to every field)**:
Every value you output MUST be taken from the provided HTML. If a value is not present
in the HTML, return null for that field (or isProductPage=false if the page shows no
product at all). NEVER invent, guess, or recall values from memory or from similar
products you have seen elsewhere. A fabricated value is the worst possible outcome —
strictly worse than null.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

currency 추론 규칙과의 충돌을 해소해야 합니다.

Line 59-65는 모든 출력값을 제공된 HTML에서만 가져오도록 요구합니다. 그러나 Line 86은 HTML에서 통화가 모호하면 페이지 언어 또는 locale로 currency를 추론하도록 허용합니다. 이 경우 모델이 HTML에 없는 통화 코드를 출력할 수 있습니다.

HTML에 통화 코드나 모호하지 않은 통화 표기가 없으면 null을 반환하도록 Line 86을 수정해야 합니다.

수정 예시
-            4. currency (string): ISO 4217 code (KRW, USD, JPY, EUR, etc.). Infer from page language/locale if ambiguous.
+            4. currency (string): ISO 4217 code only when the code or an unambiguous currency marker appears in the HTML. If the currency is absent or ambiguous, return null.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/depromeet/piki/extractor/extraction/gemini/GeminiExtractionRequest.java`
around lines 59 - 65, Update the currency guidance in the
GeminiExtractionRequest prompt so it follows the highest-priority grounding
rule: return null when the HTML lacks an explicit currency code or unambiguous
currency symbol, and remove any permission to infer currency from page language
or locale.

@m-a-king
m-a-king merged commit 819edf9 into main Aug 11, 2026
2 checks passed
@m-a-king
m-a-king deleted the feat/prompt-grounding branch August 11, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat 외부 가시적 새 기능

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant