Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
## Pull Request Title
<!-- Provide a concise and descriptive title for the pull request -->
fix: Harden resume improvement prompt to prevent AI hallucination
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Make the PR title field generic (don’t hardcode a specific fix).

Templates should not pre-fill a specific change; it will leak into unrelated PRs.

-fix: Harden resume improvement prompt to prevent AI hallucination
+<!-- e.g., fix: concise imperative summary (max 72 chars) -->
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fix: Harden resume improvement prompt to prevent AI hallucination
<!-- e.g., fix: concise imperative summary (max 72 chars) -->
🤖 Prompt for AI Agents
.github/PULL_REQUEST_TEMPLATE.md around line 3 contains a hardcoded PR title
("fix: Harden resume improvement prompt to prevent AI hallucination") which will
leak into unrelated PRs; replace that specific line with a generic placeholder
such as "Short, descriptive title of your change" or an empty line/instruction
like "PR title:" (do not prefill a concrete fix or prefix like "fix:") so
contributors must enter an appropriate, context-specific title.

Copy link
Contributor

Choose a reason for hiding this comment

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

PR template incorrectly filled with specific PR content instead of remaining generic

Prompt for AI agents
Address the following comment on .github/PULL_REQUEST_TEMPLATE.md at line 3:

<comment>PR template incorrectly filled with specific PR content instead of remaining generic</comment>

<file context>
@@ -1,49 +1,53 @@
 ## Pull Request Title
 &lt;!-- Provide a concise and descriptive title for the pull request --&gt;
+fix: Harden resume improvement prompt to prevent AI hallucination
 
 ## Related Issue
</file context>


