---
title: "Weave"
tagline: "RAG engine"
language: "Go"
license: "Apache-2.0"
since: "2026"
canonical: "https://xraph.com/work/weave"
---

# Weave

The RAG pipeline as swappable parts, covering loaders, chunkers, embedders, vector stores and retrievers, with token-budgeted assembly and citations at the end. Postgres, SQLite or memory for metadata; pgvector or memory for vectors. Runs standalone or as a Forge extension with its own HTTP surface.

## Install

```bash
go get github.com/xraph/weave
```

## What it is

Weave is a composable RAG pipeline for Go. Load documents, chunk them, embed, store vectors, retrieve relevant context and assemble a prompt, with each stage swappable, in one library.

## The pipeline

Ingest runs loader $\to$ chunker $\to$ embedder $\to$ vector store. Retrieve runs query $\to$ embedder $\to$ retriever $\to$ results. Assemble takes those results and applies a token budget and citations before the prompt is built.

Splitting assembly out as its own stage was the decision that mattered most. Most RAG failures I have debugged were not retrieval failures. The right chunk was in the result set and got truncated out of the prompt by a naive concatenation with no budget.

## Practicalities

- Storage backends: in-memory, PostgreSQL or SQLite for metadata; memory or pgvector for vectors.
- Multi-tenant data isolation through Forge scope context.
- Extension hooks for auditing, metrics, tracing and custom logic at every lifecycle point.
- A REST API with OpenAPI metadata for collections, documents and retrieval.
- Runs standalone or as a Forge extension with DI, routing and health checks.

## Where it fits

Weave supplies the retrieval half of the agent stack. Cortex runs the episode; KGKit holds what survives it. A retrieval hit and a graph claim are different kinds of evidence, and keeping them in separate systems has made it much easier to tell which one an answer actually rested on.

---

*Unpublished draft. Not peer reviewed and not submitted to a venue.*


## Anatomy

- **Ingest**: Documents in, chunked and embedded.
- **Retrieve**: Vector and keyword recall over the same store.
- **Rerank**: Ordering the candidates before they reach the model.
- **Assemble**: Context built to a budget, not to a limit.

## Constraints and trade-offs

- (trade-off) Reranking costs a round trip and is usually worth more than a larger window.
- (known gap) Evaluation of retrieval quality lives in Sentinel, not here.
