repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
BIFI | BIFI-main/utils/fairseq/fairseq/modules/sparse_multihead_attention.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
from .multihead_attention import MultiheadAttention
class SparseMultiheadAttention(MultiheadAttention):
""" Spa... | 4,525 | 42.104762 | 100 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/multihead_attention.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 typing import Dict, Optional, Tuple
import torch
import torch.nn.functional as F
from fairseq import utils
from torch import... | 18,411 | 38.51073 | 102 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/linearized_convolution.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 torch.nn.functional as F
from fairseq import utils
from .conv_tbc import ConvTBC
from fairseq.incremental_decoding_utils ... | 3,691 | 40.483146 | 95 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/downsampled_multihead_attention.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 as nn
import torch.nn.functional as F
from fairseq.modules.scalar_bias import scalar_bias
class ... | 9,815 | 37.194553 | 106 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/gelu.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.
"""
See "Gaussian Error Linear Units (GELUs)" by Dan Hendrycks and Kevin Gimpel with
the corresponding GitHub repo: https://github.com/hendryck... | 828 | 27.586207 | 87 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/positional_embedding.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.nn as nn
from .learned_positional_embedding import LearnedPositionalEmbedding
from .sinusoidal_positional_embedding import Sinuso... | 1,286 | 38 | 83 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/adaptive_input.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 torch import nn
from typing import List
class AdaptiveInput(nn.Module):
def __init__(
self,
vocab_s... | 2,363 | 30.52 | 80 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/gumbel_vector_quantizer.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 torch.nn as nn
import torch.nn.functional as F
class GumbelVectorQuantizer(nn.Module):
def __init__(
self,
... | 5,808 | 32.194286 | 117 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/vggblock.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 __future__ import absolute_import, division, print_function, unicode_literals
from collections.abc import Iterable
from itertools import... | 4,057 | 33.683761 | 88 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/character_token_embedder.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 logging
from typing import List, Tuple
import torch
from torch import nn
import torch.nn.functional as F
from fairseq.data import Dic... | 6,846 | 32.4 | 106 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/unfold.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.nn.functional as F
def unfold1d(x, kernel_size, padding_l, pad_value=0):
'''unfold T x B x C to T x B x C x K'''
if ker... | 570 | 30.722222 | 91 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/fp32_group_norm.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.
"""
Layer norm done in fp32 (for fp16 training)
"""
import torch.nn as nn
import torch.nn.functional as F
class Fp32GroupNorm(nn.GroupNorm):... | 727 | 27 | 69 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/adaptive_softmax.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 operator
import functools
import torch
import torch.nn.functional as F
from torch import nn
class TiedLinear(nn.Module):
def __i... | 7,207 | 33.821256 | 112 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/conv_tbc.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 torch.nn.modules.utils import _single
class ConvTBC(torch.nn.Module):
"""1D convolution over an input of shape (time x... | 1,356 | 35.675676 | 90 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/transformer_layer.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 typing import Dict, List, Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
from fai... | 15,495 | 40.103448 | 92 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/beamable_mm.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 torch.nn as nn
class BeamableMM(nn.Module):
"""This module provides an optimized MM for beam decoding with attention... | 1,779 | 36.083333 | 80 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/layer_norm.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 torch.nn as nn
import torch.nn.functional as F
try:
from apex.normalization import FusedLayerNorm as _FusedLayerNorm... | 1,444 | 29.104167 | 81 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/kmeans_vector_quantizer.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 torch.nn as nn
from fairseq.modules import Fp32GroupNorm
class KmeansVectorQuantizer(nn.Module):
def __init__(
... | 4,248 | 31.937984 | 89 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/dynamic_crf_layer.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.
"""
This file is to re-implemented the low-rank and beam approximation of CRF layer
Proposed by:
Sun, Zhiqing, et al.
Fast Structured Decodin... | 7,676 | 40.497297 | 99 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/scalar_bias.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
class ScalarBias(torch.autograd.Function):
"""
Adds a vector of scalars, used in self-attention mechanism to allow
... | 888 | 26.78125 | 74 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/transformer_sentence_encoder.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 typing import Optional, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq.modules import (
Layer... | 8,201 | 34.66087 | 88 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/grad_multiply.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
class GradMultiply(torch.autograd.Function):
@staticmethod
def forward(ctx, x, scale):
ctx.scale = scale
... | 442 | 22.315789 | 65 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/sparse_transformer_sentence_encoder.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.nn as nn
from fairseq.modules import TransformerSentenceEncoder
from fairseq.modules.sparse_transformer_sentence_encoder_layer im... | 2,970 | 36.1375 | 107 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/sinusoidal_positional_embedding.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 typing import Any, Optional
import torch
import torch.onnx.operators
from fairseq import utils
from torch import Tensor, nn
... | 3,880 | 35.613208 | 87 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/lightweight_convolution.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 torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
from fairseq.modules.unfold import unfold1d
from... | 10,383 | 39.5625 | 103 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/dynamic_convolution.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 torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
from .unfold import unfold1d
from fairseq.increm... | 11,004 | 43.918367 | 132 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/dynamicconv_layer/setup.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 setuptools import setup
from torch.utils.cpp_extension import CUDAExtension, BuildExtension
setup(
name='dyna... | 613 | 24.583333 | 67 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/dynamicconv_layer/dynamicconv_layer.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 torch import nn
from torch.autograd import Function
import torch.nn.functional as F
import dynamicconv_cuda
from fairseq im... | 8,697 | 39.455814 | 129 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/lightconv_layer/setup.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 setuptools import setup
from torch.utils.cpp_extension import CUDAExtension, BuildExtension
setup(
name='ligh... | 545 | 25 | 67 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/modules/lightconv_layer/lightconv_layer.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 torch import nn
from torch.autograd import Function
import torch.nn.functional as F
import lightconv_cuda
from fairseq impo... | 4,601 | 34.953125 | 98 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/logging/progress_bar.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.
"""
Wrapper around various loggers and progress bars (e.g., tqdm).
"""
import atexit
import json
import logging
import os
import sys
from col... | 11,023 | 30.053521 | 89 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/logging/meters.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
from collections import OrderedDict
import time
from typing import Dict, Optional
try:
import torch
except ImportError:
... | 7,575 | 26.549091 | 79 | py |
BIFI | BIFI-main/utils/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 inspect
from typing import Any, Dict, List
from torch.nn.modules.loss import _Loss
from fairseq import metrics, utils
class Fairseq... | 4,258 | 34.491667 | 79 | py |
BIFI | BIFI-main/utils/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 math
import torch.nn.functional as F
import torch
from torch import Tensor
from fairseq import metrics, utils
from fairseq.criterions... | 6,238 | 34.856322 | 98 | py |
BIFI | BIFI-main/utils/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
import torch.nn.functional as F
from fairseq import utils
from fairseq.criterions import FairseqCriterion, register... | 6,793 | 41.72956 | 100 | py |
BIFI | BIFI-main/utils/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.nn.functional as F
from fairseq import metrics, utils
from fairseq.criterions import FairseqCriterion, register_cri... | 3,963 | 37.862745 | 105 | py |
BIFI | BIFI-main/utils/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 metrics, utils
from fairseq.criterions import FairseqCriterion,... | 3,026 | 33.793103 | 94 | py |
BIFI | BIFI-main/utils/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 metrics, utils
from fairseq.criterions import FairseqCriterion, register_cri... | 2,871 | 37.810811 | 99 | py |
BIFI | BIFI-main/utils/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
import torch
import torch.nn.functional as F
from fairseq import metrics, utils
from fairseq.criterions import FairseqCriterion,... | 3,717 | 37.729167 | 96 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/criterions/sentence_ranking.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 metrics, utils
from fairseq.criterions import FairseqCriterion,... | 4,532 | 37.74359 | 94 | py |
BIFI | BIFI-main/utils/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.
from torch import nn
from fairseq import utils
from fairseq.criterions import FairseqCriterion, register_criterion
@register_criterion('com... | 3,689 | 35.9 | 96 | py |
BIFI | BIFI-main/utils/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 fairseq.criterions import FairseqCriterion, register... | 5,849 | 39.909091 | 126 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/wav2vec.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 logging
import math
import sys
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq.models import BaseFair... | 24,313 | 31.636242 | 131 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/lstm.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 torch.nn as nn
import torch.nn.functional as F
from fairseq import options, utils
from fairseq.models import (
Fairse... | 26,551 | 43.033167 | 105 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/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 logging
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
from fairseq.models import (
... | 14,861 | 41.462857 | 100 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/model_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 typing import List, Optional
import torch
from torch import Tensor
@torch.jit.script
def script_skip_tensor_list(x: List[Tensor], mask... | 2,335 | 24.67033 | 103 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/fairseq_encoder.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.nn as nn
from typing import List, NamedTuple, Optional
from torch import Tensor
EncoderOut = NamedTuple(
"EncoderOut",
[... | 1,746 | 29.12069 | 78 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/fconv.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 as nn
import torch.nn.functional as F
from fairseq import utils
from fairseq.models import (
Fa... | 27,651 | 40.333333 | 127 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/lightconv.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 as nn
import torch.nn.functional as F
from fairseq import options, utils
from fairseq.models import... | 36,369 | 45.272265 | 165 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/transformer.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 typing import Any, Dict, List, Optional, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairs... | 44,201 | 41.298565 | 159 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/fconv_self_att.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 logging
import math
import os
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import checkpoint_utils... | 24,269 | 40.487179 | 111 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/fairseq_decoder.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 typing import Dict, List, Optional, Tuple
import torch.nn as nn
from fairseq import utils
from torch import Tensor
class FairseqDecode... | 3,047 | 32.494505 | 83 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/fairseq_model.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.
"""
Base classes for various fairseq models.
"""
import logging
from typing import Dict, List, Optional, Tuple
import torch
import torch.nn a... | 18,070 | 34.433333 | 86 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/distributed_fairseq_model.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 inspect
import torch.nn as nn
from fairseq.legacy_distributed_data_parallel import LegacyDistributedDataParallel
from fairseq.models ... | 2,545 | 35.898551 | 82 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/bart/hub_interface.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 copy
import logging
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import List
fr... | 6,933 | 36.080214 | 129 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/bart/model.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.
"""
BART: Denoising Sequence-to-Sequence Pre-training for
Natural Language Generation, Translation, and Comprehension
"""
import logging
impo... | 11,763 | 40.716312 | 121 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/nat/levenshtein_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 torch
from fairseq.utils import new_arange
# -------------- Helper Functions --------------------------------------------------- #
d... | 9,358 | 31.838596 | 103 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/nat/levenshtein_transformer.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 torch.nn as nn
import torch.nn.functional as F
from fairseq.iterative_refinement_generator import DecoderOut
from fairseq... | 19,592 | 39.903967 | 120 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/nat/fairseq_nat_model.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
from fairseq.models.transformer import TransformerModel, TransformerEncoder, TransformerDecoder
from fairseq.modules... | 4,959 | 32.972603 | 95 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/nat/nonautoregressive_ensembles.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.models.nat import (
_fill,
_skip,
_skip_encoder_out,
_... | 9,020 | 37.883621 | 120 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/nat/insertion_transformer.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 torch.nn.functional as F
from fairseq.models import register_model, register_model_architecture
from f... | 10,448 | 36.185053 | 88 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/nat/nonautoregressive_transformer.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 torch.nn.functional as F
from fairseq import utils
from fairseq.iterative_refinement_generator import DecoderOut
from fai... | 16,144 | 36.988235 | 108 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/nat/iterative_nonautoregressive_transformer.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.models import register_model, register_model_architecture
from fairseq.models.nat import NATransformerModel
def _... | 8,427 | 39.912621 | 99 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/roberta/hub_interface.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 torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
from fairseq.data import enco... | 8,410 | 40.029268 | 114 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/roberta/model.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.
"""
RoBERTa: A Robustly Optimized BERT Pretraining Approach.
"""
import logging
import torch
import torch.nn as nn
import torch.nn.functional... | 15,922 | 42.035135 | 122 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/roberta/alignment_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 collections import Counter
from typing import List
import torch
def align_bpe_to_words(roberta, bpe_tokens: torch.LongTensor, other_to... | 4,074 | 34.12931 | 98 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/models/huggingface/hf_gpt2.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 logging
import os
import sys
from typing import Dict, List, Optional
import torch
from fairseq.models import (
FairseqIncrementalD... | 6,267 | 34.01676 | 86 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/model_parallel/modules/multihead_attention.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 typing import Dict, Optional, Tuple
import torch
import torch.nn.functional as F
from fairseq import utils
from torch import Tensor, nn
... | 12,538 | 38.933121 | 98 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/model_parallel/models/transformer.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 logging
import torch.nn as nn
import torch.nn.functional as F
from fairseq.models import (
register_model,
)
from fairseq.models... | 3,569 | 31.162162 | 107 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/model_parallel/models/transformer_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 torch.nn as nn
from fairseq.models import (
register_model,
register_model_architecture,
)
from fairseq.models.transformer_lm ... | 3,773 | 39.580645 | 116 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/bmuf.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 torch.distributed as dist
from . import FairseqOptimizer
class FairseqBMUF(FairseqOptimizer):
"""
Implements in... | 8,119 | 34.929204 | 90 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/nag.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 torch.optim.optimizer import Optimizer, required
from . import FairseqOptimizer, register_optimizer
@register_optimizer('... | 3,422 | 32.23301 | 96 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/sgd.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.optim
from . import FairseqOptimizer, register_optimizer
@register_optimizer('sgd')
class SGD(FairseqOptimizer):
def __ini... | 1,430 | 31.522727 | 92 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/adamax.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 torch.optim
from . import FairseqOptimizer, register_optimizer
@register_optimizer('adamax')
class FairseqAdamax(Fairse... | 5,890 | 36.762821 | 92 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/fp16_optimizer.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 itertools import chain
import torch
from fairseq import optim, utils
class DynamicLossScaler(object):
def __init__(
self... | 17,202 | 37.144124 | 101 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/adam.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 logging
import math
import types
import torch
import torch.optim
import torch.distributed as dist
from fairseq.optim import FairseqOp... | 8,008 | 38.453202 | 116 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/adafactor.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.optim
from . import FairseqOptimizer, register_optimizer
@register_optimizer('adafactor')
class Fairs... | 10,320 | 43.679654 | 110 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/fused_adam.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 types
import torch
def get_fused_adam_class():
"""
Look for the FusedAdam optimizer from apex. We first try to load the
... | 12,933 | 41.546053 | 108 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/adagrad.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.optim
from . import FairseqOptimizer, register_optimizer
@register_optimizer('adagrad')
class Adagrad(FairseqOptimizer):
d... | 1,266 | 29.902439 | 92 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/fairseq_optimizer.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
class FairseqOptimizer(object):
def __init__(self, args):
super().__init__()
se... | 3,992 | 32 | 87 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/adadelta.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.optim
from . import FairseqOptimizer, register_optimizer
@register_optimizer('adadelta')
class Adadelta(FairseqOptimizer):
... | 1,823 | 37 | 105 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/lr_scheduler/inverse_square_root_schedule.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 FairseqLRScheduler, register_lr_scheduler
@register_lr_scheduler('inverse_sqrt')
class InverseSquareRootSchedule(FairseqLRSche... | 2,952 | 38.905405 | 97 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/lr_scheduler/tri_stage_lr_scheduler.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 FairseqLRScheduler, register_lr_scheduler
import math
@register_lr_scheduler('tri_stage')
class TriStageLRSchedule(FairseqLRSc... | 4,993 | 30.018634 | 84 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/lr_scheduler/reduce_lr_on_plateau.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.optim.lr_scheduler
from . import FairseqLRScheduler, register_lr_scheduler
@register_lr_scheduler('reduce_lr_on_plateau')
clas... | 4,428 | 40.392523 | 97 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/optim/lr_scheduler/cosine_lr_scheduler.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 . import FairseqLRScheduler, register_lr_scheduler
@register_lr_scheduler('cosine')
class CosineSchedule(FairseqLRSchedule... | 4,752 | 38.941176 | 105 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/benchmark/dummy_model.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.nn as nn
import torch.nn.functional as F
from fairseq.data import Dictionary
from fairseq.models import (
FairseqDecoder,
... | 2,971 | 29.958333 | 78 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/benchmark/dummy_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 logging
import numpy as np
import torch
from fairseq.data import Dictionary, FairseqDataset
from fairseq.tasks import FairseqTask, re... | 3,599 | 28.268293 | 84 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/benchmark/dummy_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 logging
import numpy as np
import torch
from fairseq.data import Dictionary, FairseqDataset
from fairseq.tasks import FairseqTask, re... | 3,250 | 28.026786 | 84 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/tasks/translation_from_pretrained_bart.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 LanguagePairDataset
from .translation import load_langpair_dataset, TranslationTask
from . import regi... | 4,719 | 40.403509 | 109 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/tasks/language_modeling.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 logging
import os
import numpy as np
import torch
from fairseq import utils
from fairseq.data import (
data_utils,
Dictionary... | 10,106 | 36.712687 | 112 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/tasks/multilingual_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 logging
import os
import numpy as np
import torch
from fairseq.data import (
data_utils,
Dictionary,
encoders,
Concat... | 12,616 | 38.676101 | 98 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/tasks/multilingual_translation.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 logging
import os
import torch
from fairseq import metrics, options
from fairseq.data import (
... | 15,113 | 43.322581 | 116 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/tasks/translation_lev.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 torch
from fairseq.utils import new_arange
from fairseq.tasks import register_task
from fairseq.tasks.translation import Tr... | 6,640 | 39.993827 | 87 | py |
BIFI | BIFI-main/utils/fairseq/fairseq/tasks/fairseq_task.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 warnings
import torch
from fairseq import metrics, search, tokenizer, utils
from fairseq.data import data_utils, FairseqDataset, iter... | 15,522 | 36.136364 | 87 | py |
BIFI | BIFI-main/utils/fairseq/docs/conf.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... | 4,235 | 30.849624 | 80 | py |
BIFI | BIFI-main/utils/fairseq/fairseq_cli/generate.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.
"""
Translate pre-processed data with a trained model.
"""
import logging
import math
import os
import sys
import t... | 11,110 | 37.313793 | 114 | py |
BIFI | BIFI-main/utils/fairseq/fairseq_cli/validate.py | #!/usr/bin/env python3 -u
#!/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.
import logging
import sys
import torch
from fairseq import checkpoint_utils, options, ut... | 3,706 | 30.415254 | 88 | py |
BIFI | BIFI-main/utils/fairseq/fairseq_cli/eval_lm.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.
"""
Evaluate the perplexity of a trained language model.
"""
import logging
import math
import os
import torch
fr... | 8,462 | 32.717131 | 112 | py |
BIFI | BIFI-main/utils/fairseq/fairseq_cli/interactive.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.
"""
Translate raw text with a trained model. Batches data on-the-fly.
"""
from collections import namedtuple
import ... | 7,270 | 32.353211 | 103 | py |
BIFI | BIFI-main/utils/fairseq/fairseq_cli/train.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.
"""
Train a new model on one or across multiple GPUs.
"""
import logging
import math
import os
import random
import ... | 12,581 | 33.853186 | 117 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.