Skip to content

Commit

Permalink
remove index again
Browse files Browse the repository at this point in the history
  • Loading branch information
cbh123 committed Oct 11, 2023
1 parent 42af92e commit fe3b5a9
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lib/emoji/embeddings/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ defmodule Emoji.Embeddings.Index do
end

def init(_args) do
{:ok, full_index} = HNSWLib.Index.new(:l2, 1024, 100_000)
{:ok, image_index} = HNSWLib.Index.new(:l2, 1024, 100_000)
# {:ok, full_index} = HNSWLib.Index.new(:l2, 1024, 100_000)
# {:ok, image_index} = HNSWLib.Index.new(:l2, 1024, 100_000)

Emoji.Predictions.list_predictions_with_text_embeddings()
|> Enum.each(fn prediction ->
HNSWLib.Index.add_items(full_index, Nx.from_binary(prediction.embedding, :f32),
ids: Nx.tensor([prediction.id])
)
end)
# Emoji.Predictions.list_predictions_with_text_embeddings()
# |> Enum.each(fn prediction ->
# HNSWLib.Index.add_items(full_index, Nx.from_binary(prediction.embedding, :f32),
# ids: Nx.tensor([prediction.id])
# )
# end)

Emoji.Predictions.list_predictions_with_image_embeddings()
|> Enum.each(fn prediction ->
HNSWLib.Index.add_items(image_index, Nx.from_binary(prediction.image_embedding, :f32),
ids: Nx.tensor([prediction.id])
)
end)
# Emoji.Predictions.list_predictions_with_image_embeddings()
# |> Enum.each(fn prediction ->
# HNSWLib.Index.add_items(image_index, Nx.from_binary(prediction.image_embedding, :f32),
# ids: Nx.tensor([prediction.id])
# )
# end)

Logger.info("Index successfully created")
{:ok, %{full_index: %{}, image_index: %{}}}
Expand Down

0 comments on commit fe3b5a9

Please sign in to comment.