r/Rag • • 11h ago

Tutorial RAG Step-by-Step Tutorial for Beginners: How to Stop AI Hallucinations with Your Own Data

20 Upvotes

If you are tired of LLMs making up facts when querying private documents, Retrieval-Augmented Generation (RAG) is the standard fix. Instead of relying on static training weights, RAG retrieves relevant chunks from your own files and passes them directly to the model as context.

​I put together a practical, step-by-step RAG tutorial for beginners that skips the heavy academic theory and focuses on building a working pipeline from scratch.

​Inside the guide, you will learn how to:

  • ​Split and chunk raw documents without losing semantic meaning
  • ​Generate vector embeddings and store them in a vector database
  • ​Connect a retriever to an LLM to ground every response in verified sources

​Check out the full technical cheat sheet and architecture breakdown here: https://interconnectd.com/forum/thread/31/rag-for-beginners-the-technical-cheat-sheet-that-stops-ai-hallucinations/

Let me know what vector database or embedding model you are testing first.


r/Rag • • 2h ago

Tools & Resources I got tired of paying $0.04/paper for LlamaParse, so I built a deterministic $0.005/paper extractor for ArXiv with citations & RAG chunks

3 Upvotes

Hey everyone,

Like many of you building RAG pipelines or local agent research monitors, my biggest headache has always been academic PDFs.

Tools like LlamaParse and Unstructured do great work, but they charge ~$0.003/page. When you're indexing hundreds of 15–30 page papers, that quickly runs into $50–$100 bills for simple batch jobs—and vision-based models often hallucinate equation numbers or fail on two-column layouts.

So I wrote a deterministic, sub-3-second extractor in Python combining PyMuPDF (`fitz` in C) with the official ArXiv Atom API, and packaged it as a Pay-Per-Event (PPE) Actor on Apify.

### What it extracts cleanly:

  1. **Authoritative Metadata**: Title, authors, affiliations, date, canonical ArXiv ID, and DOI.
  2. **Decomposed Sections**: Headings (`1. Introduction`, `3.2 Methodology`) with automatic hyphenation de-wrapping.
  3. **Analytics**: Exact count of display equation blocks and table captions with context.
  4. **Structured Citations**: Parses references into `{raw_text, title_guess, year, arxiv_id_if_present}` so you can build paper-citation graphs.
  5. **RAG-Ready Chunks**: Overlapping, token-bounded chunks pre-tagged with section breadcrumbs (`[Section: Methodology]\n...`), ready to drop straight into Qdrant/Pinecone/Chroma.

### Cost & Speed Benchmark (15-page Paper: "Attention Is All You Need"):

- **LlamaParse**: ~$0.045 / paper (12–25 seconds)

- **This Actor**: $0.005 / paper (3.8 seconds)

- **Failure Guarantee**: If an invalid PDF or 404 occurs, Apify charges $0.00.

Code is open on GitHub: https://github.com/ali1556/arxiv-pdf-structured-extractor

Apify Store Actor: https://apify.com/al1nr/arxiv-pdf-structured-extractor-1

Would love feedback from anyone running paper RAG pipelines—what fields or chunk formats are you missing most?


r/Rag • • 2h ago

Discussion Dense pooling vs. ColBERT multivectors on technical manuals (and the index RAM tax nobody mentions)

2 Upvotes

Single-vector dense embeddings compress an entire 512-token chunk into one array, which blurs out exact identifiers like error code 403 vs 404, or a 2.5mm vs 2.8mm flange spec.

Late-interaction multivector models (BAAI/bge-m3 with output_types=[""multivector""] or answerdotai/answerai-colbert-small-v1, which averages 0.466 nDCG@10 across 8 retrieval sets) avoid that collapse by keeping per-token vectors so exact technical strings still score cleanly without rewriting your chunker.

The trade-off is storage and memory bloat: storing one vector per token multiplies your vector DB footprint significantly compared to single-vector dense indexes, and models like answerai-colbert-small-v1 cap context at 512 tokens. In most cases, BM25/learned sparse + dense fusion gets you 90% of the way there for a fraction of the RAM.

If you want to A/B test whether multivectors actually move recall on your manuals before provisioning GPU nodes, you can run a small sample through sie_sdk on Superlinked Serverless first, and only move heavy nightly indexing onto a self-hosted Native Inference cluster if the recall gain justifies the extra index RAM.


r/Rag • • 5m ago

Discussion Preparing messy documents for RAG: what should survive extraction

1 Upvotes

