Stack AI's document processing is powerful but has configuration choices that significantly affect retrieval quality. Here is what to set and why.

The Default Configuration Problem

Stack AI's knowledge base is easy to set up: upload documents, connect to a workflow, done. The default configuration gets you to a working demo. It does not get you to good retrieval quality at scale.

The three settings that matter most -- chunking strategy, retrieval count, and reranking -- are all configurable but rarely explained in the platform's onboarding. This article covers each one.

Document Types and Processing

Stack AI handles document parsing before chunking. Different document types need different handling:

Document type Stack AI handling Watch out for
PDFs (text-based) Extracts text directly Scanned/image PDFs lose all content -- use OCR-enabled option
PDFs (scanned/image) Requires OCR setting -- not default Enable OCR in the knowledge base settings
Excel/CSV Converts to structured text Large spreadsheets truncate -- split before uploading
Word documents Extracts text and basic structure Complex tables and images may not extract cleanly
Web URLs Crawls and extracts text JavaScript-heavy pages may return incomplete content
Notion/Google Drive Via integration -- respects permissions Nested pages may not be indexed by default
Scanned PDFs (images of text) will appear to upload successfully but contain no extractable text unless OCR is enabled. Always enable OCR if your document library includes any scanned content.

Chunking Configuration

Chunking splits your documents into segments that are individually embedded and retrieved. The default settings work for general text. Adjust for your content type:

Content type Recommended chunk size Overlap
General documentation / articles 800-1000 tokens 100-150 tokens
Dense technical documentation 400-600 tokens 80-100 tokens
Legal / compliance documents 1200-1500 tokens 200 tokens
FAQ / short Q&A entries 200-300 tokens 30-50 tokens

To adjust chunking in Stack AI:

  1. Go to your Knowledge Base settings
  2. Under Indexing > Chunking Strategy, select Custom
  3. Set Chunk Size and Overlap for your content type
  4. Re-index affected documents after changing chunking settings
Chunk size is in tokens, not characters. 1000 tokens is approximately 750 words. If your documents contain many short sections (like FAQ entries), use smaller chunks so each section gets its own embedding rather than being merged with unrelated content.

Retrieval Count and Quality

The retrieval count (top_k) controls how many chunks are retrieved per query. The default is usually 3-5. More chunks give the LLM more context but increase token usage and can dilute the relevance signal.

  • For precise factual Q&A (specific policy questions, specific numbers): top_k=3 is usually sufficient
  • For open-ended questions requiring synthesis across multiple sections: top_k=8-10
  • For very large knowledge bases with many similar documents: top_k=10-15 with reranking enabled

In Stack AI's workflow builder, adjust the Retriever node's top_k parameter. Pair higher top_k values with reranking (see below) to maintain precision.

Enabling Reranking

Reranking re-scores the top retrieved chunks using a dedicated model that understands query-document relevance more precisely than vector similarity alone. For knowledge bases with more than 20-30 documents, reranking consistently improves answer quality.

In Stack AI:

  1. In your workflow, select the Retriever node
  2. Enable Reranker under Retrieval Settings
  3. Set Reranker Model (Cohere Rerank is a strong default)
  4. Set top_k to 10-15 (retrieve more candidates for the reranker to evaluate)
  5. Set Reranker top_n to 3-5 (reranker picks the best from the candidates)

Testing Retrieval Quality in Isolation

Before testing the full Q&A workflow, test retrieval quality separately. A good answer from a bad retrieval is impossible. Verify that your knowledge base is returning the right chunks before assuming the problem is in the LLM.

In Stack AI's workflow canvas:

  1. Add a Retriever node connected to your knowledge base
  2. Add a Text Output node connected to the Retriever's documents output
  3. Run the workflow with your test query
  4. Inspect the retrieved chunks: are they the right sections?
  5. If not: adjust chunking strategy, increase top_k, or enable reranking
Test with 10-15 representative questions covering different parts of your knowledge base. For each question, check which chunks were retrieved before checking the generated answer. This separates retrieval problems (wrong chunks returned) from generation problems (wrong answer despite right chunks).

Quick Reference

  • Enable OCR in knowledge base settings if any documents are scanned PDFs
  • Adjust chunk size to match your content type -- smaller for FAQ/dense docs, larger for narrative
  • Start with top_k=5, increase to 10-15 and add reranking for larger knowledge bases
  • Enable Cohere Rerank for knowledge bases with 20+ documents
  • Test retrieval quality in isolation before testing the full Q&A pipeline
  • Re-index documents after changing chunking settings -- old chunks persist until re-indexed