Spaces:
Running
Running
removed debugging messages now that search is working
Browse files- app.py +0 -2
- src/embeddings_search.py +3 -4
app.py
CHANGED
|
@@ -23,8 +23,6 @@ tfidf_query_docs = create_tfidf_search_function(
|
|
| 23 |
vectorizer_path = tfidf_vectorizer_path,
|
| 24 |
model_name = "facebook/fasttext-en-vectors")
|
| 25 |
|
| 26 |
-
print("generated the search functions!")
|
| 27 |
-
|
| 28 |
app = FastAPI()
|
| 29 |
|
| 30 |
|
|
|
|
| 23 |
vectorizer_path = tfidf_vectorizer_path,
|
| 24 |
model_name = "facebook/fasttext-en-vectors")
|
| 25 |
|
|
|
|
|
|
|
| 26 |
app = FastAPI()
|
| 27 |
|
| 28 |
|
src/embeddings_search.py
CHANGED
|
@@ -50,7 +50,6 @@ def sbert_query_factory(corpus_embeddings_df: pl.DataFrame, model: SentenceTrans
|
|
| 50 |
Returns:
|
| 51 |
Callable[[str], pl.DataFrame]: Function to compare the query string to the corpus and return results sorted by the cosine similarity.
|
| 52 |
"""
|
| 53 |
-
print("starting factory")
|
| 54 |
|
| 55 |
def do_sbert_query(query: str) -> pl.DataFrame:
|
| 56 |
"""
|
|
@@ -127,13 +126,13 @@ def create_embeddings_search_function_from_embeddings_df(model_name: str, embedd
|
|
| 127 |
Callable[[str], pl.DataFrame]: Function to compare the query string to the corpus and return results sorted by the cosine similarity.
|
| 128 |
|
| 129 |
"""
|
| 130 |
-
|
| 131 |
# Instantiate the sentence-transformer model:
|
| 132 |
sentence_model = SentenceTransformer(model_name).to(device = device)
|
| 133 |
-
|
| 134 |
# import the embeddings CSVs
|
| 135 |
block_embeddings_df = pl.read_parquet(embeddings_df_path)
|
| 136 |
-
|
| 137 |
# call the factory to make the search function and return it
|
| 138 |
return sbert_query_factory(corpus_embeddings_df = block_embeddings_df, model = sentence_model)
|
| 139 |
|
|
|
|
| 50 |
Returns:
|
| 51 |
Callable[[str], pl.DataFrame]: Function to compare the query string to the corpus and return results sorted by the cosine similarity.
|
| 52 |
"""
|
|
|
|
| 53 |
|
| 54 |
def do_sbert_query(query: str) -> pl.DataFrame:
|
| 55 |
"""
|
|
|
|
| 126 |
Callable[[str], pl.DataFrame]: Function to compare the query string to the corpus and return results sorted by the cosine similarity.
|
| 127 |
|
| 128 |
"""
|
| 129 |
+
|
| 130 |
# Instantiate the sentence-transformer model:
|
| 131 |
sentence_model = SentenceTransformer(model_name).to(device = device)
|
| 132 |
+
|
| 133 |
# import the embeddings CSVs
|
| 134 |
block_embeddings_df = pl.read_parquet(embeddings_df_path)
|
| 135 |
+
|
| 136 |
# call the factory to make the search function and return it
|
| 137 |
return sbert_query_factory(corpus_embeddings_df = block_embeddings_df, model = sentence_model)
|
| 138 |
|