Small experimental Rails app to build a feature with text -> vector -> embedding -> search
.
The idea was to run and host everything locally without any dependencies. Just a app and a docker-compose file. In many cases, tutorials simply use OpenAI API to transform and new fancy services to store and search.
This app seed for books is from GoodReads Best Book datasets.
To transform the book information into vectors this use Text Embeddings Inference from Hugging Face. It run locally with a Docker container with the WhereIsAI/UAE-Large-V1 model. The GitHub repo as more information. See docker-compose.yml.
The vectors are stored into a Postgres database with the pg_vector
extension.
See docker-compose.yml.
To search the nearness neighbor in pg_vector, the app use the ankane/neighbor gem to integrate with ActiveRecord. But the SQL is relatively simple and can be done without the gem.