Imports
We begin by importing a couple of hand Python libraries. The important thing ones are openai for accessing GPT-4o-mini, in addition to markdown and weasyprint to create a PDF model of the ultimate resume. Be aware: An OpenAI API secret is required for this challenge, which I imported from a separate Python script.
from IPython.show import show, Markdown
from openai import OpenAI
from top_secret import my_skfrom markdown import markdown
from weasyprint import HTML
Step 1: Enter Resume & JD
Subsequent, we’ll load our enter resume into Python as a string and use Python’s enter() perform to permit us to copy-paste it into any job description once we run the script.
# open and skim the markdown file
with open("resumes/resume.md", "r", encoding="utf-8") as file:
resume_string = file.learn()# enter job description
jd_string = enter()
A element right here is that the resume is saved in a markdown format. That is vital as a result of it is going to encourage GPT-4o-mini to generate a brand new resume in markdown, which we will simply fashion right into a PDF. Be aware: ChatGPT (or the like) can convert your PDF resume to markdown.
Step 2: Assemble Immediate
With our resume and JD imported, we will now craft a immediate to instruct the mannequin to optimize the resume. A professional tip right here is to use ChatGPT to write down an preliminary model of this immediate as a result of 1) it’s fairly lengthy, and a couple of) LLMs have a tendency to write down directions extra aligned with the expectations of different LLMs.
After some experimentation, I ended up with the next immediate template, which rewrites the resume and makes further options for enchancment if talent gaps exist.
prompt_template = lambda resume_string, jd_string : f"""
You're a skilled resume optimization professional specializing in tailoring
resumes to particular job descriptions. Your objective is to optimize my resume and
present actionable options for enchancment to align with the goal function.### Pointers:
1. **Relevance**:
- Prioritize experiences, abilities, and achievements **most related to the
job description**.
- Take away or de-emphasize irrelevant particulars to make sure a **concise** and
**focused** resume.
- Restrict work expertise part to 2-3 most related roles
- Restrict bullet factors underneath every function to 2-3 most related impacts
2. **Motion-Pushed Outcomes**:
- Use **sturdy motion verbs** and **quantifiable outcomes** (e.g.,
percentages, income, effectivity enhancements) to spotlight affect.
3. **Key phrase Optimization**:
- Combine **key phrases** and phrases from the job description naturally to
optimize for ATS (Applicant Monitoring Techniques).
4. **Further Ideas** *(If Gaps Exist)*:
- If the resume doesn't totally align with the job description, counsel:
1. **Further technical or comfortable abilities** that I might add to make my
profile stronger.
2. **Certifications or programs** I might pursue to bridge the hole.
3. **Venture concepts or experiences** that might higher align with the function.
5. **Formatting**:
- Output the tailor-made resume in **clear Markdown format**.
- Embrace an **"Further Ideas"** part on the finish with
actionable enchancment suggestions.
---
### Enter:
- **My resume**:
{resume_string}
- **The job description**:
{jd_string}
---
### Output:
1. **Tailor-made Resume**:
- A resume in **Markdown format** that emphasizes related expertise,
abilities, and achievements.
- Incorporates job description **key phrases** to optimize for ATS.
- Makes use of sturdy language and is not than **one web page**.
2. **Further Ideas** *(if relevant)*:
- Listing **abilities** that would strengthen alignment with the function.
- Suggest **certifications or programs** to pursue.
- Counsel **particular initiatives or experiences** to develop.
"""
Step 3: Make API Name
Utilizing the above immediate template, we will dynamically assemble a immediate utilizing the enter resume and JD after which ship it to OpenAI through their API.
# create immediate
immediate = prompt_template(resume_string, jd_string)# setup api shopper
shopper = OpenAI(api_key=my_sk)
# make api name
response = shopper.chat.completions.create(
mannequin="gpt-4o-mini",
messages=[
{"role": "system", "content": "Expert resume writer"},
{"role": "user", "content": prompt}
],
temperature = 0.7
)
# extract response
response_string = response.selections[0].message.content material
Step 4: Save New Resume
Lastly, we will extract the optimized resume and options for enchancment.
# separate new resume from enchancment options
response_list = response_string.cut up("## Further Ideas")
For the resume, we will convert the markdown output to HTML utilizing the markdown library. Then, convert the HTML to a PDF utilizing weasyprint.
# save as PDF
output_pdf_file = "resumes/resume_new.pdf"# Convert Markdown to HTML
html_content = markdown(response_list[0])
# Convert HTML to PDF and save
HTML(string=html_content).write_pdf(output_pdf_file,
stylesheets=['resumes/style.css'])
Right here’s what the ultimate consequence appears to be like like.
For the development options, we will print these immediately.
show(Markdown(response_list[1]))
Bonus: Construct a GUI
Whereas the code above streamlines this course of to some extent, we will do higher. To enhance the usability of this software, we will create a easy internet interface utilizing Gradio.
The ultimate product is proven under. A person can add a markdown file of their resume and paste it into any job description extra straightforwardly. I additionally added an space the place customers can edit the brand new resume earlier than exporting it as a PDF.
The instance code is on the market on the GitHub repository right here. Try the YouTube video to see me discuss by the code.
Whereas tailoring one’s resume to particular job descriptions is an efficient strategy to make an utility stand out, it may be fairly tedious. Right here, we stroll by the implementation of an AI-powered resume optimization software utilizing Python and OpenAI’s API.
If in case you have any questions or wish to dive deeper into any of the subjects lined, let me know within the feedback 🙂
—
y2b.io helped me write this text.