repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
RocketQA
RocketQA-main/examples/jina_example/rocketqa_reranker/executor.py
import numpy as np import rocketqa from jina import Executor, Document, DocumentArray, requests from jina.types.score import NamedScore class RocketQAReranker(Executor): """ Re-rank the `matches` of a Document based on the relevance to the question stored in the `text` field with RocketQA matching model. ...
2,516
43.946429
143
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/metric/generate_candrank.py
import csv import sys from collections import defaultdict score_f = sys.argv[1] id_f = sys.argv[2] #id_f = 'marco_joint_qtp/qtp.test.id' #id_f = 'dev.es_1000.id' outputf = 'metric/ranking_res' scores = [] q_ids = [] p_ids = [] q_dic = defaultdict(list) with open(score_f, 'r') as f: for line in f: scores....
950
20.133333
62
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/metric/tokenizers.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. """ Most of the tokenizers code here is copied from DrQA codebase to avoid adding extra dependency ...
8,194
29.692884
94
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/metric/nq_eval_rerank.py
import numpy as np from tqdm import tqdm import random import sys from tokenizers import SimpleTokenizer from tokenizers import has_answer f_answer = open('corpus/nq/test.answers.txt', 'r') #f_answer = open('nq.58812.ans', 'r') print('reading text') p_text = [] for i in range(8): f_p_text = open('corpus/nq/para_...
1,972
21.94186
61
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/metric/msmarco_eval.py
""" This module computes evaluation metrics for MSMARCO dataset on the ranking task. Command line: python msmarco_eval_ranking.py <path_to_reference_file> <path_to_candidate_file> Creation Date : 06/12/2018 Last Modified : 1/21/2019 Authors : Daniel Campos <dacamp@microsoft.com>, Rutger van Haasteren <ruvanh@microsoft....
8,406
38.843602
161
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/metric/nq_eval.py
import sys import numpy as np sys.path.append('data_process/') sys.path.append('metric/') from dpr.utils.tokenizers import SimpleTokenizer import utils import unicodedata recall_cands_file = sys.argv[1] topk = 100 answers = utils.load_answers('test') q_text, p_text, p_title = utils.load_corpus(corpus='nq', q_type='te...
2,204
31.426471
73
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/metric/dpr/utils/tokenizers.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. """ Most of the tokenizers code here is copied from DrQA codebase to avoid adding extra dependency ...
5,679
28.278351
94
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/optimization.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
6,674
38.497041
106
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/tokenization.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required...
14,348
32.921986
84
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/inference_de.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
4,126
31.496063
96
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/finetune_args.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
8,173
67.116667
134
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/merge.py
import sys total_part = 8 shift = int(sys.argv[1]) top = int(sys.argv[2]) f_list = [] for part in range(total_part): f0 = open('res.top%s-part%s' % (top, part)) f_list.append(f0) line_list = [] for part in range(total_part): line = f_list[part].readline() line_list.append(line) out = open('output/re...
1,230
24.645833
81
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/batching.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
2,683
33.410256
78
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/train_je.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
17,415
36.86087
96
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/index_search.py
import sys import time import faiss import math import numpy as np def read_embed(file_name, dim=768, bs=3000): if file_name.endswith('npy'): i = 0 emb_np = np.load(file_name) while(i < len(emb_np)): vec_list = emb_np[i:i+bs] i += bs yield vec_list el...
1,948
27.661765
84
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/finetune/dual_encoder_infer.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
6,365
34.366667
95
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/finetune/joint_encoder.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
18,127
34.475538
132
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/reader/reader_de_infer.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
13,641
36.581267
97
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/reader/task_reader_shuffle.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
17,374
39.595794
138
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/utils/cards.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
1,008
31.548387
74
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/utils/args.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
2,996
34.678571
119
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/utils/init.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
3,632
35.33
108
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/utils/fp16.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
9,177
44.661692
81
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/model/transformer_encoder.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
12,649
35.666667
91
py
RocketQA
RocketQA-main/research/RocketQAv2_EMNLP2021/model/src/model/ernie.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
11,151
39.70073
92
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/metric/msmarco_eval.py
""" This module computes evaluation metrics for MSMARCO dataset on the ranking task. Command line: python msmarco_eval_ranking.py <path_to_reference_file> <path_to_candidate_file> Creation Date : 06/12/2018 Last Modified : 1/21/2019 Authors : Daniel Campos <dacamp@microsoft.com>, Rutger van Haasteren <ruvanh@microsoft....
8,406
38.843602
161
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/metric/nq_eval.py
import sys import numpy as np sys.path.append('data_process/') sys.path.append('metric/') from dpr.utils.tokenizers import SimpleTokenizer import utils import unicodedata recall_cands_file = sys.argv[1] topk = 100 answers = utils.load_answers('test') q_text, p_text, p_title = utils.load_corpus(corpus='nq', q_type='te...
2,204
31.426471
73
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/metric/dpr/__init__.py
0
0
0
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/metric/dpr/utils/tokenizers.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. """ Most of the tokenizers code here is copied from DrQA codebase to avoid adding extra dependency ...
5,679
28.278351
94
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/metric/dpr/utils/__init__.py
0
0
0
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/data_process/construct_marco_train_ce.py
import sys import random sys.path.append('data_process/') import utils recall_cands_file = sys.argv[1] outfile = sys.argv[2] random_seed = 111 rng = random.Random(random_seed) neg_cnt = 4 q_text, p_text, p_title = utils.load_corpus(corpus='marco', q_type='train') pos_qp, pos_qp_new = utils.load_pos_examples(p_text)...
1,050
26.657895
91
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/data_process/construct_marco_train_de.py
import sys import random sys.path.append('data_process/') import utils recall_cands_file = sys.argv[1] ce_score_file = sys.argv[2] outfile = sys.argv[3] random_seed = 111 rng = random.Random(random_seed) neg_cnt = 4 ce_threshold_neg = 0.1 ce_threshold_pos = 0.9 q_text, p_text, p_title = utils.load_corpus(corpus='ma...
1,665
29.290909
88
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/data_process/construct_nq_train_de.py
import sys import random import utils recall_cands_file = sys.argv[1] ce_score_file = sys.argv[2] outfile = sys.argv[3] neg_cnt = 4 ce_threshold_neg = 0.1 ce_threshold_pos = 0.9 q_text, p_text, p_title = utils.load_corpus(corpus='nq', q_type='train') answers = utils.load_answers(q_type='train') cand_qp_all, train_qi...
1,132
30.472222
105
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/data_process/utils.py
import sys import os cur_path = os.path.dirname(os.path.realpath(__file__)) corpus_path = 'corpus/' def load_id_text(file_name): """load tsv files""" id_text = {} with open(file_name) as inp: for line in inp: line = line.strip() id, text = line.split('\t') id_te...
3,845
31.05
78
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/data_process/construct_nq_train_ce.py
import sys import random sys.path.append('data_process/') import utils recall_cands_file = sys.argv[1] outfile = sys.argv[2] random_seed = 111 rng = random.Random(random_seed) q_text, p_text, p_title = utils.load_corpus(corpus='nq', q_type='train') answers = utils.load_answers(q_type='train') cand_qp_all, train_qids...
1,034
30.363636
105
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/data_process/construct_unlabel_train_de.py
import sys import random sys.path.append('data_process/') import utils recall_cands_file = sys.argv[1] ce_score_file = sys.argv[2] outfile = sys.argv[3] corpus = sys.argv[4] random_seed = 111 rng = random.Random(random_seed) neg_cnt = 1 if corpus == 'marco': neg_cnt = 4 ce_threshold_neg = 0.1 ce_threshold_pos = ...
1,692
26.754098
88
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/train_de.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
14,023
36.198939
163
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/optimization.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
5,185
37.701493
83
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/tokenization.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required...
14,348
32.921986
84
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/inference_de.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
4,126
31.496063
96
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/finetune_args.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
8,197
67.890756
127
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/merge.py
import sys total_part = 8 shift = int(sys.argv[1]) top = int(sys.argv[2]) f_list = [] for part in range(total_part): f0 = open('res.top%s-part%s' % (top, part)) f_list.append(f0) line_list = [] for part in range(total_part): line = f_list[part].readline() line_list.append(line) out = open('output/re...
1,230
24.645833
81
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/batching.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
2,683
33.410256
78
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/index_search.py
import sys import time import faiss import math import numpy as np def read_embed(file_name, dim=768, bs=3000): if file_name.endswith('npy'): i = 0 emb_np = np.load(file_name) while(i < len(emb_np)): vec_list = emb_np[i:i+bs] i += bs yield vec_list el...
1,948
27.661765
84
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/train_ce.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
14,978
35.713235
96
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/finetune/dual_encoder_infer.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
6,355
34.311111
95
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/finetune/dual_encoder.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
15,329
35.327014
132
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/finetune/__init__.py
0
0
0
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/finetune/cross_encoder.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
11,546
33.885196
132
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/reader/reader_de.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
17,266
39.437939
161
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/reader/reader_de_infer.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
13,641
36.581267
97
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/reader/reader_ce.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
12,992
36.770349
138
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/reader/__init__.py
0
0
0
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/utils/args.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
2,996
34.678571
119
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/utils/init.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
2,695
34.946667
108
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/utils/__init__.py
0
0
0
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/model/transformer_encoder.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
12,649
35.666667
91
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/model/__init__.py
0
0
0
py
RocketQA
RocketQA-main/research/RocketQA_NAACL2021/model/src/model/ernie.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
10,858
38.631387
92
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/metric/tokenizers.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. """ Most of the tokenizers code here is copied from DrQA codebase to avoid adding extra dependency ...
5,679
28.278351
94
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/metric/msmarco_eval.py
""" This module computes evaluation metrics for MSMARCO dataset on the ranking task. Command line: python msmarco_eval_ranking.py <path_to_reference_file> <path_to_candidate_file> Creation Date : 06/12/2018 Last Modified : 1/21/2019 Authors : Daniel Campos <dacamp@microsoft.com>, Rutger van Haasteren <ruvanh@microsoft....
8,406
38.843602
161
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/metric/nq_eval.py
import sys import numpy as np sys.path.append('data_process/') sys.path.append('metric/') from tokenizers import SimpleTokenizer import utils import unicodedata recall_cands_file = sys.argv[1] topk = 100 answers = utils.load_answers('test') q_text, p_text, p_title = utils.load_corpus(corpus='nq', q_type='test') cand_...
2,194
31.279412
73
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/data_process/utils.py
import sys import os cur_path = os.path.dirname(os.path.realpath(__file__)) corpus_path = 'corpus/' def load_id_text(file_name): """load tsv files""" id_text = {} with open(file_name) as inp: for line in inp: line = line.strip() id, text = line.split('\t') id_te...
3,844
31.310924
78
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/train_de.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
14,023
36.198939
163
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/optimization.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
5,185
37.701493
83
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/tokenization.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required...
14,348
32.921986
84
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/inference_de.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
4,126
31.496063
96
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/finetune_args.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
8,257
67.816667
127
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/merge.py
import sys total_part = 8 shift = int(sys.argv[1]) top = int(sys.argv[2]) f_list = [] for part in range(total_part): f0 = open('res.top%s-part%s' % (top, part)) f_list.append(f0) line_list = [] for part in range(total_part): line = f_list[part].readline() line_list.append(line) out = open('output/re...
1,230
24.645833
81
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/batching.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
2,683
33.410256
78
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/index_search.py
import sys import time import faiss import math import numpy as np def read_embed(file_name, dim=768, bs=3000): if file_name.endswith('npy'): i = 0 emb_np = np.load(file_name) while(i < len(emb_np)): vec_list = emb_np[i:i+bs] i += bs yield vec_list el...
1,948
27.661765
84
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/finetune/dual_encoder_infer.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
6,359
34.333333
95
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/finetune/dual_encoder.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
16,226
35.963554
132
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/reader/reader_de.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
17,266
39.437939
161
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/reader/reader_de_infer.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
13,641
36.581267
97
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/utils/args.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
2,996
34.678571
119
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/utils/init.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
2,695
34.946667
108
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/model/transformer_encoder.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
12,649
35.666667
91
py
RocketQA
RocketQA-main/research/PAIR_ACL2021/model/src/model/ernie.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
10,858
38.631387
92
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/metric/convert_recall_res_to_json.py
# Convert the retrieval output to standard json format # loading files: para.map.json -> mapping from row id of para to pid in md5 # loading files: q2qid.dev.json -> mapping from query in Chinese to qid in md5 import hashlib import json import sys from collections import defaultdict q2id_map = sys.argv[1] p2id_map =...
983
25.594595
78
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/metric/convert_rerank_res_to_json.py
import csv import sys import json from collections import defaultdict score_f = sys.argv[1] id_f = sys.argv[2] outputf = 'output/cross_res.json' scores = [] q_ids = [] p_ids = [] q_dic = defaultdict(list) with open(score_f, 'r') as f: for line in f: scores.append(float(line.strip())) with open(id_f, 'r...
983
19.5
54
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/metric/evaluation.py
""" This module computes evaluation metrics for MSMARCO dataset on the ranking task. Command line: python msmarco_eval_ranking.py <path_to_reference_file> <path_to_candidate_file> Creation Date : 06/12/2018 Last Modified : 1/21/2019 Authors : Daniel Campos <dacamp@microsoft.com>, Rutger van Haasteren <ruvanh@microsoft....
6,849
36.845304
161
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/train_de.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
14,101
36.110526
163
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/optimization.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
5,185
37.701493
83
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/tokenization.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required...
14,348
32.921986
84
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/inference_de.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
4,204
31.346154
96
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/finetune_args.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
8,197
67.890756
127
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/merge.py
import sys shift = int(sys.argv[1]) top = int(sys.argv[2]) total_part = int(sys.argv[3]) f_list = [] for part in range(total_part): f0 = open('output/res.top%s-part%s' % (top, part)) f_list.append(f0) line_list = [] for part in range(total_part): line = f_list[part].readline() line_list.append(line) ...
1,260
25.270833
81
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/batching.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
2,683
33.410256
78
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/index_search.py
import sys import time import faiss import math import numpy as np def read_embed(file_name, dim=768, bs=3000): if file_name.endswith('npy'): i = 0 emb_np = np.load(file_name) while(i < len(emb_np)): vec_list = emb_np[i:i+bs] i += bs yield vec_list el...
1,969
27.970588
84
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/train_ce.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
15,056
35.635036
96
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/finetune/dual_encoder_infer.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
6,355
34.311111
95
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/finetune/dual_encoder.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
15,265
35.175355
132
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/finetune/__init__.py
0
0
0
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/finetune/cross_encoder.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
11,546
33.885196
132
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/reader/reader_de.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
17,266
39.437939
161
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/reader/reader_de_infer.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
13,641
36.581267
97
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/reader/reader_ce.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
12,992
36.770349
138
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/reader/__init__.py
0
0
0
py
RocketQA
RocketQA-main/research/DuReader-Retrieval-Baseline/src/utils/args.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
2,996
34.678571
119
py