Skip to content

Commit

Permalink
Updated the Readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
labrijisaad authored May 28, 2024
1 parent ab792cd commit 6a70a9c
Showing 1 changed file with 51 additions and 32 deletions.
83 changes: 51 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,84 @@
# `LLM RAG` - Streamlit RAG Language Model App 🤖

## 🌟 Overview
This is a Streamlit app leveraging a RAG (Retrieval-Augmented Generation) Language Model (LLM) with FAISS to offer answers from uploaded markdown files 📂. The app allows users to upload files, ask questions related to the content of these files, and receive relevant answers generated by the RAG LLM 📚.
This Streamlit app leverages Retrieval-Augmented Generation (RAG) by using OpenAI's Large Language Model (LLM) in conjunction with FAISS, a vector database. The app allows users to upload markdown files 📂, ask questions related to the content of these files, and receive AI-generated answers based on the uploaded content 📚.

## ❓How It Works
## How It Works
The LLM RAG Streamlit app is structured into several key areas, each serving a specific function within the application:

<p align="center">
<img src="https://github.com/labrijisaad/LLM-RAG/assets/74627083/61518120-e3a0-4e76-84ea-4fb11bd82e4a" width="60%" />
</p>

- **`Setup` Knowledge Base** 📂: Users can establish their **knowledge base** by uploading **markdown documents**. This forms the foundational data that the app will reference for generating answers.
- **`Setup` Knowledge Base** 📂: Users can establish their knowledge base by uploading markdown documents. These documents are split into chunks and stored in the knowledge base, forming the reference data used to generate answers.

- **`Explore` Knowledge Base** 🔍: After setting up the knowledge base, users can browse and manage the uploaded documents. This allows users to ensure that the data is ready for queries.
- **`Explore` Knowledge Base** 🔍: After setting up the knowledge base, users can browse and manage the uploaded documents. Users also have the option to delete documents.

- **RAG `Query`** 💡: In this tab, users can pose questions that the app will answer by referencing the content within the knowledge base. The RAG (Retrieval-Augmented Generation) model utilizes both the uploaded documents and the model's own knowledge to generate responses.
- **RAG `Query`** 💡: In this section, users can ask questions that the app will answer by referencing the content within the knowledge base. The RAG primarily uses the uploaded documents along with the LLM's inherent knowledge to generate responses.

Additionally, the app offers advanced settings to tailor the querying experience:
Additionally, the app offers advanced settings for customization based on user needs:

<p align="center">
<img src="https://github.com/labrijisaad/LLM-RAG/assets/74627083/8f878a40-f268-4ba9-ae0f-75ca2391357d" width="45%" />
</p>

- **OpenAI `Embedding Model` Settings**: Users select the desired embedding model for document vectorization. Choices affect the precision of semantic search and the cost per token processed.
- **OpenAI `Embedding Model` Settings**: Users select the desired embedding model for document vectorization. Choices affect the precision of Similarity Search and the cost per token processed.

- **OpenAI `LLM` Settings**: This setting allows users to choose the specific OpenAI language model variant for generating answers. It also displays the associated costs for input and output processing per 1,000 tokens.
- **OpenAI `LLM` Settings**: This setting allows users to choose the specific OpenAI language model variant for generating answers.

- **Model `Temperature`**: Adjusting this parameter influences the creativity of the language model’s responses. A higher temperature may yield more varied and creative outputs, while a lower temperature results in more deterministic and conservative text.
- **Model `Temperature`**: Adjusting this parameter influences the creativity of the language model’s responses.

- **Max `Completion Tokens`**: Users can define the maximum length of the generated response by setting the maximum number of tokens (words and characters) the model should produce.
- **Max `Completion Tokens`**: Users can define the maximum length of the generated response by setting the maximum number of tokens the model should produce.

- **Drop All Documents in `Knowledge Base`**: This functionality is crucial for managing the knowledge base. If users need to clear the database, they can do so by typing a confirmatory command.
- **Drop All Documents in `Knowledge Base`**

## 🛠️ System Architecture
The following diagram illustrates the flow of data through the system:

```mermaid
graph TD
A[User Files] -->|Read & Process| B[Semantic Database Setup]
B -->|Generate Embeddings & FAISS Index| C[Vector Store]
C -->|Utilize OpenAI's Models| D[Semantic Search]
E[User Query] -->|Vectorization| D
D -->|Select Top Documents| F[Top Documents]
F -->|Include Selected Docs in Context| G[Contextualized Documents]
E -->|Determine Expertise using OpenAI| H[Expertise Area]
H -->|Formulate Prompt| I[Prompt with Context]
G --> I
I -->|Query OpenAI LLM| J[LLM Response]
J -->|Generate Answer| K[Answer]
A[Markdown Documents] -->|Data Cleaning &<br>Splitting in Chunks| B[Cleaned Text]
B -->|OpenAI Model<br>Embedding| C[Document Embeddings]
C -->|Store| D[(Vectorstore)]
D -->|Similarity Search| E[Relevant Documents]
F[User Question] -->|OpenAI Model<br>Embedding| G[Query Embedding]
G -->|Fetch| D
F --> J[Contextualized Prompt]
E --> J
J -->|OpenAI LLM Model| L[Answer]
subgraph Data Preparation
A
B
end
subgraph Vectorization
C
G
end
subgraph Relevant Documents Retrieval
D
E
end
subgraph LLM Querying
J
L
end
%% Styles
style A fill:#7f7f7f,stroke:#fff,stroke-width:2px
style B fill:#8fa1b3,stroke:#fff,stroke-width:2px
style C fill:#8fa1b3,stroke:#fff,stroke-width:2px
style D fill:#8fa1b3,stroke:#fff,stroke-width:2px
style E fill:#7f7f7f,stroke:#fff,stroke-width:2px
style F fill:#8fa1b3,stroke:#fff,stroke-width:2px
style E fill:#8fa1b3,stroke:#fff,stroke-width:2px
style F fill:#7f7f7f,stroke:#fff,stroke-width:2px
style G fill:#8fa1b3,stroke:#fff,stroke-width:2px
style H fill:#8fa1b3,stroke:#fff,stroke-width:2px
style I fill:#e07b53,stroke:#fff,stroke-width:2px
style J fill:#e07b53,stroke:#fff,stroke-width:2px
style K fill:#e07b53,stroke:#fff,stroke-width:2px
style L fill:#e07b53,stroke:#fff,stroke-width:2px
```

## Project Structure 🏗️
Expand Down Expand Up @@ -98,12 +117,12 @@ To begin using the LLM RAG app, follow these simple steps:
Set up your virtual environment using either venv or conda:
```
# Using venv
python -m venv env
source env/bin/activate
python -m venv env_llm_rag
source env_llm_rag/bin/activate
# Using conda
conda create --name env_name
conda activate env_name
conda create --name env_llm_rag
conda activate env_llm_rag
```

3. **Install Dependencies:**
Expand Down

0 comments on commit 6a70a9c

Please sign in to comment.