Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

database-vector

livebook-notes/database-vector.livemd

database-vector

Mix.install(
  [
    {:postgrex, ">= 0.0.0"},
    {:ecto_sql, "~> 3.11"},
    {:pgvector, "~> 0.2.1"},
    {:kino, "~> 0.12.3"}
  ],
  config: [
    demo: [
      {:ecto_repos, [Demo.Repo]},
      {Demo.Repo, [types: Demo.PostgrexTypes]}
    ]
  ]
)

Section

Running Postgres with pgvector

docker run -d --name pgvector-local -e POSTGRES_PASSWORD=postgres -p 5433:5432 pgvector/pgvector:pg16
Postgrex.Types.define(
  Demo.PostgrexTypes,
  [Pgvector.Extensions.Vector] ++ Ecto.Adapters.Postgres.extensions(),
  []
)

defmodule Demo.Repo do
  use Ecto.Repo, adapter: Ecto.Adapters.Postgres, otp_app: :demo, types: Demo.PostgrexTypes
end

url = "postgres://postgres:postgres@localhost:5433/demo?sslmode=disable"

Kino.start_child!({Demo.Repo, url: url})
defmodule Demo.Migrations.CreateVectorExtension do
  use Ecto.Migration

  def up do
    execute("CREATE EXTENSION IF NOT EXISTS vector")
  end

  def down do
    execute("DROP EXTENSION vector")
  end
end

defmodule Demo.Migrations.CreateTabel do
  use Ecto.Migration

  def change do
    create table(:data) do
      add(:embedding, :vector, size: 384)
    end
  end
end

migrations = [{0, Demo.Migrations.CreateVectorExtension}, {1, Demo.Migrations.CreateTabel}]

Ecto.Migrator.run(Demo.Repo, migrations, :down, all: true)
Ecto.Migrator.run(Demo.Repo, migrations, :up, all: true)
defmodule Demo.Data do
  use Ecto.Schema

  schema "data" do
    field(:embedding, Pgvector.Ecto.Vector)
  end
