|
| 1 | +# Codebase Embeddings Demo |
| 2 | + |
| 3 | +This demo application enables semantic search over your codebase using AI embeddings. Ask natural language questions like "Where is the model packaging code?" and get relevant code snippets with similarity scores. |
| 4 | + |
| 5 | +## Quick Start (Recommended) ⚡ |
| 6 | + |
| 7 | +The demo automatically downloads a pre-generated embeddings index from a [GitHub Gist](https://gist.githubusercontent.com/ilopezluna/235518ab315c23275c90c5cddb1375b8/raw/df541734b3f4843f99b8ce34f4cee240addde08f/embeddings-index.json) on first run, so you can start searching immediately without waiting for indexing. |
| 8 | + |
| 9 | +### Prerequisites |
| 10 | + |
| 11 | +- **Node.js** (version 18 or higher) |
| 12 | +- **Docker Model Runner** running on port 12434 |
| 13 | + |
| 14 | +### Installation |
| 15 | + |
| 16 | +```bash |
| 17 | +# Pull ai/qwen3-embedding:0.6B-F16 |
| 18 | +docker model pull ai/qwen3-embedding:0.6B-F16 |
| 19 | + |
| 20 | +# Navigate to the demo directory |
| 21 | +cd demos/embeddings |
| 22 | + |
| 23 | +# Install dependencies |
| 24 | +npm install |
| 25 | + |
| 26 | +# Start the server |
| 27 | +npm start |
| 28 | +``` |
| 29 | + |
| 30 | +The server will automatically: |
| 31 | +1. Check if an embeddings index exists locally |
| 32 | +2. If not found, download the pre-generated index from the Gist |
| 33 | +3. Load the index and start the server |
| 34 | +4. Open your browser to http://localhost:3000 |
| 35 | + |
| 36 | +**That's it!** You can now search the codebase with natural language queries. |
| 37 | + |
| 38 | +### About the Pre-generated Index |
| 39 | + |
| 40 | +The pre-generated embeddings index: |
| 41 | +- Contains embeddings for the entire Docker Model Runner codebase |
| 42 | +- Generated using the `ai/qwen3-embedding:0.6B-F16` model |
| 43 | +- Hosted on GitHub Gist for easy access |
| 44 | + |
| 45 | +**Note**: The pre-generated index represents a snapshot of the codebase. If you've made local code changes and want search results to reflect them, see the "Generate Your Own Index" section below. |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## Generate Your Own Index 🔨 |
| 50 | + |
| 51 | +Want to generate fresh embeddings for your local codebase? |
| 52 | + |
| 53 | +```bash |
| 54 | +# Navigate to demo directory |
| 55 | +cd demos/embeddings |
| 56 | + |
| 57 | +# Run the indexer (takes ~20 minutes) |
| 58 | +npm run index |
| 59 | +``` |
| 60 | + |
| 61 | +This will: |
| 62 | +1. Scan all source files in the project (respecting .gitignore) |
| 63 | +2. Generate embeddings for each file/chunk |
| 64 | +3. Save the index to `embeddings-index.json` |
| 65 | + |
| 66 | +After indexing completes, start the server: |
| 67 | +```bash |
| 68 | +npm start |
| 69 | +``` |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## Additional Resources |
| 74 | + |
| 75 | +- [Docker Model Runner Documentation](https://docs.docker.com/ai/model-runner/) |
| 76 | +- [Embedding Models on Docker Hub](https://hub.docker.com/u/ai?page=1&search=embed) |
| 77 | +- [Pre-generated Index Gist](https://gist.githubusercontent.com/ilopezluna/235518ab315c23275c90c5cddb1375b8/raw/df541734b3f4843f99b8ce34f4cee240addde08f/embeddings-index.json) |
| 78 | +- [Cosine Similarity Explanation](https://en.wikipedia.org/wiki/Cosine_similarity) |
0 commit comments