vecs icon indicating copy to clipboard operation
vecs copied to clipboard

Feature Request: Query should optionally return the embedding as well.

Open dan-jacobson opened this issue 10 months ago • 1 comments

Summary

The .query() method can currently optionally return 1) the distance value, and 2) the metadata for records, along with the vector ids. However, AFAIK, the developer has to take those returned vector IDs, instantiate a separate supabase client, and use those ids to actually pull down the embeddings for the records. It'd be nice (and clean) to allow the developer to just get the embeddings back too. That way, you just need to make the one .query() call in order to get your records.

Rationale

It's frustrating to have to make a whole second db call just to get back the embeddings.

Design

Feels like you could just add an include_embedding argument that would do this:

if include_embedding:
    cols.append(self.table.c.vec)

Examples

From the vecs Introduction docs:

docs.query(
    data=[0.4,0.5,0.6],              # required
    limit=1,                         # number of records to return
    filters={"year": {"$eq": 2012}}, # metadata filters
    include_embedding=true,
)

# Returns: [("vec1", [0.7, 0.8, 0.9])]

Drawbacks

I dunno what's happening on the db side to know if this is awful for some reason.

Alternatives

I can make another db call if I have to.

dan-jacobson avatar Mar 14 '25 03:03 dan-jacobson

Maybe I just test to see if this works and then throw up the worlds simplest PR if it does.

dan-jacobson avatar Mar 14 '25 03:03 dan-jacobson