id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
37,991 | import typing as t
from typing import Optional
from .utils import log
class Config:
def is_public(self) -> bool:
return True
def is_org(self) -> bool:
return not self.is_public
def is_authenticated(self) -> bool:
return False
def is_anonymous(self) -> bool:
return True
co... | Get the current config object, doesn't attempt to re-init the API token |
37,992 | from datapane.common import DPError
def add_help_text(x: str) -> str:
return f"{x}\nPlease run with `dp.enable_logging()`, restart your Jupyter kernel/Python instance, and/or visit https://www.github.com/datapane/datapane" | null |
37,993 | import argparse
import time
from pprint import pprint
import numpy as np
import paddle
import pynvml
from paddlenlp.transformers import CodeGenForCausalLM, CodeGenTokenizer
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--perf_type",
default="pd",
type=str,
... | null |
37,994 | import argparse
import time
from pprint import pprint
import numpy as np
import paddle
import pynvml
from paddlenlp.transformers import CodeGenForCausalLM, CodeGenTokenizer
def perf_pd(args):
start_mem = query_by_id(args.gpu_id)
place = "gpu"
place = paddle.set_device(place)
tokenizer = CodeGenTokenizer... | null |
37,995 | import argparse
import sys
import time
from pprint import pprint
import numpy as np
import paddle
import torch
from transformers.models.opt.modeling_opt import OPTForCausalLM as hf_opt_model
from paddlenlp.transformers import GPTTokenizer, OPTForCausalLM
def parse_args():
parser = argparse.ArgumentParser()
par... | null |
37,996 | import argparse
import sys
import time
from pprint import pprint
import numpy as np
import paddle
import torch
from transformers.models.opt.modeling_opt import OPTForCausalLM as hf_opt_model
from paddlenlp.transformers import GPTTokenizer, OPTForCausalLM
def do_predict(args):
place = "gpu"
place = paddle.set_d... | null |
37,997 | import argparse
import time
from pprint import pprint
import numpy as np
import paddle
import pynvml
from paddlenlp.transformers import (
PegasusChineseTokenizer,
PegasusForConditionalGeneration,
)
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--perf_type",
... | null |
37,998 | import argparse
import time
from pprint import pprint
import numpy as np
import paddle
import pynvml
from paddlenlp.transformers import (
PegasusChineseTokenizer,
PegasusForConditionalGeneration,
)
def perf_pd(args):
start_mem = query_by_id(args.gpu_id)
place = "gpu"
place = paddle.set_device(place)... | null |
37,999 | import argparse
import time
from pprint import pprint
import paddle
import torch
from transformers import BartForConditionalGeneration as hf_bart_model
from paddlenlp.data import Pad
from paddlenlp.transformers import BartForConditionalGeneration, BartTokenizer
def parse_args():
parser = argparse.ArgumentParser()
... | null |
38,000 | import argparse
import time
from pprint import pprint
import paddle
import torch
from transformers import BartForConditionalGeneration as hf_bart_model
from paddlenlp.data import Pad
from paddlenlp.transformers import BartForConditionalGeneration, BartTokenizer
def prepare_input(tokenizer, sentences):
word_pad = Pa... | null |
38,001 | import argparse
import time
from pprint import pprint
import numpy as np
import paddle
import torch
from transformers import GPT2LMHeadModel as hf_gpt_model
from paddlenlp.transformers import GPTLMHeadModel, GPTTokenizer
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--model... | null |
38,002 | import argparse
import time
from pprint import pprint
import numpy as np
import paddle
import torch
from transformers import GPT2LMHeadModel as hf_gpt_model
from paddlenlp.transformers import GPTLMHeadModel, GPTTokenizer
def do_predict(args):
place = "gpu"
place = paddle.set_device(place)
tokenizer = GPTT... | null |
38,003 | import argparse
import time
from pprint import pprint
import paddle
from paddlenlp.ops import enable_ft_para, get_ft_para_conf
from paddlenlp.transformers import GPTChineseTokenizer, GPTLMHeadModel, GPTTokenizer
MODEL_CLASSES = {
"gpt-cpm-large-cn": (GPTLMHeadModel, GPTChineseTokenizer),
"gpt-cpm-small-cn-disti... | null |
38,004 | import argparse
import time
from pprint import pprint
import paddle
from paddlenlp.ops import enable_ft_para, get_ft_para_conf
from paddlenlp.transformers import GPTChineseTokenizer, GPTLMHeadModel, GPTTokenizer
def profile(batch_size, total_step=50, warmup_step=10, rank=0):
def _wrapper(func):
def _impl(*... | null |
38,005 | import paddle
from paddlenlp.transformers import MBart50Tokenizer, MBartForConditionalGeneration
tokenizer = MBart50Tokenizer.from_pretrained(model_name, src_lang="en_XX")
The provided code snippet includes necessary dependencies for implementing the `postprocess_response` function. Write a Python function `def postpr... | Post-process the decoded sequence. |
38,006 | from paddlenlp.transformers import (
UnifiedTransformerLMHeadModel,
UnifiedTransformerTokenizer,
)
The provided code snippet includes necessary dependencies for implementing the `postprocess_response` function. Write a Python function `def postprocess_response(token_ids, tokenizer)` to solve the following prob... | Post-process the decoded sequence. Truncate from the first <eos>. |
38,007 | from paddlenlp.transformers import UNIMOLMHeadModel, UNIMOTokenizer
The provided code snippet includes necessary dependencies for implementing the `postprocess_response` function. Write a Python function `def postprocess_response(token_ids, tokenizer)` to solve the following problem:
Post-process the decoded sequence.... | Post-process the decoded sequence. Truncate from the first <eos>. |
38,008 | import argparse
from paddlenlp.transformers import T5ForConditionalGeneration, T5Tokenizer
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--max_length", default=256, type=int, help="Maximum output sequence length.")
parser.add_argument("--beam_size", default=4, type=int, help="Th... | null |
38,009 | import argparse
from paddlenlp.transformers import T5ForConditionalGeneration, T5Tokenizer
def predict(args):
model_name = "t5-base"
model = T5ForConditionalGeneration.from_pretrained(model_name)
model.eval()
tokenizer = T5Tokenizer.from_pretrained(model_name)
en_text = ' This image section from ... | null |
38,010 | import argparse
import os
import time
from distutils.util import strtobool
from pprint import pprint
import paddle
from paddlenlp.data import DataCollatorWithPadding
from paddlenlp.ops import enable_ft_para, get_ft_para_conf
from paddlenlp.transformers import (
UnifiedTransformerLMHeadModel,
UnifiedTransformerT... | null |
38,011 | import argparse
import os
import time
from distutils.util import strtobool
from pprint import pprint
import paddle
from paddlenlp.data import DataCollatorWithPadding
from paddlenlp.ops import enable_ft_para, get_ft_para_conf
from paddlenlp.transformers import (
UnifiedTransformerLMHeadModel,
UnifiedTransformerT... | null |
38,012 | import argparse
import os
import time
from distutils.util import strtobool
from pprint import pprint
import paddle
from paddlenlp.data import DataCollatorWithPadding
from paddlenlp.ops import enable_ft_para, get_ft_para_conf
from paddlenlp.transformers import (
UnifiedTransformerLMHeadModel,
UnifiedTransformerT... | Post-process the decoded sequence. Truncate from the first <eos>. |
38,013 | import errno
import io
import os
import subprocess
import setuptools
def read(*names, **kwargs):
with io.open(os.path.join(os.path.dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8")) as fp:
return fp.read()
def read_requirements_file(filepath):
with open(filepath) as fin:
requi... | null |
38,014 | import errno
import io
import os
import subprocess
import setuptools
if os.getenv(PADDLENLP_STABLE_VERSION):
__version__ = __version__.replace(".post", "")
The provided code snippet includes necessary dependencies for implementing the `is_git_repo` function. Write a Python function `def is_git_repo(dir: str) -> bo... | Is the given directory version-controlled with git? |
38,015 | import errno
import io
import os
import subprocess
import setuptools
The provided code snippet includes necessary dependencies for implementing the `have_git` function. Write a Python function `def have_git() -> bool` to solve the following problem:
Can we run the git executable?
Here is the function:
def have_git()... | Can we run the git executable? |
38,016 | import errno
import io
import os
import subprocess
import setuptools
The provided code snippet includes necessary dependencies for implementing the `git_revision` function. Write a Python function `def git_revision(dir: str) -> bytes` to solve the following problem:
Get the SHA-1 of the HEAD of a git repository.
Here... | Get the SHA-1 of the HEAD of a git repository. |
38,017 | import errno
import io
import os
import subprocess
import setuptools
The provided code snippet includes necessary dependencies for implementing the `git_checkout` function. Write a Python function `def git_checkout(dir: str, filename: str) -> bytes` to solve the following problem:
Get the SHA-1 of the HEAD of a git re... | Get the SHA-1 of the HEAD of a git repository. |
38,018 | import errno
import io
import os
import subprocess
import setuptools
The provided code snippet includes necessary dependencies for implementing the `is_dirty` function. Write a Python function `def is_dirty(dir: str) -> bool` to solve the following problem:
Check whether a git repository has uncommitted changes.
Here... | Check whether a git repository has uncommitted changes. |
38,019 | import errno
import io
import os
import subprocess
import setuptools
commit = "unknown"
if commit.endswith("unknown") and is_git_repo(paddlenlp_dir) and have_git():
commit = git_revision(paddlenlp_dir).decode("utf-8")
if is_dirty(paddlenlp_dir):
commit += ".dirty"
if os.getenv(PADDLENLP_STABLE_VERSION):... | null |
38,020 | import errno
import io
import os
import subprocess
import setuptools
if os.getenv(PADDLENLP_STABLE_VERSION):
__version__ = __version__.replace(".post", "")
The provided code snippet includes necessary dependencies for implementing the `get_package_data_files` function. Write a Python function `def get_package_data... | Helps to list all specified files in package including files in directories since `package_data` ignores directories. |
38,021 | import os
import re
The provided code snippet includes necessary dependencies for implementing the `modify_doc_title_dir` function. Write a Python function `def modify_doc_title_dir(abspath_rstfiles_dir)` to solve the following problem:
rst文件中:有‘========’和‘----------’行的表示其行上一行的文字是标题, ‘=’和‘-’要大于等于标题的长度。 使用sphinx-apidoc... | rst文件中:有‘========’和‘----------’行的表示其行上一行的文字是标题, ‘=’和‘-’要大于等于标题的长度。 使用sphinx-apidoc -o ./source/rst_files /home/myubuntu/pro/mypro命令将 生成rst文件放在./source/rst_files目录下, 执行sphinx-quickstart命令生成的 index.rst不用放到这个目录中。 或在source目录下新建 rst_files目录然后将rst文件剪切到这个目录下,修改后再剪切出来 生成rst文件后将rst_files/modules.rst文件中的标题去掉,并修改maxdepth字段。 删除和修改... |
38,022 | import argparse
import distutils.util
import math
import os
import re
from pprint import pprint
import fastdeploy as fd
import six
from paddlenlp.transformers import AutoTokenizer
from paddlenlp.utils.tools import get_bool_ids_greater_than, get_span
def parse_arguments():
parser = argparse.ArgumentParser()
par... | null |
38,023 | import argparse
import distutils.util
import math
import os
import re
from pprint import pprint
import fastdeploy as fd
import six
from paddlenlp.transformers import AutoTokenizer
from paddlenlp.utils.tools import get_bool_ids_greater_than, get_span
def dbc2sbc(s):
rs = ""
for char in s:
code = ord(cha... | null |
38,024 | import argparse
import distutils.util
import math
import os
import re
from pprint import pprint
import fastdeploy as fd
import six
from paddlenlp.transformers import AutoTokenizer
from paddlenlp.utils.tools import get_bool_ids_greater_than, get_span
The provided code snippet includes necessary dependencies for impleme... | Cut the Chinese sentences more precisely, reference to "https://blog.csdn.net/blmoistawinde/article/details/82379256". |
38,025 | import argparse
import distutils.util
import math
import os
import re
from pprint import pprint
import fastdeploy as fd
import six
from paddlenlp.transformers import AutoTokenizer
from paddlenlp.utils.tools import get_bool_ids_greater_than, get_span
The provided code snippet includes necessary dependencies for impleme... | Return text id and probability of predicted spans Args: span_set (set): set of predicted spans. offset_mapping (list[int]): list of pair preserving the index of start and end char in original text pair (prompt + text) for each token. Returns: sentence_id (list[tuple]): index of start and end char in original text. prob... |
38,026 | import argparse
import os
import json
def convert(dataset, task_type):
def do_convert(args):
if not os.path.exists(args.labelstudio_file):
raise ValueError("Please input the correct path of label studio file.")
with open(args.labelstudio_file, "r", encoding="utf-8") as infile:
for content in ... | null |
38,027 | import argparse
import json
import os
import time
from decimal import Decimal
import numpy as np
from utils import convert_cls_examples, convert_ext_examples, set_seed
from paddlenlp.trainer.argparser import strtobool
from paddlenlp.utils.log import logger
def set_seed(seed):
paddle.seed(seed)
random.seed(seed... | null |
38,028 | import argparse
from functools import partial
import paddle
from utils import (
convert_example,
create_data_loader,
get_relation_type_dict,
reader,
unify_prompt_name,
)
from paddlenlp.data import DataCollatorWithPadding
from paddlenlp.datasets import MapDataset, load_dataset
from paddlenlp.metrics ... | null |
38,029 | import argparse
import paddle
from decode import beam_search_infilling, post_process
from encode import after_padding, convert_example
from paddle.io import DataLoader
from paddlenlp.data import Pad, Tuple
from paddlenlp.datasets import load_dataset
from paddlenlp.transformers import (
BertTokenizer,
ElectraTok... | null |
38,030 | import argparse
import paddle
from decode import beam_search_infilling
from encode import after_padding, convert_example
from paddle.io import DataLoader
from tqdm import tqdm
from paddlenlp.data import Pad, Tuple
from paddlenlp.datasets import load_dataset
from paddlenlp.metrics import Rouge1, Rouge2
from paddlenlp.tr... | null |
38,031 | import re
from collections import namedtuple
import numpy as np
import paddle
import paddle.nn as nn
def gen_bias(encoder_inputs, decoder_inputs, step):
decoder_bsz, decoder_seqlen = decoder_inputs.shape[:2]
encoder_bsz, encoder_seqlen = encoder_inputs.shape[:2]
attn_bias = paddle.reshape(paddle.arange(0, d... | null |
38,032 | import re
from collections import namedtuple
import numpy as np
import paddle
import paddle.nn as nn
def log_softmax(x):
e_x = np.exp(x - np.max(x))
return np.log(e_x / e_x.sum()) | null |
38,033 | import argparse
import os
import random
import time
from collections import defaultdict
from functools import partial
import numpy as np
import paddle
import paddle.nn as nn
from data import ClassifierIterator, HYPTextPreprocessor, ImdbTextPreprocessor
from metrics import F1
from paddle.metric import Accuracy
from padd... | null |
38,034 | import argparse
import os
import random
import time
from collections import defaultdict
from functools import partial
import numpy as np
import paddle
import paddle.nn as nn
from data import MCQIterator
from paddle.metric import Accuracy
from paddle.optimizer import AdamW
from paddlenlp.datasets import load_dataset
fro... | null |
38,035 | import itertools
from collections import namedtuple
import numpy as np
from paddle.utils import try_import
from paddlenlp.transformers import tokenize_chinese_chars
from paddlenlp.utils.log import logger
The provided code snippet includes necessary dependencies for implementing the `get_related_pos` function. Write a ... | generate relative postion ids |
38,036 | import itertools
from collections import namedtuple
import numpy as np
from paddle.utils import try_import
from paddlenlp.transformers import tokenize_chinese_chars
from paddlenlp.utils.log import logger
The provided code snippet includes necessary dependencies for implementing the `pad_batch_data` function. Write a P... | Pad the instances to the max sequence length in batch, and generate the corresponding position data and attention bias. |
38,037 | import argparse
import os
import random
import time
from collections import namedtuple
from functools import partial
import numpy as np
import paddle
from data import MRCIterator
from metrics import EM_AND_F1, compute_qa_predictions
from paddle.optimizer import AdamW
from paddlenlp.datasets import load_dataset
from pad... | null |
38,038 | import argparse
import os
import random
import time
from collections import defaultdict
from functools import partial
import numpy as np
import paddle
import paddle.nn as nn
from data import SemanticMatchingIterator
from model import ErnieDocForTextMatching
from paddle.metric import Accuracy
from paddle.optimizer impor... | null |
38,039 | import argparse
import os
import random
import time
from collections import defaultdict
from functools import partial
import numpy as np
import paddle
from data import SequenceLabelingIterator
from paddle.optimizer import AdamW
from paddlenlp.datasets import load_dataset
from paddlenlp.metrics import ChunkEvaluator
fro... | null |
38,040 | import argparse
import logging
import math
import os
import random
import time
from functools import partial
import numpy as np
import paddle
import paddle.nn.functional as F
from paddle.io import DataLoader
from paddle.metric import Accuracy
from paddlenlp.data import Pad, Stack, Tuple
from paddlenlp.datasets import l... | null |
38,041 | import argparse
import logging
import math
import os
import random
import time
from functools import partial
import numpy as np
import paddle
import paddle.nn.functional as F
from paddle.io import DataLoader
from paddle.metric import Accuracy
from paddlenlp.data import Pad, Stack, Tuple
from paddlenlp.datasets import l... | null |
38,042 | import argparse
import logging
import math
import os
import random
import time
from functools import partial
import numpy as np
import paddle
import paddle.nn.functional as F
from paddle.io import DataLoader
from paddle.metric import Accuracy
from paddlenlp.data import Pad, Stack, Tuple
from paddlenlp.datasets import l... | print arguments |
38,043 | import argparse
import logging
import os
import random
import time
from concurrent.futures import ThreadPoolExecutor
import numpy as np
import paddle
from paddle.io import DataLoader
from paddle.metric import Accuracy
from paddlenlp.data import Pad, Tuple
from paddlenlp.metrics import AccuracyAndF1, Mcc, PearsonAndSpea... | null |
38,044 | import argparse
import logging
import os
import random
import time
from concurrent.futures import ThreadPoolExecutor
import numpy as np
import paddle
from paddle.io import DataLoader
from paddle.metric import Accuracy
from paddlenlp.data import Pad, Tuple
from paddlenlp.metrics import AccuracyAndF1, Mcc, PearsonAndSpea... | null |
38,045 | import argparse
import logging
import os
import random
import time
from concurrent.futures import ThreadPoolExecutor
import numpy as np
import paddle
from paddle.io import DataLoader
from paddle.metric import Accuracy
from paddlenlp.data import Pad, Tuple
from paddlenlp.metrics import AccuracyAndF1, Mcc, PearsonAndSpea... | print arguments |
38,046 | import argparse
import csv
import logging
import os
import random
import re
import unicodedata
import numpy as np
import paddle
from paddlenlp.transformers import BertForPretraining, BertTokenizer
The provided code snippet includes necessary dependencies for implementing the `strip_accents` function. Write a Python fu... | Strip accents from input String. :param text: The input string. :type text: String. :returns: The processed String. :rtype: String. |
38,047 | import argparse
import csv
import logging
import os
import random
import re
import unicodedata
import numpy as np
import paddle
from paddlenlp.transformers import BertForPretraining, BertTokenizer
def _is_valid(string):
return True if not re.search("[^a-z]", string) else False | null |
38,048 | import argparse
import csv
import logging
import os
import random
import re
import unicodedata
import numpy as np
import paddle
from paddlenlp.transformers import BertForPretraining, BertTokenizer
The provided code snippet includes necessary dependencies for implementing the `_read_tsv` function. Write a Python functi... | Reads a tab separated value file. |
38,049 | import argparse
import csv
import logging
import os
import random
import re
import unicodedata
import numpy as np
import paddle
from paddlenlp.transformers import BertForPretraining, BertTokenizer
def prepare_embedding_retrieval(glove_file, vocab_size=100000):
cnt = 0
words = []
embeddings = {}
# only... | null |
38,050 | import argparse
from collections import OrderedDict
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 paddle
im... | null |
38,051 | import argparse
import numpy as np
import paddle
from paddlenlp.transformers import AutoModelForConditionalGeneration, AutoTokenizer
args = parser.parse_args()
def predict():
paddle.set_device(args.device)
tokenizer = AutoTokenizer.from_pretrained(args.model_name_or_path)
model = AutoModelForConditionalGe... | null |
38,052 | import json
import os
import random
from dataclasses import dataclass, field
from functools import partial
from typing import Optional
import numpy as np
import paddle
from datasets import load_dataset
from paddle.io import Dataset
from paddle.metric import Accuracy
import paddlenlp
from paddlenlp.data import DataColla... | null |
38,053 | import distutils.util
import os
import fastdeploy as fd
import numpy as np
from paddlenlp.transformers import AutoTokenizer
def parse_arguments():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--model_dir", required=True, help="The directory of model.")
parser.add_argument("-... | null |
38,054 | import distutils.util
import os
import fastdeploy as fd
import numpy as np
from paddlenlp.transformers import AutoTokenizer
def batchfy_text(texts, batch_size):
batch_texts = []
batch_start = 0
while batch_start < len(texts):
batch_texts += [texts[batch_start : min(batch_start + batch_size, len(tex... | null |
38,055 | import numpy as np
def get_label_name(filename_intent, filename_slot):
intent_names, slot_names = [], []
intent2id, slot2id = {}, {}
for id, line in enumerate(open(filename_intent)):
line = line.strip()
intent_names.append(line)
intent2id[line] = id
for id, line in enumerate(op... | null |
38,056 | import numpy as np
The provided code snippet includes necessary dependencies for implementing the `read_example` function. Write a Python function `def read_example(filename, intent2id, slot2id, tokenizer, max_seq_length=16, no_entity_id=0)` to solve the following problem:
Reads data from file. tokenized_query = ['来',... | Reads data from file. tokenized_query = ['来', '一', '首', '周', '华', '健', '的', '花', '心'] slot_sentence = '来一首<singer>周华健</singer>的<song>花心</song>' after processing: slot_label = ['O', 'O', 'O', 'B-singer', 'I-singer', 'I-singer', 'O', 'B-song', 'I-song'] |
38,057 | import numpy as np
def read_test_file(filename):
for line in open(filename):
line = line.strip().split("\t")
if len(line) < 2:
continue
query = line[1]
yield {"query": query} | null |
38,058 | import numpy as np
def input_preprocess(text, tokenizer, max_seq_length=16):
data = tokenizer(text, max_length=max_seq_length)
input_ids = data["input_ids"]
return {
"input_ids": np.array(input_ids, dtype="int32"),
} | null |
38,059 | import numpy as np
def intent_cls_postprocess(logits, intent_label_names):
max_value = np.max(logits, axis=1, keepdims=True)
exp_data = np.exp(logits - max_value)
probs = exp_data / np.sum(exp_data, axis=1, keepdims=True)
out_dict = {"intent": intent_label_names[int(probs.argmax(axis=-1))], "confidence... | null |
38,060 | import numpy as np
def slot_cls_postprocess(logits, input_data, label_names):
batch_preds = logits.argmax(axis=-1).tolist()
value = []
for batch, preds in enumerate(batch_preds):
start = -1
label_name = ""
items = []
for i, pred in enumerate(preds):
if (label_nam... | null |
38,061 | import os
import fastdeploy as fd
import numpy as np
from paddlenlp.trainer.argparser import strtobool
from paddlenlp.transformers import AutoTokenizer
def strtobool(v):
if isinstance(v, bool):
return v
if v.lower() in ("yes", "true", "t", "y", "1"):
return True
elif v.lower() in ("no", "fa... | null |
38,062 | import os
import fastdeploy as fd
import numpy as np
from paddlenlp.trainer.argparser import strtobool
from paddlenlp.transformers import AutoTokenizer
def batchify_text(texts, batch_size):
batch_texts = []
batch_start = 0
while batch_start < len(texts):
batch_texts += [texts[batch_start : min(batc... | null |
38,063 | import numpy as np
from paddlenlp import SimpleServer
from paddlenlp.server import BasePostHandler, TokenClsModelHandler
def _extract_chunk(tokens):
chunks = set()
start_idx, cur_idx = 0, 0
while cur_idx < len(tokens):
if tokens[cur_idx][0] == "B":
start_idx = cur_idx
cur_id... | null |
38,064 | import argparse
import psutil
from predictor import SPOPredictor
from paddlenlp.utils.log import logger
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--model_path_prefix", type=str, required=True, help="The path prefix of inference model to be used."
)
parser.add_ar... | null |
38,065 | import argparse
import psutil
from predictor import CLSPredictor
from paddlenlp.utils.log import logger
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--model_path_prefix", type=str, required=True, help="The path prefix of inference model to be used."
)
parser.add_ar... | null |
38,066 | import argparse
import psutil
from predictor import NERPredictor
from paddlenlp.utils.log import logger
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--model_path_prefix", type=str, required=True, help="The path prefix of inference model to be used."
)
parser.add_ar... | null |
38,067 | import argparse
import os
import paddle
from model import ElectraForBinaryTokenClassification, ElectraForSPO
from paddlenlp.transformers import ElectraForSequenceClassification
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--train_dataset", required=True, type=str, help="The name of... | null |
38,068 | import argparse
import os
import random
import time
from functools import partial
import numpy as np
import paddle
from model import ElectraForBinaryTokenClassification
from utils import (
LinearDecayWithWarmup,
NERChunkEvaluator,
convert_example_ner,
create_dataloader,
)
from paddlenlp.data import Dict... | null |
38,069 | import argparse
import distutils.util
import os
import random
import time
from functools import partial
import numpy as np
import paddle
import paddle.nn.functional as F
from model import ElectraForSPO
from tqdm import tqdm
from utils import (
LinearDecayWithWarmup,
SPOChunkEvaluator,
convert_example_spo,
... | null |
38,070 | import argparse
import distutils.util
import os
import random
import time
from functools import partial
import numpy as np
import paddle
import paddle.nn.functional as F
from paddle.metric import Accuracy
from utils import LinearDecayWithWarmup, convert_example, create_dataloader
from paddlenlp.data import Pad, Stack, ... | null |
38,071 | import argparse
import io
import multiprocessing
import os
import re
import sys
import time
import numpy as np
from tqdm import tqdm
from paddlenlp.transformers import ElectraTokenizer
def parse_args():
parser = argparse.ArgumentParser("Preprocessor for ERNIE-Health")
parser.add_argument(
"--input_path... | null |
38,072 | import argparse
import io
import multiprocessing
import os
import re
import sys
import time
import numpy as np
from tqdm import tqdm
from paddlenlp.transformers import ElectraTokenizer
def lac_segmentation():
from LAC import LAC
tool = LAC(mode="lac")
def process(text):
words, _ = tool.run(text)
... | null |
38,073 | import argparse
import io
import multiprocessing
import os
import re
import sys
import time
import numpy as np
from tqdm import tqdm
from paddlenlp.transformers import ElectraTokenizer
def seg_segmentation():
from LAC import LAC
tool = LAC(mode="seg")
def process(text):
words = tool.run(text)
... | null |
38,074 | import argparse
import io
import multiprocessing
import os
import re
import sys
import time
import numpy as np
from tqdm import tqdm
from paddlenlp.transformers import ElectraTokenizer
def jieba_segmentation():
import jieba
def process(text):
words = jieba.cut(text)
return list(words)
ret... | null |
38,075 | import argparse
import json
import os
import random
import time
from collections import defaultdict
import numpy as np
import paddle
from dataset import DataCollatorForErnieHealth, MedicalCorpus, create_dataloader
from visualdl import LogWriter
from paddlenlp.transformers import (
ElectraConfig,
ElectraTokenize... | null |
38,076 | import argparse
import json
import os
import random
import time
from collections import defaultdict
import numpy as np
import paddle
from dataset import DataCollatorForErnieHealth, MedicalCorpus, create_dataloader
from visualdl import LogWriter
from paddlenlp.transformers import (
ElectraConfig,
ElectraTokenize... | null |
38,077 | import argparse
import json
import os
import random
import time
from collections import defaultdict
import numpy as np
import paddle
from dataset import DataCollatorForErnieHealth, MedicalCorpus, create_dataloader
from visualdl import LogWriter
from paddlenlp.transformers import (
ElectraConfig,
ElectraTokenize... | print arguments |
38,078 | import base64
import collections
import hashlib
import random
import cv2
import datasets
import editdistance
import numpy as np
import scipy
import six
from PIL import Image
from seqeval.metrics.sequence_labeling import get_entities
from paddlenlp.trainer import EvalPrediction
The provided code snippet includes necess... | Get md5 value for string |
38,079 | import base64
import collections
import hashlib
import random
import cv2
import datasets
import editdistance
import numpy as np
import scipy
import six
from PIL import Image
from seqeval.metrics.sequence_labeling import get_entities
from paddlenlp.trainer import EvalPrediction
The provided code snippet includes necess... | Scale the bounding box of each character within maximum boundary. |
38,080 | import base64
import collections
import hashlib
import random
import cv2
import datasets
import editdistance
import numpy as np
import scipy
import six
from PIL import Image
from seqeval.metrics.sequence_labeling import get_entities
from paddlenlp.trainer import EvalPrediction
The provided code snippet includes necess... | Permute |
38,081 | import base64
import collections
import hashlib
import random
import cv2
import datasets
import editdistance
import numpy as np
import scipy
import six
from PIL import Image
from seqeval.metrics.sequence_labeling import get_entities
from paddlenlp.trainer import EvalPrediction
def _decode_image(im_base64):
"""Decod... | null |
38,082 | import base64
import collections
import hashlib
import random
import cv2
import datasets
import editdistance
import numpy as np
import scipy
import six
from PIL import Image
from seqeval.metrics.sequence_labeling import get_entities
from paddlenlp.trainer import EvalPrediction
def get_label_ld(qas, scheme="bio"):
... | null |
38,083 | import base64
import collections
import hashlib
import random
import cv2
import datasets
import editdistance
import numpy as np
import scipy
import six
from PIL import Image
from seqeval.metrics.sequence_labeling import get_entities
from paddlenlp.trainer import EvalPrediction
def anls_score(labels, predictions):
... | null |
38,084 | import base64
import collections
import cv2
import numpy as np
import paddle
import scipy
import six
from paddleocr import PaddleOCR
from PIL import Image
from seqeval.metrics.sequence_labeling import get_entities
from paddlenlp.transformers import AutoTokenizer
from paddlenlp.utils.image_utils import ppocr2example
fro... | Scale the bounding box of each character within maximum boundary. |
38,085 | import base64
import collections
import cv2
import numpy as np
import paddle
import scipy
import six
from paddleocr import PaddleOCR
from PIL import Image
from seqeval.metrics.sequence_labeling import get_entities
from paddlenlp.transformers import AutoTokenizer
from paddlenlp.utils.image_utils import ppocr2example
fro... | Permute |
38,086 | import base64
import collections
import cv2
import numpy as np
import paddle
import scipy
import six
from paddleocr import PaddleOCR
from PIL import Image
from seqeval.metrics.sequence_labeling import get_entities
from paddlenlp.transformers import AutoTokenizer
from paddlenlp.utils.image_utils import ppocr2example
fro... | null |
38,087 | import argparse
from predictor import Predictor
def parse_args():
# yapf: disable
parser = argparse.ArgumentParser()
# Required parameters
parser.add_argument("--model_path_prefix", type=str, required=True, help="The path prefix of inference model to be used.")
parser.add_argument("--batch_size", d... | null |
38,088 | import argparse
import collections
import os
import random
from io import open
import h5py
import numpy as np
from tqdm import tqdm
from paddlenlp.transformers import BertTokenizer
from paddlenlp.transformers.tokenizer_utils import convert_to_unicode
The provided code snippet includes necessary dependencies for implem... | Create example files from `TrainingInstance`s. |
38,089 | import argparse
import collections
import os
import random
from io import open
import h5py
import numpy as np
from tqdm import tqdm
from paddlenlp.transformers import BertTokenizer
from paddlenlp.transformers.tokenizer_utils import convert_to_unicode
def create_instances_from_document(
all_documents,
document_i... | Create `TrainingInstance`s from raw text. |
38,092 | import argparse
import os
import paddle
from run_glue_trainer import MODEL_CLASSES
MODEL_CLASSES = {
"bert": (BertForSequenceClassification, BertTokenizer),
"ernie": (ErnieForSequenceClassification, ErnieTokenizer),
}
def parse_args():
parser = argparse.ArgumentParser()
# Required parameters
pars... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.