Skip to content

Commit

Permalink
[neural search][fix bug of evaluate.py] (#7832)
Browse files Browse the repository at this point in the history
* [fix][fix bug of evaluate.py]

* Update evaluate.py

* Update evaluate.py
  • Loading branch information
ZeyuTeng96 authored Jan 11, 2024
1 parent ee4b9dd commit a1d1aee
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions applications/neural_search/recall/in_batch_negative/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,29 @@
# limitations under the License.

import argparse
import time

import numpy as np

import time

parser = argparse.ArgumentParser()
parser.add_argument("--similar_text_pair", type=str,
default='', help="The full path of similar pair file")
parser.add_argument("--recall_result_file", type=str,
default='', help="The full path of recall result file")
parser.add_argument("--recall_num", type=int, default=10,
help="Most similar number of doc recalled from corpus per query")
parser.add_argument(
"--similar_text_pair",
type=str,
default="",
help="The full path of similar pair file",
)
parser.add_argument(
"--recall_result_file",
type=str,
default="",
help="The full path of recall result file",
)
parser.add_argument(
"--recall_num",
type=int,
default=10,
help="Most similar number of doc recalled from corpus per query",
)


args = parser.parse_args()
Expand Down Expand Up @@ -62,7 +73,6 @@ def recall(rs, N=10):
with open(args.recall_result_file, "r", encoding="utf-8") as f:
relevance_labels = []
for index, line in enumerate(f):

if index % args.recall_num == 0 and index != 0:
rs.append(relevance_labels)
relevance_labels = []
Expand All @@ -73,6 +83,8 @@ def recall(rs, N=10):
else:
relevance_labels.append(0)

rs.append(relevance_labels)

recall_N = []
recall_num = [1, 5, 10, 20, 50]
for topN in recall_num:
Expand Down

0 comments on commit a1d1aee

Please sign in to comment.