A RAG dataset often starts with PDFs, tables, charts, and code snippets. Turning them into usable records means deciding what belongs together and what context needs to survive. Those records might be document chunks or QA pairs—QA conversion is useful for some workflows, but isn’t a requirement for RAG.

One approach is to separate preparation into operators: document parsing, text cleaning, chunking, optional QA generation, evaluation, and filtering. Each operator reads named fields and writes its output for the next step.

A few details matter:

  • Keep visual content connected to its context. For PDF-to-VQA preparation, the workflow includes layout parsing, OCR, and image–text alignment before extracting questions and answers. Flattening everything into plain text can lose the information needed to interpret a figure.
  • Make intermediate outputs inspectable. Explicit input and output fields let you examine extracted content before generating QA pairs, or inspect generated pairs before filtering them.
  • Separate scoring from the filtering decision. Saving scores first lets you try different thresholds against the same scored data. That avoids another model call just to change which records you keep.
  • Keep model access separate from processing logic. Operators use a configured serving backend, with API and local inference options, so model calls don’t need to be wired into every pipeline from scratch.

The remaining question is whether the prepared records preserve enough evidence to answer real queries; clean formatting alone doesn’t establish that.

These building blocks are implemented in OpenDCAI/DataFlow—how are you handling mixed documents in your RAG pipelines, and which preprocessing decisions have made the biggest difference?


r/Rag • • 1h ago

Discussion Building a fully local RAG system for complex legal/union contracts — looking for architecture and accuracy recommendations

1 Upvotes

I’m developing a desktop application using Flutter that helps union representatives analyze collective bargaining agreements (CBAs), workplace policies, grievances, and other labor-related documents.
The goal is to build a production-grade, completely local RAG system that provides accurate answers with verifiable citations. Confidential documents must remain on the user’s computer.
Current stack:
● Flutter/Dart desktop application (Windows/Linux)
● Ollama for local LLM inference
● Qwen3 1.7B/4B models
● Haystack 3.x for retrieval experimentation
● Qwen3-Embedding-0.6B
● BGE reranker
● BM25 and vector retrieval experiments
Problems we’ve encountered:

  1. Retrieval accuracy: The system sometimes retrieves related contract language but misses the exact provision needed to answer correctly.
  2. Context fragmentation: Relevant provisions may span multiple paragraphs or pages. Retrieving isolated chunks can lose important conditions, exceptions, or deadlines.
  3. Citation reliability: We need accurate article, section, and physical PDF page references. We’ve encountered cases where the AI confused two different deadlines in the same article.
  4. LLM performance: Smaller local models sometimes produce incomplete responses, take too long, or struggle with larger contexts.
  5. Document processing: We need reliable extraction of complex PDFs, including tables, headings, numbered sections, scanned documents, and cross-references.
    What we’re considering:
    ● Docling for layout-aware document extraction
    ● A normalized document representation preserving sections, tables, and source metadata
    ● Hierarchical/parent-child chunking
    ● Hybrid BM25 + dense retrieval
    ● Reranking and evidence verification
    ● Agentic retrieval when initial evidence is insufficient
    ● A benchmark dataset of verified contract questions
    Questions for developers with production RAG experience:
  6. What document-processing and chunking architecture would you recommend for complex, structured legal documents?
  7. Would you use standard dense embeddings, ColBERT/multivector retrieval, or another approach for precise clause retrieval?
  8. How do you reliably preserve citations and relationships between sections across PDF pages?
  9. What techniques have made the biggest measurable difference in reducing incorrect answers and unsupported citations?
  10. What local models or retrieval frameworks would you recommend for balancing accuracy, latency, and memory usage on consumer hardware?
    I’m especially interested in existing open-source tools and proven architectures rather than building every component from scratch.
    Any recommendations, benchmarks, or lessons learned would be appreciated.

r/Rag • • 9h ago

Discussion How would you improve RAG answer generation without using an LLM?

2 Upvotes

Hey everyone!

We've been building a research desktop application called ResearchLens with our team.

One interesting challenge we're exploring is generating good, coherent answers from documents without relying on an LLM or neural embeddings.

Our current pipeline uses SQLite FTS5, BM25, TF-IDF query expansion, RRF and deterministic extractive answer composition with source citations.

Retrieval works reasonably well, but making the final answers more coherent, complete and context-aware is still challenging.

For those who have worked on traditional NLP or non-LLM RAG systems:

  • How would you improve answer composition?
  • Are there good approaches for connecting facts across multiple passages?
  • Would graph-based extraction or hierarchical summarization help?

