id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
18,629 | import logging
import os
import sys
import threading
from logging import CRITICAL
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import NOTSET
from logging import WARN
from logging import WARNING
from typing import Optional
def _get_library_na... | Return a logger with the specified name. This function is not supposed to be directly accessed unless you are writing a custom transformers module. |
18,630 | import logging
import os
import sys
import threading
from logging import CRITICAL
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import NOTSET
from logging import WARN
from logging import WARNING
from typing import Optional
def set_verbosity(v... | Set the verbosity to the `INFO` level. |
18,631 | import logging
import os
import sys
import threading
from logging import CRITICAL
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import NOTSET
from logging import WARN
from logging import WARNING
from typing import Optional
def set_verbosity(v... | Set the verbosity to the `WARNING` level. |
18,632 | import logging
import os
import sys
import threading
from logging import CRITICAL
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import NOTSET
from logging import WARN
from logging import WARNING
from typing import Optional
def set_verbosity(v... | Set the verbosity to the `DEBUG` level. |
18,633 | import logging
import os
import sys
import threading
from logging import CRITICAL
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import NOTSET
from logging import WARN
from logging import WARNING
from typing import Optional
def set_verbosity(v... | Set the verbosity to the `ERROR` level. |
18,634 | import logging
import os
import sys
import threading
from logging import CRITICAL
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import NOTSET
from logging import WARN
from logging import WARNING
from typing import Optional
_default_handler: O... | Disable the default handler of the HuggingFace Transformers's root logger. |
18,635 | import logging
import os
import sys
import threading
from logging import CRITICAL
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import NOTSET
from logging import WARN
from logging import WARNING
from typing import Optional
_default_handler: O... | Enable the default handler of the HuggingFace Transformers's root logger. |
18,636 | import logging
import os
import sys
import threading
from logging import CRITICAL
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import NOTSET
from logging import WARN
from logging import WARNING
from typing import Optional
def _get_library_ro... | adds a handler to the HuggingFace Transformers's root logger. |
18,637 | import logging
import os
import sys
import threading
from logging import CRITICAL
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import NOTSET
from logging import WARN
from logging import WARNING
from typing import Optional
def _get_library_ro... | removes given handler from the HuggingFace Transformers's root logger. |
18,638 | import logging
import os
import sys
import threading
from logging import CRITICAL
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import NOTSET
from logging import WARN
from logging import WARNING
from typing import Optional
def _get_library_ro... | Disable propagation of the library log outputs. Note that log propagation is disabled by default. |
18,639 | import logging
import os
import sys
import threading
from logging import CRITICAL
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import NOTSET
from logging import WARN
from logging import WARNING
from typing import Optional
def _get_library_ro... | Enable propagation of the library log outputs. Please disable the HuggingFace Transformers's default handler to prevent double logging if the root logger has been configured. |
18,640 | import logging
import os
import sys
import threading
from logging import CRITICAL
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import NOTSET
from logging import WARN
from logging import WARNING
from typing import Optional
def _get_library_ro... | Enable explicit formatting for every HuggingFace Transformers's logger. The explicit formatter is as follows: :: [LEVELNAME|FILENAME|LINE NUMBER] TIME >> MESSAGE All handlers currently bound to the root logger are affected by this method. |
18,642 | import logging
import os
import sys
import threading
from logging import CRITICAL
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import NOTSET
from logging import WARN
from logging import WARNING
from typing import Optional
The provided code ... | This method is identical to `logger.warning()`, but if env var TRANSFORMERS_NO_ADVISORY_WARNINGS=1 is set, this warning will not be printed |
18,646 | import functools
import re
import types
def _prepare_output_docstrings(output_type, config_class, min_indent=None):
"""
Prepares the return part of the docstring using `output_type`.
"""
output_docstring = output_type.__doc__
# Remove the head of the docstring to keep the list of args only
lines... | null |
18,649 | import operator
import re
import sys
from typing import Optional
from packaging import version
def require_version(requirement: str, hint: Optional[str] = None) -> None:
"""
Perform a runtime check of the dependency versions, using the exact same syntax used by pip.
The installed module version comes from t... | require_version wrapper which emits a core-specific hint on failure |
18,650 | import os
import torch
from sofa.models.plug import (
PlugArgs,
BertTokenizer,
PalmModel,
DistributedPlugNLG,
TrainerPlugNLG,
PlugNLGConfig,
data_preparation_nlg,
PROCESSOR_MAPPING
)
from sofa.models.plug.data_palm import WeatherProcessor
from sofa.utils import mpu, print_rank_0
def p... | null |
18,651 | import os
import sys
import json
def weather():
os.system("wget https://alice-open.oss-cn-zhangjiakou.aliyuncs.com/PALM/weather_train.txt \
&& mv weather_train.txt train.txt \
&& wget https://alice-open.oss-cn-zhangjiakou.aliyuncs.com/PALM/weather_dev.txt \
&& mv weather_dev.txt dev.txt \
... | null |
18,652 | import os
import sys
import json
def process(fn):
fn("train")
fn("dev")
os.remove("train.json")
os.remove("dev.json")
def dureaderqg():
os.system("wget --no-check-certificate https://bj.bcebos.com/paddlenlp/datasets/DuReaderQG/train.json \
&& wget --no-check-certificate https://bj.bcebos.co... | null |
18,653 | import os
import sys
import json
def process(fn):
fn("train")
fn("dev")
os.remove("train.json")
os.remove("dev.json")
def dureader_robust():
os.system("wget --no-check-certificate https://dataset-bj.cdn.bcebos.com/dureader_robust/data/dureader_robust-data.tar.gz \
&& tar -zxvf dureader_robu... | null |
18,654 | import os
import sys
import json
def process(fn):
fn("train")
fn("dev")
os.remove("train.json")
os.remove("dev.json")
def lcsts():
os.system("wget --no-check-certificate https://bj.bcebos.com/paddlenlp/datasets/LCSTS_new/train.json \
&& wget --no-check-certificate https://bj.bcebos.com/padd... | null |
18,655 | from __future__ import division
import argparse
import os
from others.logging import init_logger
from train_abstractive import validate_abs, train_abs, baseline, test_abs, test_text_abs
def str2bool(v):
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', '... | null |
18,656 | from __future__ import division
import argparse
import collections
import glob
import os
import random
import signal
import time
import torch
from transformers import BertTokenizer
from transformers import RobertaTokenizer
import distributed
from models import data_loader, model_builder
from models.data_loader import l... | null |
18,657 | from __future__ import division
import argparse
import collections
import glob
import os
import random
import signal
import time
import torch
from transformers import BertTokenizer
from transformers import RobertaTokenizer
import distributed
from models import data_loader, model_builder
from models.data_loader import l... | null |
18,658 | from __future__ import division
import argparse
import collections
import glob
import os
import random
import signal
import time
import torch
from transformers import BertTokenizer
from transformers import RobertaTokenizer
import distributed
from models import data_loader, model_builder
from models.data_loader import l... | null |
18,659 | from __future__ import division
import argparse
import collections
import glob
import os
import random
import signal
import time
import torch
from transformers import BertTokenizer
from transformers import RobertaTokenizer
import distributed
from models import data_loader, model_builder
from models.data_loader import l... | null |
18,660 | from __future__ import division
import argparse
import collections
import glob
import os
import random
import signal
import time
import torch
from transformers import BertTokenizer
from transformers import RobertaTokenizer
import distributed
from models import data_loader, model_builder
from models.data_loader import l... | null |
18,661 | from __future__ import division
import argparse
import collections
import glob
import os
import random
import signal
import time
import torch
from transformers import BertTokenizer
from transformers import RobertaTokenizer
import distributed
from models import data_loader, model_builder
from models.data_loader import l... | null |
18,662 | import math
from pathlib import Path
import sys
from IPython import display
from base64 import b64encode
from omegaconf import OmegaConf
from PIL import Image
from taming.models import cond_transformer, vqgan
import taming.modulesiceMind.PALM.models import encoder
import torch
from torch import nn, optim
from torch.nn ... | null |
18,663 | import math
from pathlib import Path
import sys
from IPython import display
from base64 import b64encode
from omegaconf import OmegaConf
from PIL import Image
from taming.models import cond_transformer, vqgan
import taming.modulesiceMind.PALM.models import encoder
import torch
from torch import nn, optim
from torch.nn ... | null |
18,664 | import math
from pathlib import Path
import sys
from IPython import display
from base64 import b64encode
from omegaconf import OmegaConf
from PIL import Image
from taming.models import cond_transformer, vqgan
import taming.modulesiceMind.PALM.models import encoder
import torch
from torch import nn, optim
from torch.nn ... | null |
18,665 | import math
from pathlib import Path
import sys
from IPython import display
from base64 import b64encode
from omegaconf import OmegaConf
from PIL import Image
from taming.models import cond_transformer, vqgan
import taming.modulesiceMind.PALM.models import encoder
import torch
from torch import nn, optim
from torch.nn ... | null |
18,666 | import math
from pathlib import Path
import sys
from IPython import display
from base64 import b64encode
from omegaconf import OmegaConf
from PIL import Image
from taming.models import cond_transformer, vqgan
import taming.modulesiceMind.PALM.models import encoder
import torch
from torch import nn, optim
from torch.nn ... | null |
18,667 | import math
from pathlib import Path
import sys
from IPython import display
from base64 import b64encode
from omegaconf import OmegaConf
from PIL import Image
from taming.models import cond_transformer, vqgan
import taming.modulesiceMind.PALM.models import encoder
import torch
from torch import nn, optim
from torch.nn ... | null |
18,668 | import argparse
from os import path
from functools import reduce
import re
def str2bool(v):
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
return False
else:
raise argparse.ArgumentTypeError('Boolean value expected.') | null |
18,669 | import argparse
from os import path
from functools import reduce
import re
def n_grams(tokens, n):
def has_repeat(elements):
def cal_self_repeat(summary):
ngram_repeats = {2: 0, 4: 0, 8: 0}
sents = summary.split('<q>')
for n in ngram_repeats.keys():
# Respect sentence boundary
grams = reduc... | null |
18,670 | import argparse
from os import path
from functools import reduce
import re
def cal_novel(summary, gold, source, summary_ngram_novel, gold_ngram_novel):
summary = summary.replace('<q>',' ')
summary = re.sub(r' +', ' ', summary).strip()
gold = gold.replace('<q>',' ')
gold = re.sub(r' +', ' ', gold).strip(... | null |
18,671 | from __future__ import division
import os
import io
import sys
import argparse
import torch
import argparse
import collections
import glob
import os
import random
import signal
import time
import torch
from pytorch_transformers import BertTokenizer
from transformers import RobertaTokenizer
import distributed
from model... | Generate a parameters parser. |
18,672 | import glob
import json
import os
import random
import re
import subprocess
from collections import Counter
from os.path import join as pjoin
import torch
from others.logging import logger
from transformers import BertTokenizer
from transformers import RobertaTokenizer
from others.utils import clean
from prepro.utils i... | null |
18,673 | import glob
import json
import os
import random
import re
import subprocess
from collections import Counter
from os.path import join as pjoin
import torch
from others.logging import logger
from transformers import BertTokenizer
from transformers import RobertaTokenizer
from others.utils import clean
from prepro.utils i... | null |
18,674 | from __future__ import print_function
import math
import pickle
import torch.distributed
from others.logging import logger
The provided code snippet includes necessary dependencies for implementing the `all_reduce_and_rescale_tensors` function. Write a Python function `def all_reduce_and_rescale_tensors(tensors, resca... | All-reduce and rescale tensors in chunks of the specified size. Args: tensors: list of Tensors to all-reduce rescale_denom: denominator for rescaling summed Tensors buffer_size: all-reduce chunk size in bytes |
18,675 | from __future__ import print_function
import math
import pickle
import torch.distributed
from others.logging import logger
The provided code snippet includes necessary dependencies for implementing the `all_gather_list` function. Write a Python function `def all_gather_list(data, max_size=4096)` to solve the following... | Gathers arbitrary data from all nodes into a list. |
18,676 | from __future__ import print_function, unicode_literals, division
import os
import re
import codecs
import platform
from subprocess import check_output
from tempfile import mkdtemp
from functools import partial
from pyrouge.utils import log
from pyrouge.utils.file_utils import verify_dir
REMAP = {"-lrb-": "(", "-rrb-":... | null |
18,677 | import os
import re
import shutil
import time
from others import pyrouge
REMAP = {"-lrb-": "(", "-rrb-": ")", "-lcb-": "{", "-rcb-": "}",
"-lsb-": "[", "-rsb-": "]", "``": '"', "''": '"'}
def clean(x):
return re.sub(
r"-lrb-|-rrb-|-lcb-|-rcb-|-lsb-|-rsb-|``|''",
lambda m: REMAP.get(m.group... | null |
18,678 | import os
import re
import shutil
import time
from others import pyrouge
from pyrouge.utils import log
from pyrouge.utils.file_utils import verify_dir
def process(params):
temp_dir, data = params
candidates, references, pool_id = data
cnt = len(candidates)
current_time = time.strftime('%Y-%m-%d-%H-%M-... | null |
18,679 | import os
import re
import shutil
import time
from others import pyrouge
from pyrouge.utils import log
from pyrouge.utils.file_utils import verify_dir
def test_rouge(temp_dir, cand, ref):
candidates = [line.strip() for line in open(cand, encoding='utf-8')]
references = [line.strip() for line in open(ref, enco... | null |
18,680 | import os
import re
import shutil
import time
from others import pyrouge
The provided code snippet includes necessary dependencies for implementing the `tile` function. Write a Python function `def tile(x, count, dim=0)` to solve the following problem:
Tiles x on dimension dim count times.
Here is the function:
def ... | Tiles x on dimension dim count times. |
18,681 | import os
import re
import shutil
import time
from others import pyrouge
def rouge_results_to_str(results_dict):
return ">> ROUGE-F(1/2/3/l): {:.2f}/{:.2f}/{:.2f}\nROUGE-R(1/2/3/l): {:.2f}/{:.2f}/{:.2f}\n".format(
results_dict["rouge_1_f_score"] * 100,
results_dict["rouge_2_f_score"] * 100,
... | null |
18,682 | from __future__ import absolute_import, division, print_function, unicode_literals
import collections
import logging
import os
import unicodedata
from io import open
from pytorch_transformers import cached_path
The provided code snippet includes necessary dependencies for implementing the `load_vocab` function. Write ... | Loads a vocabulary file into a dictionary. |
18,683 | from __future__ import absolute_import, division, print_function, unicode_literals
import collections
import logging
import os
import unicodedata
from io import open
from pytorch_transformers import cached_path
The provided code snippet includes necessary dependencies for implementing the `whitespace_tokenize` functio... | Runs basic whitespace cleaning and splitting on a peice of text. |
18,684 | from __future__ import absolute_import, division, print_function, unicode_literals
import collections
import logging
import os
import unicodedata
from io import open
from pytorch_transformers import cached_path
The provided code snippet includes necessary dependencies for implementing the `_is_whitespace` function. Wr... | Checks whether `chars` is a whitespace character. |
18,685 | from __future__ import absolute_import, division, print_function, unicode_literals
import collections
import logging
import os
import unicodedata
from io import open
from pytorch_transformers import cached_path
The provided code snippet includes necessary dependencies for implementing the `_is_control` function. Write... | Checks whether `chars` is a control character. |
18,686 | from __future__ import absolute_import, division, print_function, unicode_literals
import collections
import logging
import os
import unicodedata
from io import open
from pytorch_transformers import cached_path
The provided code snippet includes necessary dependencies for implementing the `_is_punctuation` function. W... | Checks whether `chars` is a punctuation character. |
18,687 | from __future__ import (absolute_import, division, print_function,
unicode_literals)
import logging
import os
import tensorflow as tf
from .configuration_utils import PretrainedConfig
from .file_utils import cached_path, WEIGHTS_NAME, TF_WEIGHTS_NAME, TF2_WEIGHTS_NAME
from .modeling_tf_pytorch_u... | Creates a `tf.initializers.truncated_normal` with the given range. Args: initializer_range: float, initializer range for stddev. Returns: TruncatedNormal initializer with stddev = `initializer_range`. |
18,688 | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import os
import sys
from io import open
import numpy as np
import tensorflow as tf
from .configuration_ctrl import CTRLConfig
from .modeling_tf_utils import TFPreTrainedModel, get_initializer, shape_list, TFSharedEmbeddin... | null |
18,689 | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import os
import sys
from io import open
import numpy as np
import tensorflow as tf
from .configuration_ctrl import CTRLConfig
from .modeling_tf_utils import TFPreTrainedModel, get_initializer, shape_list, TFSharedEmbeddin... | null |
18,690 | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import os
import sys
from io import open
import numpy as np
import tensorflow as tf
from .configuration_ctrl import CTRLConfig
from .modeling_tf_utils import TFPreTrainedModel, get_initializer, shape_list, TFSharedEmbeddin... | null |
18,691 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import torch
from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert
import logging
def convert_tf_checkpoint_to_pytorch(tf_checkpoint_path, bert_config_file, pytorch_du... | null |
18,692 | from __future__ import absolute_import, division, print_function, unicode_literals
import collections
import json
import logging
import math
import os
import sys
from io import open
import numpy as np
import torch
import torch.nn as nn
from torch.nn import CrossEntropyLoss
from torch.nn.parameter import Parameter
from ... | null |
18,693 | from __future__ import absolute_import, division, print_function, unicode_literals
import collections
import json
import logging
import math
import os
import sys
from io import open
import numpy as np
import torch
import torch.nn as nn
from torch.nn import CrossEntropyLoss
from torch.nn.parameter import Parameter
from ... | null |
18,694 | from __future__ import absolute_import, division, print_function, unicode_literals
import collections
import json
import logging
import math
import os
import sys
from io import open
import numpy as np
import torch
import torch.nn as nn
from torch.nn import CrossEntropyLoss
from torch.nn.parameter import Parameter
from ... | null |
18,695 | from __future__ import (absolute_import, division, print_function,
unicode_literals)
import json
import logging
import os
import re
from io import open
from .tokenization_utils import PreTrainedTokenizer
from .tokenization_bert import BasicTokenizer
The provided code snippet includes necessary ... | Return set of symbol pairs in a word. word is represented as tuple of symbols (symbols being variable-length strings) |
18,696 | from __future__ import (absolute_import, division, print_function,
unicode_literals)
import json
import logging
import os
import re
from io import open
from .tokenization_utils import PreTrainedTokenizer
from .tokenization_bert import BasicTokenizer
The provided code snippet includes necessary ... | fixes some issues the spacy tokenizer had on books corpus also does some whitespace standardization |
18,697 |
The provided code snippet includes necessary dependencies for implementing the `gelu` function. Write a Python function `def gelu(x)` to solve the following problem:
Gaussian Error Linear Unit. This is a smoother version of the RELU. Original paper: https://arxiv.org/abs/1606.08415 Args: x: float Tensor to perform ac... | Gaussian Error Linear Unit. This is a smoother version of the RELU. Original paper: https://arxiv.org/abs/1606.08415 Args: x: float Tensor to perform activation. Returns: `x` with the GELU activation applied. |
18,698 |
def swish(x):
return x * tf.math.sigmoid(x) | null |
18,699 | from __future__ import absolute_import, division, print_function
import argparse
from io import open
import torch
from transformers import (CONFIG_NAME, WEIGHTS_NAME,
GPT2Config,
GPT2Model,
... | null |
18,700 | from __future__ import absolute_import, division, print_function
import argparse
from io import open
import torch
from transformers import (CONFIG_NAME, WEIGHTS_NAME,
OpenAIGPTConfig,
OpenAIGPTModel,
... | null |
18,701 | from __future__ import absolute_import, division, print_function, unicode_literals
import os
import json
import math
import logging
import collections
import sys
from io import open
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import CrossEntropyLoss
from torch.nn.parameter import Pa... | Load tf checkpoints in a pytorch model |
18,702 | from __future__ import (absolute_import, division, print_function,
unicode_literals)
import json
import logging
import os
import regex as re
from io import open
from .tokenization_utils import PreTrainedTokenizer
The provided code snippet includes necessary dependencies for implementing the `ge... | Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings). |
18,703 | from __future__ import (absolute_import, division, print_function,
unicode_literals)
import glob
import logging
import os
import sys
from collections import Counter, OrderedDict
from io import open
import numpy as np
from .file_utils import cached_path
from .tokenization_utils import PreTrainedT... | null |
18,704 | from __future__ import (absolute_import, division, print_function, unicode_literals)
import sys
import json
import logging
import os
import six
import shutil
import tempfile
import fnmatch
from functools import wraps
from hashlib import sha256
from io import open
import boto3
from botocore.config import Config
from bot... | null |
18,705 | from __future__ import (absolute_import, division, print_function, unicode_literals)
import sys
import json
import logging
import os
import six
import shutil
import tempfile
import fnmatch
from functools import wraps
from hashlib import sha256
from io import open
import boto3
from botocore.config import Config
from bot... | null |
18,706 | from __future__ import (absolute_import, division, print_function, unicode_literals)
import sys
import json
import logging
import os
import six
import shutil
import tempfile
import fnmatch
from functools import wraps
from hashlib import sha256
from io import open
import boto3
from botocore.config import Config
from bot... | null |
18,707 | from __future__ import (absolute_import, division, print_function, unicode_literals)
import sys
import json
import logging
import os
import six
import shutil
import tempfile
import fnmatch
from functools import wraps
from hashlib import sha256
from io import open
import boto3
from botocore.config import Config
from bot... | null |
18,708 | from __future__ import (absolute_import, division, print_function, unicode_literals)
import sys
import json
import logging
import os
import six
import shutil
import tempfile
import fnmatch
from functools import wraps
from hashlib import sha256
from io import open
import boto3
from botocore.config import Config
from bot... | Return the url and etag (which may be ``None``) stored for `filename`. Raise ``EnvironmentError`` if `filename` or its stored metadata do not exist. |
18,709 | from __future__ import (absolute_import, division, print_function, unicode_literals)
import sys
import json
import logging
import os
import six
import shutil
import tempfile
import fnmatch
from functools import wraps
from hashlib import sha256
from io import open
import boto3
from botocore.config import Config
from bot... | Given something that might be a URL (or might be a local path), determine which. If it's a URL, download the file and cache it, and return the path to the cached file. If it's already a local path, make sure the file exists and then return the path. Args: cache_dir: specify a cache directory to save the file to (overwr... |
18,710 | from __future__ import (absolute_import, division, print_function, unicode_literals)
import sys
import json
import logging
import os
import six
import shutil
import tempfile
import fnmatch
from functools import wraps
from hashlib import sha256
from io import open
import boto3
from botocore.config import Config
from bot... | Wrapper function for s3 requests in order to create more helpful error messages. |
18,711 | from collections import defaultdict
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
The provided code snippet includes necessary dependencies for implementing the `sample_logits` function. Write a Python function `def sample_logits(embedding, bias, labels, inputs, sampler)` to sol... | embedding: an nn.Embedding layer bias: [n_vocab] labels: [b1, b2] inputs: [b1, b2, n_emb] sampler: you may use a LogUniformSampler Return logits: [b1, b2, 1 + n_sample] |
18,712 | from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import math
import os
import sys
from io import open
import numpy as np
import tensorflow as tf
from .configuration_xlnet import XLNetConfig
from .modeling_tf_utils import TFPreTrainedModel, TFSharedEmbeddings,... | Implementation of the gelu activation function. XLNet is using OpenAI GPT's gelu Also see https://arxiv.org/abs/1606.08415 |
18,713 | from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import math
import os
import sys
from io import open
import numpy as np
import tensorflow as tf
from .configuration_xlnet import XLNetConfig
from .modeling_tf_utils import TFPreTrainedModel, TFSharedEmbeddings,... | null |
18,714 | from __future__ import absolute_import, division, print_function, unicode_literals
import collections
import json
import logging
import math
import os
import sys
from io import open
import numpy as np
import tensorflow as tf
from .modeling_tf_utils import (TFPreTrainedModel, TFConv1D, TFSharedEmbeddings,
... | Gaussian Error Linear Unit. This is a smoother version of the RELU. Original paper: https://arxiv.org/abs/1606.08415 Args: x: float Tensor to perform activation. Returns: `x` with the GELU activation applied. |
18,715 | import logging
import os
from .utils import DataProcessor, InputExample, InputFeatures
from ...file_utils import is_tf_available
if is_tf_available():
import tensorflow as tf
logger = logging.getLogger(__name__)
glue_processors = {
"cola": ColaProcessor,
"mnli": MnliProcessor,
"mnli-mm": MnliMismatchedP... | Loads a data file into a list of ``InputFeatures`` Args: examples: List of ``InputExamples`` or ``tf.data.Dataset`` containing the examples. tokenizer: Instance of a tokenizer that will tokenize the examples max_length: Maximum example length task: GLUE task label_list: List of labels. Can be obtained from the processo... |
18,716 | import os
import argparse
import torch
import numpy as np
import tensorflow as tf
from transformers import BertModel
The provided code snippet includes necessary dependencies for implementing the `convert_pytorch_checkpoint_to_tf` function. Write a Python function `def convert_pytorch_checkpoint_to_tf(model:BertModel,... | :param model:BertModel Pytorch model instance to be converted :param ckpt_dir: Tensorflow model directory :param model_name: model name :return: Currently supported HF models: Y BertModel N BertForMaskedLM N BertForPreTraining N BertForMultipleChoice N BertForNextSentencePrediction N BertForSequenceClassification N Ber... |
18,717 | from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import math
import os
import sys
from io import open
import torch
from torch import nn
from torch.nn import functional as F
from torch.nn import CrossEntropyLoss, MSELoss
from .modeling_utils import PreTrainedM... | Load tf checkpoints in a pytorch model |
18,718 | from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import math
import os
import sys
from io import open
import torch
from torch import nn
from torch.nn import functional as F
from torch.nn import CrossEntropyLoss, MSELoss
from .modeling_utils import PreTrainedM... | Implementation of the gelu activation function. XLNet is using OpenAI GPT's gelu (not exactly the same as BERT) Also see https://arxiv.org/abs/1606.08415 |
18,719 | from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import math
import os
import sys
from io import open
import torch
from torch import nn
from torch.nn import functional as F
from torch.nn import CrossEntropyLoss, MSELoss
from .modeling_utils import PreTrainedM... | null |
18,720 | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import math
import os
import itertools
import numpy as np
import tensorflow as tf
from .configuration_xlm import XLMConfig
from .modeling_tf_utils import TFPreTrainedModel, TFSharedEmbeddings, TFSequenceSummary, shape_list... | null |
18,721 | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import math
import os
import itertools
import numpy as np
import tensorflow as tf
from .configuration_xlm import XLMConfig
from .modeling_tf_utils import TFPreTrainedModel, TFSharedEmbeddings, TFSequenceSummary, shape_list... | Gaussian Error Linear Unit. Original Implementation of the gelu activation function in Google Bert repo when initially created. For information: OpenAI GPT's gelu is slightly different (and gives slightly different results): 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3)))) Also see ... |
18,722 | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import math
import os
import itertools
import numpy as np
import tensorflow as tf
from .configuration_xlm import XLMConfig
from .modeling_tf_utils import TFPreTrainedModel, TFSharedEmbeddings, TFSequenceSummary, shape_list... | Generate hidden states mask, and optionally an attention mask. |
18,723 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import argparse
import torch
from transformers import (CONFIG_NAME, WEIGHTS_NAME,
XLNetConfig,
XL... | null |
18,724 | from __future__ import absolute_import, division, print_function, unicode_literals
import collections
import json
import logging
import math
import os
import sys
from io import open
import torch
import torch.nn as nn
from torch.nn import CrossEntropyLoss
from torch.nn.parameter import Parameter
from .modeling_utils imp... | Load tf checkpoints in a pytorch model |
18,725 | from __future__ import absolute_import, division, print_function, unicode_literals
import collections
import json
import logging
import math
import os
import sys
from io import open
import torch
import torch.nn as nn
from torch.nn import CrossEntropyLoss
from torch.nn.parameter import Parameter
from .modeling_utils imp... | null |
18,726 | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import math
import itertools
import numpy as np
import torch
from torch import nn
from torch.nn import functional as F
from torch.nn import CrossEntropyLoss, MSELoss
from .modeling_utils import PreTrainedModel, prune_linea... | null |
18,727 | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import math
import itertools
import numpy as np
import torch
from torch import nn
from torch.nn import functional as F
from torch.nn import CrossEntropyLoss, MSELoss
from .modeling_utils import PreTrainedModel, prune_linea... | GELU activation https://arxiv.org/abs/1606.08415 https://github.com/huggingface/pytorch-openai-transformer-lm/blob/master/model_pytorch.py#L14 https://github.com/huggingface/transformers/blob/master/modeling.py |
18,728 | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import math
import itertools
import numpy as np
import torch
from torch import nn
from torch.nn import functional as F
from torch.nn import CrossEntropyLoss, MSELoss
from .modeling_utils import PreTrainedModel, prune_linea... | Generate hidden states mask, and optionally an attention mask. |
18,729 | from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import math
import copy
import sys
from io import open
import itertools
import numpy as np
import torch
import torch.nn as nn
from .modeling_utils import PreTrainedModel, prune_linear_layer
from .configuration_... | null |
18,730 | from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import math
import copy
import sys
from io import open
import itertools
import numpy as np
import torch
import torch.nn as nn
from .modeling_utils import PreTrainedModel, prune_linear_layer
from .configuration_... | null |
18,731 | from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import math
import os
import sys
from io import open
import numpy as np
import tensorflow as tf
from .configuration_bert import BertConfig
from .modeling_tf_utils import TFPreTrainedModel, get_initializer
from ... | Gaussian Error Linear Unit. Original Implementation of the gelu activation function in Google Bert repo when initially created. For information: OpenAI GPT's gelu is slightly different (and gives slightly different results): 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3)))) Also see ... |
18,732 | from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import math
import os
import sys
from io import open
import numpy as np
import tensorflow as tf
from .configuration_bert import BertConfig
from .modeling_tf_utils import TFPreTrainedModel, get_initializer
from ... | Gaussian Error Linear Unit. This is a smoother version of the RELU. Original paper: https://arxiv.org/abs/1606.08415 Args: x: float Tensor to perform activation. Returns: `x` with the GELU activation applied. |
18,733 | from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import math
import os
import sys
from io import open
import numpy as np
import tensorflow as tf
from .configuration_bert import BertConfig
from .modeling_tf_utils import TFPreTrainedModel, get_initializer
from ... | null |
18,734 | from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import math
import copy
import sys
from io import open
import itertools
import numpy as np
import tensorflow as tf
from .configuration_distilbert import DistilBertConfig
from .modeling_tf_utils import TFPreTrai... | Gaussian Error Linear Unit. Original Implementation of the gelu activation function in Google Bert repo when initially created. For information: OpenAI GPT's gelu is slightly different (and gives slightly different results): 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3)))) Also see ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.