Spaces:
Sleeping
Sleeping
feat: db query
Browse files
app.py
CHANGED
|
@@ -2,19 +2,24 @@ from huggingface_hub import hf_hub_download
|
|
| 2 |
from gensim.models import Word2Vec
|
| 3 |
|
| 4 |
import faiss
|
|
|
|
| 5 |
|
| 6 |
import streamlit as st
|
| 7 |
import pandas as pd
|
| 8 |
import dask.dataframe as dd
|
| 9 |
|
| 10 |
@st.cache_data
|
| 11 |
-
def
|
| 12 |
-
|
| 13 |
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
@st.cache_data
|
| 20 |
def get_model():
|
|
|
|
| 2 |
from gensim.models import Word2Vec
|
| 3 |
|
| 4 |
import faiss
|
| 5 |
+
import duckdb
|
| 6 |
|
| 7 |
import streamlit as st
|
| 8 |
import pandas as pd
|
| 9 |
import dask.dataframe as dd
|
| 10 |
|
| 11 |
@st.cache_data
|
| 12 |
+
def get_db(path='arxiv.db'):
|
| 13 |
+
con = duckdb.connect(path)
|
| 14 |
|
| 15 |
|
| 16 |
+
def query_neighbours(rows: list):
|
| 17 |
+
con = get_db()
|
| 18 |
+
placeholders = ",".join("?" for _ in rows)
|
| 19 |
+
return con.execute(
|
| 20 |
+
f"SELECT * FROM arxiv WHERE column0 IN ({placeholders})",
|
| 21 |
+
rows,
|
| 22 |
+
).fetchall()
|
| 23 |
|
| 24 |
@st.cache_data
|
| 25 |
def get_model():
|