Skip to content

[Feat] Gpt prompt tuning#13

Merged
chaeyuuu merged 14 commits intomainfrom
feat/#10/gpt-prompt-tuning
Aug 13, 2025
Merged

[Feat] Gpt prompt tuning#13
chaeyuuu merged 14 commits intomainfrom
feat/#10/gpt-prompt-tuning

Conversation

@chaeyuuu
Copy link
Contributor

@chaeyuuu chaeyuuu commented Aug 13, 2025

💻 Related Issue


🚀 Work Description

  • 추가된 문항에 따른 키워드 추가
  • gpt 프롬프트 튜닝

🙇🏻‍♀️ To Reviewer

새로 추가된 문항에 대하여 키워드 예시 문항에 추가하였습니다. 더불어 점수화 로직을 수정하고 gpt 프롬프트 튜닝을 완료하였습니다.


Summary by CodeRabbit

  • 새로운 기능

    • 키워드 유사도 기반 매칭 도입(오타/공백/대소문자 포함) 및 사용자 키워드·추가설명까지 점수 산정 반영
    • 이미지 콘텐츠는 유형 분류 참고로 처리
  • 개선 사항

    • 점수 규칙 전면 재조정: 가중치 튜닝, 기관·행동 중심 토큰 확장, URL 의존도 축소, 상담 연결 유도 반영
    • 사기 예시 데이터의 키워드 체계를 멀티채널/범용 어휘로 고도화
    • 표시되는 사기 위험도 상한을 80으로 확대

@chaeyuuu chaeyuuu marked this pull request as ready for review August 13, 2025 08:46
@coderabbitai
Copy link

coderabbitai bot commented Aug 13, 2025

Walkthrough

FraudResponse.score 상한을 70→80으로 확장했고, FRAUD_EXAMPLES 및 score_rules의 키워드·가중치가 광범위하게 갱신되었으며, 스코어링 대상과 매칭 규칙이 messageContent/keywords/additionalDescription 및 유사어 완화 매칭으로 확장되었습니다. (50단어 이내)

Changes

Cohort / File(s) Summary
Model bound update
app/models/fraud_response.py
FraudResponse.score 상한 70→80 및 설명 갱신.
Prompt dataset overhaul
app/prompts/data/fraud_examples.py
FRAUD_EXAMPLES 키워드 체계 전면 개편(다중채널·기관·행위·행동 단서 추가, 용어 통일). 데이터 변경만 존재.
Scoring rules reweighting
app/prompts/data/score_rules.txt
CAT01–CAT18 가중치(A) 전반 재조정(대부분 하향), 토큰 확장·URL 의존도 축소, 상담 연결 유도 등 흐름 제어 표현 추가.
Scoring logic expansion
app/prompts/fraud_prompts.py
스코어링 대상 확대(messageContent, keywords, additionalDescription), 유사어/오탈자 완화 매칭 도입, imageContent는 분류 참고로 사용. 카테고리별 캡 유지 및 기존 동점 규칙 유지.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant FraudScorer as fraud_prompts.py
  participant RuleLoader as score_rules.txt
  participant Examples as fraud_examples.py

  User->>FraudScorer: messageContent, keywords, additionalDescription, imageContent
  FraudScorer->>RuleLoader: 규칙 불러오기(카테고리/가중치/토큰)
  RuleLoader-->>FraudScorer: 규칙 데이터
  FraudScorer->>FraudScorer: 텍스트·키워드·추가설명에서 완화 매칭 수행
  FraudScorer->>FraudScorer: 규칙별 점수 합산(카테고리 캡 적용, 최종 상한 80)
  FraudScorer->>Examples: 예시 힌트 조회(선택적)
  Examples-->>FraudScorer: 예시 기반 보조정보
  FraudScorer-->>User: FraudResponse(score 0~80, category, matches, explanation)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
