This guide explains how to set up and use the RAG system in your note-taking app.
RAG enhances AI responses by automatically searching your notes for relevant context. When enabled, the AI will:
- Search through your notes to find relevant information
- Include citations with links to source notes
- Provide more accurate answers about your content
First, install PostgreSQL and the pgvector extension:
macOS:
brew install postgresql
brew install pgvector
brew services start postgresqlUbuntu/Debian:
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo apt install postgresql-15-pgvectorInstall Ollama for local embedding generation:
# Download from https://ollama.ai
# Then pull the embedding model:
ollama pull embeddinggemma-
Run the setup script:
cd scripts ./setup_postgres.sh -
Configure environment variables:
The script creates a
.envfile. Update it if needed:POSTGRES_HOST=localhost POSTGRES_PORT=5432 POSTGRES_DB=noteraity_vectors POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres OLLAMA_HOST=http://localhost:11434 OLLAMA_EMBEDDING_MODEL=embeddinggemma
-
Start the app:
npm run dev
- Open Settings → AI Configuration
- Find the "RAG (Retrieval-Augmented Generation)" section
- Click the toggle to enable RAG
When you first enable RAG, you need to index your existing notes:
- In the Tauri dev console, you can manually trigger indexing
- New notes are automatically indexed when created/updated
When RAG is enabled:
- Your questions will automatically search through your notes
- Responses will include numbered citations [1], [2], etc.
- Click on citations to navigate to the source note
- Hover over citations to see relevance scores
- Each citation shows:
- Note title
- Preview of relevant content
- Relevance score (0-100%)
- Click to navigate to the note
- Uses semantic search (understands meaning, not just keywords)
- Finds related concepts even with different wording
- Ranks results by relevance
# Check if PostgreSQL is running
pg_isready
# Check pgvector installation
psql -d noteraity_vectors -c "CREATE EXTENSION IF NOT EXISTS vector;"# Check if Ollama is running
curl http://localhost:11434/api/tags
# Check if embedding model is installed
ollama list | grep embeddinggemma- Check the browser console for errors
- Ensure PostgreSQL is running
- Ensure Ollama is running
- Try re-indexing your notes
- Chunking: Notes are split into ~512 token chunks with 128 token overlap
- Embeddings: Vectors generated using embeddinggemma
- Storage: PostgreSQL with pgvector for efficient similarity search
- Retrieval: Top 5 most relevant chunks with >30% similarity threshold