diff --git a/api/get_blocks.py b/api/get_blocks.py index 6f30cb1..965d41f 100644 --- a/api/get_blocks.py +++ b/api/get_blocks.py @@ -47,13 +47,25 @@ def get_embedding(text: str) -> np.ndarray: # Get the k blocks most semantically similar to the query. def get_top_k_blocks(data, user_query: str, k: int = 10) -> List[Block]: + # print time + t = time.time() + # Get the embedding for the query. query_embedding = get_embedding(user_query) - + + t1 = time.time() + print("Time to get embedding: ", t1 - t) + similarity_scores = np.dot(data["embeddings"], query_embedding) # big fat calculation + + t2 = time.time() + print("Time to get similarity scores: ", t2 - t1) top_k_block_indices = list(reversed(np.argpartition(similarity_scores, -k)[-k:])) # Get the top k indices of the blocks + t3 = time.time() + print("Time to get top k indices: ", t3 - t2) + top_k_metadata_indexes = [data["embeddings_metadata_index"][i] for i in top_k_block_indices] top_k_texts = [strip_block(data["embedding_strings"][i]) for i in top_k_block_indices] top_k_metadata = [data["metadata"][i] for i in top_k_metadata_indexes] diff --git a/web/src/styles/globals.css b/web/src/styles/globals.css index 2e88fa2..f304db2 100644 --- a/web/src/styles/globals.css +++ b/web/src/styles/globals.css @@ -15,6 +15,8 @@ main { max-width: 800px; margin: 0 auto; padding: 0 2rem; + margin-top: 4rem; + margin-bottom: 4rem; } a {