점수화 키워드 개선 (#12)
프롬프트 튜닝 (#12)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
FraudResponse.score 상한 70→80 (app/models/fraud_response.py) 이슈 #12는 키워드·프롬프트 튜닝을 요구하며, 모델 응답 필드 상한 변경은 명시된 목표에 포함되어 있지 않음.

Possibly related PRs

  • [Feat] 점수화 로직 추가 #11: 동일한 FraudResponse.score 필드 범위 조정 및 관련 prompts/데이터 변경을 다루어 코드 레벨 상 직접적인 연관성이 있음.

Suggested labels

🚀 Feature

Suggested reviewers

  • yeonju73

Poem

토끼가 깡충 와서 말하네, 점수는 이제 여든까지 뛰어도 좋아요.
키워드 밭에 새 씨앗 뿌려, 기관 이름 콕콕 심었지요.
철자 하나 삐끗해도 귀로 알아듣는 귀여운 귀,
프롬프트 길 닦아 올바른 길로 인도할게요. 🥕✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8806e09 and 72cdda8.

📒 Files selected for processing (1)
  • app/prompts/fraud_prompts.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/prompts/fraud_prompts.py
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#10/gpt-prompt-tuning

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🔭 Outside diff range comments (2)
app/prompts/fraud_prompts.py (2)

34-34: 점수 범위 불일치 문제

Line 34에서 점수 범위가 여전히 "0~70"으로 되어 있으나, FraudResponse 모델에서는 상한이 80으로 변경되었습니다.

-  "score": <0~70의 실수값>
+  "score": <0~80의 실수값>

11-11: 시스템 프롬프트의 점수 범위 업데이트 필요

Line 11에서도 점수 범위가 "최대 70점"으로 되어 있어 업데이트가 필요합니다.

-3) 점수는 최소 0점에서 최대 70점
+3) 점수는 최소 0점에서 최대 80점
♻️ Duplicate comments (1)
app/prompts/data/fraud_examples.py (1)

65-65: Line 65의 키워드 형식 불일치 발견

Line 23과 동일하게 "송금/현금인출" 키워드에 불필요한 공백이 있습니다.

🧹 Nitpick comments (2)
app/prompts/fraud_prompts.py (2)

16-19: 점수 계산 로직이 명확하게 확장되었습니다.

messageContent, keywords, additionalDescription 필드를 모두 고려하도록 점수 계산 로직이 확장되었습니다. 특히 Line 17의 "의미/표현상 해당 룰에 해당된다면 판단하면"이라는 표현은 다소 어색하니 수정을 제안합니다.

-- 'messageContent', 'keywords', 'additionalDescription'에 해당 룰의 키워드 중 1개라도 의미/표현상 해당 룰에 해당된다면 판단하면 그 룰의 배점을 가산(룰별 최대 1회).
+- 'messageContent', 'keywords', 'additionalDescription'에 해당 룰의 키워드 중 1개라도 의미/표현상 매칭되면 그 룰의 배점을 가산(룰별 최대 1회).

19-20: 유사 키워드 매칭 로직 추가가 효과적입니다.

Line 19의 "규칙표의 각자 룰들의 키워드들의 유사성을 분석하고"는 문법적으로 개선이 필요합니다. 관대한 매칭은 사기 탐지율을 높이는 데 도움이 될 것입니다.

-- 규칙표의 각자 룰들의 키워드들의 유사성을 분석하고, 유사한 키워드도 해당 룰에 매칭여부를 관대하게 판단할 것을 명심해라.
+- 규칙표의 각 룰에 있는 키워드들의 유사성을 분석하고, 유사한 키워드도 해당 룰에 매칭되는 것으로 관대하게 판단할 것.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d50b898 and ccbdbe6.

📒 Files selected for processing (4)
  • app/models/fraud_response.py (1 hunks)
  • app/prompts/data/fraud_examples.py (18 hunks)
  • app/prompts/data/score_rules.txt (1 hunks)
  • app/prompts/fraud_prompts.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
