
Neural networks at work, part 2: local models and RAG — searching through your documents
🌐 Machine-translated from Russian. Show original
In this part:
When a local model is needed#
- data cannot be sent to external services (trade secrets, personal data);
- need to work without the internet;
- a large volume of similar tasks, where API fees become noticeable.
The price is hardware: for comfortable work, you need a video card with a large amount of memory or a computer with a large amount of shared memory. Small models run on regular PCs as well, but the response quality is lower than that of large cloud ones.
Quick start#
Tools like Ollama or LM Studio download and run open models (families Qwen, Llama, Mistral, DeepSeek, etc.) with a single command and provide a local API compatible with the OpenAI format. About open models — a post about Qwen from the Vibcoding series.
What is RAG#
Retrieval-Augmented Generation — the model responds not "from memory," but based on found fragments of your documents:
- Indexing: documents (regulations, instructions, knowledge base) are cut into fragments, each counted as embedding — a numerical vector of meaning.
- Search: the user's question also turns into a vector, finding the most similar fragments.
- Answer: the model passes the question and the found fragments with the instruction "answer only based on these materials and indicate the source."
Simple RAG architecture#
| Component | Variants |
|---|---|
| Vector storage | PostgreSQL with the pgvector extension, specialized vector databases, |
| Embedding model | local or cloud-based, with support for Russian and Kazakh |
| Language model | on-premises or cloud-based—according to data requirements |
| Interface | chat on the internal portal, bot in messenger, |
What is important for quality#
- Document quality is more important than model: outdated and contradictory regulations will give incorrect answers.
- Slicing: fragments by semantic sections, with the document and section title in each fragment.
- Source references in each response — the user should be able to verify.
- Access rights: search only by documents the user can see. Otherwise, RAG will become a way to read other people's documents.
- The answer 'I don't know' is better than fiction: explicitly instruct the model to refuse if there is no answer in the materials.
Assessment#
Collect 30–50 real employee questions with correct answers and check the system on them after each change — it shows whether things have improved or worsened.
Comments · 0
No comments yet.Sign in to comment, rate and see all comments.