end
Demo.Repo.all(Demo.Data)
cat =
  Demo.Repo.insert!(%Demo.Data{
    embedding: [
      0.03733031451702118,
      0.05116182565689087,
      -3.060799208469689e-4,
      0.060209911316633224,
      -0.11749438941478729,
      -0.014230071566998959,
      0.10577620565891266,
      0.026786262169480324,
      0.02633773721754551,
      -0.025700824335217476,
      -0.023490427061915398,
      -0.05955524742603302,
      -0.030213946476578712,
      0.01632021553814411,
      -0.02907012403011322,
      -0.02168976701796055,
      -0.06624994426965714,
      0.0018566122744232416,
      -0.024006253108382225,
      -0.028462624177336693,
      -0.04663164168596268,
      0.04970480129122734,
      0.0030829228926450014,
      0.0017627214547246695,
      -0.06775753945112228,
      0.0761016309261322,
      -0.045329973101615906,
      -0.03643452748656273,
      -0.018794745206832886,
      -0.0591583289206028,
      -0.06607438623905182,
      -3.2656066468916833e-4,
      -0.008920306339859962,
      0.053416233509778976,
      -0.05470167472958565,
      -0.05120447650551796,
      -0.009808496572077274,
      0.0011381555814296007,
      0.05640070140361786,
      0.0617821104824543,
      -0.03502184525132179,
      -0.08470240980386734,
      -0.027238687500357628,
      -0.019216084852814674,
      -0.03014107421040535,
      0.00426468113437295,
      0.029739895835518837,
      -0.06179835647344589,
      0.04495338723063469,
      -0.003923097159713507,
      -0.06464503705501556,
      0.020693589001893997,
      -0.03689085319638252,
      -0.0050590503960847855,
      -0.016317542642354965,
      1.643998984945938e-4,
      0.05130370333790779,
      -0.01897975616157055,
      -0.025225359946489334,
      -0.0296596921980381,
      0.0046123783104121685,
      0.010546988807618618,
      -1.2557017907965928e-4,
      0.0781174823641777,
      0.025477135553956032,
      -3.2681973607395776e-6,
      2.756128378678113e-4,
      0.009694863110780716,
      0.04977681487798691,
      -0.011180036701261997,
      0.012095817364752293,
      0.03868110850453377,
      -0.029366599395871162,
      -2.8452748665586114e-4,
      0.019265031442046165,
      -0.0329861044883728,
      0.1317162662744522,
      -0.0073304492980241776,
      0.10367874801158905,
      0.015774745494127274,
      -0.006975154858082533,
      0.028203094378113747,
      -0.026833904907107353,
      0.03720369189977646,
      0.040000226348638535,
      0.06586146354675293,
      -0.0017604869790375233,
      0.01639672927558422,
      -0.06748654693365097,
      0.020654132589697838,
      0.017164412885904312,
      -0.010133122093975544,
      0.06467211246490479,
      0.014943457208573818,
      -0.11084959656000137,
      0.031181588768959045,
      -0.007726348005235195,
      -0.07746341824531555,
      -0.04207177087664604,
      0.23520724475383759,
      0.025494035333395004,
      0.025855476036667824,
      -0.044165950268507004,
      0.056878719478845596,
      0.00432354724034667,
      -0.015330089256167412,
      0.01121631171554327,
      0.0017131036147475243,
      0.006893911398947239,
      0.014921048656105995,
      -0.0020004166290163994,
      -0.04708623141050339,
      -0.05938074737787247,
      0.05458276346325874,
      0.03664473071694374,
      0.021196337416768074,
      -0.0226663239300251,
      -0.033385518938302994,
      0.08896195888519287,
      -0.018063032999634743,
      0.03752698004245758,
      -0.009956798516213894,
      -0.04760896787047386,
      -0.011007046326994896,
      -0.052097659558057785,
      -0.08540461212396622,
      -0.047713592648506165,
      -4.5456498789412325e-33,
      -0.004844179376959801,
      -0.09760895371437073,
      0.014730207622051239,
      -0.026084015145897865,
      0.04912842810153961,
      0.05850325524806976,
      0.0028911682311445475,
      0.029065119102597237,
      -0.08842667192220688,
      0.01612311229109764,
      -0.08860386162996292,
      0.012519471347332,
      -0.07366228848695755,
      -0.012363121844828129,
      0.03294415399432182,
      -0.009775537066161633,
      -0.013371282257139683,
      0.02275080233812332,
      -0.0343572273850441,
      0.01697026751935482,
      -0.0130313104018569,
      0.07845918089151382,
      0.07198299467563629,
      0.078214630484581,
      -0.0048031373880803585,
      -0.0842384472489357,
      -0.03150895982980728,
      -0.08608409017324448,
      -0.016402825713157654,
      0.010649354197084904,
      0.05274113267660141,
      -0.009831147268414497,
      0.0637749433517456,
      -0.0038865823298692703,
      -0.09037607163190842,
      -0.12911860644817352,
      -0.019389325752854347,
      -0.04714936017990112,
      0.01723872683942318,
      0.024575870484113693,
      0.049313485622406006,
      0.01524596381932497,
      0.052764151245355606,
      0.02120657078921795,
      0.007927109487354755,
      0.006518167909234762,
      0.03986276313662529,
      0.08464998006820679,
      -0.0680956244468689,
      0.058130018413066864,
      0.08200757950544357,
      -0.025385543704032898,
      -0.016495388001203537,
      -0.02540748566389084,
      -0.02050217241048813,
      -0.010569298639893532,
      -0.01229021605104208,
      -0.06475038826465607,
      -0.0017496193759143353,
      0.10200168937444687,
      0.02206498570740223,
      0.07658028602600098,
      0.09286636859178543,
      0.02781110629439354,
      0.06639957427978516,
      -0.09011595696210861,
      0.05881250277161598,
      -0.010556078515946865,
      0.10835208743810654,
      0.04515168070793152,
      -0.09467638283967972,
      -0.00397519813850522,
      0.05559932813048363,
      -0.07512979209423065,
      0.042563047260046005,
      -0.04162268713116646,
      -0.03164692595601082,
      0.022920018061995506,
      -0.07881375402212143,
      0.024342887103557587,
      -4.6647185808978975e-4,
      -0.0020791476126760244,
      0.06402023136615753,
      0.04672595113515854,
      -0.051049716770648956,
      0.08571244031190872,
      -0.003941883333027363,
      -0.08086041361093521,
      -0.0012964733177796006,
      0.09354420006275177,
      -0.08106527477502823,
      0.059140097349882126,
      0.049215804785490036,
      -0.07231657207012177,
      0.05887306109070778,
      3.782487354976725e-33,
      0.012545879930257797,
      -0.044461414217948914,
      -0.02448979765176773,
      0.04101358354091644,
      -0.08004337549209595,
      0.054829880595207214,
      0.03494761884212494,
      -0.019040264189243317,
      -0.026668226346373558,
      0.09057903289794922,
      -0.04087647423148155,
      0.06050929054617882,
      0.12900975346565247,
      0.012991120107471943,
      0.0380307137966156,
      0.03300977125763893,
      -0.014435183256864548,
      -0.039801374077796936,
      0.032570093870162964,
      0.011381708085536957,
      -0.07342982292175293,
      -0.010433497838675976,
      -0.07071489095687866,
      0.03185998648405075,
      0.017511049285531044,
      -0.006756157148629427,
      0.025242220610380173,
      0.0011838413774967194,
      0.032667551189661026,
      -0.15093408524990082,
      0.031178856268525124,
      -0.059040263295173645,
      -0.014013712294399738,
      -0.03338368982076645,
      0.008506791666150093,
      0.125481516122818,
      -0.01662348583340645,
      -0.025405682623386383,
      -0.023232245817780495,
      -0.00570935383439064,
      0.02903098054230213,
      0.044740285724401474,
      -0.015073766931891441,
      0.07225784659385681,
      -0.05189727246761322,
      -0.02070477232336998,
      -0.0392509326338768,
      0.0036010558251291513,
      0.04026917740702629,
      0.017428286373615265,
      -0.08170262724161148,
      -0.06424959748983383,
      -8.61674954649061e-4,
      -0.03882845118641853,
      0.022051909938454628,
      0.019644981250166893,
      -0.042081449180841446,
      -0.02161140739917755,
      -0.004930433351546526,
      0.02734968066215515,
      0.02682458981871605,
      0.04687769338488579,
      -0.009210282005369663,
      0.05176463723182678,
      -0.06490636616945267,
      -0.02696293778717518,
      -0.020811503753066063,
      -0.0746670737862587,
      -0.0031140989158302546,
      -0.05041155219078064,
      0.1300455927848816,
      0.04714149981737137,
      -0.08545416593551636,
      -0.004047973081469536,
      -0.06145003065466881,
      0.03889448195695877,
      0.005142959300428629,
      0.04706955328583717,
      -0.029664041474461555,
      -0.05775678530335426,
      -0.003847534069791436,
      -0.04252533242106438,
      -0.013100939802825451,
      0.03536305949091911,
      -0.03501339256763458,
      -0.06737861782312393,
      0.05176941305398941,
      0.06665308773517609,
      -0.002996085910126567,
      0.02367370016872883,
      0.033628594130277634,
      0.010094592347741127,
      0.0015439920825883746,
      -0.06326894462108612,
      -0.00808243453502655,
      -1.3356749484216834e-8,
      -0.0393853485584259,
      -0.04605558514595032,
      -0.08799871802330017,
      0.010793725028634071,
      0.0767190158367157,
      0.046816807240247726,
      -0.024283064529299736,
      -0.08208191394805908,
      -0.02560182847082615,
      -0.010608958080410957,
      0.05409188196063042,
      -0.032357826828956604,
      0.03481867164373398,
      0.04324429854750633,
      0.07993128150701523,
      0.0238735843449831,
      -0.029143469408154488,
      0.0012296916684135795,
      0.025209711864590645,
      0.11311161518096924,
      -0.07022912055253983,
      0.03528955578804016,
      -0.08676891773939133,
      0.0323723629117012,
      -0.03739370033144951,
      -0.021842272952198982,
      9.298676741309464e-4,
      0.10743872821331024,
      0.007365558762103319,
      -0.017454015091061592,
      -0.001484299311414361,
      0.018017087131738663,
      -0.037510767579078674,
      -0.07899516075849533,
      0.011136546730995178,
      -0.03322901576757431,
      0.027380289509892464,
      -0.07640183717012405,
      0.07584808021783829,
      -0.01616726815700531,
      0.030557796359062195,
      0.05776344612240791,
      0.08141151070594788,
      -0.0730246752500534,
      -0.11145446449518204,
      2.83084053080529e-4,
      0.029737135395407677,
      -0.08533911406993866,
      0.015011368319392204,
      0.0074540842324495316,
      0.001321339514106512,
      0.06907466053962708,
      0.046015381813049316,
      0.06226345896720886,
      0.002010945463553071,
      0.01572311483323574,
      -0.004215599503368139,
      -0.015644241124391556,
      -0.03716272860765457,
      0.053079646080732346,
      0.15966255962848663,
      0.061269208788871765,
      0.06081463769078255,
      0.0492803230881691
    ]
  })

