Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/THUDM/P-tuning
/ functions
Functions
222 in github.com/THUDM/P-tuning
⨍
Functions
222
◇
Types & classes
43
↓ 13 callers
Method
shortenable
Return an instance of this string that is marked as shortenable
PT-Fewshot/data_utils/task_pvps.py:90
↓ 8 callers
Method
from_pretrained
Load a pretrained wrapper from a given path.
PT-Fewshot/pet/wrapper.py:190
↓ 6 callers
Method
generate_default_inputs
(self, batch: Dict[str, torch.Tensor])
PT-Fewshot/pet/wrapper.py:564
↓ 6 callers
Method
load
Load a config from a file.
PT-Fewshot/pet/config.py:18
↓ 5 callers
Method
_create_examples
(self, path: str, set_type: str, hypothesis_name: str = "hypothesis", premise_name: s
PT-Fewshot/data_utils/task_processors.py:147
↓ 5 callers
Method
_create_examples
(path: str, set_type: str)
PT-Fewshot/data_utils/task_processors.py:200
↓ 5 callers
Method
_create_examples
(path: str, set_type: str)
PT-Fewshot/data_utils/task_processors.py:240
↓ 5 callers
Method
_create_examples
(path: str, set_type: str)
PT-Fewshot/data_utils/task_processors.py:320
↓ 5 callers
Method
_create_examples
(path: str, set_type: str)
PT-Fewshot/data_utils/task_processors.py:359
↓ 5 callers
Method
_create_examples
(path: str, set_type: str)
PT-Fewshot/data_utils/task_processors.py:415
↓ 5 callers
Method
_create_examples
(path, set_type, seed=42, max_train_candidates_per_question: int = 10)
PT-Fewshot/data_utils/task_processors.py:472
↓ 5 callers
Method
eval
(self, eval_data: List[InputExample], per_gpu_eval_batch_size: int = 8,
PT-Fewshot/pet/wrapper.py:476
↓ 5 callers
Method
eval_dev
(self, dev_data, eval_config, n_gpu)
PT-Fewshot/pet/wrapper.py:453
↓ 5 callers
Function
get_verbalization_ids
Get the token ids corresponding to a verbalization :param word: the verbalization :param tokenizer: the tokenizer to use :param force
PT-Fewshot/pet/utils.py:265
↓ 5 callers
Function
load_file
(filename)
LAMA/data_utils/dataset.py:7
↓ 4 callers
Method
_create_examples
Creates examples for the training and dev sets.
PT-Fewshot/data_utils/custom_task_processor.py:95
↓ 4 callers
Method
_seq_length
(parts: List[Tuple[str, bool]], only_shortenable: bool = False)
PT-Fewshot/data_utils/task_pvps.py:168
↓ 4 callers
Method
add
Add a new input example to this list. :param example: the example to add :returns: `true` iff the example was actually added
PT-Fewshot/data_utils/task_processors.py:73
↓ 4 callers
Function
evaluate
(model: TransformerModelWrapper, eval_data: List[InputExample], config: EvalConfig)
PT-Fewshot/pet/modeling.py:206
↓ 3 callers
Method
encode
Encode an input example using this pattern-verbalizer pair. :param example: the input example to encode :param priming: whet
PT-Fewshot/data_utils/task_pvps.py:108
↓ 3 callers
Function
eq_div
Equally divide N examples among i buckets. For example, `eq_div(12,3) = [4,4,4]`.
PT-Fewshot/pet/utils.py:199
↓ 3 callers
Method
evaluate
(self, epoch_idx, evaluate_type)
LAMA/cli.py:117
↓ 3 callers
Method
get_labels
(self)
PT-Fewshot/data_utils/task_processors.py:174
↓ 3 callers
Function
load_examples
Load examples for a given task.
PT-Fewshot/data_utils/task_processors.py:584
↓ 3 callers
Method
remove_final_punc
Remove the final punctuation mark
PT-Fewshot/data_utils/task_pvps.py:95
↓ 3 callers
Method
verbalize
Return all verbalizations for a given label. :param label: the label :return: the list of verbalizations
PT-Fewshot/data_utils/task_pvps.py:205
↓ 2 callers
Method
_convert_single_mlm_logits_to_cls_logits
(self, logits: torch.Tensor)
PT-Fewshot/data_utils/task_pvps.py:225
↓ 2 callers
Method
_generate_dataset
(self, data: List[InputExample], labelled: bool = True)
PT-Fewshot/pet/wrapper.py:529
↓ 2 callers
Method
_remove_last
(parts: List[Tuple[str, bool]])
PT-Fewshot/data_utils/task_pvps.py:172
↓ 2 callers
Method
convert_mlm_logits_to_cls_logits
(self, mlm_labels: torch.Tensor, logits: torch.Tensor)
PT-Fewshot/data_utils/task_pvps.py:220
↓ 2 callers
Function
exact_match
Compute the exact match (EM) for a sequence of predictions and actual labels
PT-Fewshot/pet/utils.py:311
↓ 2 callers
Method
get_save_path
(self)
LAMA/cli.py:151
↓ 2 callers
Function
get_vocab_by_strategy
(args, tokenizer)
LAMA/data_utils/vocab.py:37
↓ 2 callers
Method
lowercase_first
Lowercase the first character
PT-Fewshot/data_utils/task_pvps.py:102
↓ 2 callers
Method
save
(self, best_ckpt)
LAMA/cli.py:166
↓ 2 callers
Method
save
Save this config to a file.
PT-Fewshot/pet/config.py:12
↓ 2 callers
Method
save
(self, path: str)
PT-Fewshot/pet/wrapper.py:163
↓ 2 callers
Function
save_logits
Save an array of logits to a file
PT-Fewshot/pet/utils.py:220
↓ 2 callers
Function
save_predictions
Save a sequence of predictions to a file
PT-Fewshot/pet/utils.py:228
↓ 2 callers
Function
token_wrapper
(args, token)
LAMA/data_utils/vocab.py:11
↓ 1 callers
Method
__init__
Create a new LogitsList. :param score: the corresponding PET model's score on the training set :param logits: the list of log
PT-Fewshot/pet/utils.py:31
↓ 1 callers
Method
__init__
Create a new task helper. :param wrapper: The wrapper for the language model being used.
PT-Fewshot/pet/task_helpers.py:34
↓ 1 callers
Function
__setup_custom_logger
(name: str)
PT-Fewshot/log.py:21
↓ 1 callers
Method
_build_mlm_logits_to_cls_logits_tensor
(self)
PT-Fewshot/data_utils/task_pvps.py:62
↓ 1 callers
Method
_convert_examples_to_features
(self, examples: List[InputExample], labelled: bool = True)
PT-Fewshot/pet/wrapper.py:547
↓ 1 callers
Method
_get_choice_log_probability
(self, batch, target_sequence, decoding_strategy: str = 'default')
PT-Fewshot/pet/task_helpers.py:128
↓ 1 callers
Method
_load_config
(path: str)
PT-Fewshot/pet/wrapper.py:231
↓ 1 callers
Method
_save_config
(self, path: str)
PT-Fewshot/pet/wrapper.py:225
↓ 1 callers
Function
_shuffle_and_restrict
Shuffle a list of examples and restrict it to a given maximum size. :param examples: the examples to shuffle and restrict :param num_exa
PT-Fewshot/data_utils/task_processors.py:32
↓ 1 callers
Function
_write_results
(path: str, all_results: Dict, dev32_results: Dict)
PT-Fewshot/pet/modeling.py:232
↓ 1 callers
Method
add_features_to_dict
Add special features from the ``meta`` dictionary of a sequence of features to the corresponding dictionary :param features: the sequ
PT-Fewshot/pet/task_helpers.py:67
↓ 1 callers
Method
add_special_input_features
Add special features to the ``meta`` dictionary of a feature set :param input_example: the input example considered :param in
PT-Fewshot/pet/task_helpers.py:58
↓ 1 callers
Method
build_model
Build a new model instance.
LAMA/megatron_11b/models.py:10
↓ 1 callers
Function
construct_generation_args
()
LAMA/cli.py:31
↓ 1 callers
Function
create_model
(args)
LAMA/p_tuning/models.py:4
↓ 1 callers
Method
embed_input
(self, queries)
LAMA/p_tuning/modeling.py:57
↓ 1 callers
Method
eval_step
Custom implementation of the eval step for this task. :param batch: a batch of examples :return: a tensor of logits
PT-Fewshot/pet/task_helpers.py:50
↓ 1 callers
Method
get_TREx_parameters
(self)
LAMA/cli.py:111
↓ 1 callers
Method
get_checkpoint
(self, epoch_idx, dev_hit1, test_hit1)
LAMA/cli.py:155
↓ 1 callers
Method
get_dev32_examples
(self, data_dir)
PT-Fewshot/data_utils/task_processors.py:141
↓ 1 callers
Method
get_dev_examples
(self, data_dir)
PT-Fewshot/data_utils/task_processors.py:132
↓ 1 callers
Function
get_embedding_layer
(args, model)
LAMA/p_tuning/models.py:29
↓ 1 callers
Method
get_input_features
Convert the given example into a set of input features
PT-Fewshot/pet/preprocessor.py:38
↓ 1 callers
Method
get_mask_positions
(self, input_ids: List[int])
PT-Fewshot/data_utils/task_pvps.py:214
↓ 1 callers
Function
get_model_and_tokenizer_class
(args)
LAMA/p_tuning/models.py:18
↓ 1 callers
Method
get_parts
Given an input example, apply a pattern to obtain two text sequences (text_a and text_b) containing exactly one mask token (or one co
PT-Fewshot/data_utils/task_pvps.py:193
↓ 1 callers
Method
get_query
(self, x_h, prompt_tokens, x_t=None)
LAMA/p_tuning/modeling.py:74
↓ 1 callers
Function
get_task_args
()
LAMA/megatron_11b/megatron_wrapper.py:12
↓ 1 callers
Method
get_task_name
(self)
LAMA/cli.py:142
↓ 1 callers
Method
get_test_examples
(self, data_dir)
PT-Fewshot/data_utils/task_processors.py:135
↓ 1 callers
Method
get_train_examples
(self, data_dir)
PT-Fewshot/data_utils/task_processors.py:129
↓ 1 callers
Method
get_unlabeled_examples
(self, data_dir)
PT-Fewshot/data_utils/task_processors.py:138
↓ 1 callers
Function
get_vocab
(model_name, strategy)
LAMA/data_utils/vocab.py:18
↓ 1 callers
Function
init_model
Initialize a new model from the given config.
PT-Fewshot/pet/modeling.py:36
↓ 1 callers
Function
init_vocab
(args)
LAMA/data_utils/vocab.py:5
↓ 1 callers
Method
load
Load a list from a file
PT-Fewshot/pet/utils.py:51
↓ 1 callers
Function
load_megatron_lm
Load Megatron_lm in fp16. A Tesla V100 is enough for inference. I haven't implement the parallel method for fine-tuning. You can refer to
LAMA/megatron_11b/megatron_wrapper.py:17
↓ 1 callers
Function
load_pet_configs
Load the model, training and evaluation configs for PET from the given command line arguments.
PT-Fewshot/cli.py:34
↓ 1 callers
Function
main
(relation_id=None)
LAMA/cli.py:224
↓ 1 callers
Function
main
()
PT-Fewshot/cli.py:70
↓ 1 callers
Method
predict
(self, prev_output_tokens, inputs_embeds, attention_mask, labels, encoder_out=None, incrementa
LAMA/megatron_11b/models.py:69
↓ 1 callers
Method
pretty_print
(self, tokenizer)
PT-Fewshot/pet/utils.py:141
↓ 1 callers
Function
set_seed
(args)
LAMA/cli.py:24
↓ 1 callers
Function
set_seed
Set RNG seeds for python's `random` module, numpy and torch
PT-Fewshot/pet/utils.py:190
↓ 1 callers
Method
to_dict
Serialize this instance to a Python dictionary.
PT-Fewshot/pet/utils.py:90
↓ 1 callers
Method
to_dict
Serialize this instance to a Python dictionary.
PT-Fewshot/pet/utils.py:150
↓ 1 callers
Method
to_json_string
Serialize this instance to a JSON string.
PT-Fewshot/pet/utils.py:95
↓ 1 callers
Method
to_json_string
Serialize this instance to a JSON string.
PT-Fewshot/pet/utils.py:155
↓ 1 callers
Method
to_list
(self)
PT-Fewshot/data_utils/task_processors.py:87
↓ 1 callers
Method
train
(self)
LAMA/cli.py:174
↓ 1 callers
Method
train
Train the underlying language model. :param train_data: the training examples to use :param per_gpu_train_batch_size: the nu
PT-Fewshot/pet/wrapper.py:235
↓ 1 callers
Function
train_pet
Train and evaluate a new PET model for a given task. :param model_config: the model configuration for each model corresponding to an individ
PT-Fewshot/pet/modeling.py:43
↓ 1 callers
Function
train_single_model
Train a single model. :param model: the model to train :param train_data: the training examples to use :param config: the training co
PT-Fewshot/pet/modeling.py:157
↓ 1 callers
Method
train_step
Custom implementation of the train step for this task. :param batch: a batch of examples :return: a scalar loss tensor
PT-Fewshot/pet/task_helpers.py:42
↓ 1 callers
Function
trim_input_ids
Trim a sequence of input ids by removing all padding tokens and keeping at most a specific number of mask tokens. :param input_ids: the seque
PT-Fewshot/pet/utils.py:287
↓ 1 callers
Method
truncate
Truncate two sequences of text to a predefined total maximum length
PT-Fewshot/data_utils/task_pvps.py:176
Method
__getitem__
(self, i)
LAMA/data_utils/dataset.py:34
Method
__getitem__
(self, index)
PT-Fewshot/pet/utils.py:183
Method
__init__
(self, args)
LAMA/cli.py:80
Method
__init__
(self, args, dictionary, embed_tokens, no_encoder_attn=False)
LAMA/megatron_11b/models.py:65
next →
1–100 of 222, ranked by callers