Update app.py
Browse files
app.py
CHANGED
|
@@ -11,12 +11,12 @@ from datasets import load_dataset
|
|
| 11 |
|
| 12 |
#@st.cache
|
| 13 |
@st.cache_data
|
| 14 |
-
def read_data(dataset_repo='dhmeltzer/
|
| 15 |
"""Read the data from huggingface."""
|
| 16 |
return load_dataset(dataset_repo)['validation_asks']
|
| 17 |
|
| 18 |
@st.cache_data
|
| 19 |
-
def load_faiss_index(path_to_faiss="./
|
| 20 |
"""Load and deserialize the Faiss index."""
|
| 21 |
with open(path_to_faiss, "rb") as h:
|
| 22 |
data = pickle.load(h)
|
|
@@ -25,11 +25,9 @@ def load_faiss_index(path_to_faiss="./faiss_index_small.pickle"):
|
|
| 25 |
def main():
|
| 26 |
# Load data and models
|
| 27 |
data = read_data()
|
| 28 |
-
#model = load_bert_model()
|
| 29 |
-
#tok = load_tokenizer()
|
| 30 |
faiss_index = load_faiss_index()
|
| 31 |
|
| 32 |
-
model_id="sentence-transformers/
|
| 33 |
|
| 34 |
api_url = f"https://api-inference.huggingface.co/pipeline/feature-extraction/{model_id}"
|
| 35 |
headers = {"Authorization": f"Bearer {st.secrets['HF_token']}"}
|
|
@@ -65,6 +63,7 @@ def main():
|
|
| 65 |
|
| 66 |
|
| 67 |
st.write(f"**Title**: {row['title']}")
|
|
|
|
| 68 |
st.write(f"**Score**: {row['answers']['score'][0]}")
|
| 69 |
st.write(f"**Top Answer**: {answers[0]}")
|
| 70 |
st.write("-"*20)
|
|
|
|
| 11 |
|
| 12 |
#@st.cache
|
| 13 |
@st.cache_data
|
| 14 |
+
def read_data(dataset_repo='dhmeltzer/ELI5_embedded'):
|
| 15 |
"""Read the data from huggingface."""
|
| 16 |
return load_dataset(dataset_repo)['validation_asks']
|
| 17 |
|
| 18 |
@st.cache_data
|
| 19 |
+
def load_faiss_index(path_to_faiss="./faiss_index.pickle"):
|
| 20 |
"""Load and deserialize the Faiss index."""
|
| 21 |
with open(path_to_faiss, "rb") as h:
|
| 22 |
data = pickle.load(h)
|
|
|
|
| 25 |
def main():
|
| 26 |
# Load data and models
|
| 27 |
data = read_data()
|
|
|
|
|
|
|
| 28 |
faiss_index = load_faiss_index()
|
| 29 |
|
| 30 |
+
model_id="sentence-transformers/all-MiniLM-L6-v2"
|
| 31 |
|
| 32 |
api_url = f"https://api-inference.huggingface.co/pipeline/feature-extraction/{model_id}"
|
| 33 |
headers = {"Authorization": f"Bearer {st.secrets['HF_token']}"}
|
|
|
|
| 63 |
|
| 64 |
|
| 65 |
st.write(f"**Title**: {row['title']}")
|
| 66 |
+
st.write(f"**Split**: {row['split']}")
|
| 67 |
st.write(f"**Score**: {row['answers']['score'][0]}")
|
| 68 |
st.write(f"**Top Answer**: {answers[0]}")
|
| 69 |
st.write("-"*20)
|