https://github.com/postgresml/korvus Skip to content Navigation Menu Toggle navigation Sign in * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + GitHub Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions By size + Enterprise + Teams + Startups By industry + Healthcare + Financial services + Manufacturing By use case + CI/CD & Automation + DevOps + DevSecOps * Resources Topics + AI + DevOps + Innersource + Open Source + Security + Software Development Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} postgresml / korvus Public * Notifications You must be signed in to change notification settings * Fork 2 * Star 248 Korvus is a search SDK that unifies the entire RAG pipeline in a single database query. Built on top of Postgres with bindings for Python, JavaScript, Rust and C. postgresml.org License MIT license 248 stars 2 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 3 * Pull requests 0 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights postgresml/korvus This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main BranchesTags Go to file Code Folders and files Name Name Last commit Last commit message date Latest commit History 36 Commits .github/workflows .github/ workflows korvus korvus rust-bridge rust-bridge CONTRIBUTING.md CONTRIBUTING.md LICENSE LICENSE README.md README.md View all files Repository files navigation * README * MIT license Logo One query to rule them all | Documentation | Blog | Discord | --------------------------------------------------------------------- Korvus is a search SDK that unifies the entire RAG pipeline in a single database query. Built on top of Postgres with bindings for Python, JavaScript and Rust, Korvus delivers high-performance, customizable search capabilities with minimal infrastructure concerns. Table of Contents * What is Korvus? * Languages * Why Korvus? * [?] Key Features * System Architecture * Get Started * The Power of SQL * Documentation * Community * Contributing demo.mp4 What is Korvus? Korvus is an all-in-one, open-source RAG (Retrieval-Augmented Generation) pipeline built for Postgres. It combines LLMs, vector memory, embedding generation, reranking, summarization and custom models into a single query, maximizing performance and simplifying your search architecture. korvus-demo Languages Korvus provides SDK support for multiple programming languages, allowing you to integrate it seamlessly into your existing tech stack: * Python: PyPI Package * JavaScript: npm Package * Rust: Crates.io Package * C: Build from source Why Korvus? Korvus stands out by harnessing the full power of Postgres for RAG operations: 1. Postgres-Native RAG: Korvus leverages Postgres' robust capabilities, allowing you to perform complex RAG operations directly within your database. This approach eliminates the need for external services and API calls, significantly reducing latency and complexity many times over. 2. Single Query Efficiency: With Korvus, your entire RAG pipeline - from embedding generation to text generation - is executed in a single SQL query. This "one query to rule them all" approach simplifies your architecture and boosts performance. 3. Scalability and Performance: By building on Postgres, Korvus inherits its excellent scalability and performance characteristics. As your data grows, Korvus grows with it, maintaining high performance even with large datasets. [?] Key Features * Simplified Architecture: Replace complex service oriented architectures with a single, powerful query. * High Performance: Eliminates API calls and data movement for faster processing and greater reliability. * Open Source: Improve your developer experience with open source software and models that run locally in Docker too. * Multi-Language Support: Use Korvus with Python, JavaScript and Rust. Open an issue to vote for other language support. * Unified Pipeline: Combine embedding generation, vector search, reranking, and text generation in one query. * Postgres-Powered: Under the hood, Korvus operations are powered by efficient SQL queries on a time-tested database platform. System Architecture Korvus utilizes PostgresML's pgml extension and the pgvector extension to compress the entire RAG pipeline inside of Postgres. PostgresML_Old-V-New_Diagram-Update Get Started Prerequisites To use Korvus, you need a Postgres database with pgml and pgvector installed. You have two options: 1. Self-hosted: Set up your own database with pgml and pgvector. + For instructions, see our self-hosting guide. 2. Hosted Service: Use our managed Postgres service with pgml and pgvector pre-installed. + Sign up for PostgresML Cloud. Quick Start 1. Install Korvus: pip install korvus 2. Set the KORVUS_DATABASE_URL env variable: export KORVUS_DATABASE_URL="{YOUR DATABASE CONNECTION STRING}" 3. Initialize a Collection and Pipeline: from korvus import Collection, Pipeline import asyncio collection = Collection("korvus-demo-v0") pipeline = Pipeline( "v1", { "text": { "splitter": {"model": "recursive_character"}, "semantic_search": {"model": "Alibaba-NLP/gte-base-en-v1.5"}, } }, ) async def add_pipeline(): await collection.add_pipeline(pipeline) asyncio.run(add_pipeline()) 4. Insert documents: async def upsert_documents(): documents = [ {"id": "1", "text": "Korvus is incredibly fast and easy to use."}, {"id": "2", "text": "Tomatoes are incredible on burgers."}, ] await collection.upsert_documents(documents) asyncio.run(upsert_documents()) 5. Perform RAG async def rag(): query = "Is Korvus fast?" print(f"Querying for response to: {query}") results = await collection.rag( { "CONTEXT": { "vector_search": { "query": { "fields": {"text": {"query": query}}, }, "document": {"keys": ["id"]}, "limit": 1, }, "aggregate": {"join": "\n"}, }, "chat": { "model": "meta-llama/Meta-Llama-3-8B-Instruct", "messages": [ { "role": "system", "content": "You are a friendly and helpful chatbot", }, { "role": "user", "content": f"Given the context\n:{{CONTEXT}}\nAnswer the question: {query}", }, ], "max_tokens": 100, }, }, pipeline, ) print(results) asyncio.run(rag()) The Power of SQL While Korvus provides a high-level interface in multiple programming languages, its core operations are built on optimized SQL queries. This approach offers several advantages: * Transparency: Advanced users can inspect and understand the underlying queries. * Customizability: Extend Korvus's capabilities by modifying or adding to its SQL operations. * Performance: Benefit from PostgreSQL's advanced query optimization capabilities. Don't worry if you're not a SQL expert - Korvus's intuitive API abstracts away the complexity while still allowing you to harness the full power of SQL-based operations. Documentation For comprehensive documentation, including API references, tutorials, and best practices, visit our official documentation. Community Join our community to get help, share ideas, and contribute: * Discord * Twitter Contributing We welcome contributions to Korvus! Please read our Contribution Guidelines before submitting pull requests. --------------------------------------------------------------------- Korvus is maintained by PostgresML. For enterprise support and consulting services, please contact us. About Korvus is a search SDK that unifies the entire RAG pipeline in a single database query. Built on top of Postgres with bindings for Python, JavaScript, Rust and C. postgresml.org Topics javascript python search sql ai ml embeddings rag llm Resources Readme License MIT license Activity Custom properties Stars 248 stars Watchers 3 watching Forks 2 forks Report repository Contributors 2 * * Languages * Rust 87.6% * Python 6.8% * TypeScript 2.7% * JavaScript 2.1% * C 0.4% * PLpgSQL 0.2% * Other 0.2% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.