code stringlengths 17 6.64M |
|---|
def set_seed(args):
random.seed(args.seed)
np.random.seed(args.seed)
torch.manual_seed(args.seed)
if (args.n_gpu > 0):
torch.cuda.manual_seed_all(args.seed)
|
def _sorted_checkpoints(args, checkpoint_prefix='checkpoint', use_mtime=False) -> List[str]:
ordering_and_checkpoint_path = []
glob_checkpoints = glob.glob(os.path.join(args.output_dir, '{}-*'.format(checkpoint_prefix)))
for path in glob_checkpoints:
if use_mtime:
ordering_and_checkpoi... |
def _rotate_checkpoints(args, checkpoint_prefix='checkpoint', use_mtime=False) -> None:
if (not args.save_total_limit):
return
if (args.save_total_limit <= 0):
return
checkpoints_sorted = _sorted_checkpoints(args, checkpoint_prefix, use_mtime)
if (len(checkpoints_sorted) <= args.save_t... |
def mask_tokens(inputs: torch.Tensor, tokenizer: PreTrainedTokenizer, args) -> Tuple[(torch.Tensor, torch.Tensor)]:
' Prepare masked tokens inputs/labels for masked language modeling: 80% MASK, 10% random, 10% original. '
if (tokenizer.mask_token is None):
raise ValueError('This tokenizer does not hav... |
def train(args, train_dataset, model: PreTrainedModel, tokenizer: PreTrainedTokenizer) -> Tuple[(int, float)]:
' Train the model '
if (args.local_rank in [(- 1), 0]):
tb_writer = SummaryWriter()
args.train_batch_size = (args.per_gpu_train_batch_size * max(1, args.n_gpu))
def collate(examples:... |
class AverageMeter(object):
'Computes and stores the average and current value'
def __init__(self):
self.reset()
def reset(self):
self.avg = 0
self.sum = 0
self.count = 0
def update(self, val, n=1):
self.sum += (val * n)
self.count += n
def get_a... |
def evaluate(args, model: PreTrainedModel, tokenizer: PreTrainedTokenizer, prefix='') -> Dict:
eval_output_dir = args.output_dir
eval_dataset = load_and_cache_examples(args, tokenizer, evaluate=True)
if (args.local_rank in [(- 1), 0]):
os.makedirs(eval_output_dir, exist_ok=True)
args.eval_batc... |
def main():
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--train_data_file', default=None, type=str, required=True, help='The input training data file (a text file).')
parser.add_argument('--output_dir', type=str, required=True, help='The ou... |
class Loader(abc.ABC):
ALLOW_UNSHARED = {}
ALLOW_UNLOADEDED = {}
@abc.abstractmethod
def load_from_saved_pipeline(self, args, to_original=True, **kw):
raise NotImplementedError()
def _check_load_matching(self, original_state, unified_state):
if (not (self.ALLOW_UNSHARED or self.A... |
def base_checkoint_name(name_prefix, stage):
return f'{name_prefix}_Partition{stage}.pt'
|
class HFLoader(Loader):
IS_HUGGINFACE_TRANSFORMER = True
def __init__(self, hf_transformers_model_class=AutoModel):
super().__init__()
self.MODEL_CLASS = hf_transformers_model_class
def load_from_saved_pipeline(self, args, to_original=True, **kw):
cfg = args.model
partiti... |
class T5HFLoader(HFLoader):
def __init__(self, hf_transformers_model_class=T5ForConditionalGeneration):
super().__init__(hf_transformers_model_class=hf_transformers_model_class)
def substitue_state_dict_keys_back_to_original(self, training_state_dict):
d = dict()
for (k, v) in traini... |
class NaiveModelParallelSplitter():
def __init__(self):
pass
@staticmethod
def spread_on_devices(model: torch.nn.Module, devices: Optional[List]=None):
' Spread a transformers model on several devices by moving block on several devices (simple model parallelism)\n The blocks o... |
def decorate_args_and_kwargs_to_deivce(func, device):
"Decorate torch.nn.Module forward function by moving all inputs and outputs to device\n\n Note that we cannot easily use `forward_pre_hook` to move tensors around since this type of hooks currently\n only act on the positional arguments send to t... |
def get_my_send_recv_ranks(pipe_config: PipelineConfig, stage_id, stage_to_rank_map=None, prefer_seq_sends=True):
def ranks_in_stage(given_stage):
if stage_to_rank_map:
return stage_to_rank_map[given_stage]
else:
return [given_stage]
stages = pipe_config.d['stages']
... |
class PartitioningConfigParser():
def __init__(self, cfg, rank, bs_train, bs_eval, handler=None, send_target_in_pipe=False, prefer_seq_sends=True):
if (handler is None):
handler = AVAILABLE_MODELS.get(cfg)
if (handler is None):
raise ValueError(f'Model {cfg} not fo... |
def is_shared_parameter(tensor_scope):
return ('Parameter' in tensor_scope)
|
def _check_shared_parameters(pipe_config: PipelineConfig):
shared = defaultdict(set)
for (i, s) in pipe_config.d['stages'].items():
for n in chain(s['inputs'], s['outputs']):
if is_shared_parameter(n):
shared[i].add(n)
if shared:
pprint(f'Shared Parameters: {sha... |
def _import_handlers_from_dir(tasks_dir=os.path.dirname(__file__), module_name='.models.registery.', package='pipe'):
' Automatically import any Python files in the tasks directory\n in order to automatically register all available tasks\n Args:\n tasks_dir: task dir to import from\n '
for... |
def get_cep_model(n=50, k=11, c=500, n_split=4):
model = Net(n, c, n_split=n_split)
return model
|
class CEPModelHandler(CommonModelHandler):
def __init__(self, normal_model_fn, *args, **kw):
super().__init__(*args, **kw)
self.normal_model_fn = normal_model_fn
def _get_normal_model_instance(self, *args, **kwargs):
return self.normal_model_fn(*args, **kwargs)
|
class ParamDictCVMOdelHandler(CommonModelHandler):
def __init__(self, dict_params, model_class, *args, **kw):
super().__init__(*args, **kw)
self.dict_params = dict_params
self.model_class = model_class
def _get_normal_model_instance(self, *args, **kw):
return self.model_class... |
def register_cv_hardcoded_model(name, *args, **kw):
ParamDictCVMOdelHandler(*args, **kw).register_autogenerated(generated_file_name_or_path=name)
|
class DummyModelHandler(CommonModelHandler):
def __init__(self, *args, **kw):
super().__init__(*args, **kw)
def _get_normal_model_instance(self, *args, **kwargs):
if (self.normal_model_instance is None):
args = SimpleNamespace()
p = DumT5Partitioner(args)
... |
class GetConfigFrom(Enum):
HardCoded = auto()
ParsedArgs = auto()
Generated = auto()
|
class HFModelHandler(CommonModelHandler):
def __init__(self, method: GetConfigFrom=GetConfigFrom.HardCoded, *args, **kw):
super().__init__(*args, **kw)
self.pipeline_transformer_config = None
self.method = method
self.tokenizer = None
self.config = None
def _get_norma... |
class CommonModelHandler(abc.ABC):
def __init__(self, partitioned_models_package=_PARTITIONED_MODELS_PACKAGE):
self.partitioned_models_package = partitioned_models_package
self.generated_file_name_or_path = None
self.normal_model_instance = None
self.generated = None
self.... |
def register_model(generated_file_name_or_path, handler: CommonModelHandler):
global AVAILABLE_MODELS
AVAILABLE_MODELS[generated_file_name_or_path] = handler
|
def register_model_func(generated_file_name_or_path, _get_normal_model_instance, get_extra=None):
d = dict(_get_normal_model_instance=_get_normal_model_instance)
if get_extra:
d['get_extra'] = get_extra
handler_cls = type('AutoGeneratedModelHandler', (CommonModelHandler,), d)
handler: CommonMo... |
def load_module(full_path: str):
spec = importlib.util.spec_from_file_location('module.name', full_path)
foo = importlib.util.module_from_spec(spec)
spec.loader.exec_module(foo)
return foo
|
def register_normal_model_by_function(fn):
model_name = fn.__name__
NORMAL_MODEL_ENTRY_POINTS[model_name] = fn
class EntryPointFunctionModelHandler(CommonModelHandler):
def __init__(self, normal_model_fn, *args, **kw):
super().__init__(*args, **kw)
self.normal_model_fn = ... |
def normal_model_entry_point(model_name):
return NORMAL_MODEL_ENTRY_POINTS[model_name]
|
def normal_model_entry_point_handler(model_name):
return NORMAL_MODEL_ENTRY_POINTS_HANDLERS[model_name]
|
class PipelineConfig():
'\n Config to handle basic partitioning.\n '
def __init__(self, d):
self.d = d
@property
def n_ranks(self) -> int:
return sum((len(stage['devices']) for stage in self.d['stages']))
def get_stage_to_ranks_map(self) -> Dict[(int, List[int])]:
... |
def atomic_batch_change(atomic_is_batched, atomic_shape, dim, batch_size) -> torch.Size:
assert isinstance(atomic_is_batched, bool)
if atomic_is_batched:
TMP_SHAPE_CLS = type(atomic_shape)
assert (TMP_SHAPE_CLS == _SHAPE_CLS)
atomic_shape = list(atomic_shape)
atomic_shape[dim] ... |
def op_graph_t5_3b_tied_lmheads_64_4_8p_bw12_squad1_pipedream():
return dict(model_type='new_t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'return_dict': False, 'use_cache... |
def op_graph_t5_3b_tied_lmheads_512_4_8p_bw12_squad1_pipedream():
return dict(model_type='new_t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'return_dict': False, 'use_cach... |
def op_graph_t5_3b_tied_lmheads_320_8_8p_bw12_squad1_pipedream():
return dict(model_type='new_t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'return_dict': False, 'use_cach... |
def layer_graph_t5_3b_tied_lmheads_512_4_8p_bw12_squad1_pipedream():
return dict(model_type='new_t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'return_dict': False, 'use_c... |
def layer_graph_t5_3b_tied_lmheads_320_8_8p_bw12_squad1_pipedream():
return dict(model_type='new_t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'return_dict': False, 'use_c... |
def layer_graph_t5_3b_tied_lmheads_64_4_8p_bw12_squad1_pipedream():
return dict(model_type='new_t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'return_dict': False, 'use_ca... |
def op_t5_3b_tied_lmheads_512_4_8p_bw12_async_squad1_mpipe():
return dict(model_type='new_t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'return_dict': False, 'use_cache': ... |
def layer_graph_t5_3b_tied_lmheads_512_4_8p_bw12_async_squad1_mpipe():
return dict(model_type='new_t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'return_dict': False, 'use... |
def op_t5_3b_tied_lmheads_320_8_8p_bw12_async_squad1_mpipe():
return dict(model_type='new_t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'return_dict': False, 'use_cache': ... |
def layer_graph_t5_3b_tied_lmheads_320_8_8p_bw12_async_squad1_mpipe():
return dict(model_type='new_t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'return_dict': False, 'use... |
def op_t5_3b_tied_lmheads_64_4_8p_bw12_async_squad1_mpipe():
return dict(model_type='new_t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'return_dict': False, 'use_cache': F... |
def layer_graph_t5_3b_tied_lmheads_64_4_8p_bw12_async_squad1_mpipe():
return dict(model_type='new_t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'return_dict': False, 'use_... |
def roberta_large_8p_bw11_0_async_mnli_glue():
return dict(model_type='roberta_glue', model_name_or_path='roberta-large', do_lower_case=False, output_past=False, stateless_tied=False, explicitly_set_dict={'precompute_attention_mask': True}, num_labels=3, finetuning_task='mnli')
|
def bert_large_uncased_whole_word_masking_8p_bw11_0_async_rte_glue():
return dict(model_type='bert_glue', model_name_or_path='bert-large-uncased-whole-word-masking', do_lower_case=False, output_past=False, explicitly_set_dict={'precompute_attention_mask': True}, stateless_tied=False, num_labels=2, finetuning_task... |
def bert_large_uncased_whole_word_masking_8p_bw11_0_async_mnli_glue():
return dict(model_type='bert_glue', model_name_or_path='bert-large-uncased-whole-word-masking', do_lower_case=False, output_past=False, stateless_tied=False, num_labels=3, explicitly_set_dict={'precompute_attention_mask': True}, finetuning_tas... |
def bert_base_uncased_4p_bw11_0_async_mnli_glue():
return dict(model_type='bert_glue', model_name_or_path='bert-base-uncased', do_lower_case=False, output_past=False, stateless_tied=False, num_labels=3, finetuning_task='mnli')
|
def bert_base_uncased_8p_bw11_0_async_mnli_glue():
return dict(model_type='bert_glue', model_name_or_path='bert-base-uncased', do_lower_case=False, output_past=False, stateless_tied=False, num_labels=3, explicitly_set_dict={'precompute_attention_mask': True}, finetuning_task='mnli')
|
def roberta_base_8p_bw11_0_async_mnli_glue():
return dict(model_type='roberta_glue', model_name_or_path='roberta-base', do_lower_case=False, output_past=False, stateless_tied=False, num_labels=3, explicitly_set_dict={'precompute_attention_mask': True}, finetuning_task='mnli')
|
def gpt2_p4_lm_untied():
return dict(model_type='gpt2_lm_stateless', model_name_or_path='gpt2', do_lower_case=False, explicitly_set_dict=dict(output_past=False), stateless_tied=False)
|
def gpt2_p4_lm_tied():
return dict(model_type='gpt2_lm_stateless', model_name_or_path='gpt2', do_lower_case=False, explicitly_set_dict=dict(output_past=False), stateless_tied=True)
|
def new_gpt2_xl_tied_lm_p8_seq_512():
return dict(model_type='gpt2_lm', model_name_or_path='gpt2-xl', do_lower_case=False, explicitly_set_dict=dict(output_past=False), stateless_tied=False)
|
def old_gpt2xl_8p_untied():
return dict(model_type='gpt2_lm_stateless', model_name_or_path='gpt2-xl', do_lower_case=False, explicitly_set_dict=dict(output_past=False), stateless_tied=False)
|
def gpt2_xl_p8_lm_untied():
return dict(model_type='gpt2_lm_stateless', model_name_or_path='gpt2-xl', do_lower_case=False, explicitly_set_dict=dict(output_past=False), stateless_tied=False)
|
def gpt2_xl_p8_lm_tied():
return dict(model_type='gpt2_lm_stateless', model_name_or_path='gpt2-xl', do_lower_case=False, explicitly_set_dict=dict(output_past=False), stateless_tied=True)
|
def bert_large_uncased_squad_8p():
return dict(model_type='bert_squad_old', model_name_or_path='bert-large-uncased-whole-word-masking', do_lower_case=True, output_past=False, stateless_tied=False)
|
def bert_base_uncaseds_384_2p_bw12_pipedream():
return dict(model_type='bert_squad_old', model_name_or_path='bert-base-uncased', do_lower_case=True, output_past=False, stateless_tied=False, explicitly_set_dict={'return_dict': False}, do_resize_token_embedding=False)
|
def bert_base_uncaseds_384_2p_bw12_async_pipedream():
return dict(model_type='bert_squad_old', model_name_or_path='bert-base-uncased', do_lower_case=True, output_past=False, stateless_tied=False, explicitly_set_dict={'return_dict': False}, do_resize_token_embedding=False)
|
def bert_large_uncased_whole_word_maskings_384_2p_bw12_pipedream():
return dict(model_type='bert_squad', model_name_or_path='bert-large-uncased-whole-word-masking', do_lower_case=True, output_past=False, stateless_tied=False, explicitly_set_dict={'precompute_attention_mask': True, 'return_dict': False}, do_resize... |
def bert_large_uncased_whole_word_maskings_384_2p_bw12_async_pipedream():
return dict(model_type='bert_squad', model_name_or_path='bert-large-uncased-whole-word-masking', do_lower_case=True, output_past=False, stateless_tied=False, explicitly_set_dict={'precompute_attention_mask': True, 'return_dict': False}, do_... |
def bert_large_uncased_whole_word_maskings_384_8p_bw12_pipedream():
return dict(model_type='bert_squad', model_name_or_path='bert-large-uncased-whole-word-masking', do_lower_case=True, output_past=False, stateless_tied=False, explicitly_set_dict={'precompute_attention_mask': True, 'return_dict': False}, do_resize... |
def bert_large_uncased_whole_word_maskings_384_8p_bw12_async_pipedream():
return dict(model_type='bert_squad', model_name_or_path='bert-large-uncased-whole-word-masking', do_lower_case=True, output_past=False, stateless_tied=False, explicitly_set_dict={'precompute_attention_mask': True, 'return_dict': False}, do_... |
def layer_bert_large_uncased_whole_word_maskings_384_8p_bw12_async_pipedream():
return dict(model_type='bert_squad', model_name_or_path='bert-large-uncased-whole-word-masking', do_lower_case=True, output_past=False, stateless_tied=False, explicitly_set_dict={'precompute_attention_mask': True, 'return_dict': False... |
def bert_large_uncased_whole_word_maskings_384_4p_bw12_pipedream():
return dict(model_type='bert_squad', model_name_or_path='bert-large-uncased-whole-word-masking', do_lower_case=True, output_past=False, stateless_tied=False, explicitly_set_dict={'precompute_attention_mask': True, 'return_dict': False}, do_resize... |
def bert_large_uncased_whole_word_maskings_384_4p_bw12_async_pipedream():
return dict(model_type='bert_squad', model_name_or_path='bert-large-uncased-whole-word-masking', do_lower_case=True, output_past=False, stateless_tied=False, explicitly_set_dict={'precompute_attention_mask': True, 'return_dict': False}, do_... |
def gpt2_p4_lm_tied_gpipe():
return gpt2_p4_lm_tied()
|
def gpt2_p4_lm_untied_gpipe():
return gpt2_p4_lm_untied()
|
def gpt2_xl_p8_lm_tied_gpipe():
return gpt2_xl_p8_lm_tied()
|
def gpt2_xl_p8_lm_untied_gpipe():
return gpt2_xl_p8_lm_untied()
|
def t5_small_tied_lmhead_4p_bw12_async_squad1():
return dict(model_type='t5_stateless', model_name_or_path='t5-small', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, explicitly_set_dict={'output_only': True, 'output_attentions': False, 'precomputed_masks': True, 'outp... |
def t5_large_tied_lmhead_8p_bw12_async_squad1():
return dict(model_type='t5_stateless', model_name_or_path='t5-large', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, explicitly_set_dict={'output_only': True, 'output_attentions': False, 'precomputed_masks': True, 'outp... |
def t5_3b_tied_lmheads_320_8_8p_bw12_squad1():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, explicitly_set_dict={'output_only': True, 'output_attentions': False, 'precomputed_masks': True, 'output_hi... |
def t5_3b_tied_lmheads_320_8_8p_bw12_squad1_virtual_stages():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attentions... |
def t5_3b_tied_lmheads_64_6_8p_bw12_squad1_virtual_stages():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attentions'... |
def t5_3b_tied_lmheads_64_4_8p_bw12_squad1_virtual_stages():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attentions'... |
def t5_3b_tied_lmheads_64_4_8p_bw12_async_squad1_mpipe():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attentions': F... |
def t5_3b_tied_lmheads_512_4_8p_bw12_async_squad1_mpipe():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attentions': ... |
def t5_3b_tied_lmheads_512_4_8p_bw12_async_squad1_pipedream():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attention... |
def t5_3b_tied_lmheads_320_8_8p_bw12_squad1_pipedream():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attentions': Fa... |
def t5_3b_tied_lmheads_320_8_8p_bw12_async_squad1_mpipe():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attentions': ... |
def t5_3b_tied_lmheads_512_4_8p_bw12_squad1_virtual_stages():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attentions... |
def t5_3b_tied_lmheads_512_4_8p_bw12_async_squad1_mpipe_L32():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attention... |
def t5_3b_tied_lmheads_64_4_8p_bw12_squad1_acyclic():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attentions': False... |
def t5_3b_tied_lmheads_64_4_8p_bw12_squad1_pipedream():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attentions': Fal... |
def t5_3b_tied_lmheads_512_4_8p_bw12_squad1_acyclic():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attentions': Fals... |
def t5_3b_tied_lmheads_512_4_8p_bw12_squad1_pipedream():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attentions': Fa... |
def t5_base_tied_lmheads_512_4_8p_bw12_squad1_pipedream():
return dict(model_type='t5_stateless', model_name_or_path='t5-base', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_attentions'... |
def t5_small_tied_lmheads_512_4_3p_bw12_squad1_virtual_stages():
return dict(model_type='t5_stateless', model_name_or_path='t5-small', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, do_resize_token_embedding=True, explicitly_set_dict={'output_only': True, 'output_atte... |
def t5_3b_tied_lmheads_64_4_8p_bw12_squad1():
return dict(model_type='t5_stateless', model_name_or_path='t5-3b', do_lower_case=False, output_past=False, output_attentions=False, output_hidden_states=False, explicitly_set_dict={'output_only': True, 'output_attentions': False, 'precomputed_masks': True, 'output_hid... |
class GetConfigFrom(Enum):
HardCoded = auto()
ParsedArgs = auto()
Generated = auto()
|
def resize_token_embeddings(model, tokenizer):
model_to_resize = (model.module if hasattr(model, 'module') else model)
model_to_resize.resize_token_embeddings(len(tokenizer))
|
def pretrained_model_config_and_tokenizer(model_type: str, model_name_or_path: str, config_name: str='', tokenizer_name: str='', do_lower_case: bool=False, cache_dir: str='', stateless_tied=False, do_resize_token_embedding=True, explicitly_set_dict={}, **config_kw):
(config_class, model_class, tokenizer_class) = ... |
def _dev():
'Used to infer the mapping manually'
MODEL_PATH = 'C:\\Users\\saareliad\\workspace\\ViT-B_16.npz'
MODEL_PATH = pathlib.Path(MODEL_PATH)
def read_npz_checkpoint(path):
with np.load(path) as data:
lst = data.files
state_dict = {k: data[k] for k in lst}
... |
def map_checkpoint_to_state_dict(state_dict: Dict[(str, np.ndarray)]):
'\n See: https://github.com/google/flax/blob/9015cc26d1d4a8b086e1bffacd157f863988fc4d/flax/linen/attention.py\n See: https://github.com/google-research/vision_transformer/blob/master/vit_jax/models.py\n\n Args:\n state_dict:\n\... |
class Adafactor(torch.optim.Optimizer):
'Implements Adafactor algorithm.\n This implementation is based on:\n `Adafactor: Adaptive Learning Rates with Sublinear Memory Cost`\n (see https://arxiv.org/abs/1804.04235)\n Note that this optimizer internally adjusts the learning rate\n depending on the *... |
class Adam(Optimizer):
'Implements Adam algorithm.\n\n It has been proposed in `Adam: A Method for Stochastic Optimization`_.\n\n Arguments:\n params (iterable): iterable of parameters to optimize or dicts defining\n parameter groups\n lr (float, optional): learning rate (default: 1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.