Skip to main content
Version: 0.2.3

Large Language Models

Sercha can optionally use a Large Language Model (LLM) to enhance search and document understanding. This is entirely optional, Sercha works without an LLM using pure keyword search.

What LLMs Enable

When configured, an LLM provides:

  • Query Rewriting: Expands search queries with synonyms, fixes typos, and adds context
  • Summarisation: Creates summaries of indexed content
  • Query Understanding: Better interpretation of natural language queries

Architecture

LLM integration is a driven port in the hexagonal architecture. The core defines an LLMService interface, and adapters implement it for different providers.

┌─────────────────────────────────────────────────┐
│ Core Domain │
│ ┌─────────────────────────────────────────┐ │
│ │ LLMService Port │ │
│ │ - Generate(prompt) │ │
│ │ - Chat(messages) │ │
│ │ - RewriteQuery(query) │ │
│ │ - Summarise(content) │ │
│ └─────────────────────────────────────────┘ │
└─────────────────────────────────────────────────┘

┌─────────────┼─────────────┐
▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌─────────┐
│ OpenAI │ │ Ollama │ │ None │
│ │ │ │ │ (stub) │
└─────────┘ └─────────┘ └─────────┘

Graceful Degradation

When no LLM is configured:

  • Search falls back to pure keyword matching
  • No query rewriting or summarisation is available
  • The application remains fully functional for basic search

Supported Providers

ProviderModelsNotes
OpenAIGPT-4, GPT-3.5-turboRequires API key
AnthropicClaude 3.xRequires API key
Ollamallama3, mistral, etc.Local inference
LM StudioAny loaded modelLocal inference
NoneGraceful degradation

Individual adapter documentation will be added as adapters are implemented.