app/prompts/data/fraud_examples.py (1)
app/prompts/fraud_example.py (1)
  • FraudExample (4-8)
🔇 Additional comments (9)
app/models/fraud_response.py (1)

8-8: 점수 상한 변경이 적절히 적용되었습니다.

위험도 점수 상한이 70에서 80으로 증가되었고, 설명도 일치하게 업데이트되었습니다. 변경이 정확하게 구현되었습니다.

app/prompts/data/fraud_examples.py (3)

19-27: 새로운 키워드 분류 체계가 잘 적용되었습니다.

"문자 및 전화 (연계 사용)", "금융기관", "송금/현금인출" 등 멀티채널 사기 패턴을 포착하는 새로운 키워드들이 추가되었습니다. 특히 복합적인 사기 수법을 탐지하는 데 효과적일 것으로 보입니다.


87-89: 새로운 사기 유형별 키워드 구성이 적절합니다.

돌잔치 초대장형에 "문자/메신저", "가족/친구/지인", "앱 설치(링크클릭)/파일 다운로드" 키워드가 적절히 배치되어 해당 사기 유형의 특성을 잘 반영하고 있습니다.


216-218: 투자 관련 사기 유형의 키워드 확장이 체계적입니다.

알바/부업, 가상화폐, 주식투자, 청약 공모주 사기형에 대해 "투자회사/가상화폐거래소", "주식추천/리딩방/청약당첨", "투자리딩방/가상화폐거래소" 등 세분화된 키워드가 추가되어 금융 사기 탐지 정확도가 향상될 것으로 예상됩니다.

Also applies to: 277-281, 298-301, 319-322

app/prompts/fraud_prompts.py (1)

21-21: 카테고리별 점수 상한 유지에 대한 확인 필요

카테고리별 점수 상한이 여전히 70으로 유지되고 있으나, FraudResponse.score의 상한은 80으로 증가했습니다. 이는 의도적인 것인지 확인이 필요합니다.

프롬프트에서 카테고리별 상한을 70으로 유지하면서 전체 점수 상한을 80으로 설정한 것이 의도적인지 확인이 필요합니다. 만약 의도적이라면 여러 카테고리의 점수를 합산하는 로직이 있는지, 아니면 보너스 점수가 추가되는지 명확히 해야 합니다.

app/prompts/data/score_rules.txt (4)

2-7: 기관 사칭형(CAT01) 가중치 조정이 적절합니다.

A 가중치가 30에서 20으로 감소했고, "정부/공공기관", "범죄연루" 등 새로운 키워드가 추가되어 탐지 범위가 확대되었습니다.


15-15: "상담 연결 유도" 키워드의 전략적 배치가 효과적입니다.

여러 카테고리에 "상담 연결 유도" 키워드가 추가되어 피싱의 핵심 패턴인 상담 유도를 효과적으로 탐지할 수 있을 것으로 보입니다.

Also applies to: 22-22, 30-30, 36-36, 44-44, 68-68, 81-81, 105-105, 112-112, 128-128


94-98: 택배 사기형(CAT13) 확장이 포괄적입니다.

택배사 목록(CJ대한통운, 한진택배, 로젠택배)과 배송 관련 키워드("배송 조회", "배송조회 페이지")가 추가되어 택배 사칭 사기를 더 효과적으로 탐지할 수 있을 것입니다.


100-105: 가상화폐 사기형(CAT14) 재구성이 체계적입니다.

가상화폐 거래소를 A 항목으로 재배치하고 가중치를 조정한 것이 적절합니다. 특히 "해외IP 로그인", "휴면계정 소각" 등 실제 사기 수법을 반영한 키워드가 효과적입니다.

@chaeyuuu chaeyuuu merged commit 37ddca1 into main Aug 13, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor] GPT 프롬프트 튜닝

2 participants