File size: 1,820 Bytes
b876970
 
 
 
 
 
 
 
 
 
 
699a68e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
title: LangGraph RAG + RAGAS
emoji: 🤖
colorFrom: blue
colorTo: indigo
sdk: streamlit
sdk_version: 1.31.1
app_file: app.py
pinned: false
---

# LangGraph RAG + RAGAS

Built this RAG system to experiment with LangGraph's workflow capabilities and RAGAS metrics. It's a straightforward implementation that lets you upload docs, ask questions, and get quality metrics for each response.

## What it does

- Takes your docs and chunks them semantically (sentence-level similarity with greedy paragraph grouping)
- Uses ChromaDB to store and retrieve relevant context
- Spits out responses with RAGAS metrics:
  - Faithfulness: How well the response sticks to the context
  - Answer Relevancy: How relevant the answer is to the question
  - Context Precision: How precise the retrieved context is
  - Context Recall: How much relevant context was retrieved
  - Answer Correctness: How accurate the answer is
- Simple Streamlit UI to interact with it all

## Getting it running

1. Clone the repo
2. Install the deps:
   ```bash
   pip install -r requirements.txt
   ```
3. Toss your OpenAI key in `.env`:
   ```
   OPENAI_API_KEY=your_key_here
   ```

## Using it

1. Run the Streamlit app:
   ```bash
   streamlit run app.py
   ```
2. Upload your docs in the sidebar
3. Fire away with questions
4. Check the metrics to see how well it's doing

## Under the hood

- LangGraph handles the RAG pipeline (retrieve -> generate -> evaluate)
- ChromaDB stores the vectors with cosine similarity
- GPT-3.5-turbo generates responses
- RAGAS evaluates response quality
- Streamlit for the UI

## Heads up

- Vectors get stored in `chroma_db`
- Using semantic chunking with sentence-level similarity and paragraph grouping
- Each response comes with its RAGAS metrics
- Minimum chunk size is a single sentence, max is 1000 chars