[ERNIE-Gram: Pre-Training with Explicitly N-Gram Masked Language Modeling for Natural Language Understanding](https://arxiv.org/abs/2010.12148). NAACL-HLT 2021: 1702-1715
[1] Xiao, Dongling, Yu-Kun Li, Han Zhang, Yu Sun, Hao Tian, Hua Wu, and Haifeng Wang. “ERNIE-Gram: Pre-Training with Explicitly N-Gram Masked Language Modeling for Natural Language Understanding.” ArXiv:2010.12148 [Cs].
[2] Yingqi Qu, Yuchen Ding, Jing Liu, Kai Liu, Ruiyang Ren, Wayne Xin Zhao, Daxiang Dong, Hua Wu, Haifeng Wang:
RocketQA: An Optimized Training Approach to Dense Passage Retrieval for Open-Domain Question Answering. NAACL-HLT 2021: 5835-5847
# Copyright (c) 2021 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 applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
importargparse
importos
importsys
importnumpyasnp
importpaddle
frompaddleimportinference
fromscipy.specialimportsoftmax
frompaddlenlp.dataimportPad,Tuple
frompaddlenlp.datasetsimportload_dataset
frompaddlenlp.transformersimportAutoTokenizer
frompaddlenlp.utils.logimportlogger
sys.path.append(".")
# yapf: disable
parser=argparse.ArgumentParser()
parser.add_argument("--model_dir",type=str,required=True,help="The directory to static model.")
parser.add_argument("--input_file",type=str,required=True,help="The test set file.")
parser.add_argument("--max_seq_length",default=128,type=int,help="The maximum total input sequence length after tokenization. Sequences longer than this will be truncated, sequences shorter will be padded.")
parser.add_argument("--batch_size",default=32,type=int,help="Batch size per GPU/CPU for training.")
parser.add_argument('--device',choices=['cpu','gpu','xpu'],default="gpu",help="Select which device to train model, defaults to gpu.")
parser.add_argument('--use_tensorrt',default=False,type=eval,choices=[True,False],help='Enable to use tensorrt to speed up.')
parser.add_argument("--test_file",type=str,required=True,help="The full path of test file")
parser.add_argument("--max_seq_length",default=128,type=int,help="The maximum total input sequence length after tokenization. Sequences longer than this will be truncated, sequences shorter will be padded.")
parser.add_argument("--batch_size",default=32,type=int,help="Batch size per GPU/CPU for training.")
parser.add_argument('--model_name_or_path',default="rocketqa-base-cross-encoder",help="The pretrained model used for training")
parser.add_argument("--init_from_ckpt",type=str,default=None,help="The path of checkpoint to be loaded.")
parser.add_argument("--seed",type=int,default=1000,help="Random seed for initialization.")
parser.add_argument('--device',choices=['cpu','gpu'],default="gpu",help="Select which device to train model, defaults to gpu.")
parser.add_argument("--params_path",type=str,required=True,default='./checkpoint/model_900/model_state.pdparams',help="The path to model parameters to be loaded.")
parser.add_argument("--output_path",type=str,default='./output',help="The path of model parameter in static graph to be saved.")
parser.add_argument('--model_name_or_path',default="rocketqa-base-cross-encoder",help="The pretrained model used for training")
default='inference.pdiparams',help="The name of file to load all parameters. It is only used for the case that all parameters were saved in a single binary file. If parameters were saved in separate files, set it as None. Default: None.")
parser.add_argument("--params_path",type=str,required=True,default="checkpoints/model_900/model_state.pdparams",help="The path to model parameters to be loaded.")
parser.add_argument("--max_seq_length",type=int,default=128,help="The maximum total input sequence length after tokenization. Sequences longer than this will be truncated, sequences shorter will be padded.")
parser.add_argument("--batch_size",type=int,default=32,help="Batch size per GPU/CPU for training.")
parser.add_argument("--test_set",type=str,required=True,help="The full path of test_set.")