Llama 包 - 简历筛选器 📄¶
此示例展示了如何使用简历筛选器 Llama 包。您可以在 https://llamahub.ai 上找到所有包
简历筛选器旨在根据一组标准分析候选人的简历,并决定候选人是否适合该职位。
在此示例中,我们将评估一份示例简历(例如,Jerry 的旧简历)。
In [ ]
已复制!
%pip install llama-index-readers-wikipedia
%pip install llama-index-readers-wikipedia
In [ ]
已复制!
!pip install llama-index llama-hub
!pip install llama-index llama-hub
设置数据¶
我们将加载一些关于 OpenAI、Sam、Mira 和 Emmett 的维基百科样本数据。为什么?没有特别的原因 :)
In [ ]
已复制!
from llama_index.readers.wikipedia import WikipediaReader
loader = WikipediaReader()
documents = loader.load_data(
pages=["OpenAI", "Sam Altman", "Mira Murati", "Emmett Shear"],
auto_suggest=False,
)
from llama_index.readers.wikipedia import WikipediaReader loader = WikipediaReader() documents = loader.load_data( pages=["OpenAI", "Sam Altman", "Mira Murati", "Emmett Shear"], auto_suggest=False, )
In [ ]
已复制!
# do sentence splitting on the first piece of text
from llama_index.core.node_parser import SentenceSplitter
# do sentence splitting on the first piece of text from llama_index.core.node_parser import SentenceSplitter
In [ ]
已复制!
sentence_splitter = SentenceSplitter(chunk_size=1024)
sentence_splitter = SentenceSplitter(chunk_size=1024)
我们获取每篇文章的第一个块。
In [ ]
已复制!
# get the first 1024 tokens for each entity
openai_node = sentence_splitter.get_nodes_from_documents([documents[0]])[0]
sama_node = sentence_splitter.get_nodes_from_documents([documents[1]])[0]
mira_node = sentence_splitter.get_nodes_from_documents([documents[2]])[0]
emmett_node = sentence_splitter.get_nodes_from_documents([documents[3]])[0]
# get the first 1024 tokens for each entity openai_node = sentence_splitter.get_nodes_from_documents([documents[0]])[0] sama_node = sentence_splitter.get_nodes_from_documents([documents[1]])[0] mira_node = sentence_splitter.get_nodes_from_documents([documents[2]])[0] emmett_node = sentence_splitter.get_nodes_from_documents([documents[3]])[0]
我们还将下载 Jerry 在 2019 年的简历。
从 LlamaHub 下载简历筛选器包¶
这里我们从 LlamaHub 下载简历筛选器包类。
我们将用它来实现两个用例
- 候选人是否适合前端 / 全栈工程师职位。
- 候选人是否适合担任 OpenAI 的首席执行官。
In [ ]
已复制!
from llama_index.core.llama_pack import download_llama_pack
from llama_index.core.llama_pack import download_llama_pack
In [ ]
已复制!
ResumeScreenerPack = download_llama_pack(
"ResumeScreenerPack", "./resume_screener_pack"
)
ResumeScreenerPack = download_llama_pack( "ResumeScreenerPack", "./resume_screener_pack" )
筛选机器学习工程师 (MLE) 职位的候选人¶
我们从 Meta 网站上获取了一份机器学习工程师 (MLE) 职位的描述。
In [ ]
已复制!
meta_jd = """\
Meta is embarking on the most transformative change to its business and technology in company history, and our Machine Learning Engineers are at the forefront of this evolution. By leading crucial projects and initiatives that have never been done before, you have an opportunity to help us advance the way people connect around the world.
The ideal candidate will have industry experience working on a range of recommendation, classification, and optimization problems. You will bring the ability to own the whole ML life cycle, define projects and drive excellence across teams. You will work alongside the world’s leading engineers and researchers to solve some of the most exciting and massive social data and prediction problems that exist on the web.\
"""
meta_jd = """\ Meta is embarking on the most transformative change to its business and technology in company history, and our Machine Learning Engineers are at the forefront of this evolution. By leading crucial projects and initiatives that have never been done before, you have an opportunity to help us advance the way people connect around the world. The ideal candidate will have industry experience working on a range of recommendation, classification, and optimization problems. You will bring the ability to own the whole ML life cycle, define projects and drive excellence across teams. You will work alongside the world’s leading engineers and researchers to solve some of the most exciting and massive social data and prediction problems that exist on the web.\ """
In [ ]
已复制!
resume_screener = ResumeScreenerPack(
job_description=meta_jd,
criteria=[
"2+ years of experience in one or more of the following areas: machine learning, recommendation systems, pattern recognition, data mining, artificial intelligence, or related technical field",
"Experience demonstrating technical leadership working with teams, owning projects, defining and setting technical direction for projects",
"Bachelor's degree in Computer Science, Computer Engineering, relevant technical field, or equivalent practical experience.",
],
)
resume_screener = ResumeScreenerPack( job_description=meta_jd, criteria=[ "2+ years of experience in one or more of the following areas: machine learning, recommendation systems, pattern recognition, data mining, artificial intelligence, or related technical field", "Experience demonstrating technical leadership working with teams, owning projects, defining and setting technical direction for projects", "Bachelor's degree in Computer Science, Computer Engineering, relevant technical field, or equivalent practical experience.", ], )
In [ ]
已复制!
response = resume_screener.run(resume_path="jerry_resume.pdf")
response = resume_screener.run(resume_path="jerry_resume.pdf")
In [ ]
已复制!
for cd in response.criteria_decisions:
print("### CRITERIA DECISION")
print(cd.reasoning)
print(cd.decision)
print("#### OVERALL REASONING ##### ")
print(str(response.overall_reasoning))
print(str(response.overall_decision))
for cd in response.criteria_decisions: print("### CRITERIA DECISION") print(cd.reasoning) print(cd.decision) print("#### OVERALL REASONING ##### ") print(str(response.overall_reasoning)) print(str(response.overall_decision))
### CRITERIA DECISION Jerry Liu has more than 2 years of experience in machine learning and artificial intelligence. He worked as a Machine Learning Engineer at Quora Inc. for a year and has been an AI Research Scientist at Uber ATG since 2018. His work involves deep learning, information theory, and 3D geometry, among other areas. True ### CRITERIA DECISION Jerry Liu has demonstrated technical leadership in his roles at Uber ATG and Quora Inc. He has led and mentored multiple projects on multi-agent simulation, prediction, and planning. He also researched and productionized GBDT’s for new users at Quora, contributing to a 5% increase in new user active usage. True ### CRITERIA DECISION Jerry Liu has a Bachelor of Science in Engineering (B.S.E.) in Computer Science from Princeton University. He graduated Summa Cum Laude and was a member of Phi Beta Kappa, Tau Beta Pi, and Sigma Xi. True #### OVERALL REASONING ##### Jerry Liu meets all the screening criteria for the Machine Learning Engineer position at Meta. He has the required experience in machine learning and artificial intelligence, has demonstrated technical leadership, and has a relevant degree. True
筛选前端 (FE) / Typescript 职位的候选人¶
In [ ]
已复制!
resume_screener = ResumeScreenerPack(
job_description="We're looking to hire a front-end engineer",
criteria=[
"The individual needs to be experienced in front-end / React / Typescript"
],
)
resume_screener = ResumeScreenerPack( job_description="We're looking to hire a front-end engineer", criteria=[ "The individual needs to be experienced in front-end / React / Typescript" ], )
In [ ]
已复制!
response = resume_screener.run(resume_path="jerry_resume.pdf")
response = resume_screener.run(resume_path="jerry_resume.pdf")
In [ ]
已复制!
print(str(response.overall_reasoning))
print(str(response.overall_decision))
print(str(response.overall_reasoning)) print(str(response.overall_decision))
The candidate does not meet the specific criteria of having experience in front-end, React, or Typescript. False
筛选 OpenAI 首席执行官职位的候选人¶
Jerry 不会写 Typescript,但他能成为 OpenAI 的首席执行官吗?
In [ ]
已复制!
job_description = f"""\
We're looking to hire a CEO for OpenAI.
Instead of listing a set of specific criteria, each "criteria" is instead a short biography of a previous CEO.\
For each criteria/bio, outline if the candidate's experience matches or surpasses that of the candidate.
Also, here's a description of OpenAI from Wikipedia:
{openai_node.get_content()}
"""
profile_strs = [
f"Profile: {n.get_content()}" for n in [sama_node, mira_node, emmett_node]
]
resume_screener = ResumeScreenerPack(
job_description=job_description, criteria=profile_strs
)
job_description = f"""\ We're looking to hire a CEO for OpenAI. Instead of listing a set of specific criteria, each "criteria" is instead a short biography of a previous CEO.\ For each criteria/bio, outline if the candidate's experience matches or surpasses that of the candidate. Also, here's a description of OpenAI from Wikipedia: {openai_node.get_content()} """ profile_strs = [ f"Profile: {n.get_content()}" for n in [sama_node, mira_node, emmett_node] ] resume_screener = ResumeScreenerPack( job_description=job_description, criteria=profile_strs )
In [ ]
已复制!
response = resume_screener.run(resume_path="jerry_resume.pdf")
response = resume_screener.run(resume_path="jerry_resume.pdf")
In [ ]
已复制!
for cd in response.criteria_decisions:
print("### CRITERIA DECISION")
print(cd.reasoning)
print(cd.decision)
print("#### OVERALL REASONING ##### ")
print(str(response.overall_reasoning))
print(str(response.overall_decision))
for cd in response.criteria_decisions: print("### CRITERIA DECISION") print(cd.reasoning) print(cd.decision) print("#### OVERALL REASONING ##### ") print(str(response.overall_reasoning)) print(str(response.overall_decision))
### CRITERIA DECISION The candidate, Jerry Liu, has a strong background in AI research and has led multiple projects in this field. However, he does not have the same level of executive leadership experience as Samuel Harris Altman, who served as CEO of OpenAI and president of Y Combinator. Altman also has experience leading an advanced AI research team at Microsoft, which Liu does not have. False ### CRITERIA DECISION While Jerry Liu has a strong background in AI and machine learning, his experience does not match or surpass that of Mira Murati. Murati served as the chief technology officer of OpenAI and briefly as its interim CEO. She led the company's work on several major projects and oversaw multiple teams. Liu does not have the same level of leadership or executive experience. False ### CRITERIA DECISION Jerry Liu's experience does not match or surpass that of Emmett Shear. Shear co-founded Justin.tv and served as the CEO of Twitch, demonstrating significant entrepreneurial and executive leadership experience. He also served as a part-time partner at venture capital firm Y Combinator and briefly as interim CEO of OpenAI. Liu, while having a strong background in AI research, does not have the same level of leadership or executive experience. False #### OVERALL REASONING ##### While Jerry Liu has a strong background in AI research and has led multiple projects in this field, his experience does not match or surpass that of the previous CEOs in terms of executive leadership and entrepreneurial experience. False
...可惜不能