https://github.com/atgreen/cl-rag-example
A simple Common Lisp example of using LLMs with RAG
https://github.com/atgreen/cl-rag-example
Last synced: 2 months ago
JSON representation
A simple Common Lisp example of using LLMs with RAG
- Host: GitHub
- URL: https://github.com/atgreen/cl-rag-example
- Owner: atgreen
- Created: 2024-03-28T20:23:10.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-06T19:14:00.000Z (about 2 years ago)
- Last Synced: 2024-04-06T20:23:59.785Z (about 2 years ago)
- Language: Common Lisp
- Size: 18.6 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-cl - cl-rag-example - chat](https://github.com/atgreen/cl-chat), a LLM chat library and web UI. (Machine Learning)
README
# 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](https://www.trychroma.com/) vector database, and then uses
RAG-assisted generative AI to answer questions.
To support this task, we use:
* [cl-embeddings](https://github.com/atgreen/cl-embeddings) for LLM embeddings.
* [cl-completions](https://github.com/atgreen/cl-completions) for LLM completions.
* [cl-chroma](https://github.com/atgreen/cl-chroma) for the vector DB interface.
Usage
------
Install `pdftotext`. On Fedora, this is provided in the
`poppler-utils` package.
Install all Lisp dependencies with [ocicl](https://github.com/ocicl/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](https://github.com/atgreen) and is distributed under the terms
of the MIT license.