dog =
  Demo.Repo.insert!(%Demo.Data{
    embedding: [
      -0.05314703658223152,
      0.014194397255778313,
      0.007145756855607033,
      0.06860864907503128,
      -0.0784803256392479,
      0.01016745064407587,
      0.10228317230939865,
      -0.012064830400049686,
      0.09521341323852539,
      -0.030350161716341972,
      0.0021646982058882713,
      -0.06486447155475616,
      -0.002594382967799902,
      0.006218919064849615,
      -0.003928675781935453,
      -0.030624568462371826,
      -0.04791150614619255,
      -0.01930052414536476,
      -0.059885360300540924,
      -0.1041673794388771,
      -0.08614891767501831,
      0.0363595113158226,
      -0.02552606724202633,
      0.0016389443771913648,
      -0.07144207507371902,
      0.061680056154727936,
      0.0171945933252573,
      -0.05661112442612648,
      0.024812225252389908,
      -0.0778224840760231,
      -0.03249919041991234,
      -0.00869906134903431,
      -0.011532521806657314,
      0.03816736117005348,
      -0.05693076178431511,
      -0.05327102541923523,
      0.004925705958157778,
      0.03250062093138695,
      0.07253246754407883,
      0.03298487141728401,
      0.024722913280129433,
      -0.08334521949291229,
      -0.015685761347413063,
      -0.04811980575323105,
      -0.003477234160527587,
      0.0043504685163497925,
      -0.03589561581611633,
      -0.05185402184724808,
      0.0156733226031065,
      0.003522393759340048,
      -0.010323255322873592,
      0.047641705721616745,
      -0.040158603340387344,
      -0.00909929908812046,
      -0.03463481366634369,
      -0.03698180243372917,
      -0.0408402755856514,
      0.017719142138957977,
      -0.009393051266670227,
      -0.05363635718822479,
      0.011133106425404549,
      0.016180483624339104,
      0.01378462091088295,
      0.02831326797604561,
      0.04025886952877045,
      0.020901702344417572,
      -0.01446562446653843,
      -0.0015999695751816034,
      -0.004975114017724991,
      0.012072636745870113,
      0.0455365926027298,
      0.013122142292559147,
      0.07058043777942657,
      -0.030829252675175667,
      0.030435513705015182,
      -0.10847659409046173,
      0.05547671765089035,
      -0.017531752586364746,
      0.16431543231010437,
      0.051455870270729065,
      -0.027683524414896965,
      -0.029959065839648247,
      -0.056952230632305145,
      0.056823428720235825,
      0.05094674229621887,
      0.015132183209061623,
      -0.0012805198784917593,
      0.023995013907551765,
      -0.0632866844534874,
      0.028871778398752213,
      -0.05534106492996216,
      -0.03493926674127579,
      0.030283210799098015,
      0.026885848492383957,
      -0.08350417017936707,
      0.01836238242685795,
      -0.035157788544893265,
      -0.08281907439231873,
      -0.07189121842384338,
      0.19799093902111053,
      0.016415627673268318,
      0.04458478465676308,
      -0.0037554120644927025,
      -0.03850795328617096,
      0.053483594208955765,
      -0.003469461342319846,
      -0.043481722474098206,
      0.0633896142244339,
      -0.013175549916923046,
      -0.019762827083468437,
      -0.04527373984456062,
      0.020712923258543015,
      -0.05651777982711792,
      0.05744059383869171,
      0.055534325540065765,
      0.021156543865799904,
      -0.10093533247709274,
      -0.03430291637778282,
      0.029364410787820816,
      -0.03324667736887932,
      0.028912052512168884,
      0.030096787959337234,
      -0.051864586770534515,
      0.008204218000173569,
      -0.016697702929377556,
      -0.08435992151498795,
      0.011142008937895298,
      -5.923914801228457e-33,
      0.03065081499516964,
      -0.085042804479599,
      0.00271755107678473,
      -0.04106852412223816,
      -0.042725518345832825,
      0.041027504950761795,
      0.02944086864590645,
      0.03645972162485123,
      -0.12123756110668182,
      0.013488669879734516,
      -0.013879113830626011,
      0.03126824274659157,
      -0.021619286388158798,
      0.01617732271552086,
      0.1122300997376442,
      -0.0067082480527460575,
      -0.001892926637083292,
      0.05322013050317764,
      0.032610926777124405,
      -0.037766214460134506,
      -0.04691629856824875,
      0.061948440968990326,
      0.06361372023820877,
      0.05011948570609093,
      -0.007603964768350124,
      -0.021480979397892952,
      -0.037787534296512604,
      -0.08291462063789368,
      -0.026290377601981163,
      0.036140259355306625,
      0.04127700999379158,
      0.014518526382744312,
      0.07345045357942581,
      6.527092191390693e-4,
      -0.0814354345202446,
      -0.05578262731432915,
      -0.04213268309831619,
      -0.09667716175317764,
      -0.04012605920433998,
      0.028559526428580284,
      0.12905004620552063,
      0.010448027402162552,
      0.025106076151132584,
      0.017339760437607765,
      -0.027208272367715836,
      -0.004948332905769348,
      0.01573403738439083,
      0.03437734767794609,
      -0.044487591832876205,
      0.020837493240833282,
      0.027518942952156067,
      -0.014314553700387478,
      0.028818266466259956,
      -0.021267380565404892,
      0.008817844092845917,
      0.009855765849351883,
      0.0029994703363627195,
      -0.0238090418279171,
      0.013047417625784874,
      0.06634412705898285,
      0.0689176619052887,
      0.0825468897819519,
      0.008786121383309364,
      -0.014059165492653847,
      0.09107070416212082,
      -0.12217667698860168,
      -0.045309487730264664,
      -0.01808135025203228,
      -0.02217216044664383,
      0.021522780880331993,
      -0.03884340077638626,
      -0.019557273015379906,
      0.0797145664691925,
      -0.01576273702085018,
      0.06888049840927124,
      -0.015566345304250717,
      0.02278212457895279,
      0.025295395404100418,
      -0.031191561371088028,
      -0.033500321209430695,
      -0.021587878465652466,
      -0.010069391690194607,
      0.0055008321069180965,
      0.04897749423980713,
      -0.02150457538664341,
      0.0638372004032135,
      -0.019717033952474594,
      -0.030271975323557854,
      0.006232813000679016,
      0.045180629938840866,
      -0.045809656381607056,
      -0.049157898873090744,
      0.08708889782428741,
      0.027344979345798492,
      0.09059284627437592,
      3.432162855124821e-33,
      0.06254414469003677,
      0.02896781452000141,
      5.441743996925652e-5,
      0.0914405882358551,
      -0.03037312813103199,
      0.004910525865852833,
      -0.025467127561569214,
      0.06670121103525162,
      -0.03414911776781082,
      0.047809846699237823,
      -0.034206733107566833,
      0.007902400568127632,
      0.10791868716478348,
      0.009035124443471432,
      0.007591940928250551,
      0.08858619630336761,
      0.00373834534548223,
      -0.03047105297446251,
      0.02170719765126705,
      -0.004327213857322931,
      -0.14471672475337982,
      0.011570456437766552,
      0.018367605283856392,
      -0.025850147008895874,
      -0.05193903297185898,
      0.03941745311021805,
      0.037535831332206726,
      -0.014728974550962448,
      -0.022241536527872086,
      -0.04871096462011337,
      -0.0065196119248867035,
      -0.03956878185272217,
      -0.041273001581430435,
      -0.028437446802854538,
      0.010693784803152084,
      0.158605694770813,
      0.04765569791197777,
      -0.04726951941847801,
      -0.06290382891893387,
      0.008551893755793571,
      0.05990678444504738,
      0.01931130699813366,
      -0.03222966194152832,
      0.11158400774002075,
      0.016122914850711823,
      0.05269932374358177,
      -0.017932996153831482,
      -0.005921725649386644,
      0.052918802946805954,
      0.01842353492975235,
      -0.04744260758161545,
      -0.014329860918223858,
      0.030033966526389122,
      -0.07333710044622421,
      -0.012593400664627552,
      0.004521231632679701,
      -0.09498979896306992,
      0.018820740282535553,
      -0.029087066650390625,
      -0.005304867401719093,
      -0.002841720823198557,
      0.06969694793224335,
      0.012459018267691135,
      0.1219218447804451,
      -0.1048354059457779,
      -0.053725264966487885,
      -0.012763230130076408,
      -0.027916911989450455,
      0.05001469701528549,
      -0.07645858079195023,
      0.02428736910223961,
      0.04536538943648338,
      -0.028986932709813118,
      0.010187781415879726,
      -0.010616538114845753,
      0.031045757234096527,
      -0.04648571461439133,
      0.004574026446789503,
      0.007662683259695768,
      -0.0063811601139605045,
      -0.07788287848234177,
      -0.06529122591018677,
      -0.047676797956228256,
      0.010323774069547653,
      -0.0566282719373703,
      -0.011250861920416355,
      0.0021043354645371437,
      0.06386016309261322,
      -0.013329937122762203,
      -0.030173087492585182,
      -0.00982380285859108,
      0.05496024712920189,
      -0.021686818450689316,
      -0.05331655964255333,
      -0.028597617521882057,
      -1.3319514380327746e-8,
      -0.02869223989546299,
      -0.02917375974357128,
      -0.04298403114080429,
      -0.0195621345192194,
      0.09974845498800278,
      0.06951726973056793,
      -0.030107108876109123,
      -0.04013076424598694,
      -0.006630493327975273,
      0.026162950322031975,
      0.04425722360610962,
      -0.016367796808481216,
      -0.07000916451215744,
      0.01344552543014288,
      0.04655243456363678,
      -0.015150444582104683,
      -0.05343765392899513,
      0.03986130654811859,
      0.0628618523478508,
      0.07714775204658508,
      -0.05102364346385002,
      0.0302715040743351,
      0.05550666153430939,
      0.002205807715654373,
      -0.05122806131839752,
      -0.035941142588853836,
      0.045603733509778976,
      0.10606111586093903,
      -0.08217962086200714,
      0.038097672164440155,
      -0.022630101069808006,
      0.1406116932630539,
      -0.0761837512254715,
      -0.030086789280176163,
      -0.00403566611930728,
      -0.06968795508146286,
      0.07609093189239502,
      -0.0792493000626564,
      0.025034183636307716,
      0.03404047712683678,
      0.050425201654434204,
      0.15210048854351044,
      -0.020087024196982384,
      -0.07890963554382324,
      -5.837610806338489e-4,
      0.06229373440146446,
      0.026448005810379982,
      -0.12159693986177444,
      -0.028296897187829018,
      -0.05642316862940788,
      -0.09823251515626907,
      -0.007412878330796957,
      0.0279071144759655,
      0.06906426697969437,
      0.015004917979240417,
      0.005070952698588371,
      -0.01311839185655117,
      -0.048034701496362686,
      -0.01673538237810135,
      0.036670368164777756,
      0.11144452542066574,
      0.029856877401471138,
      0.02390546351671219,
      0.11009308695793152
    ]
  })
