Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

45 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OmniRetrieve Multi-Search Client for Vector and Graph RAG

Go CI Go Lint Go SAST Docs 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
  • πŸ“ BM25 Search - Keyword-based text search with configurable parameters
  • πŸ•ΈοΈ Graph Retrieval - Relationship-aware traversal for structured knowledge
  • ⚑ Hybrid Retrieval - Combine vector and graph strategies with configurable policies
  • πŸ—„οΈ Memory Manager - Collection-based document storage with semantic search
  • πŸ“Š 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
β”œβ”€β”€ bm25/          # BM25 keyword-based text search
β”œβ”€β”€ graph/         # Graph retrieval implementation
β”œβ”€β”€ hybrid/        # Hybrid retrieval with policies
β”œβ”€β”€ observe/       # Observability and tracing
β”œβ”€β”€ rerank/        # Reranking implementations
β”œβ”€β”€ memory/        # In-memory implementations and memory manager
└── providers/
    └── pgvector/  # PostgreSQL pgvector provider

Retrieval Strategies

Strategy Best For Trade-offs
Vector Semantic similarity, fuzzy matching May miss explicit relationships
BM25 Keyword matching, exact terms No semantic understanding
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.

About

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.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages