Composable RAG pipeline engine for Go

Weave your context

Ingest documents, chunk text, generate embeddings, store vectors, and retrieve semantic context — tenant-scoped, plugin-extensible, and Forge-native.

$go get github.com/xraph/weave
Ingest()
Chunk
Embed
Store
doc.loaded
parsed
chunks.12
stored
vec.ready
indexed
pgvector
Multi-Tenant
Forge-Native
Pluggable
Features

Everything you need for RAG pipelines

Weave handles the hard parts — ingestion, chunking, embedding, retrieval, and multi-tenancy — so you can focus on your application.

Document Ingestion Pipeline

Load, chunk, embed, and store in one call. Weave handles the full lifecycle from raw content to searchable vectors.

ingest.go
doc, err := engine.Ingest(ctx, "col-123",
weave.IngestInput{
Title: "Product FAQ",
Content: "Our return policy...",
Source: "faq.md",
})
"text-fd-muted-foreground/60 italic">// doc.State=ready chunks=12

Semantic Retrieval

Cosine similarity, MMR, and hybrid search. Retrieve the most relevant chunks across a collection with configurable top-K and score thresholds.

retrieve.go
results, err := engine.Retrieve(ctx, "col-123",
&weave.RetrieveInput{
Query: "return policy",
TopK: 5,
MinScore: 0.75,
})
"text-fd-muted-foreground/60 italic">// [0.94] Our return policy allows...

Multi-Tenant Isolation

Every collection, document, and chunk is scoped to a tenant via context. Cross-tenant queries are structurally impossible.

scope.go
ctx = weave.WithTenant(ctx, "tenant-1")
ctx = weave.WithApp(ctx, "myapp")
 
"text-fd-muted-foreground/60 italic">// All ingestions and retrievals are
"text-fd-muted-foreground/60 italic">// automatically scoped to tenant-1

Pluggable Backends

Start with in-memory for development, swap to PostgreSQL + pgvector for production. Every subsystem is a Go interface.

main.go
engine, _ := weave.NewEngine(
weave.WithStore(postgres.New(pool)),
weave.WithVectorStore(pgvector.New(pool)),
weave.WithEmbedder(myEmbedder),
weave.WithLogger(slog.Default()),
)

Extension Hooks

OnIngestCompleted, OnRetrievalStarted, and 12 other lifecycle events. Wire in metrics, audit trails, or custom logic.

extension.go
func (e *MetricsExt) OnIngestCompleted(
ctx context.Context,
colID string,
docs, chunks int,
elapsed time.Duration,
) {
metrics.Inc("weave.chunks.created", chunks)
}

Collection Management

Organize documents with per-collection embedding models, chunk strategies, and metadata. Reindex any collection at any time.

collection.go
col, _ := engine.CreateCollection(ctx,
weave.CreateCollectionInput{
Name: "product-docs",
EmbeddingModel: "text-embedding-3-small",
ChunkStrategy: "recursive",
ChunkSize: 512,
ChunkOverlap: 50,
})
"text-fd-muted-foreground/60 italic">// Reindex: engine.Reindex(ctx, col.ID)
RAG Ingestion Pipeline

From document to searchable context.

Weave orchestrates the entire ingestion lifecycle — tenant scoping, text chunking, embedding generation, and vector storage.

Automatic Tenant Scoping

Every ingestion and retrieval is stamped with TenantID and AppID from context. Collection and chunk isolation is enforced at the store layer — no tenant can access another's data.

Configurable Chunk Strategies

Recursive or fixed-size chunking with configurable token size and overlap. Per-collection strategy overrides let you tune chunking for different document types.

Lifecycle Extension Hooks

OnIngestCompleted, OnRetrievalFailed, and 12 other lifecycle events. Wire in metrics, audit trails, or custom processing logic without modifying engine code.

Ingest()
doc.ingest
Chunkerrecursive
Embeddertext-emb-3
doc.loaded
✓ Parsed
chunks.created
⟳ Chunking
vec.stored
✓ Indexed
Ready
Processing
Chunking
Failed
Developer Experience

Simple API. Powerful retrieval.

Ingest a document and retrieve semantically similar chunks in under 20 lines. Weave handles the rest.

Ingestion
main.go
1package main
2 
3import (
4 "context"
5 "log/slog"
6 
7 "github.com/xraph/weave"
8 "github.com/xraph/weave/store/postgres"
9 "github.com/xraph/weave/vectorstore/pgvector"
10)
11 
12func main() {
13 ctx := context.Background()
14 
15 engine, _ := weave.NewEngine(
16 weave.WithStore(postgres.New(pool)),
17 weave.WithVectorStore(pgvector.New(pool)),
18 weave.WithEmbedder(myEmbedder),
19 weave.WithLogger(slog.Default()),
20 )
21 
22 ctx = weave.WithTenant(ctx, "tenant-1")
23 ctx = weave.WithApp(ctx, "myapp")
24 
25 "text-fd-muted-foreground/60 italic">// Ingest a document — chunk, embed, store
26 doc, _ := engine.Ingest(ctx, "col-123",
27 weave.IngestInput{
28 Title: "Product FAQ",
29 Content: "Our return policy...",
30 Source: "faq.md",
31 })
32 "text-fd-muted-foreground/60 italic">// doc.State=ready chunks=12
33}
Retrieval
retrieve.go
1package main
2 
3import (
4 "context"
5 "fmt"
6 
7 "github.com/xraph/weave"
8)
9 
10func queryContext(
11 engine *weave.Engine,
12 ctx context.Context,
13) {
14 ctx = weave.WithTenant(ctx, "tenant-1")
15 
16 "text-fd-muted-foreground/60 italic">// Semantic retrieval with score threshold
17 results, _ := engine.Retrieve(ctx, "col-123",
18 &weave.RetrieveInput{
19 Query: "What is the return policy?",
20 TopK: 5,
21 MinScore: 0.75,
22 })
23 
24 for _, r := range results {
25 fmt.Printf("[%.2f] %s\n",
26 r.Score, r.Content[:80])
27 }
28 "text-fd-muted-foreground/60 italic">// [0.94] Our return policy allows...
29 "text-fd-muted-foreground/60 italic">// [0.87] Items must be returned...
30}

Start building with Weave

Add production-grade RAG pipelines to your Go service in minutes. Weave handles ingestion, chunking, embedding, and semantic retrieval out of the box.

$go get github.com/xraph/weave