pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: matheusft (@matheusft) <noreply+matheusft@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #640: Late interaction embedding support
Date: Thu, 23 Jan 2025 13:48:33 +0000
Message-ID: <gh-pgvector-pgvector-640-c2609856697@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-640@github.com>
References: <gh-pgvector-pgvector-640@github.com>

Hello,

I'm struggling to add my Multi-Vector (ColBERT) embedding into my Postgres DB.
Below is a demo version of the python code I'm using.

```python
from dotenv import load_dotenv
import os
import psycopg
import numpy as np

load_dotenv()

# Connect to your postgres DB
conn = psycopg.connect(
    "dbname={} user={} password={} host={}".format(
        os.getenv("DB"),
        os.getenv("USER"),
        os.getenv("PASSWORD"),
        os.getenv("HOST"),
    )
)

# Open a cursor to perform database operations
cur = conn.cursor()

embedding = [np.random.rand(3, 128)]

# Insert the formatted string into the database
conn.execute('INSERT INTO SCHEMA.TABLE (content, embeddings) VALUES (%s, %s)',
             ("content", embedding))
```

This is how my table looks like


```bash
MY_DB=# \d SCHEMA.TABLE;
                               Table "SCHEMA.TABLE"
   Column   |     Type      | Collation | Nullable |                Default                
------------+---------------+-----------+----------+---------------------------------------
 id         | bigint        |           | not null | nextval('documents_id_seq'::regclass)
 content    | text          |           |          | 
 embeddings | vector(128)[] |           |          | 
Indexes:
    "documents_pkey" PRIMARY KEY, btree (id)
```

This is what the python code above gives me.
⚠️⚠️⚠️
`psycopg.ProgrammingError: cannot adapt type 'ndarray' using placeholder '%s' (format: AUTO)`
⚠️⚠️⚠️

Any help?



view thread (20+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-640-c2609856697@github.com>
Permalink:  ../gh-pgvector-pgvector-640-c2609856697@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox