Nodes/Comfyui-Easy-RAG/EasyRAG - Vector Store Builder (FAISS)
ComfyUI Node

EasyRAG - Vector Store Builder (FAISS)

The node that actually does the 'R' in RAG

By nregret·Created 5 months ago·Updated about a month ago· 68
EasyRAG - Vector Store Builder (FAISS)
  • documents
  • RAG Index
  • summary
build_modecreate_new
index_listdefault_index
index_name
embedding_model
chunk_size4000
chunk_overlap0
show_retrieval_logtrue
unload_embedding_model_after_buildtrue

The two loaders just get text into the graph. This is the node that makes retrieval possible. EasyRAG - Vector Store Builder (FAISS) takes the RAG_DOCUMENTS from a loader, chops them into chunks, runs a local embedding model over every chunk, and writes a FAISS index to disk. Once that's built, every chat node in the pack can search it - and search results, not your whole document, are what get fed to the LLM. That search-then-answer step is the entire difference between "chat with your docs" and "dumped your whole corpus into the context window until it overflowed."

How it works, mechanism first

The build is three steps, all on CPU and all visible in the console:

  1. Chunking. The current version splits on non-empty lines - each line becomes one retrieval chunk. This is worth knowing because it makes chunk_size and chunk_overlap mostly decorative right now: they're accepted, recorded into the index metadata, and ignored by the actual splitter. For a prompt library where each line is a complete prompt, that's the correct behavior. For long prose paragraphs, each paragraph-ish line becomes a chunk, which is... fine, but don't expect smart windowing.
  2. Embedding. Every chunk goes through a SentenceTransformer model (the one you pick) and gets normalized to unit length.
  3. Indexing. The vectors go into faiss.IndexFlatIP - inner product, which with normalized vectors is cosine similarity. The whole thing (index + chunks.json + meta.json) is saved to ComfyUI/models/RAG/VectorDB/<your-index-name>/, and it persists across restarts.

The node is also smart about not re-doing work: if you point it at an index that already exists on disk, it skips the rebuild, loads the metadata, and hands you the RAG_INDEX handle straight away. You don't need to re-embed a 10k-prompt file every time you touch the workflow.

The inputs that matter

The full list of required inputs is: documents, build_mode, index_list, index_name, embedding_model, chunk_size, chunk_overlap, show_retrieval_log, and unload_embedding_model_after_build. A beginner really only sets four of them:

  • documents - the RAG_DOCUMENTS output from either loader. Non-negotiable.
  • build_mode - create_new vs use_existing. The web UI trims this to just those two options (the backend tolerates a few legacy spellings).
  • index_name - type a name here to build a fresh index. index_list is the companion dropdown that picks an existing one when you're in use_existing mode. The tooltip says it plainly: leave index_name empty to use the selection above.
  • embedding_model - a dropdown of model folders sitting in ComfyUI/models/embeddings. The README recommends bge-small-zh-v1.5 (it's a Chinese pack, so of course); English users get better results from something like all-MiniLM-L6-v2. Any sentence-transformers folder with a config.json works.

show_retrieval_log prints what got retrieved to the console - keep it on while you're debugging, it's genuinely useful. And unload_embedding_model_after_build (default on) is the pack's whole VRAM philosophy in one checkbox: the embedding model gets forced off the GPU the moment it's done, so your SDXL/FLUX model isn't fighting for memory with a sentence encoder.

Gotchas

  • Empty embedding dropdown = the build fails. There's no auto-download fallback in this version; the node just raises "please select a valid embedding model." Drop a sentence-transformers model folder into models/embeddings and refresh.
  • The index is bound to its embedding model. meta.json records which model built it, and at query time the same model is reloaded to embed your question. Swap embedding models between build and query and retrieval silently gets worse - cosine similarity between differently-embedded vectors is meaningless.
  • Line-based chunking, again. If you notice retrieval returning whole multi-sentence lines instead of tight snippets, that's the splitter, not a bug.

Install

It's part of the pack, so: ComfyUI Manager → search "ComfyUI Easy RAG" → install, or

cd ComfyUI/custom_nodes
git clone https://github.com/nregret/Comfyui-Easy-RAG
cd Comfyui-Easy-RAG
pip install -r requirements.txt

then restart. Dependencies are faiss-cpu, sentence-transformers, requests, pypdf - the build itself is CPU-bound, so no GPU drama, and the unload-after-build toggle keeps the memory footprint of even a big embedding model to a blip.

Verdict: this is the node that makes the pack worth installing. Everything else in EasyRAG is a chat client you could bolt together from any LLM API - but a persisted, local, FAISS-backed index that your private docs actually get embedded into is the part that takes real setup. Build it once, reuse it forever.

CategoryRagPrompt

Inputs (9)

NameTypeDefaultDescription
documentsRAG_DOCUMENTS
build_modeCOMBOcreate_newChoose whether to create a new vector store or use an existing one
index_listCOMBOdefault_indexSelect an existing vector store
index_nameSTRINGLeave empty to use selection above; enter a name to create a new index
embedding_modelCOMBOSelect a local embedding model
chunk_sizeINT4000100–4000
chunk_overlapINT00–2000
show_retrieval_logBOOLEANtrue
unload_embedding_model_after_buildBOOLEANtrue

Outputs (2)

NameTypeDescription
RAG IndexRAG_INDEX
summarySTRING