id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
38,813 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.distributed import fleet
from paddlenlp.ops import Topology
from paddlenlp.trainer... | print config values |
38,814 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.distributed import fleet
from paddlenlp.ops import Topology
from paddlenlp.trainer... | null |
38,815 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.distributed import fleet
from paddlenlp.ops import Topology
from paddlenlp.trainer... | null |
38,816 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.distributed import fleet
from paddlenlp.ops import Topology
from paddlenlp.trainer... | print("=======model_state_dict=======") for (k,v) in model_state_dict.items(): print(f"{k}=>{v.shape}") |
38,817 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.distributed import fleet
from paddlenlp.ops import Topology
from paddlenlp.trainer... | null |
38,818 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.distributed import fleet
from paddlenlp.ops import Topology
from paddlenlp.trainer... | null |
38,819 | import contextlib
import os
import random
import sys
import time
import types
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
import paddle.distributed.auto_parallel as auto
from paddle.base.data_feeder import convert_uint16_t... | null |
38,820 | import contextlib
import os
import random
import sys
import time
import types
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
import paddle.distributed.auto_parallel as auto
from paddle.base.data_feeder import convert_uint16_t... | null |
38,821 | import contextlib
import os
import random
import sys
import time
import types
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
import paddle.distributed.auto_parallel as auto
from paddle.base.data_feeder import convert_uint16_t... | null |
38,822 | import contextlib
import os
import random
import sys
import time
import types
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
import paddle.distributed.auto_parallel as auto
from paddle.base.data_feeder import convert_uint16_t... | null |
38,823 | import contextlib
import os
import random
import sys
import time
import types
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
import paddle.distributed.auto_parallel as auto
from paddle.base.data_feeder import convert_uint16_t... | null |
38,824 | import contextlib
import os
import random
import sys
import time
import types
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
import paddle.distributed.auto_parallel as auto
from paddle.base.data_feeder import convert_uint16_t... | print config values |
38,825 | import contextlib
import os
import random
import sys
import time
import types
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
import paddle.distributed.auto_parallel as auto
from paddle.base.data_feeder import convert_uint16_t... | null |
38,826 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | null |
38,827 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | null |
38,828 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | null |
38,829 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | null |
38,830 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | print config values |
38,831 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | null |
38,832 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | null |
38,833 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | null |
38,834 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | null |
38,835 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | null |
38,836 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | null |
38,837 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | null |
38,838 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | null |
38,839 | import os
import random
import sys
import types
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import List, Optional
import numpy as np
import paddle
import paddle.distributed as dist
from paddle.autograd import PyLayer
from paddle.distributed import fleet
from paddle.io import... | null |
38,840 | import copy
import json
import os
import sys
from dataclasses import dataclass, field
from functools import partial
import paddle
from benchmark_utils import (
LlamaTrainer,
compute_metrics,
compute_metrics_not_do_generation,
)
from paddlenlp.data import DataCollatorForSeq2Seq
from paddlenlp.datasets import... | null |
38,841 | import copy
import json
import os
import sys
from dataclasses import dataclass, field
from functools import partial
import paddle
from benchmark_utils import (
LlamaTrainer,
compute_metrics,
compute_metrics_not_do_generation,
)
from paddlenlp.data import DataCollatorForSeq2Seq
from paddlenlp.datasets import... | Convert an example into necessary features. |
38,842 | import re
def regitser_extract_layer_name_func(func):
def register_index_layer_func(func):
def register_layername_prefix(layer_name):
def register_pp_reshard_information(num_hidden_layers):
from paddlenlp.trainer.utils.reshard.pp_reshard import (
register_index_layer_func,
register_la... | null |
38,843 | import copy
import math
import os
import sys
import time
from dataclasses import dataclass, field
from typing import List, Optional
import paddle
from paddlenlp.data.causal_dataset import (
build_train_valid_test_datasets,
check_data_split,
print_rank_0,
)
from paddlenlp.trainer import (
PdArgumentParse... | null |
38,844 | import copy
import math
import os
import sys
import time
from dataclasses import dataclass, field
from typing import List, Optional
import paddle
from paddlenlp.data.causal_dataset import (
build_train_valid_test_datasets,
check_data_split,
print_rank_0,
)
from paddlenlp.trainer import (
PdArgumentParse... | null |
38,845 | import copy
import math
import os
import sys
import time
from dataclasses import dataclass, field
from typing import List, Optional
import paddle
from paddlenlp.data.causal_dataset import (
build_train_valid_test_datasets,
check_data_split,
print_rank_0,
)
from paddlenlp.trainer import (
PdArgumentParse... | null |
38,846 | import collections
import math
import os
import re
import time
import numpy as np
import paddle
from paddlenlp.data.indexed_dataset import get_indexed_dataset_
The provided code snippet includes necessary dependencies for implementing the `get_a_and_b_segments` function. Write a Python function `def get_a_and_b_segmen... | Divide sample into a and b segments. |
38,847 | import collections
import math
import os
import re
import time
import numpy as np
import paddle
from paddlenlp.data.indexed_dataset import get_indexed_dataset_
The provided code snippet includes necessary dependencies for implementing the `truncate_segments` function. Write a Python function `def truncate_segments(tok... | Truncates a pair of sequences to a maximum sequence length. |
38,848 | import collections
import math
import os
import re
import time
import numpy as np
import paddle
from paddlenlp.data.indexed_dataset import get_indexed_dataset_
The provided code snippet includes necessary dependencies for implementing the `create_tokens_and_tokentypes` function. Write a Python function `def create_tok... | Merge segments A and B, add [CLS] and [SEP] and build tokentypes. |
38,849 | import collections
import math
import os
import re
import time
import numpy as np
import paddle
from paddlenlp.data.indexed_dataset import get_indexed_dataset_
MaskedLmInstance = collections.namedtuple("MaskedLmInstance", ["index", "label"])
def is_start_piece(piece):
"""Check if the current word piece is the start... | Creates the predictions for the masked LM objective. Note: Tokens here are vocab ids and not text tokens. |
38,850 | import collections
import math
import os
import re
import time
import numpy as np
import paddle
from paddlenlp.data.indexed_dataset import get_indexed_dataset_
The provided code snippet includes necessary dependencies for implementing the `pad_and_convert_to_numpy` function. Write a Python function `def pad_and_conver... | Pad sequences and convert them to numpy. |
38,851 | import collections
import math
import os
import re
import time
import numpy as np
import paddle
from paddlenlp.data.indexed_dataset import get_indexed_dataset_
class BlendableDataset(paddle.io.Dataset):
"""
The BlendableDataset is a wrapper which used to mix different dataset.
The input is a list of dataset... | null |
38,852 | import collections
import math
import os
import re
import time
import numpy as np
import paddle
from paddlenlp.data.indexed_dataset import get_indexed_dataset_
def get_local_rank():
return int(os.getenv("PADDLE_RANK_IN_NODE", 0))
print_rank_0 = print
def compile_helper():
"""Compile helper function ar runtime. ... | Get a list that maps a sample index to a starting sentence index, end sentence index, and length |
38,853 | import collections
import json
import pickle
import random
import numpy as np
import paddle
import sklearn
from scipy.stats import pearsonr, spearmanr
from sklearn.metrics import accuracy_score, f1_score, matthews_corrcoef
from paddlenlp.transformers import (
CosineDecayWithWarmup,
LinearDecayWithWarmup,
Po... | null |
38,854 | import collections
import json
import pickle
import random
import numpy as np
import paddle
import sklearn
from scipy.stats import pearsonr, spearmanr
from sklearn.metrics import accuracy_score, f1_score, matthews_corrcoef
from paddlenlp.transformers import (
CosineDecayWithWarmup,
LinearDecayWithWarmup,
Po... | null |
38,855 | import collections
import json
import pickle
import random
import numpy as np
import paddle
import sklearn
from scipy.stats import pearsonr, spearmanr
from sklearn.metrics import accuracy_score, f1_score, matthews_corrcoef
from paddlenlp.transformers import (
CosineDecayWithWarmup,
LinearDecayWithWarmup,
Po... | null |
38,856 | import collections
import json
import pickle
import random
import numpy as np
import paddle
import sklearn
from scipy.stats import pearsonr, spearmanr
from sklearn.metrics import accuracy_score, f1_score, matthews_corrcoef
from paddlenlp.transformers import (
CosineDecayWithWarmup,
LinearDecayWithWarmup,
Po... | null |
38,857 | import collections
import json
import pickle
import random
import numpy as np
import paddle
import sklearn
from scipy.stats import pearsonr, spearmanr
from sklearn.metrics import accuracy_score, f1_score, matthews_corrcoef
from paddlenlp.transformers import (
CosineDecayWithWarmup,
LinearDecayWithWarmup,
Po... | null |
38,858 | import collections
import json
import pickle
import random
import numpy as np
import paddle
import sklearn
from scipy.stats import pearsonr, spearmanr
from sklearn.metrics import accuracy_score, f1_score, matthews_corrcoef
from paddlenlp.transformers import (
CosineDecayWithWarmup,
LinearDecayWithWarmup,
Po... | null |
38,859 | import collections
import json
import pickle
import random
import numpy as np
import paddle
import sklearn
from scipy.stats import pearsonr, spearmanr
from sklearn.metrics import accuracy_score, f1_score, matthews_corrcoef
from paddlenlp.transformers import (
CosineDecayWithWarmup,
LinearDecayWithWarmup,
Po... | null |
38,860 | from collections import OrderedDict
import argparse
dont_transpose = [
"shared.weight",
"layer_norm.weight",
".layer_norm.weight",
"relative_attention_bias.weight",
"embed_tokens.weight",
]
def convert_pytorch_checkpoint_to_paddle(pytorch_checkpoint_path, paddle_dump_path):
import torch
imp... | null |
38,861 | import collections
import os
from functools import partial
from paddle.io import BatchSampler, DataLoader
from utils import load_pickle, save_pickle
from paddlenlp.data import Pad, Tuple
from paddlenlp.datasets import load_dataset
def trans_func(example, tokenizer, args):
task_name = args.task_name
processed, l... | null |
38,862 | import collections
import os
from functools import partial
from paddle.io import BatchSampler, DataLoader
from utils import load_pickle, save_pickle
from paddlenlp.data import Pad, Tuple
from paddlenlp.datasets import load_dataset
def trans_func(example, tokenizer, args):
task_name = args.task_name
processed, l... | null |
38,863 | import collections
import os
from functools import partial
from paddle.io import BatchSampler, DataLoader
from utils import load_pickle, save_pickle
from paddlenlp.data import Pad, Tuple
from paddlenlp.datasets import load_dataset
def trans_func(example, tokenizer, args):
task_name = args.task_name
processed, l... | null |
38,864 | import os
from dataclasses import dataclass, field
from functools import partial
from typing import Optional
import paddle
from data import CLUE_PROCESSED
from utils import CLUE_METRICS, load_pickle, save_pickle
from paddlenlp.data.data_collator import DataCollatorForSeq2Seq
from paddlenlp.datasets import load_dataset
... | null |
38,865 | import os
from dataclasses import dataclass, field
from functools import partial
from typing import Optional
import paddle
from data import CLUE_PROCESSED
from utils import CLUE_METRICS, load_pickle, save_pickle
from paddlenlp.data.data_collator import DataCollatorForSeq2Seq
from paddlenlp.datasets import load_dataset
... | null |
38,866 | import argparse
import logging
import math
import os
import paddle
from data import (
GLUE_PROCESSED,
get_dev_dataloader,
get_mnli_dev_dataloader,
get_train_dataloader,
)
from paddle.amp import GradScaler, auto_cast
from paddle.optimizer import AdamW
from tqdm import tqdm
from utils import GLUE_METRICS,... | null |
38,867 | import argparse
import logging
import math
import os
import paddle
from data import (
GLUE_PROCESSED,
get_dev_dataloader,
get_mnli_dev_dataloader,
get_train_dataloader,
)
from paddle.amp import GradScaler, auto_cast
from paddle.optimizer import AdamW
from tqdm import tqdm
from utils import GLUE_METRICS,... | null |
38,868 | import collections
import copy
import numpy as np
import paddle
from dataset_utils import create_masked_lm_predictions, get_samples_mapping
def pad_and_convert_to_numpy(
tokens,
masked_positions,
masked_labels,
pad_id,
max_seq_length,
max_seq_length_dec,
masked_spans=None,
bos_id=None,
... | Build training sample. Arguments: sample: A list of sentences in which each sentence is a list token ids. target_seq_length: Desired sequence length. max_seq_length: Maximum length of the sequence. All values are padded to this length. vocab_id_list: List of vocabulary ids. Used to pick a random id. vocab_id_to_token_d... |
38,869 | import collections
import copy
import numpy as np
import paddle
from dataset_utils import create_masked_lm_predictions, get_samples_mapping
The provided code snippet includes necessary dependencies for implementing the `make_attention_mask_3d` function. Write a Python function `def make_attention_mask_3d(source_block,... | Returns a 3-dimensional (3-D) attention mask :param source_block: 1-D array :param target_block: 1-D array |
38,870 | import collections
import copy
import numpy as np
import paddle
from dataset_utils import create_masked_lm_predictions, get_samples_mapping
def make_history_mask_3d(block):
batch, length = block.shape
arange = paddle.arange(length, device=block.device)
history_mask = (arange[None, :] <= arange[:, None])[No... | null |
38,871 | import math
import os
import random
import time
from dataclasses import dataclass, field
from typing import Optional
import numpy as np
import paddle
from dataset_utils import build_train_valid_test_datasets
from paddlenlp.data import Stack
from paddlenlp.trainer import (
PdArgumentParser,
Trainer,
Training... | null |
38,872 | import math
import os
import random
import time
from dataclasses import dataclass, field
from typing import Optional
import numpy as np
import paddle
from dataset_utils import build_train_valid_test_datasets
from paddlenlp.data import Stack
from paddlenlp.trainer import (
PdArgumentParser,
Trainer,
Training... | null |
38,873 | import math
import os
import random
import time
from dataclasses import dataclass, field
from typing import Optional
import numpy as np
import paddle
from dataset_utils import build_train_valid_test_datasets
from paddlenlp.data import Stack
from paddlenlp.trainer import (
PdArgumentParser,
Trainer,
Training... | null |
38,874 | import math
import os
import random
import time
from dataclasses import dataclass, field
from typing import Optional
import numpy as np
import paddle
from dataset_utils import build_train_valid_test_datasets
from paddlenlp.data import Stack
from paddlenlp.trainer import (
PdArgumentParser,
Trainer,
Training... | null |
38,875 | import paddle
from collections import Counter
from paddlenlp.transformers import T5ForConditionalGeneration, T5Tokenizer
def task_type_map(task_type):
task_map = {
"sentiment_classifier": sentiment_cls,
"news_classifier": news_cls,
"medical_domain_intent_classifier": domain_cls,
"ent... | null |
38,876 | import os
from dataclasses import dataclass, field
from functools import partial
from typing import Any, Dict, List, Optional, Tuple, Union
import paddle
import paddle.nn as nn
from data import GLUE_1_1_PROCESSED, GLUE_PROCESSED
from utils import GLUE_METRICS, load_pickle, save_pickle
from paddlenlp.data import Pad
fro... | null |
38,877 | import os
from dataclasses import dataclass, field
from functools import partial
from typing import Any, Dict, List, Optional, Tuple, Union
import paddle
import paddle.nn as nn
from data import GLUE_1_1_PROCESSED, GLUE_PROCESSED
from utils import GLUE_METRICS, load_pickle, save_pickle
from paddlenlp.data import Pad
fro... | null |
38,878 | import os
from dataclasses import dataclass, field
from functools import partial
from typing import Any, Dict, List, Optional, Tuple, Union
import paddle
import paddle.nn as nn
from data import GLUE_1_1_PROCESSED, GLUE_PROCESSED
from utils import GLUE_METRICS, load_pickle, save_pickle
from paddlenlp.data import Pad
fro... | null |
38,887 | import argparse
import os
import tqdm
from paddle.utils.cpp_extension import load
from paddlenlp.trainer.argparser import strtobool
g_current_progress = 0
def ProgressFunc(progress, total):
global g_current_progress
if progress != g_current_progress:
g_current_progress = progress
print(f"Graph ... | null |
38,888 | import argparse
import os
import tqdm
from paddle.utils.cpp_extension import load
from paddlenlp.trainer.argparser import strtobool
def str_to_bool(val):
return bool(strtobool(val))
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--task",
type=str,
default... | null |
38,894 | import logging
import os
import pickle
import random
import time
import numpy as np
import paddle
import paddle.optimizer
import paddle.static
from dataset_ipu import PretrainingHDF5DataLoader
from modeling import (
BertModel,
DeviceScope,
IpuBertConfig,
IpuBertPretrainingMLMAccAndLoss,
IpuBertPretr... | null |
38,898 | import argparse
import os
import random
import time
from functools import partial
import numpy as np
import paddle
import paddle.distributed.fleet as fleet
from paddle.io import DataLoader
from paddle.metric import Accuracy
from paddlenlp.data import Pad, Stack, Tuple
from paddlenlp.datasets import load_dataset
from pa... | null |
38,901 | import h5py
import numpy as np
import paddle
from paddle.io import DataLoader, Dataset
from paddlenlp.data import Stack
class PretrainingDataset(Dataset):
def __init__(self, input_file, max_pred_length):
self.input_file = input_file
self.max_pred_length = max_pred_length
f = h5py.File(input_... | null |
38,902 | import h5py
import numpy as np
import paddle
from paddle.io import DataLoader, Dataset
from paddlenlp.data import Stack
def create_data_holder(args):
input_ids = paddle.static.data(name="input_ids", shape=[-1, -1], dtype="int64")
segment_ids = paddle.static.data(name="segment_ids", shape=[-1, -1], dtype="int64... | null |
38,908 | import argparse
import os
import random
import sys
import time
from concurrent.futures import ThreadPoolExecutor
import h5py
import numpy as np
import paddle
from paddle.io import DataLoader, Dataset
from paddlenlp.data import Stack
from paddlenlp.trainer.argparser import strtobool
from paddlenlp.transformers import (
... | null |
38,910 | from collections import OrderedDict
import argparse
huggingface_to_paddle = {
"embeddings.LayerNorm": "embeddings.layer_norm",
"encoder.layer": "encoder.layers",
"attention.self.query": "self_attn.q_proj",
"attention.self.key": "self_attn.k_proj",
"attention.self.value": "self_attn.v_proj",
"att... | null |
38,911 | import argparse
import logging
import os
import random
import time
from functools import partial
import jieba
import numpy as np
import paddle
import paddle.nn as nn
import paddle.nn.functional as F
from paddle.io import DataLoader
from paddle.metric import Accuracy
from paddlenlp.data import Pad, Stack, Tuple
from pad... | null |
38,912 | import argparse
import logging
import os
import random
import time
from functools import partial
import jieba
import numpy as np
import paddle
import paddle.nn as nn
import paddle.nn.functional as F
from paddle.io import DataLoader
from paddle.metric import Accuracy
from paddlenlp.data import Pad, Stack, Tuple
from pad... | null |
38,913 | import argparse
import logging
import os
import random
import time
from functools import partial
import jieba
import numpy as np
import paddle
import paddle.nn as nn
import paddle.nn.functional as F
from paddle.io import DataLoader
from paddle.metric import Accuracy
from paddlenlp.data import Pad, Stack, Tuple
from pad... | print arguments |
38,914 | import argparse
import logging
import os
import random
import time
from functools import partial
import numpy as np
import paddle
from paddle.io import DataLoader
from paddle.metric import Accuracy
from paddlenlp.data import Pad, Stack, Tuple
from paddlenlp.datasets import load_dataset
from paddlenlp.trainer.argparser ... | null |
38,915 | import argparse
import logging
import os
import random
import time
from functools import partial
import numpy as np
import paddle
from paddle.io import DataLoader
from paddle.metric import Accuracy
from paddlenlp.data import Pad, Stack, Tuple
from paddlenlp.datasets import load_dataset
from paddlenlp.trainer.argparser ... | null |
38,916 | import argparse
import logging
import os
import random
import time
from functools import partial
import numpy as np
import paddle
from paddle.io import DataLoader
from paddle.metric import Accuracy
from paddlenlp.data import Pad, Stack, Tuple
from paddlenlp.datasets import load_dataset
from paddlenlp.trainer.argparser ... | print arguments |
38,917 | import paddle
from args import parse_args
from model import CrossEntropyLossForLm, RnnLm, UpdateModel
from reader import create_data_loader
from paddlenlp.metrics import Perplexity
paddle.seed(102)
class RnnLm(nn.Layer):
def __init__(self, vocab_size, hidden_size, batch_size, num_layers=1, init_scale=0.1, dropout=... | null |
38,918 | import argparse
def parse_args():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--data_path", type=str, default=None, help="all the data for train,valid,test")
parser.add_argument("--batch_size", type=int, default=20, help="batch size")
parser.add_argument("--hidden_size", ... | null |
38,919 | import numpy as np
import paddle
from paddlenlp.datasets import load_dataset
from paddlenlp.data import Vocab
def create_data_loader(batch_size, num_steps, data_path=None):
train_ds, valid_ds, test_ds = load_dataset("ptb", splits=("train", "valid", "test"))
train_examples = [train_ds[i]["sentence"].split() fo... | null |
38,920 | import json
import math
import os
import random
import time
from functools import partial
import numpy as np
import paddle
from args import parse_args
from datasets import load_dataset
from paddle.io import DataLoader
from paddlenlp.data import Dict, Pad, Stack
from paddlenlp.metrics.squad import compute_prediction, sq... | null |
38,921 | import argparse
def parse_args():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--model_type", default="bert", type=str, help="Type of pre-trained model.")
parser.add_argument(
"--model_name_or_path",
default="bert-base-uncased",
type=str,
help="... | null |
38,922 | import argparse
import json
import logging
import os
import numpy as np
import paddle
import paddle.nn.functional as F
from open_entity_processor import DatasetProcessor, convert_examples_to_features
from paddle.io import DataLoader, Dataset
from paddle.optimizer import AdamW
from tqdm import tqdm
from paddlenlp.transf... | null |
38,923 | import time
import paddle
_GLOBAL_TIMERS = None
def _ensure_var_is_not_initialized(var, name):
"""Make sure the input variable is not None."""
assert var is None, "{} is not initialized.".format(name)
class Timers:
"""Group of timers."""
def __init__(self):
self.timers = {}
def __call__(self... | Initialize timers. |
38,924 | import os
import random
import time
import types
from types import MethodType
import numpy as np
import paddle
import paddle.distributed as dist
from args import parse_args
from checkpointing import load_checkpoint, save_checkpoint
from dataset import create_pretrained_dataset
from framework import AdamW, group_sharded... | null |
38,925 | import argparse
import paddle
from paddlenlp.trainer.argparser import strtobool
from paddlenlp.utils.log import logger
def process_batch_size(args):
if args.global_batch_size is None and args.local_batch_size is None:
raise ValueError("global_batch_size or local_batch_size should be set.")
elif args.glo... | null |
38,926 | import os
import time
import numpy as np
import paddle
from paddle.io import DataLoader
from paddlenlp.data import Stack, Tuple
from paddlenlp.utils.batch_sampler import DistributedBatchSampler
from paddlenlp.utils.log import logger
def _num_tokens(documents, lens):
"""Total number of tokens in the dataset."""
... | documents: document index from 0 to len(docs) sizes: the length list of all docs. num_samples: total step*bs iterations of data. seq_length: the sequence length. sum(sizes) = tokens_per_epoch data_nums = num_samples * micro_batch_size num_epochs = (data_nums + 1) // sum(sizes) len(doc_idx) = num_epochs * sum(sizes) |
38,927 | import collections
import paddle
import paddle.incubate as incubate
import paddle.nn as nn
import paddle.nn.functional as F
import paddle.tensor as tensor
from paddle.distributed import fleet
from paddle.distributed.fleet.meta_parallel import (
LayerDesc,
PipelineLayer,
SharedLayerDesc,
get_rng_state_tr... | null |
38,928 | from types import MethodType
import paddle
from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_optimizer_stage2 import (
GroupShardedOptimizerStage2,
)
from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_stage2 import (
GroupShardedStage2,
)
from paddle.framework import core
from p... | null |
38,929 | from collections import OrderedDict
import numpy as np
from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_storage import (
GradStorage,
ParamStorage,
)
from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_utils import Type
from paddle.framework import core
def assign_group_by_size(... | null |
38,932 | import copy
import numpy as np
import paddle
from .dataset_utils import (
create_masked_lm_predictions,
create_tokens_and_tokentypes,
get_a_and_b_segments,
get_samples_mapping,
truncate_segments,
)
def pad_and_convert_to_numpy(tokens, tokentypes, masked_positions, masked_labels, pad_id, max_seq_leng... | Biuld training sample. Arguments: sample: A list of sentences in which each sentence is a list token ids. target_seq_length: Desired sequence length. max_seq_length: Maximum length of the sequence. All values are padded to this length. vocab_id_list: List of vocabulary ids. Used to pick a random id. vocab_id_to_token_d... |
38,933 | import argparse
import math
import os
import random
import time
from functools import partial
import numpy as np
import paddle
import paddle.nn as nn
from paddle.io import BatchSampler, DataLoader, DistributedBatchSampler
from paddle.metric import Accuracy
from paddle.optimizer import Adam
from paddlenlp.data import Pa... | null |
38,934 | import argparse
import math
import os
import random
import time
from functools import partial
import numpy as np
import paddle
import paddle.nn as nn
from paddle.io import BatchSampler, DataLoader, DistributedBatchSampler
from paddle.metric import Accuracy
from paddle.optimizer import Adam
from paddlenlp.data import Pa... | null |
38,935 | import argparse
import math
import os
import random
import time
from functools import partial
import numpy as np
import paddle
import paddle.nn as nn
from paddle.io import BatchSampler, DataLoader, DistributedBatchSampler
from paddle.metric import Accuracy
from paddle.optimizer import Adam
from paddlenlp.data import Pa... | print arguments |
38,936 | import argparse
from functools import partial
import numpy as np
import paddle
from paddle.io import BatchSampler, DataLoader
from paddlenlp.transformers import XLMForSequenceClassification, XLMTokenizer
from paddlenlp.datasets import load_dataset
from paddlenlp.data import Stack, Tuple, Pad
from paddle.metric import A... | null |
38,937 | import argparse
from functools import partial
import numpy as np
import paddle
from paddle.io import BatchSampler, DataLoader
from paddlenlp.transformers import XLMForSequenceClassification, XLMTokenizer
from paddlenlp.datasets import load_dataset
from paddlenlp.data import Stack, Tuple, Pad
from paddle.metric import A... | null |
38,938 | import argparse
from functools import partial
import numpy as np
import paddle
from paddle.io import BatchSampler, DataLoader
from paddlenlp.transformers import XLMForSequenceClassification, XLMTokenizer
from paddlenlp.datasets import load_dataset
from paddlenlp.data import Stack, Tuple, Pad
from paddle.metric import A... | print arguments |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.