Vecto

Hybrid Search with Postgres and Ecto

Loosely based on:

Installation

If available in Hex, the package can be installed by adding vecto to your list of dependencies in mix.exs:

def deps do
  [
    {:vecto, "~> 0.1.1"}
  ]
end

Setup

  1. Create a tsvector column in your table (postgres "generated" column recommended based on one or combo of text columns)
  2. Create a GIN index on the tsvector column
  3. Create a HNSW Cosine distance index on the vector column
  4. Generate embeddings for your documents and store them in the vector column (e.g. using BERT via Bumblebee, OpenAI's API, etc)
  5. Generate embeddings for your search query and pass to query_embedding

Usage

Blog
|> Vecto.hybrid_search([0.11, 0.03, -0.02, ...], "what is a cat")
|> Repo.all()

You can also use the keyword_search and semantic_search functions as stand-alone queries

TODO

Docs can be found at https://hexdocs.pm/vecto