---
sidebar_position: 3
title: "🧠 Troubleshooting RAG (Retrieval-Augmented Generation)"
---

Retrieval-Augmented Generation (RAG) enables language models to reason over external content—documents, knowledge bases, and more—by retrieving relevant info and feeding it into the model. But when things don't work as expected (e.g., the model "hallucinates" or misses relevant info), it's often not the model's fault—it's a context issue.

Let's break down the common causes and solutions so you can supercharge your RAG accuracy! 🚀

## Common RAG Issues and How to Fix Them 🛠️

### 1. The Model "Can't See" Your Content 👁️❌

This is the most common problem—and it's typically caused by issues during your content ingestion process. The model doesn't hallucinate because it's wrong, it hallucinates because it was never given the right content in the first place.

✅ Solution: Check your content extraction settings

- Navigate to: **Admin Settings > Documents**.
- Make sure you're using a robust content extraction engine such as:
  - Apache Tika
  - Docling
  - Custom extractors (depending on your document types)

:::tip

Try uploading a document and preview the extracted content. If it's blank or missing key sections, you need to adjust your extractor settings or use a different engine.

:::

---

### 2. Only a Small Part of the Document is Being Used 📄➡️✂️

Open WebUI is designed to work with models that have limited context windows by default. For instance, many local models (e.g., Ollama's default models) are limited to 2048 tokens. Because of this, Open WebUI aggressively trims down the retrieved content to fit within the assumed available space.

✅ Solutions:

- Go to **Admin Settings > Documents**
- Either:
  - 💡 Enable "Bypass Embedding and Retrieval" — This sends full content directly without applying strict retrieval filters.
  - 🔍 Toggle on "Full Context Mode" — This injects more comprehensive content into the model prompt.

:::warning

📌 Warning: Be mindful of context limits—if your model can't handle more tokens, it will still get cut off.

:::

---

### 3. Token Limit is Too Short ⏳

Even if retrieval works, your model might still not process all the content it receives—because it simply can't.

By default, many models (especially Ollama-hosted LLMs) are limited to a 2048-token context window. That means only a fraction of your retrieved data will actually be used.

**Why Web Search Especially Needs Larger Context Windows:**
Web pages are particularly challenging for small context windows because they contain far more content than typical documents. A single web page often includes:
- Main content (the actual information you want)
- Navigation menus, headers, and footers
- Sidebar content and advertisements
- Comments sections and related links
- Metadata and embedded scripts

Even after content extraction and cleaning, web pages easily consume 4,000-8,000+ tokens of context. With a 2048-token limit, you're getting less than half the content, often missing the most relevant information that appears later in the page. Even 4096 tokens is frequently insufficient for comprehensive web content analysis.

✅ Solutions:

- 🛠️ **For Ollama Models**: Extend the model's context length:
  - Navigate to: **Admin Panel > Models > Settings** (of the model you want to edit)
  - Go to **Advanced Parameters**
  - Modify the context length (e.g., increase to 8192+ or ideally beyond 16000 tokens if supported by your model)

- 🌐 **For OpenAI and Other Integrated Models**: These models typically have their own context limits that cannot be modified through Open WebUI settings. Ensure you're using a model with sufficient context length.

ℹ️ Note: The 2048-token default is a big limiter for web search. For better RAG results with web content, we strongly recommend using at least 8192 tokens, with 16384+ being ideal for complex web pages.

✅ Alternative: Use an external LLM with larger context capacity

- Try GPT-4, GPT-4o, Claude 3, Gemini 1.5, or Mixtral with 8k+ context
- Compare performance to Ollama—notice the dramatic accuracy difference when more web content can be processed!

:::tip

For web search and complex document analysis, stick with models that support 8192+ token contexts in production use cases.

:::

---

### 4. Embedding Model is Low-Quality or Mismatched 📉🧠

Bad embeddings = bad retrieval. If the vector representation of your content is poor, the retriever won't pull the right content—no matter how powerful your LLM is.

✅ Solution:

- Change to a high-quality embedding model (e.g., all-MiniLM-L6-v2, Instructor X, or OpenAI embeddings)
- Go to: **Admin Settings > Documents**
- After changing the model, be sure to:
  - ⏳ Reindex all existing documents so the new embeddings take effect.

📌 Remember: Embedding quality directly affects what content is retrieved.

---

### 5. ❌ 400: 'NoneType' object has no attribute 'encode'

This error indicates a misconfigured or missing embedding model. When Open WebUI tries to create embeddings but doesn't have a valid model loaded, it can't process the text—and the result is this cryptic error.

💥 Cause:
- Your embedding model isn't set up properly.
- It might not have downloaded completely.
- Or if you're using an external embedding model, it may not be accessible.

✅ Solution:

- Go to: **Admin Settings > Documents > Embedding Model**
- Save the embedding model again—even if it's already selected. This forces a recheck/download.
- If you're using a remote/external embedding tool, make sure it's running and accessible to Open WebUI.

:::tip

After fixing the configuration, try re-embedding a document and verify no error is shown in the logs.

:::

---

## 🧪 Pro Tip: Test with GPT-4o or GPT-4

If you're not sure whether the issue is with retrieval, token limits, or embedding—try using GPT-4o temporarily (e.g., via OpenAI API). If the results suddenly become more accurate, it's a strong signal that your local model's context limit (2048 by default in Ollama) is the bottleneck.

- GPT-4o handles larger inputs (128k tokens!)
- Provides a great benchmark to evaluate your system's RAG reliability

---

## Summary Checklist ✅

| Problem | Fix |
|--------|------|
| 🤔 Model can't "see" content | Check document extractor settings |
| 🧹 Only part of content used | Enable Full Context Mode or Bypass Embedding |
| ⏱ Limited by 2048 token cap | Increase model context length (Admin Panel > Models > Settings > Advanced Parameters for Ollama) or use large-context LLM |
| 📉 Inaccurate retrieval | Switch to a better embedding model, then reindex |
| Still confused? | Test with GPT-4o and compare outputs |

---

By optimizing these areas—extraction, embedding, retrieval, and model context—you can dramatically improve how accurately your LLM works with your documents. Don't let a 2048-token window or weak retrieval pipeline hold back your AI's power 🎯.
