Skip to content

RAG & Knowledge Base

SalmAlm includes a zero-dependency RAG (Retrieval-Augmented Generation) system β€” no external vector DB, no embeddings API. Everything runs locally in SQLite.

How It Works

User Query β†’ Tokenize β†’ BM25 + TF-IDF Hybrid Search β†’ Top-K Chunks β†’ Inject into Prompt
  1. Indexing: Files are chunked (5 lines, 2-line overlap) and tokenized with Korean jamo decomposition + English stemming
  2. Search: Hybrid BM25 (text weight 0.3) + TF-IDF cosine similarity (vector weight 0.7)
  3. Injection: Top results are prepended to the system prompt as context

What Gets Indexed

Source Auto-indexed Tool
Memory files (~/SalmAlm/memory/) βœ… memory_write
Notes βœ… note
Saved links βœ… save_link
Workspace files On demand file_index
Session transcripts Optional Config toggle

Configuration

Edit ~/SalmAlm/rag.json:

{
  "hybrid": {
    "enabled": true,
    "vectorWeight": 0.7,
    "textWeight": 0.3
  },
  "sessionIndexing": {
    "enabled": false,
    "retentionDays": 30
  },
  "chunkSize": 5,
  "chunkOverlap": 2,
  "reindexInterval": 120
}

Korean Language Support

SalmAlm's RAG has first-class Korean support:

  • Jamo decomposition β€” decomposes Hangul into consonants/vowels for fuzzy matching
  • Korean stemming β€” strips common suffixes (은/λŠ”/이/κ°€/을/λ₯Ό/μ—μ„œ/으둜 etc.)
  • Synonym expansion β€” 검색→찾기/탐색, 였λ₯˜β†’μ—λŸ¬/버그 etc.
  • Stop word filtering β€” removes Korean particles and common English stop words

Web UI

Access the RAG panel at Settings β†’ RAG & Knowledge to:

  • View index statistics (document count, chunk count, last indexed)
  • Trigger manual reindex
  • Configure hybrid search weights
  • Enable/disable session indexing
  • rag_search β€” Direct semantic search
  • memory_write / memory_search β€” Long-term memory CRUD
  • note β€” Quick notes (auto-indexed)
  • save_link β€” Save URLs with auto-fetched content
  • file_index β€” Index workspace files on demand