Home

Awesome

cl-rag-example

A simple demo of LLM+RAG using Common Lisp and OpenAI

This simple demo ingests an annual shareholder report into a Chroma vector database, and then uses RAG-assisted generative AI to answer questions.

To support this task, we use:

Usage

Install pdftotext. On Fedora, this is provided in the poppler-utils package.

Install all Lisp dependencies with ocicl. To make all of this work I had to submit fixes to jzon and openapi-generator, so you will need the very latest versions of those systems. They are all available in the ocicl repos.

$ ocicl install

Now examine rag.lisp to find the link to the earnings report we will analyze. Download it.

Download and install the Chroma vector DB:

$ pip install chromadb
$ chroma run

Get an OpenAI API key, and set the OPENAI_API_KEY environment variable.

$ export OPENAI_API_KEY=sk-dfgdfgdfgsdjhgdkjfghskdjfhgdskjfhgkjhg

Now run the example:

$ sbcl --eval "(asdf:load-system :rag)" --eval "(rag::run)"

Author and License

cl-rag-example was written by Anthony Green and is distributed under the terms of the MIT license.