This repo shows an example on how to use Vectors for a recommendation engine.
The example contains two examples:
Calculates a vector from three strings and calculates the distance between them. To calculate the distance uses cosine distance where returns a value between -1 and 1 where -1 is a value when both sentences are semantically far away each other, and 1 when it is the same.
To try it start the service with quarkus dev
having Docker or Podman started (required for the second example) and then access to /vector/calculate
.
This example imports a partial dataset of Ikea furniture into the PostgresSQL with pgvector database calculating the vector of the description. Then given a product, the system returns 5 similar articles based on the description.
The first thing you need to do is import the dataset into database calling the following URL /product/generate
.
Then you can start getting recommendations for products.
For example, send the following request to get 5 recommendations for the item with id 13: /product/recommend/13
.