Imports
We begin by importing a number 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. Observe: An OpenAI API key’s required for this mission, 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 are going to 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 browse 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 essential as a result of it can encourage GPT-4o-mini to generate a brand new resume in markdown, which we will simply model right into a PDF. Observe: 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 jot 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 jot 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 extra recommendations for enchancment if ability gaps exist.
prompt_template = lambda resume_string, jd_string : f"""
You're a skilled resume optimization knowledgeable specializing in tailoring
resumes to particular job descriptions. Your purpose is to optimize my resume and
present actionable recommendations for enchancment to align with the goal function.### Tips:
1. **Relevance**:
- Prioritize experiences, expertise, 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 below 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 focus on influence.
3. **Key phrase Optimization**:
- Combine **key phrases** and phrases from the job description naturally to
optimize for ATS (Applicant Monitoring Methods).
4. **Extra Solutions** *(If Gaps Exist)*:
- If the resume doesn't totally align with the job description, counsel:
1. **Extra technical or gentle expertise** 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 will higher align with the function.
5. **Formatting**:
- Output the tailor-made resume in **clear Markdown format**.
- Embody an **"Extra Solutions"** 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,
expertise, and achievements.
- Incorporates job description **key phrases** to optimize for ATS.
- Makes use of sturdy language and is not than **one web page**.
2. **Extra Solutions** *(if relevant)*:
- Record **expertise** that might strengthen alignment with the function.
- Suggest **certifications or programs** to pursue.
- Counsel **particular tasks 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 consumer
consumer = OpenAI(api_key=my_sk)
# make api name
response = consumer.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 recommendations for enchancment.
# separate new resume from enchancment recommendations
response_list = response_string.break up("## Extra Solutions")
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 end result seems to be like.
For the advance recommendations, we will print these instantly.
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 beneath. 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 offered on the GitHub repository right here. Try the YouTube video to see me speak by the code.
Whereas tailoring one’s resume to particular job descriptions is an efficient solution to make an software 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.
You probably have any questions or need to dive deeper into any of the matters coated, let me know within the feedback 🙂
—
y2b.io helped me write this text.