Introducing
LlamaIndex
![](https://s3.amazonaws.com/media-p.slid.es/uploads/136956/images/10976327/LlamaLogoSmall.png)
2024-07-24 AZD Community Call
What are we talking about?
- What is LlamaIndex
- Why you should use it
- What can it do
- Retrieval augmented generation
- World class parsing
- Agents and multi-agent systems
What is LlamaIndex?
Python: docs.llamaindex.ai
TypeScript: ts.llamaindex.ai
LlamaCloud
![](https://s3.amazonaws.com/media-p.slid.es/uploads/136956/images/11467933/bit.ly_4cXMAgY.png)
LlamaHub
- Data loaders
- Embedding models
- Vector stores
- LLMs
- Agent tools
- Pre-built strategies
- More!
Why LlamaIndex?
- Build faster
- Skip the boilerplate
- Avoid early pitfalls
- Get into production
- Deliver real value
What can LlamaIndex
do for me?
RAG explanation:
Loading
RAG, step 1:
documents = SimpleDirectoryReader("data").load_data()
Parsing
RAG, step 2:
(LlamaParse: it's really good. Really!)
# must have a LLAMA_CLOUD_API_KEY
# bring in deps
from llama_parse import LlamaParse
from llama_index.core import SimpleDirectoryReader
# set up parser
parser = LlamaParse(
result_type="markdown" # "text" also available
)
# use SimpleDirectoryReader to parse our file
file_extractor = {".pdf": parser}
documents = SimpleDirectoryReader(
input_files=['data/canada.pdf'],
file_extractor=file_extractor
).load_data()
print(documents)
Embedding
RAG, step 3:
Settings.embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
Storing
RAG, step 4:
index = VectorStoreIndex.from_documents(documents)
Retrieving
RAG, step 5:
retriever = index.as_retriever()
nodes = retriever.retrieve("Who is Paul Graham?")
Querying
RAG, step 6:
query_engine = index.as_query_engine()
response = query_engine.query("Who is Paul Graham?")
Multi-modal
create-llama
![](https://s3.amazonaws.com/media-p.slid.es/uploads/136956/images/11470026/1_8hEz3ZULj_4JmBLsPYJV3w.webp)
LlamaBot
A slack bot
Agents
Putting together an agent
def multiply(a: float, b: float) -> float:
"""Multiply two numbers and returns the product"""
return a * b
multiply_tool = FunctionTool.from_defaults(fn=multiply)
llm = OpenAI(model="gpt-4o", temperature=0.4)
agent = ReActAgent.from_tools(
[multiply_tool],
llm=llm,
verbose=True
)
RAG + Agents
budget_tool = QueryEngineTool.from_defaults(
query_engine,
name="canadian_budget_2023",
description="A RAG engine with some basic facts",
)
llm = OpenAI(model="gpt-4o", temperature=0.4)
agent = ReActAgent.from_tools(
[budget_tool],
llm=llm,
verbose=True
)
Deploying with llama-agents
![](https://s3.amazonaws.com/media-p.slid.es/uploads/136956/images/11473709/8de93915700c90d8442f4342edb3d9cdb5ef0266-720x402.webp)
Thanks!
Follow me on Twitter:
@seldo
Please don't add me on LinkedIn.
These slides and more resources:
Introducing LlamaIndex (AZD community call)
By seldo
Introducing LlamaIndex (AZD community call)
- 178