Would appreciate suggestions, research papers or alternative approaches!

We're also sharing the project here:
https://github.com/ResearchLens-Lab/ResearchAssistant

Would love some honest technical feedback!


r/Rag • • 6h ago

Showcase NornicDB - 1.5.2 - Silhouette - FGAC MIT Licensed

1 Upvotes

https://github.com/orneryd/NornicDB/releases/tag/v1.5.2

just dropped fullly implemented fine grained access control as well as some startup and throughput and performance improvements across the board.

This was the remainder of the bigger features. you can define entitlements that target specific nodes by id or label, assign those entitlements to roles. and roles to users. there’s a whole catalog of entitlements for each action in the database, and impersonation is implemented. features will never be hidden behind a paywall.

MIT Licensed, 930+ stars and counting.

love any feedback or if you find any bugs please submit an issue. if you’ve been enjoying it, give us a star!

enjoy
-OrneryD


r/Rag • • 17h ago

Discussion Lang chain/langraph vs llamaindex vs haystack

1 Upvotes

Hi folks just curios what framework are you using in your rag work flow from above and why did you choose them over others?


r/Rag • • 19h ago

Discussion Fiabilité de l'utilisation de l'outil Magistral 24B dans le cadre d'une analyse RAG basée sur des documents (Ollama vs vLLM)

0 Upvotes

Titre : Fiabilité de l’utilisation de l’outil Magistral 24B dans un système RAG ancré dans les documents (Ollama vs vLLM)

Bonjour à tous,

Je développe un assistant IA entièrement local, en français, pour un domaine de connaissances spécialisé exigeant une attribution rigoureuse des sources et un raisonnement complexe.

Notre architecture actuelle utilise :

Magistral 24B pour le raisonnement et la génération de réponses.

Python pour l’orchestration, la récupération de documents, l’exécution des outils, la gestion des permissions et la validation des sources.

Un pipeline RAG ancré dans les documents avec un corpus de référence conséquent.

Ollama, avec des expérimentations complémentaires utilisant vLLM et l’appel d’outils natifs.

Une carte graphique RTX 5070, 12 Go de RAM et 64 Go de RAM système, avec déchargement partiel du CPU/GPU.

Après de nombreux tests, nous avons rencontré plusieurs problèmes récurrents :

1. Fiabilité de l’utilisation des outils

Le modèle répond parfois sans demander de documents supplémentaires, même lorsque les preuves disponibles sont insuffisantes. Dans d'autres cas, les appels d'outils peuvent être mal gérés par le moteur d'inférence ou ses modèles.

2. Recherche versus raisonnement Lorsque les documents nécessaires sont correctement fournis, Magistral peut produire un excellent raisonnement spécifique au domaine. Cependant, il arrive que des passages critiques des sources ne parviennent pas au modèle. Nous étudions le classement des résultats de recherche, la sélection du contexte et le transport des documents indépendamment du raisonnement du modèle.

3. Sur-contrainte du modèle Nous avons expérimenté des invites, des règles de validation et des contrôles de flux de travail de plus en plus restrictifs. Ces tests n'ont pas amélioré la qualité des réponses de manière constante et ont parfois complexifié le système.

Nous nous orientons désormais vers une architecture plus simple :

Python garantit une recherche documentaire initiale avant les réponses de fond.

Magistral gère l'analyse intellectuelle, le raisonnement, les demandes de recherche complémentaires et la rédaction.

Python exécute les outils, gère les permissions, valide les références aux sources et contrôle la boucle d'exécution.

Nous évitons les instructions inutiles qui dictent la manière dont le modèle doit raisonner. Mes questions aux développeurs ayant conçu des systèmes similaires :

Avez-vous réussi à obtenir une utilisation fiable d'outils multi-étapes avec Magistral 24B ou Magistral 3 14B Reasoning ?

Quel moteur d'inférence, quelles versions, quel analyseur syntaxique d'appels d'outils et quels modèles de conversation ont fonctionné de manière fiable ?

Le passage à Python pour l'orchestration et la validation a-t-il amélioré la fiabilité tout en offrant au modèle une plus grande liberté de raisonnement ?

Comment assurez-vous la continuité du raisonnement entre les appels d'outils, gérez-vous les appels manquants et évitez-vous les boucles de raisonnement excessives ?

Avez-vous mesuré la justesse et l'exhaustivité réelles des réponses, et pas seulement la réussite de l'exécution des outils ?

Je suis particulièrement intéressé par les solutions ayant fait leurs preuves dans des applications réelles, avec des configurations reproductibles et des limitations connues.

