python_code
stringlengths
0
992k
repo_name
stringlengths
8
46
file_path
stringlengths
5
162
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np from . import BaseWrapperDataset class TruncateDataset(BaseWrapperDataset): def __init__(self, dataset, truncation_...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/truncate_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import bisect import numpy as np from torch.utils.data.dataloader import default_collate from . import FairseqDataset class ConcatDataset(...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/concat_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import BaseWrapperDataset class ReplaceDataset(BaseWrapperDataset): """Replaces tokens found in the dataset by a specified replac...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/replace_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from fairseq import utils from . import FairseqDataset def backtranslate_samples(samples, collate_fn, generate_fn, cuda=True)...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/backtranslation_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from . import FairseqDataset class IdDataset(FairseqDataset): def __getitem__(self, index): return index def...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/id_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from . import BaseWrapperDataset class PrependDataset(BaseWrapperDataset): def __init__(self, dataset, ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/prepend_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from collections import OrderedDict from typing import Callable, Dict, List import numpy as np from . import FairseqDataset def uniform_sa...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/multi_corpus_sampled_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import FairseqDataset class NumSamplesDataset(FairseqDataset): def __getitem__(self, index): return 1 def __len__(s...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/num_samples_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import numpy as np from fairseq.data import data_utils class WordNoising(object): """Generate a noisy version of a sentenc...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/noising.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np from . import BaseWrapperDataset class SubsampleDataset(BaseWrapperDataset): """Subsamples a given dataset by a spec...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/subsample_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np from . import BaseWrapperDataset class SortDataset(BaseWrapperDataset): def __init__(self, dataset, sort_order): ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/sort_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from . import data_utils, FairseqDataset def collate(samples, pad_idx, eos_idx): if len(samples) == 0: ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/monolingual_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from torch.utils.data.dataloader import default_collate from . import FairseqDataset class BaseWrapperDataset(FairseqDataset): def __i...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/base_wrapper_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from . import BaseWrapperDataset class NumelDataset(BaseWrapperDataset): def __init__(self, dataset, r...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/numel_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .dictionary import Dictionary, TruncatedDictionary from .fairseq_dataset import FairseqDataset, FairseqIterableDataset from .base_wrapp...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from . import FairseqDataset class ConcatSentencesDataset(FairseqDataset): def __init__(self, *datasets): super()...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/concat_sentences_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from functools import lru_cache import numpy as np import torch from fairseq.data import data_utils, Dictionary from . import BaseWrapperDa...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/mask_tokens_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from functools import lru_cache from . import BaseWrapperDataset class LRUCacheDataset(BaseWrapperDataset): def __init__(self, dataset...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/lru_cache_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch import math from . import data_utils, FairseqDataset def collate( samples, pad_idx, eos_idx, ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/denoising_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import BaseWrapperDataset class StripTokenDataset(BaseWrapperDataset): def __init__(self, dataset, id_to_strip): super()...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/strip_token_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. try: from collections.abc import Iterable except ImportError: from collections import Iterable import contextlib import itertools impo...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/data_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import itertools import os import random from . import BaseWrapperDataset from fairseq.data import data_utils class ShardedDataset(BaseWrap...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/sharded_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from . import BaseWrapperDataset class PrependTokenDataset(BaseWrapperDataset): def __init__(self, dat...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/prepend_token_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from . import FairseqDataset class TransformEosDataset(FairseqDataset): """A :class:`~fairseq.data.FairseqDataset` wrapper...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/transform_eos_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from . import BaseWrapperDataset class ColorizeDataset(BaseWrapperDataset): """ Adds 'colors' property to net input that i...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/colorize_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from . import FairseqDataset class RawLabelDataset(FairseqDataset): def __init__(self, labels): super().__init__(...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/raw_label_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import BaseWrapperDataset class ListDataset(BaseWrapperDataset): def __init__(self, dataset, sizes=None): super().__init...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/list_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from collections import OrderedDict import numpy as np from . import FairseqDataset class RoundRobinZipDatasets(FairseqDataset): """Zi...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/round_robin_zip_datasets.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import itertools import math import os import numpy as np import torch from . import data_utils class CountingIterator(object): """Wra...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/iterators.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import subprocess import tempfile class PlasmaArray(object): """ Wrapper around numpy arrays that automatically moves the data to sh...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/plasma_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np from . import BaseWrapperDataset, plasma_utils class ResamplingDataset(BaseWrapperDataset): """Randomly samples from...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/resampling_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from . import data_utils, FairseqDataset def collate( samples, pad_idx, eos_idx, left_pad_source=True, ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/language_pair_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from . import BaseWrapperDataset class AppendTokenDataset(BaseWrapperDataset): def __init__(self, data...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/append_token_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq.data import data_utils from . import BaseWrapperDataset class PadDataset(BaseWrapperDataset): def __init__(self, dataset,...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/pad_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from functools import lru_cache import os import shutil import struct import numpy as np import torch from . import FairseqDataset def __b...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/indexed_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from . import BaseWrapperDataset class RollDataset(BaseWrapperDataset): def __init__(self, dataset, shifts): supe...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/roll_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from collections import Counter from multiprocessing import Pool import os import torch from fairseq.tokenizer import tokenize_line from fai...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/dictionary.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch.utils.data class EpochListening: """Mixin for receiving updates whenever the epoch increments.""" de...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/fairseq_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from fairseq.data.monolingual_dataset import MonolingualDataset from . import FairseqDataset class LMConte...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/lm_context_window_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from fairseq.data import FairseqDataset, plasma_utils class TokenBlockDataset(FairseqDataset): """Break...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/token_block_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import FairseqDataset from typing import Optional class TransformEosLangPairDataset(FairseqDataset): """A :class:`~fairseq.data....
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/transform_eos_lang_pair_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq.data import Dictionary class MaskedLMDictionary(Dictionary): """ Dictionary for Masked Language Modelling tasks. This e...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/legacy/masked_lm_dictionary.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import numpy as np import torch from fairseq.data import FairseqDataset class BlockPairDataset(FairseqDataset): """Break a...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/legacy/block_pair_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .masked_lm_dictionary import BertDictionary, MaskedLMDictionary from .block_pair_dataset import BlockPairDataset from .masked_lm_dataset ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/legacy/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import numpy as np import torch from typing import Dict, List, Tuple from fairseq.data import FairseqDataset, data_utils from ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/legacy/masked_lm_dataset.py
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/audio/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import numpy as np import sys import torch import torch.nn.functional as F from .. import FairseqDataset class RawAudioDataset(...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/audio/raw_audio_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq import file_utils from fairseq.data.encoders import register_bpe @register_bpe('sentencepiece') class SentencepieceBPE(object):...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/encoders/sentencepiece_bpe.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq import file_utils from fairseq.data.encoders import register_bpe @register_bpe('fastbpe') class fastBPE(object): @staticme...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/encoders/fastbpe.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq.data.encoders import register_tokenizer @register_tokenizer('nltk') class NLTKTokenizer(object): def __init__(self, source...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/encoders/nltk_tokenizer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq import file_utils from fairseq.data.encoders import register_bpe from .gpt2_bpe_utils import get_encoder DEFAULT_ENCODER_JSON ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/encoders/gpt2_bpe.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq import file_utils from fairseq.data.encoders import register_bpe @register_bpe('subword_nmt') class SubwordNMTBPE(object): ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/encoders/subword_nmt_bpe.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import importlib import os from fairseq import registry build_tokenizer, register_tokenizer, TOKENIZER_REGISTRY = registry.setup_registry(...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/encoders/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq.data.encoders import register_bpe @register_bpe('bert') class BertBPE(object): @staticmethod def add_args(parser): ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/encoders/hf_bert_bpe.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from fairseq.data import encoders def get_whole_word_mask(args, dictionary): bpe = encoders.build_bpe(args) if bpe is n...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/encoders/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import re from fairseq.data.encoders import register_tokenizer @register_tokenizer('space') class SpaceTokenizer(object): def __init__...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/encoders/space_tokenizer.py
""" Byte pair encoding utilities from GPT-2. Original source: https://github.com/openai/gpt-2/blob/master/src/encoder.py Original license: MIT """ from functools import lru_cache import json @lru_cache() def bytes_to_unicode(): """ Returns list of utf-8 byte and a corresponding list of unicode strings. ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/encoders/gpt2_bpe_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq.data.encoders import register_tokenizer @register_tokenizer('moses') class MosesTokenizer(object): @staticmethod def a...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/data/encoders/moses_tokenizer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from torch.nn.modules.loss import _Loss class FairseqCriterion(_Loss): def __init__(self, args, task): super().__init__() ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/criterions/fairseq_criterion.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch.nn.functional as F from fairseq import utils from . import FairseqCriterion, register_criterion @register_criteri...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/criterions/cross_entropy.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch.nn.functional as F from fairseq import utils from . import FairseqCriterion, register_criterion @register_criteri...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/criterions/adaptive_loss.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq import utils from . import FairseqCriterion, register_criterion def ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/criterions/legacy_masked_lm.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch.nn.functional as F from fairseq import utils import torch from torch import Tensor from . import FairseqCriterion, ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/criterions/nat_loss.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import importlib import os from fairseq import registry from fairseq.criterions.fairseq_criterion import FairseqCriterion build_criterion, ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/criterions/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from fairseq import utils from . import FairseqCriterion, register_criterion def label_smoothed_nll_loss(lprobs, target, epsil...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/criterions/label_smoothed_cross_entropy.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from torch import nn from fairseq import utils from . import FairseqCriterion, register_criterion @register_criterion('composite_loss') cla...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/criterions/composite_loss.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq import utils from . import FairseqCriterion, register_criterion @reg...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/criterions/binary_cross_entropy.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq import utils from . import FairseqCriterion, register_criterion @re...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/criterions/sentence_prediction.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from fairseq import utils from .label_smoothed_cross_entropy import LabelSmoothedCrossEntropyCriterion from . import register_cr...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/criterions/label_smoothed_cross_entropy_with_alignment.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq import utils from . import FairseqCriterion, register_criterion @re...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/criterions/masked_lm.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq import utils from . import FairseqCriterion, register_criterion @re...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/criterions/sentence_ranking.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # fairseq documentation build configuration file, created by # sphinx-quickstart on Fri Aug 17 21:45:30 2018. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # au...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/docs/conf.py
../preprocess.py
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq_cli/preprocess.py
../generate.py
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq_cli/generate.py
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq_cli/__init__.py
../setup.py
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq_cli/setup.py
../interactive.py
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq_cli/interactive.py
../train.py
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq_cli/train.py
../eval_lm.py
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq_cli/eval_lm.py
../score.py
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq_cli/score.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. __version__ = '0.9.0' import examples.noisychannel # noqa
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/__init__.py
import rerank_utils import rerank_generate import rerank_score_bw import rerank_score_lm from fairseq import bleu, options from fairseq.data import dictionary from examples.noisychannel import rerank_options from multiprocessing import Pool import math import numpy as np def score_target_hypo(args, a, b, c, lenpen, ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/noisychannel/rerank.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq import options def get_reranking_parser(default_task='translation'): parser = options.get_parser('Generation and reranking'...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/noisychannel/rerank_options.py
import rerank import argparse import numpy as np import random from examples.noisychannel import rerank_options from fairseq import options def random_search(args): param_values = [] tuneable_parameters = ['lenpen', 'weight1', 'weight2', 'weight3'] initial_params = [args.lenpen, args.weight1, args.weight2...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/noisychannel/rerank_tune.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .rerank_options import * # noqa
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/noisychannel/__init__.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Generate n-best translations using a trained model. """ from contextlib import redirect_stdout import os import...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/noisychannel/rerank_generate.py
import subprocess import os import re from fairseq import options import eval_lm import preprocess from contextlib import redirect_stdout import math def reprocess(fle): # takes in a file of generate.py translation generate_output # returns a source dict and hypothesis dict, where keys are the ID num (as a st...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/noisychannel/rerank_utils.py
import rerank_utils import os from fairseq import options from examples.noisychannel import rerank_options def score_lm(args): using_nbest = args.nbest_list is not None pre_gen, left_to_right_preprocessed_dir, right_to_left_preprocessed_dir, \ backwards_preprocessed_dir, lm_preprocessed_dir = \ ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/noisychannel/rerank_score_lm.py
import rerank_utils import os from fairseq import options from examples.noisychannel import rerank_options from contextlib import redirect_stdout import generate def score_bw(args): if args.backwards1: scorer1_src = args.target_lang scorer1_tgt = args.source_lang else: ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/noisychannel/rerank_score_bw.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Scoring script for computing pairwise BLEU and multi-ref BLEU over a set of candidate hypotheses. See `"Mixture Mod...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/translation_moe/score.py
from . import tasks, criterions, models # noqa
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Wav2letter decoders. """ import math import itertools as it import torch from fairseq import utils from examples.s...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/w2l_decoder.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Run inference for pre-processed data with a trained model. """ import logging import math import os import sen...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/infer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import json import os import re import torch from fairseq.data import Dictionary from fairseq.tasks import FairseqTask, register_task from ex...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/tasks/speech_recognition.py
import importlib import os for file in os.listdir(os.path.dirname(__file__)): if file.endswith('.py') and not file.startswith('_'): task_name = file[:file.find('.py')] importlib.import_module('examples.speech_recognition.tasks.' + task_name)
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/tasks/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import absolute_import, division, print_function, unicode_literals from collections import namedtuple ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/datasets/asr_prep_json.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import absolute_import, division, print_function, unicode_literals import re from collections import ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/utils/wer_utils.py
import importlib import os for file in os.listdir(os.path.dirname(__file__)): if file.endswith('.py') and not file.startswith('_'): model_name = file[:file.find('.py')] importlib.import_module('examples.speech_recognition.models.' + model_name)
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/models/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import math from collections.abc import Iterable import torch import torch.nn as nn from fairseq import utils from fairseq.mo...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/models/vggtransformer.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn as nn import torch.nn.functional as F from fairseq.models import ( Fairs...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/models/w2l_conv_glu_enc.py