Spaces:
Running on Zero
Running on Zero
readME upadted
Browse files
README.md
CHANGED
|
@@ -1,12 +1,97 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
- YouTube links with public transcripts/captions
|
| 6 |
- arXiv links or IDs
|
| 7 |
- PDF documents
|
| 8 |
|
| 9 |
-
It extracts text, chunks it, embeds chunks locally with
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
## Setup
|
| 12 |
|
|
@@ -35,15 +120,6 @@ Open the local Gradio URL printed in the terminal, usually `http://127.0.0.1:786
|
|
| 35 |
|
| 36 |
The app binds to `0.0.0.0:7860`, which is suitable for Hugging Face Spaces and container deployments.
|
| 37 |
|
| 38 |
-
For Hugging Face ZeroGPU Spaces, set:
|
| 39 |
-
|
| 40 |
-
```bash
|
| 41 |
-
ENABLE_ZEROGPU=true
|
| 42 |
-
EMBEDDING_DEVICE=cuda
|
| 43 |
-
```
|
| 44 |
-
|
| 45 |
-
The Gradio ingest/search/answer callbacks are decorated with `spaces.GPU` when running on Spaces. Locally, the decorator becomes a no-op.
|
| 46 |
-
|
| 47 |
## Project Structure
|
| 48 |
|
| 49 |
```text
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: BuildSmall KnowledgeHub
|
| 3 |
+
emoji: 📚
|
| 4 |
+
colorFrom: cyan
|
| 5 |
+
colorTo: lime
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 6.17.3
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
+
short_description: Ingest PDFs, arXiv papers, and YouTube transcripts into Qdrant with NVIDIA-powered RAG.
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# BuildSmall KnowledgeHub
|
| 15 |
+
|
| 16 |
+
BuildSmall KnowledgeHub is a modular Gradio app for loading knowledge from:
|
| 17 |
|
| 18 |
- YouTube links with public transcripts/captions
|
| 19 |
- arXiv links or IDs
|
| 20 |
- PDF documents
|
| 21 |
|
| 22 |
+
It extracts text, chunks it, embeds chunks locally with the configured NVIDIA Nemotron embedding model, uploads vectors into Qdrant, and generates grounded answers with NVIDIA's OpenAI-compatible chat API.
|
| 23 |
+
|
| 24 |
+
## NVIDIA Usage
|
| 25 |
+
|
| 26 |
+
This project explicitly uses NVIDIA in two places:
|
| 27 |
+
|
| 28 |
+
- Local retrieval embedding model: `nvidia/llama-nemotron-colembed-vl-3b-v2`
|
| 29 |
+
- NVIDIA API chat model: `nvidia/nvidia-nemotron-nano-9b-v2`
|
| 30 |
+
|
| 31 |
+
The chat client calls:
|
| 32 |
+
|
| 33 |
+
```text
|
| 34 |
+
https://integrate.api.nvidia.com/v1
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
You must provide `NVIDIA_API_KEY` as a Hugging Face Space secret or in your local `.env`.
|
| 38 |
+
|
| 39 |
+
## Hugging Face Spaces Deployment
|
| 40 |
+
|
| 41 |
+
Create a new Hugging Face Space with:
|
| 42 |
+
|
| 43 |
+
- SDK: `Gradio`
|
| 44 |
+
- App file: `app.py`
|
| 45 |
+
- Hardware: `ZeroGPU` if available, otherwise CPU/GPU according to your quota
|
| 46 |
+
- Python dependencies: installed from `requirements.txt`
|
| 47 |
+
|
| 48 |
+
Push this repository to the Space repo:
|
| 49 |
+
|
| 50 |
+
```bash
|
| 51 |
+
git remote add space https://huggingface.co/spaces/<your-username>/<your-space-name>
|
| 52 |
+
git push space main
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
For ZeroGPU Spaces, add these Space variables:
|
| 56 |
+
|
| 57 |
+
```bash
|
| 58 |
+
ENABLE_ZEROGPU=true
|
| 59 |
+
EMBEDDING_DEVICE=cuda
|
| 60 |
+
ZEROGPU_DURATION_SECONDS=180
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
For local Apple Silicon development, keep:
|
| 64 |
+
|
| 65 |
+
```bash
|
| 66 |
+
EMBEDDING_DEVICE=cpu
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
The Gradio ingest, search, and answer callbacks are decorated with `spaces.GPU` when running on Hugging Face Spaces. Locally, the decorator becomes a no-op.
|
| 70 |
+
|
| 71 |
+
## Hugging Face Secrets
|
| 72 |
+
|
| 73 |
+
Add these in your Space settings under **Settings → Variables and secrets**.
|
| 74 |
+
|
| 75 |
+
Required secrets:
|
| 76 |
+
|
| 77 |
+
```bash
|
| 78 |
+
NVIDIA_API_KEY=<your-nvidia-api-key>
|
| 79 |
+
QDRANT_URL=<your-qdrant-url>
|
| 80 |
+
QDRANT_API_KEY=<your-qdrant-api-key>
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
Optional variables:
|
| 84 |
+
|
| 85 |
+
```bash
|
| 86 |
+
QDRANT_COLLECTION_NAME=knowledge_base
|
| 87 |
+
NVIDIA_API_URL=https://integrate.api.nvidia.com/v1
|
| 88 |
+
NVIDIA_CHAT_MODEL=nvidia/nvidia-nemotron-nano-9b-v2
|
| 89 |
+
NEMOTRON_EMBED_MODEL=nvidia/llama-nemotron-colembed-vl-3b-v2
|
| 90 |
+
NEMOTRON_PARSE_MODEL=Qwen/Qwen2-VL-2B-Instruct
|
| 91 |
+
HF_TOKEN=<token-if-needed-for-gated-model-downloads>
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
Use a hosted Qdrant instance for Hugging Face Spaces. `localhost:6333` only works for local development.
|
| 95 |
|
| 96 |
## Setup
|
| 97 |
|
|
|
|
| 120 |
|
| 121 |
The app binds to `0.0.0.0:7860`, which is suitable for Hugging Face Spaces and container deployments.
|
| 122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
## Project Structure
|
| 124 |
|
| 125 |
```text
|