Sunday, June 23, 2024

Create Local RAG Pipelines with R2R and Ollama for Free

 This video installs R2R (Rag to Riches) with Ollama and local models which is the ultimate open-source framework for building and deploying high-quality Retrieval-Augmented Generation (RAG) systems.



Code:

conda create -n r2r python=3.11 -y && conda activate r2r
pip install -U 'r2r[all]'
pip install -U 'r2r[local-embedding]'

sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
sudo apt install postgresql-15-pgvector
cd /tmp
sudo -u postgres psql
###create role, database and extension in video
\q to exit
sudo systemctl enable postgresql
sudo service postgresql start
sudo -u postgres psql


export POSTGRES_USER=your_user
export POSTGRES_PASSWORD=your_password
export POSTGRES_HOST=your_host
export POSTGRES_PORT=your_port
export POSTGRES_DBNAME=your_db


mkdir r2r
cd r2r
touch local_ollama

-- and then pasted below config in local_ollama file:

{
  "embedding": {
    "provider": "sentence-transformers",
    "base_model": "all-MiniLM-L6-v2",
    "base_dimension": 384,
    "batch_size": 32
  },
  "eval": {
    "provider": "local",
    "frequency": 0.0,
    "llm":{
      "provider": "litellm"
    }
  },
  "ingestion":{
    "excluded_parsers": {
      "gif": "default",
      "jpeg": "default",
      "jpg": "default",
      "png": "default",
      "svg": "default",
      "mp3": "default",
      "mp4": "default"
    }
  }
}

python3 -m r2r.examples.quickstart ingest_as_files --no-media=true --config_name=local_ollama

No comments: