Simple Rag is a lightweight library that showcases the entire RAG architecture in a gem. No need for a vector database. All you need are a few light dependencies and a Mistral API key!
The purpose of simple RAG is to showcase how RAG systems work by using the simplest tools possible to lower the friction to learning. This is not a gem to be used in production and I will likely be adding additional breaking changes to the code.
Sure, here is a high level run through of the RAG architecture:
Install the gem and add to the application's Gemfile by executing:
bundle add simple_rag
If bundler is not being used to manage dependencies, install the gem by executing:
gem install simple_rag
You will also need to install all dependencies required by the faiss gem under the installation section.
Lastly, run the following command and add a mistral-ai
. You can create one my setting up a Mistral AI account.
To run the exe locally type:
exe/simple_rag
You can press enter when prompted to retrieve a default text. You can also search project gutenberg for an html text like Frankenstein by Mary Shelly. This process of fetching text given a url could take some time as the text, once fetched get's passed to an embedding model which converts text chunks into vectors.
Screen.Recording.2024-08-12.at.4.25.18.PM.mov
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
This code was inspired by mistral's guide on Basic Rag
Andrei for making me excited about vector search with his talks on langchain.rb!
Bug reports and pull requests are welcome on GitHub at https://github.com/thedayisntgray/simple_rag.