mirror of
https://github.com/hanzoai/sqlite-vec.git
synced 2026-10-30 20:33:15 +00:00
33 KiB
33 KiB
In [1]:
.open tmp-artic2.dbOut [1]:
[no code]
In [3]:
create virtual table fts_articles using fts5(
headline,
content='articles', content_rowid='id'
);
insert into fts_articles(rowid, headline)
select rowid, headline
from articles;
insert into fts_articles(fts_articles) values('optimize');Out [3]:
0 row × 0 column
In [25]:
select *
from fts_articles
where headline match 'planned parenthood'
limit 10;Out [25]:
| headline |
|---|
| Kamala Harris visits Planned Parenthood clinic |
| Former Marine sentenced to 9 years in prison for firebombing Planned Parenthood clinic |
2 rows × 1 column
In [6]:
.load ./lembed0
.load ../../dist/vec0
insert into lembed_models(name, model) values
('default', lembed_model_from_file('./snowflake-arctic-embed-m-v1.5.d70deb40.f16.gguf'));Out [6]:
0 row × 0 column
In [9]:
create virtual table vec_articles using vec0(
article_id integer primary key,
headline_embedding float[768]
);
insert into vec_articles(article_id, headline_embedding)
select
rowid,
lembed(headline)
from articles;Out [9]:
0 row × 0 column
In [27]:
select
articles.headline,
vec_articles.distance
from vec_articles
left join articles on articles.rowid = vec_articles.article_id
where headline_embedding match lembed("planned parenthood")
and k = 10;Out [27]:
| headline | distance |
|---|---|
| Kamala Harris visits Planned Parenthood clinic | 0.492593914270401 |
| After Dobbs decision, more women are managing their own abortions | 0.5789032578468323 |
| Transforming Healthcare | 0.5822411179542542 |
| A timeline of Trump's many, many positions on abortion | 0.6101462841033936 |
| How a network of abortion pill providers works together in the wake of new threats | 0.6196886897087097 |
| 'Major hurdles': The reality check behind Biden's big abortion promise | 0.6198344826698303 |
| Trump's conflicting abortion stances are coming back to haunt him — and his party | 0.6198986768722534 |
| Where abortion rights could be on the ballot this fall: From the Politics Desk | 0.6201764345169067 |
| How the Biden campaign quickly mobilized on Trump's abortion stance | 0.633980393409729 |
| Battle over abortion heats up in Arizona — and could be on the 2024 ballot | 0.6341449022293091 |
10 rows × 2 columns
In [15]:
vacuum into 'tmp-artic2.slim.db';Out [15]:
0 row × 0 column
In [16]:
attach database 'tmp-artic2.slim.db' as slim;
drop table slim.vec_articles;Out [16]:
0 row × 0 column
In [21]:
create virtual table slim.vec_articles using vec0(
article_id integer primary key,
headline_embedding bit[768]
);
insert into slim.vec_articles(article_id, headline_embedding)
select
article_id,
vec_quantize_binary(headline_embedding)
from main.vec_articles;Out [21]:
0 row × 0 column
In [22]:
vacuum slim;Out [22]:
0 row × 0 column
In [28]:
select
slim.articles.headline,
slim.vec_articles.distance
from slim.vec_articles
left join slim.articles on slim.articles.rowid = slim.vec_articles.article_id
where headline_embedding match vec_quantize_binary(lembed("planned parenthood"))
and k = 10;Out [28]:
| headline | distance |
|---|---|
| Kamala Harris visits Planned Parenthood clinic | 139 |
| How a network of abortion pill providers works together in the wake of new threats | 151 |
| After Dobbs decision, more women are managing their own abortions | 153 |
| A timeline of Trump's many, many positions on abortion | 156 |
| Two of the country’s largest transgender rights organizations will merge | 158 |
| Transforming Healthcare | 158 |
| With Harris and Walz, Democrats put abortion rights at the top of the agenda | 159 |
| In states with strict abortion policies, simply seeing an OB/GYN for regular care can be difficult | 160 |
| Where abortion rights could be on the ballot this fall: From the Politics Desk | 161 |
| Map: Where medication abortion is and isn’t legal | 162 |
10 rows × 2 columns