Je peux partager des traces d'exécution anonymisées et des cas de reproduction minimaux si nécessaire.

Merci d'avance pour vos retours techniques.

Texte rédigé avec l'aide d'une IA ; le projet, les tests et les observations sont de moi.


r/Rag • • 23h ago

Discussion Fiabilité de l'utilisation de l'outil Magistral 24B dans le cadre d'une analyse RAG basée sur des documents (Ollama vs vLLM)

0 Upvotes

Titre : Fiabilité de l’utilisation de l’outil Magistral 24B dans un système RAG ancré dans les documents (Ollama vs vLLM)

Bonjour à tous,

Je développe un assistant IA entièrement local, en français, pour un domaine de connaissances spécialisé exigeant une attribution rigoureuse des sources et un raisonnement complexe.

Notre architecture actuelle utilise :

Magistral 24B pour le raisonnement et la génération de réponses.

Python pour l’orchestration, la récupération de documents, l’exécution des outils, la gestion des permissions et la validation des sources.

Un pipeline RAG ancré dans les documents avec un corpus de référence conséquent.

Ollama, avec des expérimentations complémentaires utilisant vLLM et l’appel d’outils natifs.

Une carte graphique RTX 5070, 12 Go de RAM et 64 Go de RAM système, avec déchargement partiel du CPU/GPU.

Après de nombreux tests, nous avons rencontré plusieurs problèmes récurrents :

1. Fiabilité de l’utilisation des outils

Le modèle répond parfois sans demander de documents supplémentaires, même lorsque les preuves disponibles sont insuffisantes. Dans d'autres cas, les appels d'outils peuvent être mal gérés par le moteur d'inférence ou ses modèles.

2. Recherche versus raisonnement Lorsque les documents nécessaires sont correctement fournis, Magistral peut produire un excellent raisonnement spécifique au domaine. Cependant, il arrive que des passages critiques des sources ne parviennent pas au modèle. Nous étudions le classement des résultats de recherche, la sélection du contexte et le transport des documents indépendamment du raisonnement du modèle.

3. Sur-contrainte du modèle Nous avons expérimenté des invites, des règles de validation et des contrôles de flux de travail de plus en plus restrictifs. Ces tests n'ont pas amélioré la qualité des réponses de manière constante et ont parfois complexifié le système.

Nous nous orientons désormais vers une architecture plus simple :

Python garantit une recherche documentaire initiale avant les réponses de fond.

Magistral gère l'analyse intellectuelle, le raisonnement, les demandes de recherche complémentaires et la rédaction.

Python exécute les outils, gère les permissions, valide les références aux sources et contrôle la boucle d'exécution.

Nous évitons les instructions inutiles qui dictent la manière dont le modèle doit raisonner. Mes questions aux développeurs ayant conçu des systèmes similaires :

Avez-vous réussi à obtenir une utilisation fiable d'outils multi-étapes avec Magistral 24B ou Magistral 3 14B Reasoning ?

Quel moteur d'inférence, quelles versions, quel analyseur syntaxique d'appels d'outils et quels modèles de conversation ont fonctionné de manière fiable ?

Le passage à Python pour l'orchestration et la validation a-t-il amélioré la fiabilité tout en offrant au modèle une plus grande liberté de raisonnement ?

Comment assurez-vous la continuité du raisonnement entre les appels d'outils, gérez-vous les appels manquants et évitez-vous les boucles de raisonnement excessives ?

Avez-vous mesuré la justesse et l'exhaustivité réelles des réponses, et pas seulement la réussite de l'exécution des outils ?

Je suis particulièrement intéressé par les solutions ayant fait leurs preuves dans des applications réelles, avec des configurations reproductibles et des limitations connues.

Je peux partager des traces d'exécution anonymisées et des cas de reproduction minimaux si nécessaire.

Merci d'avance pour vos retours techniques.

Texte rédigé avec l'aide d'une IA ; le projet, les tests et les observations sont de moi.


r/Rag • • 1d ago

Tools & Resources How to find one memory in 60 million tokens - lessons learnt from building AI memory at scale

3 Upvotes

I've been building RAG systems for 3+ years now. The largest scale system I built powers my AI memory platform MemoryPlugin. We have a multi-stage RAG pipeline, and I wrote a blog post to share my experience, the mistakes I made, and share details about our pipeline with a lot of transparency.

Happy to answer questions, get your feedback, and learn about your experiences!

https://blog.memoryplugin.com/labs-002-large-scale-memory-recall/


