omniretrieve

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2026 License: MIT

README

OmniRetrieve Multi-Search Client for Vector and Graph RAG

Go CI Go Lint Go SAST Go Report Card Docs Visualization License

OmniRetrieve is a unified retrieval library for Go that supports Vector RAG, Graph RAG, and Hybrid retrieval strategies. It provides a consistent interface for building retrieval-augmented generation (RAG) systems with pluggable backends.

Features

  • Vector Retrieval - Semantic similarity search using embeddings
  • Graph Retrieval - Relationship-aware traversal for structured knowledge
  • Hybrid Retrieval - Combine vector and graph strategies with configurable policies
  • Observability - Built-in tracing compatible with Phoenix, Opik, and Langfuse
  • Reranking - Cross-encoder and heuristic reranking support
  • Pluggable Backends - Use pgvector, Pinecone, Neo4j, or implement your own

Installation

go get github.com/plexusone/omniretrieve

For pgvector support:

go get github.com/plexusone/omniretrieve/providers/pgvector

Quick Start

Vector Retrieval
package main

import (
    "context"
    "log"

    "github.com/plexusone/omniretrieve/memory"
    "github.com/plexusone/omniretrieve/vector"
)

func main() {
    ctx := context.Background()

    // Create in-memory index and embedder for testing
    index := memory.NewVectorIndex("documents", 384)
    embedder := memory.NewHashEmbedder(384)

    // Create retriever
    retriever := vector.NewRetriever(vector.RetrieverConfig{
        Index:    index,
        Embedder: embedder,
        TopK:     10,
    })

    // Insert documents
    docs := []vector.Node{
        {ID: "1", Content: "Go is a statically typed language"},
        {ID: "2", Content: "Python is dynamically typed"},
        {ID: "3", Content: "Rust has strong memory safety"},
    }

    for _, doc := range docs {
        emb, _ := embedder.Embed(ctx, doc.Content)
        doc.Embedding = emb
        index.Insert(ctx, doc)
    }

    // Query
    results, err := retriever.Retrieve(ctx, retrieve.Query{
        Text: "programming languages with type systems",
    })
    if err != nil {
        log.Fatal(err)
    }

    for _, item := range results.Items {
        log.Printf("Score: %.3f, Content: %s", item.Score, item.Content)
    }
}
Hybrid Retrieval
package main

import (
    "context"

    "github.com/plexusone/omniretrieve/hybrid"
    "github.com/plexusone/omniretrieve/memory"
    "github.com/plexusone/omniretrieve/vector"
    "github.com/plexusone/omniretrieve/graph"
)

func main() {
    ctx := context.Background()

    // Create vector retriever
    vectorIndex := memory.NewVectorIndex("docs", 384)
    embedder := memory.NewHashEmbedder(384)
    vectorRetriever := vector.NewRetriever(vector.RetrieverConfig{
        Index:    vectorIndex,
        Embedder: embedder,
    })

    // Create graph retriever
    kg := memory.NewKnowledgeGraph()
    graphRetriever := graph.NewRetriever(graph.RetrieverConfig{
        Graph: kg,
    })

    // Create hybrid retriever
    hybridRetriever := hybrid.NewRetriever(hybrid.Config{
        VectorRetriever: vectorRetriever,
        GraphRetriever:  graphRetriever,
        Policy:          hybrid.PolicyParallel,
        VectorWeight:    0.7,
        GraphWeight:     0.3,
    })

    // Query both systems
    results, _ := hybridRetriever.Retrieve(ctx, retrieve.Query{
        Text: "What technologies does Company X use?",
    })
}
Using pgvector
package main

import (
    "database/sql"
    "log"

    _ "github.com/lib/pq"
    "github.com/plexusone/omniretrieve/providers/pgvector"
    "github.com/plexusone/omniretrieve/vector"
)

func main() {
    // Connect to PostgreSQL
    db, err := sql.Open("postgres", "postgres://user:pass@localhost/mydb?sslmode=disable")
    if err != nil {
        log.Fatal(err)
    }

    // Create pgvector index
    index, err := pgvector.New(db, pgvector.DefaultConfig("embeddings", 1536))
    if err != nil {
        log.Fatal(err)
    }

    // Use with vector retriever
    retriever := vector.NewRetriever(vector.RetrieverConfig{
        Index:    index,
        Embedder: myEmbedder, // Your embedding provider
        TopK:     10,
    })
}

Architecture

omniretrieve/
├── retrieve/      # Core interfaces (Retriever, Query, Result)
├── vector/        # Vector retrieval implementation
├── graph/         # Graph retrieval implementation
├── hybrid/        # Hybrid retrieval with policies
├── observe/       # Observability and tracing
├── rerank/        # Reranking implementations
├── memory/        # In-memory implementations for testing
└── providers/
    └── pgvector/  # PostgreSQL pgvector provider

Retrieval Strategies

Strategy Best For Trade-offs
Vector Semantic similarity, fuzzy matching May miss explicit relationships
Graph Structured knowledge, relationships Requires schema, less flexible
Hybrid Complex queries needing both Higher latency, more complexity
Hybrid Policies
  • PolicyParallel - Run vector and graph in parallel, merge results
  • PolicyVectorThenGraph - Vector first, enhance with graph context
  • PolicyGraphThenVector - Graph first, expand with vector similarity

Observability

OmniRetrieve includes built-in observability support compatible with:

import "github.com/plexusone/omniretrieve/observe"

// Create observer with exporters
obs := observe.NewObserver(
    observe.WithExporter(myPhoenixExporter),
)

// Create traced context
ctx := observe.NewContext(context.Background())

// Retrieval operations are automatically traced
results, _ := retriever.Retrieve(ctx, query)

Providers

Provider Type Status
pgvector Vector ✅ Available
Pinecone Vector Planned
Weaviate Vector Planned
Neo4j Graph Planned
Neptune Graph Planned

Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests.

License

MIT License - see LICENSE for details.

Directories

Path Synopsis
Package graph provides knowledge graph traversal for retrieval.
Package graph provides knowledge graph traversal for retrieval.
Package hybrid provides hybrid retrieval combining vector and graph strategies.
Package hybrid provides hybrid retrieval combining vector and graph strategies.
Package memory provides in-memory implementations for testing and development.
Package memory provides in-memory implementations for testing and development.
Package observe provides observability integration for OmniRetrieve.
Package observe provides observability integration for OmniRetrieve.
providers
pgvector module
Package rerank provides reranking implementations for retrieval results.
Package rerank provides reranking implementations for retrieval results.
Package retrieve defines the core interfaces and types for OmniRetrieve.
Package retrieve defines the core interfaces and types for OmniRetrieve.
Package vector provides vector similarity search for retrieval.
Package vector provides vector similarity search for retrieval.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL