From f3fd5ae9784235bee057d7b19de0fe4f12511bb9 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Wed, 17 Nov 2021 00:57:21 +0530 Subject: [PATCH] Improve code comments. Do not import unused modules in asymmetric search --- src/search_type/asymmetric.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/search_type/asymmetric.py b/src/search_type/asymmetric.py index 8aad26ae..fc4e72e4 100644 --- a/src/search_type/asymmetric.py +++ b/src/search_type/asymmetric.py @@ -2,10 +2,7 @@ # Standard Packages import json -import time import gzip -import os -import sys import re import argparse import pathlib @@ -80,7 +77,7 @@ def query(raw_query: str, model: TextSearchModel): hits = util.semantic_search(question_embedding, model.corpus_embeddings, top_k=model.top_k) hits = hits[0] # Get the hits for the first query - # Filter results using explicit filters + # Filter out entries that contain required words and do not contain blocked words hits = explicit_filter(hits, [entry[0] for entry in model.entries], required_words,blocked_words) @@ -95,9 +92,9 @@ def query(raw_query: str, model: TextSearchModel): for idx in range(len(cross_scores)): hits[idx]['cross-score'] = cross_scores[idx] - # Order results by cross encoder score followed by biencoder score - hits.sort(key=lambda x: x['score'], reverse=True) # sort by biencoder score - hits.sort(key=lambda x: x['cross-score'], reverse=True) # sort by cross encoder score + # Order results by cross-encoder score followed by bi-encoder score + hits.sort(key=lambda x: x['score'], reverse=True) # sort by bi-encoder score + hits.sort(key=lambda x: x['cross-score'], reverse=True) # sort by cross-encoder score return hits