# Vector databases

**URL:** <https://discourse.julialang.org/t/vector-databases/114396>\
**Category:** General Usage\
**Tags:** vector-search\
**Created:** [May 17, 2024, 1:43pm UTC](https://discourse.julialang.org/t/vector-databases/114396 "2024-05-17T13:43:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lilith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lilith/32/27492_2.png) [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Post date:** [May 17, 2024, 1:43pm UTC](https://discourse.julialang.org/t/vector-databases/114396/1 "2024-05-17T13:43:18Z")

</div>

Are there any vector database implementations in Julia?

Looking for a data structure that stores a collection of vectors of real numbers and maps a query vector to an ordered list of the n closest vectors to the query (or all vectors within a certain distance). Distance = cosine similarity. All vectors have the same length.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [May 17, 2024, 3:46pm UTC](https://discourse.julialang.org/t/vector-databases/114396/2 "2024-05-17T15:46:39Z")

</div>

Are you looking for something like NearestNeighbors.jl? You can get persistence saving it to disk with JLD2.jl or other generic format to store Julia objects.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [May 17, 2024, 8:58pm UTC](https://discourse.julialang.org/t/vector-databases/114396/3 "2024-05-17T20:58:35Z")

</div>

not exactly vector database but there’s discussion about [GitHub - domluna/tinyrag](https://github.com/domluna/tinyrag) in #generative-ai on Slack

---

<div class="post-metadata">

**Author:** ![Lilith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lilith/32/27492_2.png) [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Post date:** [May 17, 2024, 10:59pm UTC](https://discourse.julialang.org/t/vector-databases/114396/4 "2024-05-17T22:59:06Z")

</div>

NearestNeighbors.jl answers the question I asked, but domluna’s approach is much faster than NearestNeighbors.BruteTree and the other NearestNeighbors trees segfault on construction so…

Hand rolled linear search it is! (and the constant factor for a naive version of domluna’s approach is already about `0.05ns*vector size*number of vectors`, which is outstanding!)

---

<div class="post-metadata">

**Author:** ![domluna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/domluna/32/18536_2.png) [@domluna](https://discourse.julialang.org/u/domluna)\
**Post date:** [May 18, 2024, 4:35am UTC](https://discourse.julialang.org/t/vector-databases/114396/5 "2024-05-18T04:35:13Z")

</div>

There was an instrinsic I wasn’t using so it’s even faster now. On my macbook air m1 it takes ~1ms for a search over 1M vector using StaticArrays.

I might look into a HNSW implementation. I think if it’s focused on just this binary vector comparison use case we might be able to get something that’s just a few microseconds, or possible even less if we’re doing a logarithmic number of comparison and each comparison is \<20ns (on my machine).

---

<div class="post-metadata">

**Author:** ![ThomasCruz](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@ThomasCruz](https://discourse.julialang.org/u/ThomasCruz)\
**Post date:** [June 20, 2024, 1:48pm UTC](https://discourse.julialang.org/t/vector-databases/114396/6 "2024-06-20T13:48:04Z")

</div>

> [@domluna](#):
>
> There was an instrinsic I wasn’t using so it’s even faster now. On my macbook air m1 it takes ~1ms for a search over 1M vector using StaticArrays.
> 
> > ****
> >
> > Ensure nodes from Refplat\_images.iso are correctly imported. Restart CML service and check user permissions. Clear browser cache or try updating CML to resolve node visibility issue. Looking for a reliable writing service? I’ve used [https://domypaper.com/](https://domypaper.com/) several times, and they always deliver exceptional work. The writers are professional and understand academic requirements well. I highly recommend their services to any student in need.
> 
> I might look into a HNSW implementation. I think if it’s focused on just this binary vector comparison use case we might be able to get something that’s just a few microseconds, or possible even less if we’re doing a logarithmic number of comparison and each comparison is \<20ns (on my machine).

Thanks for the link, you made my day 🙂
