GithubHelp home page GithubHelp logo

x39826 / r2r Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sciphi-ai/r2r

0.0 0.0 0.0 10.47 MB

A framework for rapid development and deployment of production-ready RAG systems

Home Page: https://docs.sciphi.ai

License: MIT License

Shell 0.02% JavaScript 0.86% Python 69.56% TypeScript 22.90% CSS 0.87% SCSS 5.79%

r2r's Introduction

R2R: Production-ready RAG systems.

Docs Discord Github Stars Commits-per-week License: MIT

A semi-opinionated RAG framework.

Sciphi Framework

R2R was conceived to bridge the gap between experimental RAG models and robust, production-ready systems. Our semi-opinionated framework cuts through the complexity, offering a straightforward path to deploy, adapt, and maintain RAG pipelines in production. We prioritize simplicity and practicality, aiming to set a new industry benchmark for ease of use and effectiveness.

Quick Install:

Install R2R directly using pip:

# use the `'r2r[all]'` to download all required deps
pip install 'r2r[parsing,eval]'
# setup env 
export OPENAI_API_KEY=sk-...
export LOCAL_DB_PATH=local.sqlite

# OR do `vim .env.example && cp .env.example .env`

Links

Join the Discord server

Read our Docs

Basic Examples

The project includes several basic examples that demonstrate application deployment and interaction:

  1. app.py: This example runs the main application, which includes the ingestion, embedding, and RAG pipelines served via FastAPI.

    uvicorn r2r.examples.basic.app:app
  2. basic client: This example should be run after starting the main application. It demonstrates uploading text entries as well as a PDF to the local server with the python client. Further, it shows document and user-level vector management with built-in features.

    python -m r2r.examples.basic.run_client
  3. pdf chat: An example demonstrating upload and chat with a more realistic pdf.

    # Ingest pdf
    python -m r2r.examples.pdf_chat.run_client ingest
    
    # Ask a question
    python -m r2r.examples.pdf_chat.run_client search "What are the key themes of Meditations?"
  4. academy: A more sophisticated demo demonstrating how to build a more novel pipeline which involves synthetic queries

    # launch academy application
    uvicorn r2r.examples.academy.app:app
    
    # Ask a question
    python -m r2r.examples.academy.run_client search "What are the key themes of Meditations?"
  5. web: A web application which is meant to accompany the framework to provide visual intelligence.

    cd $workdir/web && pnpm install
    
    # Serve the web app
    pnpm dev

Demo

slim_demo.mp4

Full Install:

Follow these steps to ensure a smooth setup:

  1. Install Poetry:

    • Before installing the project, make sure you have Poetry on your system. If not, visit the official Poetry website for installation instructions.
  2. Clone and Install Dependencies:

  • Clone the project repository and navigate to the project directory:

    git clone [email protected]:SciPhi-AI/r2r.git
    cd r2r
  • Copy the .env.example file to .env. This file is in the main project folder:

    cp .env.example .env
    
    # Add secrets, `OPENAI_API_KEY` at a minimum
    vim .env
  • Install the project dependencies with Poetry:

    # See pyproject.toml for available extras
    # use "all" to include every optional dependency
    poetry install -E parsing -E eval
  • Execute with poetry run:

    python -m r2r.examples.pdf_chat.run_client ingest
  1. Configure Environment Variables:
    • You need to set up cloud provider secrets in your .env. At a minimum, you will need an OpenAI key.
    • The framework currently supports PostgreSQL (locally), pgvector and Qdrant with plans to extend coverage.

Key Features

  • ๐Ÿš€ Rapid Deployment: Facilitates a smooth setup and development of production-ready RAG systems.
  • โš–๏ธ Flexible Standardization: Ingestion, Embedding, and RAG with proper Observability.
  • ๐Ÿงฉ Easy to modify: Provides a structure that can be extended to deploy your own custom pipelines.
  • ๐Ÿ“ฆ Versioning: Ensures your work remains reproducible and traceable through version control.
  • ๐Ÿ”Œ Extensibility: Enables a quick and robust integration with various VectorDBs, LLMs and Embeddings Models.
  • ๐Ÿค– OSS Driven: Built for and by the OSS community, to help startups and enterprises to quickly build with RAG.
  • ๐Ÿ“ Deployment Support: Available to help you build and deploy your RAG systems end-to-end.

Core Abstractions

The framework primarily revolves around three core abstractions:

  • The Ingestion Pipeline: Facilitates the preparation of embeddable 'Documents' from various data formats (json, txt, pdf, html, etc.). The abstraction can be found in ingestion.py.

  • The Embedding Pipeline: Manages the transformation of text into stored vector embeddings, interacting with embedding and vector database providers through a series of steps (e.g., extract_text, transform_text, chunk_text, embed_chunks, etc.). The abstraction can be found in embedding.py.

  • The RAG Pipeline: Works similarly to the embedding pipeline but incorporates an LLM provider to produce text completions. The abstraction can be found in rag.py.

  • The Eval Pipeline: Samples some subset of rag_completion calls for evaluation. Currently DeepEval is supported. The abstraction can be found in eval.py.

Each pipeline incorporates a logging database for operation tracking and observability.

r2r's People

Contributors

emrgnt-cmplxty avatar jcllobet avatar abelanger5 avatar eltociear avatar penguine-ip avatar joschkabraun avatar kevo1ution avatar hanrelan avatar sauravpanda avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.