For the complete documentation index, see llms.txt. This page is also available as Markdown.

How to using RAG with AnythingLLM

Build a RAG (Retrieval-Augmented Generation) application on top of your vLLM endpoint. Chat with your own documents (PDF, DOCX, TXT, web pages). Prerequisite: A running vLLM endpoint (see the vLLM Docker Deployment Guide).

1. Overview & Architecture

AnythingLLM handles document ingestion, chunking, embedding, vector storage, and retrieval automatically. It connects to your vLLM endpoint for both chat and (optionally) embeddings.

                  ┌─────────────────────────────────────┐
                  │           AnythingLLM                │
   Documents ───► │  (ingest → chunk → embed → store)    │
                  └──────┬───────────────────┬───────────┘
                         │                   │
              embeddings │                   │ chat (LLM)
                         ▼                   ▼
                  ┌──────────────┐    ┌──────────────┐
                  │  Embedding   │    │     vLLM     │
                  │   Server     │    │  (your LLM)  │
                  │  (vLLM)      │    │              │
                  └──────────────┘    └──────────────┘


                  ┌──────────────┐
                  │  Vector DB   │
                  │  (LanceDB)   │
                  └──────────────┘

Three components:

  1. LLM — your existing vLLM (generates answers)

  2. Embedding model — converts text to vectors (separate small model)

  3. Vector DB — stores embeddings (LanceDB built-in, no separate container needed)

2. Embedding Models

Built-in vs Dedicated

Option
Pros
Cons

AnythingLLM built-in

Zero config, runs on CPU

Slower, basic quality

Dedicated vLLM embedding

Fast, GPU-accelerated, high quality

Uses extra VRAM

For production or Thai documents, a dedicated embedding server is strongly recommended.

Model
Use Case
VRAM

BAAI/bge-m3

Multilingual (incl. Thai), excellent

~2-3 GB

intfloat/multilingual-e5-large

Multilingual

~2-3 GB

BAAI/bge-large-en-v1.5

English only, fast

~1-2 GB

BAAI/bge-m3 is the top choice for Thai or mixed Thai/English documents. Always match the embedding model to your document language.

3. Vector Database Options

Vector DB
When to use

LanceDB (built-in)

Default — single instance, simplest, no extra container

Qdrant

Larger scale, shared storage, advanced filtering

LanceDB is sufficient for most deployments and requires zero setup.

4. Full Stack Deployment (Multi-GPU)

Runs vLLM (chat) + vLLM (embeddings) + AnythingLLM together. Chat on GPU 0, embeddings on GPU 1.

docker-compose.yml

Launch

Wait for all three healthy:

  • vllmApplication startup complete

  • vllm-embedApplication startup complete

  • anythingllmPrimary server in HTTP mode listening on port 3001

5. Single-GPU Deployment

Run chat + embedding on one GPU. The embedding model is small (~2-3GB), so lower the chat model's memory utilization to leave room.

Combined gpu-memory-utilization (0.70 + 0.20 = 0.90) must stay under 1.0.

6. External Vector DB (Qdrant)

For larger scale or shared vector storage, add Qdrant:

Then change AnythingLLM env:

7. Using AnythingLLM

First Launch

Open http://<your-server-ip>:3001

  1. Create your admin account

  2. Verify LLM + Embedding settings are pre-filled (from env vars)

  3. Create a Workspace

  4. Upload documents → auto-embedded and ready to chat

Document Upload

  • Supported: PDF, DOCX, TXT, MD, CSV, and web page URLs

  • Documents are chunked, embedded, and stored automatically

  • Each workspace has its own document set and chat history

Verify Embedding Server

You should get an array of numbers (the embedding vector).

8. RAG Tuning & Troubleshooting

Tuning

Setting
Where
Effect

Chunk size

Workspace settings

Smaller = precise, larger = more context

Top-K retrieval

Workspace settings

How many chunks retrieved per query

--max-model-len

vLLM chat

Must fit retrieved chunks + question + answer

Embedding model

bge-m3 for Thai

Match document language

Common Issues

AnythingLLM can't connect to vLLM

  • Check containers are on the same Docker network (same compose file = automatic)

  • Verify GENERIC_OPEN_AI_BASE_PATH uses the service name (http://vllm:8000/v1), not localhost

  • Confirm the API key matches between vLLM --api-key and AnythingLLM env

Embeddings fail / documents won't process

  • Verify embedding server: curl http://localhost:8001/v1/embeddings ...

  • Check EMBEDDING_BASE_PATH points to http://vllm-embed:8000/v1

  • Ensure embedding model loaded: docker compose logs vllm-embed

Poor answer quality

  • Increase Top-K retrieval (more context)

  • Use a larger chat model (32B vs 7B)

  • For Thai docs, confirm bge-m3 embedding (not English-only)

  • Reduce chunk size for more precise retrieval

Out of memory on single GPU

  • Lower chat --gpu-memory-utilization

  • Use a smaller chat model

  • Reduce --max-model-len

Was this helpful?