r/Rag • • 1d ago

Discussion Magistral 24B tool-use reliability in document-grounded RAG (Ollama vs vLLM)

2 Upvotes

Title: Magistral 24B tool-use reliability in document-grounded RAG (Ollama vs vLLM)
Hi everyone,
I’m developing a fully local, French-language AI assistant for a specialized knowledge domain requiring rigorous source attribution and complex reasoning.
Our current architecture uses:
Magistral 24B for reasoning and answer generation.
Python for orchestration, document retrieval, tool execution, permissions and source validation.
A document-grounded RAG pipeline with a substantial authoritative corpus.
Ollama, with additional experiments using vLLM and native tool calling.
An RTX 5070 12 GB and 64 GB system RAM, with partial CPU/GPU offloading.
After extensive testing, we’ve encountered several recurring problems:
1. Tool-use reliability
The model sometimes answers without requesting additional documents, even when the available evidence is insufficient. In other cases, tool calls may be incorrectly handled by the inference engine or its templates.
2. Retrieval versus reasoning
When the necessary documents are correctly supplied, Magistral can produce excellent domain-specific reasoning. However, critical source passages sometimes fail to reach the model. We are investigating retrieval ranking, context selection and document transport separately from model reasoning.
3. Over-constraining the model
We experimented with increasingly restrictive prompts, validation rules and workflow controls. These did not consistently improve answer quality and sometimes made the system more complicated.
We are now moving toward a simpler architecture:
Python guarantees an initial documentary search before substantive answers.
Magistral handles intellectual analysis, reasoning, follow-up research requests and writing.
Python executes tools, manages permissions, validates source references and controls the execution loop.
We avoid unnecessary instructions that dictate how the model must reason.
My questions to developers who have built similar systems:
Have you achieved reliable multi-step tool use with Magistral 24B or Ministral 3 14B Reasoning?
Which inference engine, versions, tool-call parser and chat templates have worked reliably?
Has moving orchestration and validation into Python improved reliability while allowing the model more freedom to reason?
How do you preserve reasoning continuity across tool calls, handle missing tool calls and prevent excessive reasoning loops?
Have you measured actual answer correctness and completeness, rather than just successful tool execution?
I’m particularly interested in solutions that have been tested successfully in real applications, including reproducible configurations and known limitations.
I can share anonymized execution traces and minimal reproduction cases if helpful.
Thanks in advance for any technical feedback.
English wording prepared with AI assistance; the project, tests and observations are my own.


r/Rag • • 1d ago

Discussion SharePoint mcp vs RAG vs notebook llm

2 Upvotes

Hi folks, has anyone found any issues with SharePoint mcp or notebook llm and why did you choose Rag over these available tools?


r/Rag • • 2d ago

Discussion What I did in the last 4 months on my retirement project RAG-LCC

7 Upvotes

This is a follow-up to my earlier post about the first 15 months of building RAG-LCC in retirement:

https://www.reddit.com/r/Rag/comments/1valvk6/15_months_building_a_rag_system_in_retirement/

The project kept evolving over the last 4 months, so I thought it might be interesting to share what worked, what failed, and what I learnt along the way. Since the last writeup I had success and failure moments. Of course, I learnt more from the failures about RAG.

Orchestrators

Because RAG-LCC provides a lab setup for RAG experimentation, I found it useful to introduce an Orchestrator component. The orchestrator defines RAG flows. Users can create new flows and then activate them during a RAGChat session.

Confidence scoring

With orchestrators, confidence became an issue. So static and dynamic confidence evaluation was added. The latter uses a LLM judge call. There is currently no validation against "golden answers" implemented. The LLM judge rates internal consistency and explanation clarity but not factual correctness.

TableChunker

With these new features, it was time to look at answer quality. There was a query asking for the details of PCIe card slots on my workstation's manual. The information is stored in a table. The goal was that the information is found and the grounder marks it.

The first step was to introduce a specialized TableChunker class and wire it into the already existing content specific chunkers. These chunkers pass table blocks to the TableChunker.

This showed partial success: The table was now consistently in the chunks. But it did not reliably show up in the query answers.
BTW, while looking for specific content in the chunk, the debug levels of RAG-LCC proved helpful. The levels can be changed mid-session so users get the information at the detail level they need currently.

Insight: If retrieval signals are weak, think about adding the best matching table result. Do this only if there are chunks found. Adding the table result to an empty answer set could confuse the user. This rescue may help in a large but sparse candidate pool.

Answer rendering

