Spaces:
Sleeping
Sleeping
README
Browse files- README.md +41 -174
- README_old.md +193 -0
- SPACE_README.md +0 -60
README.md
CHANGED
|
@@ -1,160 +1,3 @@
|
|
| 1 |
-
# π RAG Pedagogical Demo
|
| 2 |
-
|
| 3 |
-
A pedagogical web application demonstrating Retrieval Augmented Generation (RAG) systems for students and learners.
|
| 4 |
-
|
| 5 |
-
## π Features
|
| 6 |
-
|
| 7 |
-
- **Bilingual Interface** (English/French)
|
| 8 |
-
- **Document Processing**: Upload PDF documents or use default corpus
|
| 9 |
-
- **Configurable Retrieval**:
|
| 10 |
-
- Choose embedding models
|
| 11 |
-
- Adjust chunk size and overlap
|
| 12 |
-
- Set top-k and similarity thresholds
|
| 13 |
-
- **Configurable Generation**:
|
| 14 |
-
- Select different LLMs
|
| 15 |
-
- Adjust temperature and max tokens
|
| 16 |
-
- **Educational Visualization**:
|
| 17 |
-
- View retrieved chunks with similarity scores
|
| 18 |
-
- See the exact prompt sent to the LLM
|
| 19 |
-
- Understand each step of the RAG pipeline
|
| 20 |
-
|
| 21 |
-
## π Quick Start
|
| 22 |
-
|
| 23 |
-
### Local Installation
|
| 24 |
-
|
| 25 |
-
```bash
|
| 26 |
-
# Clone the repository
|
| 27 |
-
git clone <your-repo-url>
|
| 28 |
-
cd RAG_pedago
|
| 29 |
-
|
| 30 |
-
# Install dependencies
|
| 31 |
-
pip install -r requirements.txt
|
| 32 |
-
|
| 33 |
-
# Run the application
|
| 34 |
-
python app.py
|
| 35 |
-
```
|
| 36 |
-
|
| 37 |
-
### HuggingFace Spaces
|
| 38 |
-
|
| 39 |
-
This application is designed to run on HuggingFace Spaces with ZeroGPU support.
|
| 40 |
-
|
| 41 |
-
1. Create a new Space on HuggingFace
|
| 42 |
-
2. Select "Gradio" as the SDK
|
| 43 |
-
3. Enable ZeroGPU in Space settings
|
| 44 |
-
4. Upload all files from this repository
|
| 45 |
-
5. The app will automatically deploy
|
| 46 |
-
|
| 47 |
-
## π Usage
|
| 48 |
-
|
| 49 |
-
### 1. Corpus Management
|
| 50 |
-
- Upload your own PDF document or use the included default corpus about RAG
|
| 51 |
-
- Configure chunk size (100-1000 characters) and overlap (0-200 characters)
|
| 52 |
-
- Process the corpus to create embeddings
|
| 53 |
-
|
| 54 |
-
### 2. Retrieval Configuration
|
| 55 |
-
- Choose an embedding model:
|
| 56 |
-
- `all-MiniLM-L6-v2`: Fast, lightweight
|
| 57 |
-
- `all-mpnet-base-v2`: Better quality, slower
|
| 58 |
-
- `paraphrase-multilingual-MiniLM-L12-v2`: Multilingual support
|
| 59 |
-
- Set top-k (1-10): Number of chunks to retrieve
|
| 60 |
-
- Set similarity threshold (0.0-1.0): Minimum similarity score
|
| 61 |
-
|
| 62 |
-
### 3. Generation Configuration
|
| 63 |
-
- Select a language model:
|
| 64 |
-
- `zephyr-7b-beta`: Fast, good quality
|
| 65 |
-
- `Mistral-7B-Instruct-v0.2`: High quality
|
| 66 |
-
- `Llama-2-7b-chat-hf`: Alternative option
|
| 67 |
-
- Adjust temperature (0.0-2.0): Controls creativity
|
| 68 |
-
- Set max tokens (50-1000): Response length
|
| 69 |
-
|
| 70 |
-
### 4. Query & Results
|
| 71 |
-
- Enter your question
|
| 72 |
-
- Use example questions to get started
|
| 73 |
-
- View the generated answer
|
| 74 |
-
- Examine retrieved chunks with similarity scores
|
| 75 |
-
- Inspect the prompt sent to the LLM
|
| 76 |
-
|
| 77 |
-
## ποΈ Architecture
|
| 78 |
-
|
| 79 |
-
```
|
| 80 |
-
βββββββββββββββββββ
|
| 81 |
-
β PDF Document β
|
| 82 |
-
ββββββββββ¬βββββββββ
|
| 83 |
-
β
|
| 84 |
-
βΌ
|
| 85 |
-
βββββββββββββββββββ
|
| 86 |
-
β Text Chunking β
|
| 87 |
-
ββββββββββ¬βββββββββ
|
| 88 |
-
β
|
| 89 |
-
βΌ
|
| 90 |
-
βββββββββββββββββββ
|
| 91 |
-
β Embeddings ββββββ Embedding Model
|
| 92 |
-
ββββββββββ¬βββββββββ
|
| 93 |
-
β
|
| 94 |
-
βΌ
|
| 95 |
-
βββββββββββββββββββ
|
| 96 |
-
β FAISS Index β
|
| 97 |
-
ββββββββββ¬βββββββββ
|
| 98 |
-
β
|
| 99 |
-
βΌ
|
| 100 |
-
βββββββββββββββββββ
|
| 101 |
-
β User Query β
|
| 102 |
-
ββββββββββ¬βββββββββ
|
| 103 |
-
β
|
| 104 |
-
βΌ
|
| 105 |
-
βββββββββββββββββββ
|
| 106 |
-
β Retrieval ββββΊ Top-K Chunks
|
| 107 |
-
ββββββββββ¬βββββββββ
|
| 108 |
-
β
|
| 109 |
-
βΌ
|
| 110 |
-
βββββββββββββββββββ
|
| 111 |
-
β Generation ββββββ Language Model
|
| 112 |
-
ββββββββββ¬βββββββββ
|
| 113 |
-
β
|
| 114 |
-
βΌ
|
| 115 |
-
βββββββββββββββββββ
|
| 116 |
-
β Answer β
|
| 117 |
-
βββββββββββββββββββ
|
| 118 |
-
```
|
| 119 |
-
|
| 120 |
-
## π οΈ Technical Stack
|
| 121 |
-
|
| 122 |
-
- **Framework**: Gradio 4.44.0
|
| 123 |
-
- **Embeddings**: Sentence Transformers
|
| 124 |
-
- **Vector Store**: FAISS
|
| 125 |
-
- **LLMs**: HuggingFace Inference API
|
| 126 |
-
- **GPU**: HuggingFace ZeroGPU
|
| 127 |
-
- **PDF Processing**: PyPDF2
|
| 128 |
-
|
| 129 |
-
## π Files Structure
|
| 130 |
-
|
| 131 |
-
```
|
| 132 |
-
RAG_pedago/
|
| 133 |
-
βββ app.py # Main Gradio interface
|
| 134 |
-
βββ rag_system.py # Core RAG logic
|
| 135 |
-
βββ i18n.py # Internationalization
|
| 136 |
-
βββ requirements.txt # Python dependencies
|
| 137 |
-
βββ default_corpus.pdf # Default corpus about RAG
|
| 138 |
-
βββ default_corpus.txt # Source text for default corpus
|
| 139 |
-
βββ README.md # This file
|
| 140 |
-
```
|
| 141 |
-
|
| 142 |
-
## π― Educational Goals
|
| 143 |
-
|
| 144 |
-
This application helps students understand:
|
| 145 |
-
|
| 146 |
-
1. **Document Processing**: How text is split into chunks
|
| 147 |
-
2. **Embeddings**: How text is converted to vectors
|
| 148 |
-
3. **Similarity Search**: How relevant information is retrieved
|
| 149 |
-
4. **Prompt Engineering**: How context is provided to LLMs
|
| 150 |
-
5. **Generation**: How LLMs produce answers based on retrieved context
|
| 151 |
-
6. **Parameter Impact**: How different settings affect results
|
| 152 |
-
|
| 153 |
-
## π§ Configuration for HuggingFace Spaces
|
| 154 |
-
|
| 155 |
-
Create a `README.md` in your Space with this header:
|
| 156 |
-
|
| 157 |
-
```yaml
|
| 158 |
---
|
| 159 |
title: RAG Pedagogical Demo
|
| 160 |
emoji: π
|
|
@@ -166,28 +9,52 @@ app_file: app.py
|
|
| 166 |
pinned: false
|
| 167 |
license: mit
|
| 168 |
---
|
| 169 |
-
```
|
| 170 |
|
| 171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
-
|
| 174 |
-
- Add more embedding models
|
| 175 |
-
- Include additional LLMs
|
| 176 |
-
- Improve the interface
|
| 177 |
-
- Add more visualizations
|
| 178 |
-
- Enhance documentation
|
| 179 |
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
-
|
| 183 |
|
| 184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
|
| 186 |
-
|
| 187 |
-
- Sentence Transformers for embeddings
|
| 188 |
-
- FAISS for efficient similarity search
|
| 189 |
-
- Gradio for the interface framework
|
| 190 |
|
| 191 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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retrieval Augmented Generation (RAG) systems.
|
| 16 |
+
|
| 17 |
+
## What is RAG?
|
| 18 |
+
|
| 19 |
+
Retrieval Augmented Generation (RAG) combines information retrieval with language generation to create more accurate and grounded AI responses. Instead of relying solely on a language model's training data, RAG systems:
|
| 20 |
+
|
| 21 |
+
1. **Retrieve** relevant information from a document corpus
|
| 22 |
+
2. **Augment** the query with this retrieved context
|
| 23 |
+
3. **Generate** an answer based on both the query and the retrieved information
|
| 24 |
+
|
| 25 |
+
## Features
|
| 26 |
+
|
| 27 |
+
- π **Upload your own PDFs** or use the default corpus
|
| 28 |
+
- π§ **Configure retrieval parameters**: embedding models, chunk size, top-k, similarity threshold
|
| 29 |
+
- π€ **Configure generation parameters**: LLM selection, temperature, max tokens
|
| 30 |
+
- π **Visualize the process**: see retrieved chunks, similarity scores, and prompts
|
| 31 |
+
- π **Bilingual interface**: English and French
|
| 32 |
|
| 33 |
+
## How to Use
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
1. **Corpus Tab**: Upload a PDF or use the default corpus about RAG
|
| 36 |
+
2. **Retrieval Tab**: Choose embedding model and retrieval parameters
|
| 37 |
+
3. **Generation Tab**: Select language model and generation settings
|
| 38 |
+
4. **Query Tab**: Ask questions and see how RAG works!
|
| 39 |
|
| 40 |
+
## Educational Value
|
| 41 |
|
| 42 |
+
This demo helps you understand:
|
| 43 |
+
- How documents are processed and chunked
|
| 44 |
+
- How semantic search retrieves relevant information
|
| 45 |
+
- How context is provided to language models
|
| 46 |
+
- How different parameters affect the results
|
| 47 |
|
| 48 |
+
Perfect for students, educators, and anyone curious about modern AI systems!
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
## Technology
|
| 51 |
+
|
| 52 |
+
- **Framework**: Gradio
|
| 53 |
+
- **Embeddings**: Sentence Transformers
|
| 54 |
+
- **Vector Store**: FAISS
|
| 55 |
+
- **LLMs**: HuggingFace Inference API
|
| 56 |
+
- **Infrastructure**: HuggingF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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π RAG Pedagogical Demo
|
| 2 |
+
|
| 3 |
+
A pedagogical web application demonstrating Retrieval Augmented Generation (RAG) systems for students and learners.
|
| 4 |
+
|
| 5 |
+
## π Features
|
| 6 |
+
|
| 7 |
+
- **Bilingual Interface** (English/French)
|
| 8 |
+
- **Document Processing**: Upload PDF documents or use default corpus
|
| 9 |
+
- **Configurable Retrieval**:
|
| 10 |
+
- Choose embedding models
|
| 11 |
+
- Adjust chunk size and overlap
|
| 12 |
+
- Set top-k and similarity thresholds
|
| 13 |
+
- **Configurable Generation**:
|
| 14 |
+
- Select different LLMs
|
| 15 |
+
- Adjust temperature and max tokens
|
| 16 |
+
- **Educational Visualization**:
|
| 17 |
+
- View retrieved chunks with similarity scores
|
| 18 |
+
- See the exact prompt sent to the LLM
|
| 19 |
+
- Understand each step of the RAG pipeline
|
| 20 |
+
|
| 21 |
+
## π Quick Start
|
| 22 |
+
|
| 23 |
+
### Local Installation
|
| 24 |
+
|
| 25 |
+
```bash
|
| 26 |
+
# Clone the repository
|
| 27 |
+
git clone <your-repo-url>
|
| 28 |
+
cd RAG_pedago
|
| 29 |
+
|
| 30 |
+
# Install dependencies
|
| 31 |
+
pip install -r requirements.txt
|
| 32 |
+
|
| 33 |
+
# Run the application
|
| 34 |
+
python app.py
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
### HuggingFace Spaces
|
| 38 |
+
|
| 39 |
+
This application is designed to run on HuggingFace Spaces with ZeroGPU support.
|
| 40 |
+
|
| 41 |
+
1. Create a new Space on HuggingFace
|
| 42 |
+
2. Select "Gradio" as the SDK
|
| 43 |
+
3. Enable ZeroGPU in Space settings
|
| 44 |
+
4. Upload all files from this repository
|
| 45 |
+
5. The app will automatically deploy
|
| 46 |
+
|
| 47 |
+
## π Usage
|
| 48 |
+
|
| 49 |
+
### 1. Corpus Management
|
| 50 |
+
- Upload your own PDF document or use the included default corpus about RAG
|
| 51 |
+
- Configure chunk size (100-1000 characters) and overlap (0-200 characters)
|
| 52 |
+
- Process the corpus to create embeddings
|
| 53 |
+
|
| 54 |
+
### 2. Retrieval Configuration
|
| 55 |
+
- Choose an embedding model:
|
| 56 |
+
- `all-MiniLM-L6-v2`: Fast, lightweight
|
| 57 |
+
- `all-mpnet-base-v2`: Better quality, slower
|
| 58 |
+
- `paraphrase-multilingual-MiniLM-L12-v2`: Multilingual support
|
| 59 |
+
- Set top-k (1-10): Number of chunks to retrieve
|
| 60 |
+
- Set similarity threshold (0.0-1.0): Minimum similarity score
|
| 61 |
+
|
| 62 |
+
### 3. Generation Configuration
|
| 63 |
+
- Select a language model:
|
| 64 |
+
- `zephyr-7b-beta`: Fast, good quality
|
| 65 |
+
- `Mistral-7B-Instruct-v0.2`: High quality
|
| 66 |
+
- `Llama-2-7b-chat-hf`: Alternative option
|
| 67 |
+
- Adjust temperature (0.0-2.0): Controls creativity
|
| 68 |
+
- Set max tokens (50-1000): Response length
|
| 69 |
+
|
| 70 |
+
### 4. Query & Results
|
| 71 |
+
- Enter your question
|
| 72 |
+
- Use example questions to get started
|
| 73 |
+
- View the generated answer
|
| 74 |
+
- Examine retrieved chunks with similarity scores
|
| 75 |
+
- Inspect the prompt sent to the LLM
|
| 76 |
+
|
| 77 |
+
## ποΈ Architecture
|
| 78 |
+
|
| 79 |
+
```
|
| 80 |
+
βββββββββββββββββββ
|
| 81 |
+
β PDF Document β
|
| 82 |
+
ββββββββββ¬βββββββββ
|
| 83 |
+
β
|
| 84 |
+
βΌ
|
| 85 |
+
βββββββββββββββββββ
|
| 86 |
+
β Text Chunking β
|
| 87 |
+
ββββββββββ¬βββββββββ
|
| 88 |
+
β
|
| 89 |
+
βΌ
|
| 90 |
+
βββββββββββββββββββ
|
| 91 |
+
β Embeddings ββββββ Embedding Model
|
| 92 |
+
ββββββββββ¬βββββββββ
|
| 93 |
+
β
|
| 94 |
+
βΌ
|
| 95 |
+
βββββββββββββββββββ
|
| 96 |
+
β FAISS Index β
|
| 97 |
+
ββββββββββ¬βββββββββ
|
| 98 |
+
β
|
| 99 |
+
βΌ
|
| 100 |
+
βββββββββββββββββββ
|
| 101 |
+
β User Query β
|
| 102 |
+
ββββββββββ¬βββββββββ
|
| 103 |
+
β
|
| 104 |
+
βΌ
|
| 105 |
+
βββββββββββββββββββ
|
| 106 |
+
β Retrieval ββββΊ Top-K Chunks
|
| 107 |
+
ββββββββββ¬βββββββββ
|
| 108 |
+
β
|
| 109 |
+
βΌ
|
| 110 |
+
βββββββββββββββββββ
|
| 111 |
+
β Generation ββββββ Language Model
|
| 112 |
+
ββββββββββ¬βββββββββ
|
| 113 |
+
β
|
| 114 |
+
βΌ
|
| 115 |
+
βββββββββββββββββββ
|
| 116 |
+
β Answer β
|
| 117 |
+
βββββββββββββββββββ
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
## π οΈ Technical Stack
|
| 121 |
+
|
| 122 |
+
- **Framework**: Gradio 4.44.0
|
| 123 |
+
- **Embeddings**: Sentence Transformers
|
| 124 |
+
- **Vector Store**: FAISS
|
| 125 |
+
- **LLMs**: HuggingFace Inference API
|
| 126 |
+
- **GPU**: HuggingFace ZeroGPU
|
| 127 |
+
- **PDF Processing**: PyPDF2
|
| 128 |
+
|
| 129 |
+
## π Files Structure
|
| 130 |
+
|
| 131 |
+
```
|
| 132 |
+
RAG_pedago/
|
| 133 |
+
βββ app.py # Main Gradio interface
|
| 134 |
+
βββ rag_system.py # Core RAG logic
|
| 135 |
+
βββ i18n.py # Internationalization
|
| 136 |
+
βββ requirements.txt # Python dependencies
|
| 137 |
+
βββ default_corpus.pdf # Default corpus about RAG
|
| 138 |
+
βββ default_corpus.txt # Source text for default corpus
|
| 139 |
+
βββ README.md # This file
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
## π― Educational Goals
|
| 143 |
+
|
| 144 |
+
This application helps students understand:
|
| 145 |
+
|
| 146 |
+
1. **Document Processing**: How text is split into chunks
|
| 147 |
+
2. **Embeddings**: How text is converted to vectors
|
| 148 |
+
3. **Similarity Search**: How relevant information is retrieved
|
| 149 |
+
4. **Prompt Engineering**: How context is provided to LLMs
|
| 150 |
+
5. **Generation**: How LLMs produce answers based on retrieved context
|
| 151 |
+
6. **Parameter Impact**: How different settings affect results
|
| 152 |
+
|
| 153 |
+
## π§ Configuration for HuggingFace Spaces
|
| 154 |
+
|
| 155 |
+
Create a `README.md` in your Space with this header:
|
| 156 |
+
|
| 157 |
+
```yaml
|
| 158 |
+
---
|
| 159 |
+
title: RAG Pedagogical Demo
|
| 160 |
+
emoji: π
|
| 161 |
+
colorFrom: blue
|
| 162 |
+
colorTo: purple
|
| 163 |
+
sdk: gradio
|
| 164 |
+
sdk_version: 4.44.0
|
| 165 |
+
app_file: app.py
|
| 166 |
+
pinned: false
|
| 167 |
+
license: mit
|
| 168 |
+
---
|
| 169 |
+
```
|
| 170 |
+
|
| 171 |
+
## π€ Contributing
|
| 172 |
+
|
| 173 |
+
Contributions are welcome! Feel free to:
|
| 174 |
+
- Add more embedding models
|
| 175 |
+
- Include additional LLMs
|
| 176 |
+
- Improve the interface
|
| 177 |
+
- Add more visualizations
|
| 178 |
+
- Enhance documentation
|
| 179 |
+
|
| 180 |
+
## π License
|
| 181 |
+
|
| 182 |
+
MIT License - Feel free to use this for educational purposes.
|
| 183 |
+
|
| 184 |
+
## π Acknowledgments
|
| 185 |
+
|
| 186 |
+
- HuggingFace for the Spaces platform and ZeroGPU
|
| 187 |
+
- Sentence Transformers for embeddings
|
| 188 |
+
- FAISS for efficient similarity search
|
| 189 |
+
- Gradio for the interface framework
|
| 190 |
+
|
| 191 |
+
## π§ Contact
|
| 192 |
+
|
| 193 |
+
For questions or feedback, please open an issue on GitHub.
|
SPACE_README.md
DELETED
|
@@ -1,60 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: RAG Pedagogical Demo
|
| 3 |
-
emoji: π
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: purple
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 4.44.0
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
-
license: mit
|
| 11 |
-
---
|
| 12 |
-
|
| 13 |
-
# π RAG Pedagogical Demo
|
| 14 |
-
|
| 15 |
-
An interactive educational application to learn about Retrieval Augmented Generation (RAG) systems.
|
| 16 |
-
|
| 17 |
-
## What is RAG?
|
| 18 |
-
|
| 19 |
-
Retrieval Augmented Generation (RAG) combines information retrieval with language generation to create more accurate and grounded AI responses. Instead of relying solely on a language model's training data, RAG systems:
|
| 20 |
-
|
| 21 |
-
1. **Retrieve** relevant information from a document corpus
|
| 22 |
-
2. **Augment** the query with this retrieved context
|
| 23 |
-
3. **Generate** an answer based on both the query and the retrieved information
|
| 24 |
-
|
| 25 |
-
## Features
|
| 26 |
-
|
| 27 |
-
- π **Upload your own PDFs** or use the default corpus
|
| 28 |
-
- π§ **Configure retrieval parameters**: embedding models, chunk size, top-k, similarity threshold
|
| 29 |
-
- π€ **Configure generation parameters**: LLM selection, temperature, max tokens
|
| 30 |
-
- π **Visualize the process**: see retrieved chunks, similarity scores, and prompts
|
| 31 |
-
- π **Bilingual interface**: English and French
|
| 32 |
-
|
| 33 |
-
## How to Use
|
| 34 |
-
|
| 35 |
-
1. **Corpus Tab**: Upload a PDF or use the default corpus about RAG
|
| 36 |
-
2. **Retrieval Tab**: Choose embedding model and retrieval parameters
|
| 37 |
-
3. **Generation Tab**: Select language model and generation settings
|
| 38 |
-
4. **Query Tab**: Ask questions and see how RAG works!
|
| 39 |
-
|
| 40 |
-
## Educational Value
|
| 41 |
-
|
| 42 |
-
This demo helps you understand:
|
| 43 |
-
- How documents are processed and chunked
|
| 44 |
-
- How semantic search retrieves relevant information
|
| 45 |
-
- How context is provided to language models
|
| 46 |
-
- How different parameters affect the results
|
| 47 |
-
|
| 48 |
-
Perfect for students, educators, and anyone curious about modern AI systems!
|
| 49 |
-
|
| 50 |
-
## Technology
|
| 51 |
-
|
| 52 |
-
- **Framework**: Gradio
|
| 53 |
-
- **Embeddings**: Sentence Transformers
|
| 54 |
-
- **Vector Store**: FAISS
|
| 55 |
-
- **LLMs**: HuggingFace Inference API
|
| 56 |
-
- **Infrastructure**: HuggingFace ZeroGPU
|
| 57 |
-
|
| 58 |
-
---
|
| 59 |
-
|
| 60 |
-
*Note: This application runs on ZeroGPU. Initial requests may take longer as models are loaded.*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|