asg017 / sqlite-vec

A vector search SQLite extension that runs anywhere!
Apache License 2.0
4.24k stars 134 forks source link

Auxiliary column support #123

Closed asg017 closed 2 days ago

asg017 commented 1 month ago

References #121 , requires #122 .

Work in progress, still needs more bug fixing, docs, and tests.

create virtual table vec_chunks using vec0(
  chunk_id integer primary key,
  +contents text,
  contents_embeddings float[1024],
);

select chunk_id, contents, distance
from vec_chunks
where contents_embedding match '[...]'
  and user_id = 123
  and k = 5;
/*
┌──────────┬──────────────────────────────────────────────────────────────┬──────────┐
│ chunk_id │                           contents                           │ distance │
├──────────┼──────────────────────────────────────────────────────────────┼──────────┤
│ 20       │ 'Managers are responsible for tracking their team members''  │ 1.0      │
│          │ PTO usage.'                                                  │          │
├──────────┼──────────────────────────────────────────────────────────────┼──────────┤
│ 17       │ 'Part-time employees are eligible for PTO on a pro-rata basi │ 2.0      │
│          │ s.'                                                          │          │
├──────────┼──────────────────────────────────────────────────────────────┼──────────┤
│ 15       │ 'All PTO balances will be displayed on the employee self-ser │ 4.0      │
│          │ vice portal.'                                                │          │
├──────────┼──────────────────────────────────────────────────────────────┼──────────┤
│ 5        │ 'PTO must be used in increments of at least 4 hours.'        │ 14.0     │
├──────────┼──────────────────────────────────────────────────────────────┼──────────┤
│ 4        │ 'Unused PTO can be carried over to the following year, up to │ 15.0     │
│          │  a maximum of 40 hours.'                                     │          │
└──────────┴──────────────────────────────────────────────────────────────┴──────────┘
*/
asg017 commented 2 days ago

yolo