RAGChatServices delivers answers to Open WebUI. In the browser, .md and even Mermaid diagrams are nicely rendered. However, RAGChat showed tables with unaligned content. It was not a nice sight. So using the Rich library, answers with Markdown can be displayed in the RAGChat CLI also. But the rendering broke grounding, so additional work was required to separate the raw and display ready answer.

Raw answers gave the grounding signals and text to be grounded. The raw answer text is marked for grounding before Rich renders the resulting CLI text.

Insight: Keep the original, unrendered LLM answer for grounding evaluation. Once the grounded text is available, apply the visual grounding.

Document summarization

This was a "you wake up in the night" and have an insight moment. RAGChat has a document pin option. So once you found the right document about hedgehogs, you pin it and ask to summarize it. Hmm... the query is "create a summary" and this will not retrieve the content you are looking for.

So I introduced a summarize: option, using the pinned document or allowing the user to enter a path to retrieve the specific document by its metadata. Very large documents required batches of n chunks to be summarized and then summarize the batches in further passes until the final summary fits. This works, but it is admittedly slow.

Insight: If you want a specific action to be performed on the retrieved context, the action should not be part of the query. This leads to the next topic:

Query and query action splitting

With table, bullet point list and Mermaid rendering I wrote often queries like "Look for all animals contained in the documents and create a table containing animal, mammal yes, no, don't know".

Thought by the document summarization experience, I wondered whether it would make sense to ask a LLM to determine the effective query, the required action on the query results and the query keywords. Yes, you assume it: Each decomposed retrieval query goes now to enabled local retrievers, including vector search. In addition, the keywords go in an extra BM25-only pass. The QuerySplitter class was born.

Translation

Living in a multilingual country where you have 4 official languages and the unofficial English one, you have to bother about document languages. Luckily, during RAGLoad, the document language is added to metadata.

The old flow translated the question into English. It was also rewritten using the conversation history. Vector and indexed retrieval used the rewritten English query. The resulting candidates were reranked against the rewritten query.

The new flow rewrites the query with the conversation history in the user's language. The vector search runs the user language query against the ChromaDB collection. For reranking the rewritten original query is used. Indexed retrieval is for every active and present document-language bucket. When required, the query is translated.

vLLM integration

While inference calls were already supported using Ollama or vLLM backends, the embedder and reranker ran as local Hugging Face models previously.

What still works well

The configuration first approach is an extensible pattern. A new class gets its own config file when required. Abstracting functionality into classes helps understanding and maintaining the code.

Parallel to my work on RAG-LCC I worked on harinezumigel-llm-stack. I introduced groups such as rag and rag_old, which start up the required models after doing an available memory check.

So this is at a high level what happened in the last 4 months. The journey is going on.

If you want to have a look:

As always, feedback, ideas and bug reports are welcome.


r/Rag • • 2d ago

Tools & Resources Benchmarking PDF Extractors: Docling, Reducto, PDF Miner, etc

2 Upvotes

https://dev.to/vtempest/pdf-gec

Choosing a PDF extractor isn’t just about speed—it’s about getting the text, tables, reading order, and output format your application needs. My latest article compares PyMuPDF, Docling, Reducto, extract-pdf, and more, and outlines how to benchmark them fairly across PDF and webpage extraction tasks.


r/Rag • • 3d ago

Discussion Best Practices for Implementing and Troubleshooting a RAG system?

16 Upvotes

