🌐 AI搜索 & 代理 主页
Skip to content

plpxsk/rag-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAG demo

Uses a blog as context data, Mistral model and embedding, and vector store from langchain-core.

Examples

(.venv) rag-chain# python rag.py --q "Whats the benefit of 'chain of hindsight'?"  
The 'Chain of Hindsight' (CoH) benefits models by encouraging self-improvement. It presents the model with a sequence of past outputs and corresponding feed
back, allowing it to learn from and build upon its own mistakes. This process can lead to incremental improvements in the model's outputs over time. Additio
nally, CoH can help models learn from human feedback, making their outputs more aligned with human preferences.

(.venv) rag-chain# python rag.py --q "Who wrote the paper ReAct?"  
Yao, Y., Chen, M., & Dai, Z. (2023). ReAct: Synergizing Reasoning and Acting for Language Agents. arXiv:2304.12244.

(.venv) rag-demo# python rag.py --q "What does this demo use?" --path .  
Loading data...
Loaded 5 docs.

The demo uses a blog as context data, the Mistral model, and an embedding vector store from langchain-core.

Timed:

(.venv) rag-chain# time python rag.py --q "What's cool about AutoGPT?"  
AutoGPT is a proof-of-concept project that demonstrates the use of a language model as an autonomous agent. It's cool because it exhibits emergent social behavior, like information diffusion and event coordination, and it uses a set of commands to interact with tools and other agents.

0.79s user 0.16s system 9% cpu 10.443 total

Install

  1. Install into venv from requirements.txt
  2. Add API keys to .env file. Required keys are below

Required Keys:

MISTRAL_API_KEY="XYZ"

# generate with project: smith.langchain.com
LANGCHAIN_TRACING_V2=true
LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
LANGCHAIN_API_KEY="XYZ"
LANGCHAIN_PROJECT="XYZ"

Run

python rag.py --q "What is your question?"

By default, a blog from internet is used as context.

Pass local files:

python rag.py --q "What does chapter 8 describe?" --path my/files/here

What is RAG?

Learn about RAG from an article like the following. See especially the image "Standard RAG": anthropic.com/news/contextual-retrieval.

References

Adapted from: python.langchain.com/docs/tutorials/rag

Source document: lilianweng.github.io/posts/2023-06-23-agent

About

RAG demo with Langchain boilerplate, using Mistral LLM, with blog post as document context

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages