Spaces:
Sleeping
Sleeping
xoa-the-noob commited on
Commit Β·
d37e51e
1
Parent(s): 03bf33c
added readme descriptions
Browse files- README.md +93 -0
- faiss_index/index.faiss +3 -0
- faiss_index/index.pkl +3 -0
README.md
CHANGED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: NLP Assignment RAG App
|
| 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 |
+
---
|
| 11 |
+
|
| 12 |
+
# NLP Assignment β Research Paper RAG Assistant
|
| 13 |
+
|
| 14 |
+
This app retrieves and summarizes academic papers related to your research query using a **Retrieval-Augmented Generation (RAG)** pipeline built with:
|
| 15 |
+
|
| 16 |
+
- **FAISS** vector search (`index.faiss`, `index.pkl`)
|
| 17 |
+
- **SentenceTransformer CrossEncoder** reranker
|
| 18 |
+
- **Google Gemini (via LangChain)** as the LLM
|
| 19 |
+
- **Gradio** UI frontend
|
| 20 |
+
- **uv** package manager (modern, fast, Python-native)
|
| 21 |
+
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
## π How to Run Locally
|
| 25 |
+
|
| 26 |
+
You can run this project locally using **uv** (recommended) or plain **Python**.
|
| 27 |
+
|
| 28 |
+
### π§© Prerequisites
|
| 29 |
+
|
| 30 |
+
- Python 3.12 or higher
|
| 31 |
+
- [uv](https://docs.astral.sh/uv/) installed:
|
| 32 |
+
|
| 33 |
+
```sh
|
| 34 |
+
pip install uv
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
1. Clone the repository
|
| 38 |
+
|
| 39 |
+
```sh
|
| 40 |
+
git clone https://huggingface.co/spaces/njayman/nlp-assignment
|
| 41 |
+
cd nlp-assignment
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
2. Add your FAISS index files
|
| 45 |
+
|
| 46 |
+
Make sure your FAISS index folder is structured like this:
|
| 47 |
+
|
| 48 |
+
```sh
|
| 49 |
+
faiss_index/
|
| 50 |
+
βββ index.faiss
|
| 51 |
+
βββ index.pkl
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
3. Set up environment
|
| 55 |
+
|
| 56 |
+
Set your Gemini API key (replace with your own key):
|
| 57 |
+
|
| 58 |
+
Linux/macOS:
|
| 59 |
+
|
| 60 |
+
```sh
|
| 61 |
+
export GOOGLE_API_KEY="your_google_api_key_here"
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
Windows (PowerShell):
|
| 65 |
+
|
| 66 |
+
```sh
|
| 67 |
+
$env:GOOGLE_API_KEY="your_google_api_key_here"
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
Or add a `.env` file
|
| 71 |
+
|
| 72 |
+
```sh
|
| 73 |
+
GOOGLE_API_KEY="your_google_api_key_here"
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
4. Create a virtual env and install dependencies using uv
|
| 77 |
+
|
| 78 |
+
```sh
|
| 79 |
+
uv venv
|
| 80 |
+
uv sync
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
5. Run the Gradio app
|
| 84 |
+
|
| 85 |
+
```sh
|
| 86 |
+
uv run main.py
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
Then open the link printed in your terminal β usually:
|
| 90 |
+
|
| 91 |
+
```sh
|
| 92 |
+
http://127.0.0.1:7860
|
| 93 |
+
```
|
faiss_index/index.faiss
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2a87e286a53272c5b25a83a7c64d2fdb91f90456e75312dc12fdd4fa9dce6f98
|
| 3 |
+
size 35100717
|
faiss_index/index.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6272ece86301fc582e0a66a6d4e035e90b9635656fb8b72a821da8541c244ef7
|
| 3 |
+
size 31873745
|