easynlp.fewshot¶
PET¶
- 
class 
easynlp.fewshot_learning.fewshot_application.FewshotClassification(pretrained_model_name_or_path=None, user_defined_parameters=None, **kwargs)[source]¶ An application class for supporting fewshot learning (PET and P-tuning).
- 
class 
easynlp.fewshot_learning.fewshot_dataset.FewshotBaseDataset(pretrained_model_name_or_path, data_file, max_seq_length, first_sequence, input_schema=None, user_defined_parameters=None, label_name=None, second_sequence=None, label_enumerate_values=None, **kwargs)[source]¶ This is a dataset class for supporting fewshot learning.
Parameters: - pretrained_model_name_or_path -- The name of the path of th pretrained model for fewshot classification.
 - data_file -- The input data file.
 - max_seq_length -- The maximum sequence length for the transformer model.
 - first_sequence -- The name of the first sequence in the input schema.
 - input_schema -- The schema of the input data file.
 - user_defined_parameters -- The dict of user defined parameters for fewshot classification.
 - label_name -- The name of the label name in the input schema.
 - second_sequence -- The name of the second sequence in the input schema.
 - label_enumerate_values -- The string of all label values, seperated by comma.
 
- 
eval_metrics¶ 
- 
label_enumerate_values¶ 
- 
class 
easynlp.fewshot_learning.fewshot_evaluator.PromptEvaluator(valid_dataset, **kwargs)[source]¶ An evaluator class for supporting fewshot learning (PET and P-tuning).
- 
class 
easynlp.fewshot_learning.fewshot_predictor.FewshotPyModelPredictor(model_cls, saved_model_path, input_keys, user_defined_parameters, output_keys, **kwargs)[source]¶ This is the predictor class for supporting fewshot learning.
Parameters: - model_cls -- The classification model of the pretrained model for fewshot classification.
 - saved_model_path -- The path of the saved model.
 - input_keys -- The collection of input keys for prediction.
 - user_defined_parameters -- The dict of user defined parameters for fewshot prediction.
 - output_keys -- The collection of output keys for prediction.
 
- 
class 
easynlp.fewshot_learning.fewshot_predictor.PromptPredictor(model_dir, model_cls=None, user_defined_parameters=None, *args, **kwargs)[source]¶ This is the predictor class for supporting prompt-based fewshot learning.
Parameters: - model_dir -- The path of the model
 - model_cls -- The classification model of the pretrained model for fewshot classification.
 - user_defined_parameters -- The dict of user defined parameters for fewshot prediction.
 
CPT¶
- 
class 
easynlp.fewshot_learning.fewshot_application.CPTClassification(pretrained_model_name_or_path=None, user_defined_parameters=None, **kwargs)[source]¶ An application class for supporting CPT fewshot learning.
- 
class 
easynlp.fewshot_learning.fewshot_application.CircleLoss(margin: float = 0.4, gamma: float = 64, k: float = 1, distance_function='cos')[source]¶ 
- 
class 
easynlp.fewshot_learning.fewshot_evaluator.CPTEvaluator(valid_dataset, *args, **kwargs)[source]¶ An evaluator class for supporting CPT fewshot learning.
- 
class 
easynlp.fewshot_learning.fewshot_predictor.CPTPredictor(model_dir, model_cls=None, user_defined_parameters=None, *args, **kwargs)[source]¶ This is the predictor class for supporting CPT fewshot learning.
Parameters: - model_dir -- The path of the model
 - model_cls -- The classification model of the pretrained model for fewshot classification.
 - user_defined_parameters -- The dict of user defined parameters for fewshot prediction.