# Vector databases in Crystal?

**URL:** <https://forum.crystal-lang.org/t/vector-databases-in-crystal/5544>\
**Category:** Community\
**Created:** [April 7, 2023, 9:47pm UTC](https://forum.crystal-lang.org/t/vector-databases-in-crystal/5544 "2023-04-07T21:47:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![serge-hulne](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/serge-hulne/32/1211_2.png) [@serge-hulne](https://forum.crystal-lang.org/u/serge-hulne)\
**Post date:** [April 7, 2023, 9:47pm UTC](https://forum.crystal-lang.org/t/vector-databases-in-crystal/5544/1 "2023-04-07T21:47:47Z")

</div>

Are there Crystal API for vector databases?

---

<div class="post-metadata">

**Author:** ![kojix2](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kojix2/32/1583_2.png) [@kojix2](https://forum.crystal-lang.org/u/kojix2)\
**Post date:** [April 8, 2023, 9:16am UTC](https://forum.crystal-lang.org/t/vector-databases-in-crystal/5544/2 "2023-04-08T09:16:20Z")

</div>

for ChatGPT Retrieval Plugin?

---

<div class="post-metadata">

**Author:** ![serge-hulne](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/serge-hulne/32/1211_2.png) [@serge-hulne](https://forum.crystal-lang.org/u/serge-hulne)\
**Post date:** [April 8, 2023, 9:48am UTC](https://forum.crystal-lang.org/t/vector-databases-in-crystal/5544/3 "2023-04-08T09:48:04Z")

</div>

No, I was asking the question more generally.

A couple of years ago, I wrote an experimental search engine, using vector space, in Go and in order to make the database persistent I used SQLite to store the vector data (and some Go code to implement queries based on proximity).

Since then, owing to the role of vectors to represent data in AI applications, I was wondering if I could not rewrite my earlier code using a ready made solution based on current existing vector databases.

On the other hand, I would like try to rewrite said code in Crystal for a couple of reasons:

- Out of curiosity.

- Out of personal preferences over Go (easier OO, more conciseness, better readability, less boiler plate, String are classes (or Structs), not a simple package; Chaining, etc, Shards for NLP, Shards for Wordnet…

So I was wondering if anybody knows of a possibility to use vector databases from Crystal or alternatively if anybody is working on the topic or on something similar.

---

<div class="post-metadata">

**Author:** ![serge-hulne](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/serge-hulne/32/1211_2.png) [@serge-hulne](https://forum.crystal-lang.org/u/serge-hulne)\
**Post date:** [April 10, 2023, 11:38am UTC](https://forum.crystal-lang.org/t/vector-databases-in-crystal/5544/4 "2023-04-10T11:38:10Z")

</div>

Here is one possibility (via PostgresSQL) : [GitHub - pgvector/pgvector: Open-source vector similarity search for Postgres](https://github.com/pgvector/pgvector)

---

<div class="post-metadata">

**Author:** ![crimson-knight](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/crimson-knight/32/1643_2.png) [@crimson-knight](https://forum.crystal-lang.org/u/crimson-knight)\
**Post date:** [April 10, 2023, 12:45pm UTC](https://forum.crystal-lang.org/t/vector-databases-in-crystal/5544/5 "2023-04-10T12:45:34Z")

</div>

I’d really like to see an ORM for using Pinecone [https://pinecone.io/](https://pinecone.io/)

Maybe that’s something I can include into Amber 2.0, I’m trying to focus the framework on leaning into the AI trend.

---

<div class="post-metadata">

**Author:** ![serge-hulne](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/serge-hulne/32/1211_2.png) [@serge-hulne](https://forum.crystal-lang.org/u/serge-hulne)\
**Post date:** [April 10, 2023, 2:03pm UTC](https://forum.crystal-lang.org/t/vector-databases-in-crystal/5544/6 "2023-04-10T14:03:34Z")

</div>

On the other hand, the Postgres option is probably easier to implement as an API or perhaps as a shard.

Also, it is free (financially) to use, I think.
