kokolegorille
Hello everyone,
I am trying to group vectors into clusters of similarity.
I have extracted a video into screenshots, each seconds, and retrieved face embedding vectors with face_recognition: The vector database is postgresql, with the pg_vector extension.
Here is my migration
def change do
create table(:faces, primary_key: false) do
add :id, :binary_id, primary_key: true
add :filename, :string
add :x, :integer
add :y, :integer
add :w, :integer
add :h, :integer
add :embedding, :vector, size: 128
timestamps()
end
create index(:faces, [:filename])
# vector size is limited to 2000 dimensions!
create index("faces", ["embedding vector_cosine_ops"], using: :hnsw)
end
I can query for similarities, given an embedding… with code similar to
{:l2_order, embedding}, query ->
from p in query, order_by: l2_distance(^embedding, p.embedding)
def list_faces_with_distances(query, embedding) do
from(p in query,
where: l2_distance(^embedding, p.embedding) <= 0.5,
select: %{p | distance: l2_distance(^embedding, p.embedding)})
|> Repo.all
end
My question is… how can I cluster the vectors into groups of similarity?
Because the embeddings represents faces, I would like to group vectors from the same person. In fact, I would like to find the number of different persons
There is an example with ExFaiss which is what I would like to achieve. Unfortunately, ExFaiss has been archived GitHub - elixir-nx/ex_faiss: Elixir front-end to Facebook AI Similarity Search (Faiss) · GitHub
Thanks for taking time
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
kokolegorille
Clustering with DBSCAN is not working with high dimension vectors, and HNSW provides ANN, but has no clustering options… By combining both, it is possible to achieve high speed clustering of thousands of vectors (dim=128)
Thanks to Nx and this package hnswlib | Hex
For future reference… here is the implementation