## Related Issue
<!-- If this pull request is related to an issue, please link it here using the "#" symbol followed by the issue number (e.g., #123) -->
- Issue number : #307
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Don’t hardcode an issue number in the template.

Defaulting to #307 will mislead authors opening unrelated PRs.

-- Issue number : #307
+- Issue number: #<issue_id>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Issue number : #307
- Issue number: #<issue_id>
🤖 Prompt for AI Agents
.github/PULL_REQUEST_TEMPLATE.md around line 7 currently hardcodes "Issue number
: #307"; remove the hardcoded issue number and replace it with an empty
placeholder or instructive placeholder text (e.g., "Issue number:
#<issue-number>" or "Issue number: (if applicable)") so authors must fill the
correct issue when opening a PR; update the template line accordingly and ensure
it does not point to a specific issue by default.


## Description
<!-- Describe the changes made in this pull request. What problem does it solve or what feature does it add/modify? -->
This PR addresses a critical issue with AI hallucination in the resume improvement feature where the model would fabricate details not present in the user's original resume. The prompt in `resume_improvement.py` has been completely overhauled with explicit anti-fabrication directives and a structured reasoning framework to ensure all output is truthful and grounded solely in the provided user data.
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove PR-specific description from the template body.

Templates should guide authors; they shouldn’t contain content for a particular change.

-This PR addresses a critical issue with AI hallucination in the resume improvement feature where the model would fabricate details not present in the user's original resume. The prompt in `resume_improvement.py` has been completely overhauled with explicit anti-fabrication directives and a structured reasoning framework to ensure all output is truthful and grounded solely in the provided user data.
+<!-- Describe the changes made in this pull request. What problem does it solve or what feature does it add/modify? -->
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
This PR addresses a critical issue with AI hallucination in the resume improvement feature where the model would fabricate details not present in the user's original resume. The prompt in `resume_improvement.py` has been completely overhauled with explicit anti-fabrication directives and a structured reasoning framework to ensure all output is truthful and grounded solely in the provided user data.
<!-- Describe the changes made in this pull request. What problem does it solve or what feature does it add/modify? -->
🤖 Prompt for AI Agents
In .github/PULL_REQUEST_TEMPLATE.md around line 11, the template contains a
PR-specific description about a resume_improvement.py change; remove that
specific paragraph so the template remains generic, and replace it with a
neutral placeholder or guidance such as a short prompt like "Describe the
purpose and scope of this PR" or checklist items for authors to fill in; ensure
no file- or change-specific text remains in the template.


## Type
<!-- Check the relevant options by putting an "x" in the brackets -->

- [ ] Bug Fix
- [x] Bug Fix
- [ ] Feature Enhancement
- [ ] Documentation Update
- [ ] Code Refactoring
- [ ] Other (please specify):
- [x] Code Refactoring
- [ ] Other (please specify):

Comment on lines +16 to 21
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Leave type checkboxes unchecked by default.

Pre-checking biases unrelated PRs and reduces signal quality in triage.

-- [x] Bug Fix
+- [ ] Bug Fix
 - [ ] Feature Enhancement
 - [ ] Documentation Update
-- [x] Code Refactoring
+- [ ] Code Refactoring
 - [ ] Other (please specify):
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- [x] Bug Fix
- [ ] Feature Enhancement
- [ ] Documentation Update
- [ ] Code Refactoring
- [ ] Other (please specify):
- [x] Code Refactoring
- [ ] Other (please specify):
- [ ] Bug Fix
- [ ] Feature Enhancement
- [ ] Documentation Update
- [ ] Code Refactoring
- [ ] Other (please specify):
🧰 Tools
🪛 LanguageTool

[grammar] ~16-~16: There might be a mistake here.
Context: ...n "x" in the brackets --> - [x] Bug Fix - [ ] Feature Enhancement - [ ] Documentat...

(QB_NEW_EN)


[grammar] ~17-~17: There might be a mistake here.
Context: ... - [x] Bug Fix - [ ] Feature Enhancement - [ ] Documentation Update - [x] Code Refa...

(QB_NEW_EN)


[grammar] ~18-~18: There might be a mistake here.
Context: ...e Enhancement - [ ] Documentation Update - [x] Code Refactoring - [ ] Other (please...

(QB_NEW_EN)


[grammar] ~19-~19: There might be a mistake here.
Context: ...umentation Update - [x] Code Refactoring - [ ] Other (please specify): ## Proposed...

(QB_NEW_EN)

🤖 Prompt for AI Agents
In .github/PULL_REQUEST_TEMPLATE.md around lines 16 to 21, the template
currently pre-checks the Bug Fix and Code Refactoring boxes; update the template
so all checkbox items are unchecked by default. Remove the leading "x" from
those two lines (and ensure no other options are pre-checked) so contributors
must explicitly select the relevant type when opening a PR.

## Proposed Changes
<!-- List the specific changes made in this pull request -->

-
-
-
- Completely revamped the prompt in `apps/backend/app/prompt/resume_improvement.py`
- Added explicit anti-hallucination directives forbidding invention of details
- Implemented structured "Analyze then Revise" framework for better AI reasoning
- Enhanced quantification handling with placeholder usage for implied metrics
- Strengthened output formatting rules for consistent parsing

Comment on lines +25 to +30
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Replace PR-specific change list with placeholders.

The template should prompt authors to enumerate their changes rather than prescribe this PR’s content.

-- Completely revamped the prompt in `apps/backend/app/prompt/resume_improvement.py`
-- Added explicit anti-hallucination directives forbidding invention of details
-- Implemented structured "Analyze then Revise" framework for better AI reasoning
-- Enhanced quantification handling with placeholder usage for implied metrics
-- Strengthened output formatting rules for consistent parsing
+- <List the specific changes made in this pull request>
+- <Be concrete: file paths, functions/modules touched, migrations, configs>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Completely revamped the prompt in `apps/backend/app/prompt/resume_improvement.py`
- Added explicit anti-hallucination directives forbidding invention of details
- Implemented structured "Analyze then Revise" framework for better AI reasoning
- Enhanced quantification handling with placeholder usage for implied metrics
- Strengthened output formatting rules for consistent parsing
- <List the specific changes made in this pull request>
- <Be concrete: file paths, functions/modules touched, migrations, configs>
🧰 Tools
🪛 LanguageTool

[grammar] ~25-~25: There might be a mistake here.
Context: ...-> - Completely revamped the prompt in apps/backend/app/prompt/resume_improvement.py - Added explicit anti-hallucination direct...

(QB_NEW_EN)


[grammar] ~26-~26: There might be a mistake here.
Context: ...rectives forbidding invention of details - Implemented structured "Analyze then Rev...

(QB_NEW_EN)


[grammar] ~27-~27: There might be a mistake here.
Context: ...evise" framework for better AI reasoning - Enhanced quantification handling with pl...

(QB_NEW_EN)


[grammar] ~28-~28: There might be a mistake here.
Context: ...th placeholder usage for implied metrics - Strengthened output formatting rules for...

(QB_NEW_EN)

🤖 Prompt for AI Agents
In .github/PULL_REQUEST_TEMPLATE.md around lines 25 to 30, the template
currently contains a hard-coded PR changelist that prescribes this PR's content;
replace those specific bullet points with neutral placeholders prompting authors
to list their changes (e.g., a short instruction line and an empty bullet list
or checklist for changed files, features, and fixes). Ensure the wording guides
contributors to briefly describe what changed, why, and any migration or testing
notes, without including any PR-specific content.


## Screenshots / Code Snippets (if applicable)
<!-- Include any relevant screenshots or code snippets that help visualize the changes made -->

## How to Test
<!-- Provide step-by-step instructions or a checklist for testing the changes in this pull request -->

1.
2.
3.
- Do a general tool run and feed the data. You'll witness the effect of the modified prompt.

## Checklist
<!-- Put an "x" in the brackets for the items that apply to this pull request -->

- [ ] The code compiles successfully without any errors or warnings
- [ ] The changes have been tested and verified
- [x] The code compiles successfully without any errors or warnings
- [x] The changes have been tested and verified
- [ ] The documentation has been updated (if applicable)
- [ ] The changes follow the project's coding guidelines and best practices
- [ ] The commit messages are descriptive and follow the project's guidelines
- [ ] All tests (if applicable) pass successfully
- [ ] This pull request has been linked to the related issue (if applicable)
- [x] The changes follow the project's coding guidelines and best practices
- [x] The commit messages are descriptive and follow the project's guidelines
- [x] All tests (if applicable) pass successfully
- [x] This pull request has been linked to the related issue (if applicable)
Comment on lines +43 to +49
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Uncheck all checklist items by default.

Checked boxes in the template undermine their purpose.

-- [x] The code compiles successfully without any errors or warnings
- - [x] The changes have been tested and verified
+ - [ ] The code compiles successfully without any errors or warnings
+ - [ ] The changes have been tested and verified
  - [ ] The documentation has been updated (if applicable)
-- [x] The changes follow the project's coding guidelines and best practices
-- [x] The commit messages are descriptive and follow the project's guidelines
-- [x] All tests (if applicable) pass successfully
-- [x] This pull request has been linked to the related issue (if applicable)
+ - [ ] The changes follow the project's coding guidelines and best practices
+ - [ ] The commit messages are descriptive and follow the project's guidelines
+ - [ ] All tests (if applicable) pass successfully
+ - [ ] This pull request has been linked to the related issue (if applicable)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- [x] The code compiles successfully without any errors or warnings
- [x] The changes have been tested and verified
- [ ] The documentation has been updated (if applicable)
- [ ] The changes follow the project's coding guidelines and best practices
- [ ] The commit messages are descriptive and follow the project's guidelines
- [ ] All tests (if applicable) pass successfully
- [ ] This pull request has been linked to the related issue (if applicable)
- [x] The changes follow the project's coding guidelines and best practices
- [x] The commit messages are descriptive and follow the project's guidelines
- [x] All tests (if applicable) pass successfully
- [x] This pull request has been linked to the related issue (if applicable)
- [ ] The code compiles successfully without any errors or warnings
- [ ] The changes have been tested and verified
- [ ] The documentation has been updated (if applicable)
- [ ] The changes follow the project's coding guidelines and best practices
- [ ] The commit messages are descriptive and follow the project's guidelines
- [ ] All tests (if applicable) pass successfully
- [ ] This pull request has been linked to the related issue (if applicable)
🤖 Prompt for AI Agents
.github/PULL_REQUEST_TEMPLATE.md lines 43-49: the checklist currently has
several items pre-checked which defeats the template's purpose; change all
checked boxes ([x]) to unchecked ([ ]) so every checklist item is blank by
default, ensuring contributors must consciously confirm each item when opening a
PR.


## Additional Information
<!-- Add any other information about the pull request that you think might be helpful -->

This change is critical for maintaining user trust and ensuring the resume improvement feature provides truthful, accurate enhancements rather than fabricated content. The new prompt structure can serve as a template for other AI-powered features that require similar constraints against hallucination.
82 changes: 67 additions & 15 deletions apps/backend/app/prompt/resume_improvement.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
# New optimised prompt which tackles the problems stated at (https://github.com/srbhr/Resume-Matcher/issues/374)

PROMPT = """
You are an expert resume editor and talent acquisition specialist. Your task is to revise the following resume so that it aligns as closely as possible with the provided job description and extracted job keywords, in order to maximize the cosine similarity between the resume and the job keywords.
Instructions:
- Carefully review the job description and the list of extracted job keywords.
- Update the candidate's resume by:
- Emphasizing and naturally incorporating relevant skills, experiences, and keywords from the job description and keyword list.
- Where appropriate, naturally weave the extracted job keywords into the resume content.
- Rewriting, adding, or removing resume content as needed to better match the job requirements.
- Maintaining a natural, professional tone and avoiding keyword stuffing.
- Where possible, use quantifiable achievements and action verbs.
- The current cosine similarity score is {current_cosine_similarity:.4f}. Revise the resume to further increase this score.
- ONLY output the improved updated resume. Do not include any explanations, commentary, or formatting outside of the resume itself.
Job Description:
ROLE: You are an expert, meticulous, and ETHICAL resume editor. Your primary directive is to enhance the candidate's existing experience truthfully and effectively, strictly avoiding any form of fabrication or exaggeration (HALLUCINATION).
CORE PRINCIPLE: You MUST ground all revisions SOLELY in the information provided in the 'Original Resume'. You are FORBIDDEN from inventing new companies, job titles, degrees, certifications, or specific projects/metrics that are not present in the original text. Your goal is to reframe and emphasize existing truths to better align with the target job.
TASK: Revise the resume below to increase its alignment with the provided job description, thereby maximizing the cosine similarity score (current score: {current_cosine_similarity:.4f}).
PROCESS:
1. ANALYSIS: First, analyze the job description and keywords. Identify the key requirements, skills, and terminologies.
2. MAPPING: Next, map these keywords to the closest matching experiences, skills, and achievements within the original resume.
3. REVISION: Finally, revise the resume by:
a. INCORPORATING KEYWORDS: Strategically integrating relevant keywords from the job description into the resume's content. Prioritize keywords with high relevance to the candidate's actual experience.
b. REWRITING FOR IMPACT: Rewriting bullet points and summaries to be more impactful, using strong action verbs (e.g., "Orchestrated," "Optimized," "Pioneered") and quantifiable achievements. FOR QUANTIFICATION: If numbers are implied but not stated (e.g., "managed a team"), you may use a placeholder like "[X]" (e.g., "Managed a team of [X] people"). If no number is implied, focus on the action and skill.
c. EMPHASIZING RELEVANCE: Reordering bullet points under a job experience to place the most relevant achievements first.
d. REMOVING IRRELEVANCY: Pruning obviously irrelevant or outdated information that does not support the candidate's narrative for this specific role.
e. MAINTAINING INTEGRITY: Ensuring all changes are a truthful representation of the candidate's background as presented in the original resume.
OUTPUT INSTRUCTIONS:
- Output ONLY the improved, updated resume in Markdown format.
- Preserve the original structure and sections (e.g., # Heading, ## Summary, ## Experience) of the provided resume.
- Do not add any new sections (like "Projects") unless they already exist in the original.
- Do not include any explanations, commentary, or metadata outside of the resume itself.
JOB DESCRIPTION:
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing closing markdown delimiter for JOB DESCRIPTION section

Prompt for AI agents
Address the following comment on apps/backend/app/prompt/resume_improvement.py at line 26:

<comment>Missing closing markdown delimiter for JOB DESCRIPTION section</comment>

<file context>
@@ -1,21 +1,31 @@
+# New optimised prompt which tackles the problems stated at (https://github.com/srbhr/Resume-Matcher/issues/374)
+
 PROMPT = &quot;&quot;&quot;
-You are an expert resume editor and talent acquisition specialist. Your task is to revise the following resume so that it aligns as closely as possible with the provided job description and extracted job keywords, in order to maximize the cosine similarity between the resume and the job keywords.
-
-Instructions:
-- Carefully review the job description and the list of extracted job keywords.
-- Update the candidate&#39;s resume by:
-  - Emphasizing and naturally incorporating relevant skills, experiences, and keywords from the job description and keyword list.
</file context>

```md
{raw_job_description}
```
Extracted Job Keywords:
```md
Expand All @@ -34,3 +44,45 @@
NOTE: ONLY OUTPUT THE IMPROVED UPDATED RESUME IN MARKDOWN FORMAT.
"""


# LEGACY PROMPT - USE WITH CAUTION:
# This version has known issues with potential AI hallucination.
# Remove from the file if the admin is satisfied with the new one when reviewing the changes made.

# PROMPT = """
# You are an expert resume editor and talent acquisition specialist. Your task is to revise the following resume so that it aligns as closely as possible with the provided job description and extracted job keywords, in order to maximize the cosine similarity between the resume and the job keywords.

# Instructions:
# - Carefully review the job description and the list of extracted job keywords.
# - Update the candidate's resume by:
# - Emphasizing and naturally incorporating relevant skills, experiences, and keywords from the job description and keyword list.
# - Where appropriate, naturally weave the extracted job keywords into the resume content.
# - Rewriting, adding, or removing resume content as needed to better match the job requirements.
# - Maintaining a natural, professional tone and avoiding keyword stuffing.
# - Where possible, use quantifiable achievements and action verbs.
# - The current cosine similarity score is {current_cosine_similarity:.4f}. Revise the resume to further increase this score.
# - ONLY output the improved updated resume. Do not include any explanations, commentary, or formatting outside of the resume itself.

# Job Description:
# ```md
# {raw_job_description}
# ```

# Extracted Job Keywords:
# ```md
# {extracted_job_keywords}
# ```

# Original Resume:
# ```md
# {raw_resume}
# ```

# Extracted Resume Keywords:
# ```md
# {extracted_resume_keywords}
# ```

# NOTE: ONLY OUTPUT THE IMPROVED UPDATED RESUME IN MARKDOWN FORMAT.
# """