Bhacaz / book-neighbor

Book app demo to play with DB vector and text embedding

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

book-neighbor

Small experimental Rails app to build a feature with text -> vector -> embedding -> search.

Stack

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.

Data

This app seed for books is from GoodReads Best Book datasets.

Transform

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.

Embedding and storing

The vectors are stored into a Postgres database with the pg_vector extension. See docker-compose.yml.

Search

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.

Showcase

About

Book app demo to play with DB vector and text embedding


Languages

Language:Ruby 70.4%Language:HTML 26.4%Language:JavaScript 3.0%Language:CSS 0.2%