# Get the nearest neighbors by L2 distance

my_query = [
  0.03556492179632187,
  0.056749291718006134,
  0.03832069784402847,
  0.11054609715938568,
  -0.04206419736146927,
  -0.01978980004787445,
  0.033735912293195724,
  0.044819608330726624,
  0.02535645291209221,
  0.02615838125348091,
  0.052416685968637466,
  0.006996800657361746,
  -0.0038478949572890997,
  0.03455794230103493,
  0.013107309117913246,
  -0.01059517078101635,
  -0.06391879171133041,
  -0.03398863226175308,
  0.012714168056845665,
  -0.019239602610468864,
  -0.05043039098381996,
  0.026711758226156235,
  0.023795777931809425,
  -0.041240811347961426,
  -0.016829892992973328,
  0.07982134819030762,
  -0.07710638642311096,
  -0.0046304333955049515,
  0.0045104678720235825,
  -0.015156170353293419,
  -0.041023917496204376,
  -0.07819390296936035,
  0.011319689452648163,
  0.003460262669250369,
  -0.028674297034740448,
  -0.10341983288526535,
  0.026243101805448532,
  0.015962988138198853,
  0.04867670312523842,
  0.0552959218621254,
  -0.05757367983460426,
  0.02470201812684536,
  0.022030608728528023,
  -0.08439289033412933,
  -0.020074212923645973,
  -0.021319594234228134,
  0.041388049721717834,
  -0.05798913910984993,
  0.05999855324625969,
  -0.02760610543191433,
  -0.027620570734143257,
  -0.0071591101586818695,
  0.03526913747191429,
  0.006729034706950188,
  -0.02827576734125614,
  -0.03413502871990204,
  0.015060088597238064,
  0.008209962397813797,
  6.394750089384615e-4,
  -0.0010890779085457325,
  -0.05623896047472954,
  0.02428637444972992,
  -0.006614914163947105,
  0.018164144828915596,
  1.7572582873981446e-4,
  0.017413243651390076,
  -0.02910689264535904,
  -2.989077620441094e-5,
  0.0920371264219284,
  -0.004338088445365429,
  0.0101720429956913,
  0.03811139240860939,
  -0.017745357006788254,
  0.07948818802833557,
  -0.041750602424144745,
  0.005253063980489969,
  0.12791036069393158,
  -0.02567354589700699,
  0.06349559873342514,
  0.006262342911213636,
  -0.11195984482765198,
  0.040778324007987976,
  -0.003261747071519494,
  0.03056873008608818,
  0.0058182477951049805,
  0.03418291360139847,
  0.09698454290628433,
  0.037327609956264496,
  -0.11509198695421219,
  0.049551088362932205,
  0.07128193974494934,
  -0.01600727066397667,
  0.027652811259031296,
  0.0333639420568943,
  0.03940033167600632,
  -0.12833933532238007,
  -0.003256064373999834,
  -0.0199658814817667,
  -0.004308637697249651,
  0.0257339458912611,
  4.559815861284733e-4,
  -0.01771022193133831,
  0.06360024958848953,
  0.12898488342761993,
  0.03583579137921333,
  0.021910997107625008,
  -0.02663593925535679,
  0.016321079805493355,
  -0.01920618861913681,
  -1.2684489774983376e-4,
  -0.008342688903212547,
  -0.014996618032455444,
  0.01341144647449255,
  0.025977805256843567,
  -0.015617908909916878,
  -0.03612407669425011,
  0.030556559562683105,
  -0.040164850652217865,
  0.06926818937063217,
  -0.03557243570685387,
  0.005900944117456675,
  0.05384879559278488,
  -0.015157639048993587,
  0.003203032538294792,
  -0.055675625801086426,
  -0.10059729963541031,
  0.011338349431753159,
  -5.243319000465707e-33,
  -0.05305171012878418,
  -0.08816961199045181,
  -0.01065000705420971,
  0.042360708117485046,
  0.0485939159989357,
  0.07624366134405136,
  -0.03099030815064907,
  0.038046952337026596,
  -0.07024110108613968,
  -0.03285500407218933,
  -0.0142533453181386,
  -0.044985879212617874,
  -0.057206347584724426,
  -0.10513582080602646,
  -0.06427066773176193,
  0.017246512696146965,
  -0.08463659137487411,
  -0.018026551231741905,
  0.048913322389125824,
  0.0668245181441307,
  -0.04388033598661423,
  0.049323197454214096,
  0.04899630323052406,
  0.03920909762382507,
  0.0588972270488739,
  -0.0014919869136065245,
  -0.01655273698270321,
  -0.0818919986486435,
  0.021039364859461784,
  0.01563585363328457,
  0.0686739981174469,
  1.3931990542914718e-4,
  0.036622751504182816,
  -0.01906733028590679,
  -0.13697449862957,
  -0.06410416960716248,
  0.036342553794384,
  -0.04455915465950966,
  0.0014017376815900207,
  0.07695746421813965,
  0.062348924577236176,
  -0.04548230767250061,
  0.03855787590146065,
  -0.045177116990089417,
  0.05688183009624481,
  -0.00744211208075285,
  -0.017445283010601997,
  0.04754228889942169,
  -0.09955529123544693,
  0.006579436361789703,
  0.07503072917461395,
  6.628553965128958e-4,
  -0.048303697258234024,
  -0.09022502601146698,
  -0.048163846135139465,
  -0.013985993340611458,
  0.02614526078104973,
  -0.04365408793091774,
  -0.07369034737348557,
  0.11178293824195862,
  0.01949823461472988,
  -0.00736384280025959,
  0.08953043818473816,
  -0.017699139192700386,
  -0.014566638506948948,
  -0.10855856537818909,
  0.09593957662582397,
  0.01542101800441742,
  0.041296765208244324,
  -0.018923373892903328,
  -0.030533989891409874,
  -0.00499626062810421,
  -0.06528761982917786,
  -0.1064499095082283,
  0.021595094352960587,
  -0.05571821331977844,
  0.0071016415022313595,
  -0.017571130767464638,
  -0.14034435153007507,
  -0.017752084881067276,
  0.03419148176908493,
  -0.017763089388608932,
  0.04448816552758217,
  0.06261397153139114,
  0.02969687059521675,
  0.01628962904214859,
  -0.01187634002417326,
  -0.07892398536205292,
  -0.06727131456136703,
  0.03387092426419258,
  -0.054233040660619736,
  0.016022708266973495,
  0.03178863972425461,
  -0.10089374333620071,
  0.05296963080763817,
  2.1897283254560272e-33,
  -0.06320121139287949,
  -0.03530024364590645,
  0.02396629936993122,
  -0.026900310069322586,
  -0.0798928365111351,
  -0.041297510266304016,
  0.026875469833612442,
  0.04473210498690605,
  -0.07474475353956223,
  0.060404349118471146,
  0.03650245442986488,
  0.030799798667430878,
  0.10340016335248947,
  -0.026161694899201393,
  0.030696656554937363,
  0.018902964890003204,
  -0.090428926050663,
  0.01928149349987507,
  0.05614324286580086,
  -0.03124973364174366,
  -0.08803299069404602,
  0.04421387240290642,
  -0.037849217653274536,
  0.06123488023877144,
  0.05231519788503647,
  -0.01640728861093521,
  -0.01319980900734663,
  -0.02906171604990959,
  0.018902042880654335,
  -0.12739649415016174,
  0.05213167518377304,
  -0.025087611749768257,
  0.006669886875897646,
  -0.04095272347331047,
  0.01400379091501236,
  -0.01771208830177784,
  -0.07491886615753174,
  -0.054850801825523376,
  -0.02587588131427765,
  -0.10259940475225449,
  -0.06469458341598511,
  -0.009779191575944424,
  0.03160081431269646,
  0.09233638644218445,
  -0.04503659904003143,
  -0.03831028193235397,
  0.023141268640756607,
  -0.006527299992740154,
  0.05373532325029373,
  0.051489826291799545,
  -0.07053972780704498,
  -0.019339917227625847,
  -0.018455687910318375,
  -0.04472041502594948,
  -0.02300696261227131,
  0.03522200137376785,
  0.06487638503313065,
  -0.03280782327055931,
  0.03177047148346901,
  0.04677093029022217,
  -0.009535055607557297,
  -0.011376481503248215,
  -0.11405772715806961,
  0.05333929508924484,
  -0.007689557038247585,
  -0.044433385133743286,
  -0.04723411425948143,
  -0.09826027601957321,
  -0.11924036592245102,
  -0.033519092947244644,
  0.07767358422279358,
  0.09798499196767807,
  -0.04454640671610832,
  0.029055707156658173,
  -0.02253018319606781,
  -0.03132721781730652,
  0.024015095084905624,
  0.044925279915332794,
  -0.03158934414386749,
  9.148532408289611e-4,
  -0.020471248775720596,
  0.0169595405459404,
  0.054891545325517654,
  -0.014187542721629143,
  -0.005528847686946392,
  -0.09882450848817825,
  0.061778474599123,
  -0.004088160581886768,
  0.01013680174946785,
  0.027649635449051857,
  0.0451478511095047,
  0.0125928008928895,
  0.016438450664281845,
  -0.06955912709236145,
  -0.009000527672469616,
  -1.562801443810713e-8,
  -0.0038340731989592314,
  0.03700754791498184,
  -0.031045814976096153,
  0.03721043840050697,
  0.05675483122467995,
  5.65511581953615e-4,
  0.0452398918569088,
  -0.00834625493735075,
  -0.05997525900602341,
  0.028663989156484604,
  -0.05625830218195915,
  0.010049651376903057,
  0.02928321808576584,
  0.026041962206363678,
  0.16151867806911469,
  -0.018229996785521507,
  0.07602163404226303,
  -0.0511322021484375,
  0.06450024992227554,
  0.08072767406702042,
  -0.061360109597444534,
  0.06063167005777359,
  -0.06880165636539459,
  -0.01902814954519272,
  -0.0525667704641819,
  -0.053672779351472855,
  0.034482695162296295,
  -0.005028358194977045,
  -0.01897360570728779,
  -0.019152170047163963,
  0.08307529985904694,
  -0.012992292642593384,
  0.02446410432457924,
  -0.0024267572443932295,
  -0.02799934148788452,
  -0.016996536403894424,
  -5.681989132426679e-4,
  -0.0535927452147007,
  0.0455690436065197,
  -0.08159364759922028,
  0.08709994703531265,
  0.060460541397333145,
  0.058427054435014725,
  -0.005368121434003115,
  -0.05995311588048935,
  0.04177239164710045,
  -0.01079738512635231,
  -0.014809097163379192,
  0.036662787199020386,
  0.09559859335422516,
  0.0482025109231472,
  0.10032694041728973,
  0.038983508944511414,
  0.0032061540987342596,
  0.011607139371335506,
  0.020179372280836105,
  0.004993951879441738,
  -0.028282754123210907,
  0.01865093782544136,
  0.03904135897755623,
  0.13888435065746307,
  0.08317466825246811,
  -0.02423255890607834,
  0.035194966942071915
]

import Ecto.Query
import Pgvector.Ecto.Query
Demo.Repo.all(from(i in Demo.Data, order_by: l2_distance(i.embedding, ^my_query), limit: 1))