Skip to content
Snippets Groups Projects
Unverified Commit 09ec97cd authored by Jerry Liu's avatar Jerry Liu Committed by GitHub
Browse files

add llamapacks to docs (#9109)

parent dbefde94
No related branches found
No related tags found
No related merge requests found
...@@ -6,14 +6,15 @@ LlamaIndex has a number of community integrations, from vector stores, to prompt ...@@ -6,14 +6,15 @@ LlamaIndex has a number of community integrations, from vector stores, to prompt
LlamaHub hosts a full suite of LlamaPacks -- templates for features that you can download, edit, and try out! This offers a quick way to learn about new features and try new techniques. LlamaHub hosts a full suite of LlamaPacks -- templates for features that you can download, edit, and try out! This offers a quick way to learn about new features and try new techniques.
Just run the following command in your terminal (this terminal command is installed with the `llama-index` python package!): The full set of LlamaPacks is available on [LlamaHub](https://llamahub.ai/). Check out our dedicated page below.
```bash ```{toctree}
llamaindex-cli download-llamapack ZephyrQueryEnginePack --download-dir ./zephyr_pack ---
maxdepth: 1
---
llama_packs/root.md
``` ```
The full set of LlamaPacks is available on [LlamaHub](https://llamahub.ai/). Here's a [sample notebook on how to use a LlamaPack](/examples/llama_hub/llama_packs_example.ipynb).
## Data Loaders ## Data Loaders
The full set of data loaders are found on [LlamaHub](https://llamahub.ai/) The full set of data loaders are found on [LlamaHub](https://llamahub.ai/)
......
# Llama Packs 🦙📦
## Concept
Llama Packs are a community-driven hub of **prepackaged modules/templates** you can use to kickstart your LLM app.
This directly tackles a big pain point in building LLM apps; every use case requires cobbling together custom components and a lot of tuning/dev time. Our goal is to accelerate that through a community led effort.
They can be used in two ways:
- On one hand, they are **prepackaged modules** that can be initialized with parameters and run out of the box to achieve a given use case (whether that’s a full RAG pipeline, application template, and more). You can also import submodules (e.g. LLMs, query engines) to use directly.
- On another hand, LlamaPacks are **templates** that you can inspect, modify, and use.
**All packs are found on [LlamaHub](https://llamahub.ai/).** Go to the dropdown menu and select "LlamaPacks" to filter by packs.
**Please check the README of each pack for details on how to use**. [Example pack here](https://llamahub.ai/l/llama_packs-voyage_query_engine).
See our [launch blog post](https://blog.llamaindex.ai/introducing-llama-packs-e14f453b913a) for more details.
## Usage Pattern
You can use Llama Packs through either the CLI or Python.
CLI:
```bash
llamaindex-cli download-llamapack <pack_name> --download-dir <pack_directory>
```
Python:
```python
from llama_index.llama_pack import download_llama_pack
# download and install dependencies
pack_cls = download_llama_pack("<pack_name>", "<pack_directory>")
```
You can use the pack in different ways, either to inspect modules, run it e2e, or customize the templates.
```python
# every pack is initialized with different args
pack = pack_cls(*args, **kwargs)
# get modules
modules = pack.get_modules()
display(modules)
# run (every pack will have different args)
output = pack.run(*args, **kwargs)
```
Importantly, you can/should also go into `pack_directory` to inspect the source files/customize it. That's part of the point!
## Module Guides
Some example module guides are given below. Remember, go on [LlamaHub](https://llamahub.ai) to access the full range of packs.
```{toctree}
---
maxdepth: 1
---
/examples/llama_hub/llama_packs_example.ipynb
```
%% Cell type:markdown id:92dad89e-d84a-4d85-85e1-6beaed293605 tags:
# Llama Pack - Resume Screener 📄
<a href="https://colab.research.google.com/github/jerryjliu/llama_index/blob/main/docs/examples/llama_hub/llama_pack_resume.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
This example shows you how to use the Resume Screener Llama Pack.
You can find all packs on https://llamahub.ai
The resume screener is designed to analyze a candidate's resume according to a set of criteria, and decide whether the candidate is a fit for the job.
in this example we'll evaluate a sample resume (e.g. Jerry's old resume).
%% Cell type:code id:e4722b0b-ff5e-4e71-990b-94ec65f8b359 tags:
``` python
!pip install llama-index llama-hub
```
%% Cell type:markdown id:0221e488-0d1f-4890-b081-27530fcac5f3 tags:
### Setup Data
We'll load some sample Wikipedia data for OpenAI, Sam, Mira, and Emmett. Why? No reason in particular :)
%% Cell type:code id:3abe6c66-5107-4952-b670-e60153ff916a tags:
``` python
from llama_index.readers import WikipediaReader
loader = WikipediaReader()
documents = loader.load_data(
pages=["OpenAI", "Sam Altman", "Mira Murati", "Emmett Shear"],
auto_suggest=False,
)
```
%% Cell type:code id:98bb38b7-0235-406c-9954-ab46809eef17 tags:
``` python
# do sentence splitting on the first piece of text
from llama_index.node_parser import SentenceSplitter
```
%% Cell type:code id:a9700e6b-525d-46e2-940d-1768a42291b2 tags:
``` python
sentence_splitter = SentenceSplitter(chunk_size=1024)
```
%% Cell type:markdown id:29d74a5e-6326-462c-a6f5-0694ad6388cb tags:
We get the first chunk from each essay.
%% Cell type:code id:d3539635-e328-42fa-b712-43616841c959 tags:
``` python
# 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]
```
%% Cell type:markdown id:471e36b8-81d9-4afa-b53b-c810fbc84627 tags:
We'll also download Jerry's resume in 2019.
%% Cell type:markdown id:2a8aec6b-239c-45d5-a919-05cc52600fa1 tags:
## Download Resume Screener Pack from LlamaHub
Here we download the resume screener pack class from LlamaHub.
We'll use it for two use cases:
- whether the candidate is a good fit for a front-end / full-stack engineering role.
- whether the candidate is a good fit for the CEO of OpenAI.
%% Cell type:code id:d40792de-2518-40a2-8468-c020d0decf18 tags:
``` python
from llama_index.llama_pack import download_llama_pack
```
%% Cell type:code id:fc1819c2-0e8c-4a55-8e4b-aa17619b25b8 tags:
``` python
ResumeScreenerPack = download_llama_pack(
"ResumeScreenerPack", "./resume_screener_pack"
)
```
%% Cell type:markdown id:7e957c52-8ae0-48aa-9041-641efa0de774 tags:
### Screen Candidate for MLE Role
We take a job description on an MLE role from Meta's website.
%% Cell type:code id:d44f76f0-ac12-4f8c-ba8c-e6d1680a26d8 tags:
``` python
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.\
"""
```
%% Cell type:code id:a018abe4-8e0b-4f5d-aee2-9f2873fb245d tags:
``` python
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.",
],
)
```
%% Cell type:code id:bc406e7c-1639-4315-b627-495c18ebb47d tags:
``` python
response = resume_screener.run(resume_path="jerry_resume.pdf")
```
%% Cell type:code id:acfeed3c-dc05-4e69-af9c-bb4cbe409798 tags:
``` python
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))
```
%% Output
### 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
%% Cell type:markdown id:4cd4d149-c862-4591-bd98-9d8f55278c7c tags:
### Screen Candidate for FE / Typescript roles
%% Cell type:code id:d94efb7f-b170-4833-be2a-eb5911fed816 tags:
``` python
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"
],
)
```
%% Cell type:code id:08db7399-d43b-4139-8809-f8f493329f76 tags:
``` python
response = resume_screener.run(resume_path="jerry_resume.pdf")
```
%% Cell type:code id:7669250b-d0d0-4825-a429-c1d1c4f34ee1 tags:
``` python
print(str(response.overall_reasoning))
print(str(response.overall_decision))
```
%% Output
The candidate does not meet the specific criteria of having experience in front-end, React, or Typescript.
False
%% Cell type:markdown id:e31684e4-61ef-4796-8f13-5d7291d2c5dd tags:
### Screen Candidate for CEO of OpenAI
Jerry can't write Typescript, but can he be CEO of OpenAI?
%% Cell type:code id:57efbd93-7249-4b04-b5be-d74e5953d004 tags:
``` python
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
)
```
%% Cell type:code id:409b0a27-f550-471d-83a3-c5b39e6def71 tags:
``` python
response = resume_screener.run(resume_path="jerry_resume.pdf")
```
%% Cell type:code id:35384368-bcb5-4422-a92d-1a1cf7aab853 tags:
``` python
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))
```
%% Output
### 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
%% Cell type:markdown id:681bde1f-c254-4398-b65f-6ac1aacbf067 tags:
...sadly not
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment