Skip to content

Commit

Permalink
Update 2024-05-05-AI-Agents.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuo2000 authored May 12, 2024
1 parent 0d225fd commit 154b624
Showing 1 changed file with 1 addition and 48 deletions.
49 changes: 1 addition & 48 deletions _posts/2024-05-05-AI-Agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ category: [Lecture]
tags: [jekyll, ai]
---

Introduction to AI Agents, Langchain, LlamaIndex, SWE.
Introduction to AI Agents, Langchain, SWE.

---
## AI Agents
Expand Down Expand Up @@ -126,53 +126,6 @@ Communicative Agents for “Mind” Exploration of Large Language Model Society<
---
## Frameworks

### [LlamaIndex](https://www.llamaindex.ai/)
**Code:** [https://github.com/run-llama/llama_index](https://github.com/run-llama/llama_index)<br>
**Docs:** [](https://docs.llamaindex.ai/en/stable/)<br>
![](https://docs.llamaindex.ai/en/stable/_static/getting_started/basic_rag.png)
```
import os
os.environ["REPLICATE_API_TOKEN"] = "YOUR_REPLICATE_API_TOKEN"
from llama_index.core import Settings, VectorStoreIndex, SimpleDirectoryReader
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.llms.replicate import Replicate
from transformers import AutoTokenizer
# set the LLM
llama2_7b_chat = "meta/llama-2-7b-chat:8e6975e5ed6174911a6ff3d60540dfd4844201974602551e10e9e87ab143d81e"
Settings.llm = Replicate(
model=llama2_7b_chat,
temperature=0.01,
additional_kwargs={"top_p": 1, "max_new_tokens": 300},
)
# set tokenizer to match LLM
Settings.tokenizer = AutoTokenizer.from_pretrained(
"NousResearch/Llama-2-7b-chat-hf"
)
# set the embed model
Settings.embed_model = HuggingFaceEmbedding(
model_name="BAAI/bge-small-en-v1.5"
)
documents = SimpleDirectoryReader("YOUR_DATA_DIRECTORY").load_data()
index = VectorStoreIndex.from_documents(
documents,
)
```
```
query_engine = index.as_query_engine()
query_engine.query("YOUR_QUESTION")
```
By default, data is stored in-memory. To persist to disk (under ./storage):<br>
```
index.storage_context.persist()
```

---
### [LangChain](https://github.com/langchain-ai/langchain)
* [LangChain documents](https://js.langchain.com/docs/get_started/introduction)
* [LangChain use-cases](https://js.langchain.com/docs/use_cases)
Expand Down

0 comments on commit 154b624

Please sign in to comment.