Wanted to ask the experts here from a newbie standpoint. For context, my background is 15+ years in finance (and then some data science as that was my MBA focus). The job market's been tough so I've been working on building some finance software that makes use of an AI Agent, which will include RAG (which is the part I'm working on right now - hence this post).

I'm trying to learn as best I can but the resources I have so far is LLM itself, Chip Huyen's AI Engineering Book, and random posts from reddit. Is there like a single book or reference manual that's focused and pretty good at best practices regarding building a high quality production level RAG system?

Also am doing this because I'm pursuing a Masters in AI and targeting Finance FDE roles (unless the business becomes really successful) so would like to be able to build something with all the best practices to demonstrate experience in the area.

Edit: Also wouldn't mind materials on best practices relating to number gating and prompt engineering. So I can cross-reference to see if mine are set up well or not.


r/Rag • • 2d ago

Discussion What is the difference between cosine, euclidean, and HNSW?

2 Upvotes

What is the difference between cosine, euclidean, and HNSW?


r/Rag • • 2d ago

Discussion Three measurements that changed how I trust an eval set

2 Upvotes

I run a local index over a codebase and a harness around it: fixed operations, a gate, a trace. The index answers with file:line facts instead of dumping files into the prompt. Numbers below come from one repository and one machine, static analysis only, over roughly four weeks.

Evals are the part of this project I got wrong the longest. Not because the tasks were bad, but because the numbers I looked at could not fail the way the system actually failed. Three measurements fixed that.

1. A model call counter, not a score.

My worst regression looked like a model downgrade: 90% to 60% on a fixed task set. It was not the model. The local build was answering nothing - every task returned an empty result, and the harness scored the empty result as a normal answer. The score with no model call at all was exactly the 60%.

Now every task asserts two things before the score counts: at least one model call happened, and the call returned non-empty output. Two lines per task. It has caught more real breakage than any quality metric I have, because silence in an agent stack is usually indistinguishable from a confident wrong answer.

2. Per-case results, and a rule that beats the average.

With 14 fixed navigation tasks, one flaky case moves the average by 7 points. My first two "improvements" were noise: the average went up and nothing got better. Worse, one of them hid a real regression - the answer got shorter and more readable but stopped citing file and line, so the number improved while the thing I needed disappeared.

The replacement is a rule: no previously passing case may fail. Not a threshold, a prohibition. It caught two regressions the average had hidden, both in tasks I was not looking at.

3. Missed answers counted separately from wrong answers.

The index returns three kinds of "no": absent (not in the corpus), stale (the index knows the file changed and will not answer until refreshed), and out-of-scope (the corpus was never meant to cover it). Only the first is a real "not found". Before I split them, all three looked like an empty list.

That split also exposed why a single accuracy number is misleading: a system that abstains on everything has perfect honesty and zero utility. I now track wrong answers and missed answers as separate numbers, because they fail differently in production - one invents content, the other sends every question to a human.

Where it broke, and the uncomfortable part.

The gate. I made it refuse raw file reads until the index was used, and the refusal said "raw search is blocked". The agent retried twice, then asked me to run the command for it. Three turns lost on the first session. The fix was one sentence: name the next call - "run ensure, then search_multi". Retries went to zero, same model, same weights.

The uncomfortable part is that all three measurements are about the system, not the model. They would still apply with a much better model, and they are where I would spend the next week: a counter for silence, a rule for regressions, and a taxonomy for absence.

If your eval cannot distinguish "did nothing" from "answered wrong", it is measuring the wrong thing.


r/Rag • • 2d ago

Discussion do you cap how many chunks a rag system pulls from one doc?

3 Upvotes

say you retrieve 5 chunks and 4 come from the same guide. two of them basically say the same thing and the question still needs one detail from a different doc

would you cap it at 2 chunks per doc or pull more candidates and rerank them? curious if anyone tried a cap and found it dropped useful context on questions where most of the answer really was in one doc


r/Rag • • 3d ago

Discussion Comparison and "alternatives" pages get cited the most. How are you keeping the competitor data on them accurate?

3 Upvotes

Seems settled that comparison style pages (X vs Y, alternatives to X, best X for Y) are some of the easiest pages to get cited in AI answers

The catch is they're full of competitor data: prices, plans, features, specs. That goes stale fast, and then the engines keep quoting the stale version with your page as the source.

For people running these pages at any scale:

- how often do you refresh competitor prices and specs?

- manual, page monitors, or a data feed?

- what do you do when you can't verify a number anymore? Remove it, or keep it with a date?

Has anyone seen a citation drop because the data on the page went out of date?


r/Rag • • 3d ago

Discussion Should users be able to see what a RAG system ignored?

6 Upvotes

Most RAG systems show users the sources they used to generate an answer... What about the documents that RAG systems retrieved and then discarded?

Imagine asking a RAG system, about a company policy. The RAG system finds five documents uses two and ignores three. One of those ignored documents might contain information or an important exception.

Would showing users, the rejected sources make RAG more transparent or just create more confusion? I have rarely seen this topic discussed. I wonder what RAG engineers think.


r/Rag • • 3d ago

Showcase I let an agent file and link my notes instead of building a retrieval pipeline for them

1 Upvotes

Most of my thinking happens out loud, so I stopped treating my notes as a pile to retrieve from.

I'm the developer of Zenod, so weigh this. It's built around one idea: an agent keeps the notes for me.

How it works today:

  • Each voice note or message is kept as I said it, in a dated log that is never edited
  • An agent files it under the projects and topics it touches and links it to what I said before
  • Any MCP client (Claude, ChatGPT, Cursor) can search it, and every answer points back to the note
  • The library is plain Markdown in my own Google Drive or GitHub

What I haven't solved: agents don't always save what matters unless I ask them to.

If you keep a personal knowledge base for agents, how do you catch it when the filing is wrong?

The first ten testers get 30 memories free, no card: https://zenod.dev/testers?s=P-0448


r/Rag • • 3d ago

Tools & Resources I built an open-source viewer for ParseBench 2 so you can find the exact PDF pages where 56 parsers fail and see why

2 Upvotes

I've been digging into ParseBench 2 (currently the most active document-parsing benchmark, covering 56 parsers across Text, Formatting, Tables, Charts, Layout, and Forms) to figure out which parsers actually hold up for RAG instead of just trusting summary scores.

Since LlamaIndex open-sourced the ParseBench 2 dataset, scorer, and raw parser outputs, I threw together a free, static viewer so it's easier to audit this stuff directly in the browser (no login, no backend, not affiliated with LlamaIndex or any parser vendor). You can inspect cost/latency vs. accuracy tradeoffs, drill into any page to see the exact scored errors, and compare any two parsers head-to-head on any dimension to find the exact pages where one outperforms the other.

Built it quickly in a day, so expect rough edges. Please report any bugs you hit (I already know of a few and will keep fixing them), and additional suggestions are very welcome.


r/Rag • • 4d ago

Discussion Benchmarked 9 models on extracting data out of documents, scoring wrong values as worse than missing ones. Results and open bench+dataset

5 Upvotes

Disclosure first: I run a small document extraction API (Refractr), and its model is row 4 below. I built the benchmark, so don't take my word for anything: the documents, answer key and scorer are all open. None of the benchmark data appears in my training dataset.

Why I made it: When you extract fields or metadata from documents at ingestion, a missing value is annoying but visible. A wrong value that looks plausible goes into your store and every query downstream trusts it. Most extraction benchmarks only count right answers, so a model that guesses confidently looks the same as one that leaves a blank. I wanted a score that separates them. A correctly extracted field gives one point, a missed extraction is 0 points, a confidently wrong extraction gives -1.

About one field in seven is deliberately not in its document. The right answer there is null, which is how made-up values get caught.

Setup: 260 documents (invoices, receipts, payslips, bank statements, court opinions, SEC filings, Federal Register rules, US government forms), each with a JSON schema. Models get the original PDF, image or HTML, so parsing is part of the test. Same published prompt for every model, one request, first reply scored. Scoring is deterministic, no LLM judge.

SystemScore95% intervalMedian time per doc
Gemini 3.8 Flash94.692.9–96.17.2 s
DeepSeek v4.1 Flash93.291.3–94.93.0 s
Mistral Large 491.489.4–93.227.4 s
Refractr (mine)89.487.2–91.40.7 s
GPT-5.4 mini86.283.9–88.52.2 s
Ministral 8B85.583.0–87.73.3 s
Llama 3.1 8B73.970.5–77.20.5 s
NuExtract 2.0 (2B)58.654.7–62.41.4 s
GLiNER2 (base)24.220.8–27.60.5 s

Two things I'd like to hear from people here:

  1. How do you catch wrong extracted values in your own pipeline today? Confidence scores, a second model, sampling by hand?
  2. If you run it on your own stack (parser plus model), I'll add the result. It takes any OpenAI-style endpoint or a Python function, so a full pipeline counts as a system.

Repo: https://github.com/Refractr-io/DocFieldBench

Write-up: https://refractr.io/docfieldbench


r/Rag • • 4d ago

Discussion My RAG pipeline was working fine until I realised its knowledge was six months old

17 Upvotes

I have been working on a RAG pipeline that pulls information from documentation sites, product pages and company websites.

The initial setup was pretty straightforward. Scrape the pages, convert everything to Markdown, chunk the content, generate embeddings and push it into the vector database.
The problem showed up later.

A product changed its pricing, documentation got updated and a few pages were removed. But the vector database was still serving the old information.
I initially thought about running a complete re-index every week, but that feels wasteful when only a small percentage of the content actually changes.
I'm now looking at a setup where I can monitor the original pages, identify what changed and only reprocess the relevant content.

I have been looking at Firecrawl, Apify and context.dev for different parts of this workflow.

Context.dev caught my attention because it has scraping and website monitoring under the same API, so I wouldn't need to build another integration just for change detection.

Still figuring out the best architecture here.

For people running production RAG systems, how are you keeping your external knowledge base fresh without rebuilding the entire index every time?