repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/scripts/constraints/extract.py
scripts/constraints/extract.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. """Extracts random constraints from reference files.""" import argparse import random import sys from sacrebleu impo...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/fairseq_cli/train.py
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 argparse import logging import math import os impor...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/fairseq_cli/generate.py
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 n...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/fairseq_cli/validate.py
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. from itertools import chain import logging import os import sys import torch from fairse...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/fairseq_cli/interactive.py
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 ...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/fairseq_cli/__init__.py
fairseq_cli/__init__.py
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/fairseq_cli/score.py
fairseq_cli/score.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. """ BLEU scoring of generated translations against reference translations. """ import argparse import os import sys fr...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/fairseq_cli/eval_lm.py
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...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/fairseq_cli/preprocess.py
fairseq_cli/preprocess.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. """ Data pre-processing: build vocabularies and binarize training data. """ from collections import Counter from iterto...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_sequence_scorer.py
tests/test_sequence_scorer.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 unittest import torch from fairseq.sequence_scorer import SequenceScorer import tests.utils as test_utils class Te...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_inference_dropout.py
tests/test_inference_dropout.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 unittest from tests.test_sequence_generator import get_dummy_task_and_parser from fairseq.models.transformer import Tra...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_metrics.py
tests/test_metrics.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 unittest import uuid from fairseq import metrics class TestMetrics(unittest.TestCase): def test_nesting(self): with met...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_file_io.py
tests/test_file_io.py
# This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import sys import tempfile import os import shutil from typing import Optional import unittest from unittest.mock import MagicMock class TestFileIO(unittest.TestCase): _tmpdir: Optional[...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_sparse_multihead_attention.py
tests/test_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 torch import unittest from fairseq.modules.sparse_multihead_attention import SparseMultiheadAttention class TestSparseMultiheadAttent...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_noising.py
tests/test_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 unittest from typing import Dict, List import tests.utils as test_utils import torch from fairseq import utils from fairseq.data impor...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_convtbc.py
tests/test_convtbc.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 unittest from fairseq.modules import ConvTBC import torch.nn as nn class TestConvTBC(unittest.TestCase): def test_c...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_concat_dataset.py
tests/test_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. import unittest import torch from fairseq.data import LanguagePairDataset, TokenBlockDataset from fairseq.data.concat_dataset import ConcatDa...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_export.py
tests/test_export.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 argparse import tempfile import unittest import torch from fairseq.data.dictionary import Dictionary from fairs...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_bmuf.py
tests/test_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 argparse from multiprocessing import Manager import random import unittest import torch import torch.nn as nn from fairseq import dis...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_memory_efficient_fp16.py
tests/test_memory_efficient_fp16.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 logging import unittest import torch from fairseq.optim.adam import FairseqAdam from fairseq.optim.fp16_optimizer imp...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_multihead_attention.py
tests/test_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 torch import unittest from fairseq.modules.multihead_attention import MultiheadAttention class TestMultiheadAttention(unittest.TestCa...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_utils.py
tests/test_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 unittest import torch from fairseq import utils class TestUtils(unittest.TestCase): def test_convert_padding_direction(self): ...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_reproducibility.py
tests/test_reproducibility.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 contextlib from io import StringIO import json import os import tempfile import unittest import torch from . import test_binaries c...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_sequence_generator.py
tests/test_sequence_generator.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 tempfile import unittest import tests.utils as test_utils import torch from fairseq import search from fairseq.data.di...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_fp16_optimizer.py
tests/test_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. import argparse import copy import unittest import torch from fairseq.optim.fp16_optimizer import FP16Optimizer, MemoryEfficientFP16Optimize...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/utils.py
tests/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 argparse import os import random import sys import torch import torch.nn.functional as F from io import StringIO from fairseq import o...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_dictionary.py
tests/test_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 io import tempfile import unittest import torch from fairseq.data import Dictionary class TestDictionary(unittest.TestCase): d...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_token_block_dataset.py
tests/test_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. import unittest import torch from fairseq.data import TokenBlockDataset import tests.utils as test_utils class TestTokenBlockDataset(unit...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_lstm_jitable.py
tests/test_lstm_jitable.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 tempfile import unittest import torch from fairseq.data.dictionary import Dictionary from fairseq.models.lstm import L...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_label_smoothing.py
tests/test_label_smoothing.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 copy import unittest import torch from fairseq.criterions.cross_entropy import CrossEntropyCriterion from fairseq.cri...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/__init__.py
tests/__init__.py
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_binaries.py
tests/test_binaries.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 contextlib from io import StringIO import logging import os import random import tempfile import unittest import torch from fairseq i...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
true
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_backtranslation_dataset.py
tests/test_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 unittest import torch from fairseq.data import ( BacktranslationDataset, LanguagePairDataset, TransformEosDataset, ) from...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_character_token_embedder.py
tests/test_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 torch import unittest from fairseq.data import Dictionary from fairseq.modules import CharacterTokenEmbedder class TestCharacterToke...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_average_checkpoints.py
tests/test_average_checkpoints.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 collections import os import tempfile import unittest import shutil import numpy as np import torch from torch import nn from script...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_resampling_dataset.py
tests/test_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 collections import unittest import numpy as np from fairseq.data import ListDataset, ResamplingDataset class TestResamplingDataset(...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_iterators.py
tests/test_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 unittest from fairseq.data import iterators class TestIterators(unittest.TestCase): def test_counting_iterator(self, ref=None, ...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_train.py
tests/test_train.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 contextlib import logging import unittest from io import StringIO from unittest.mock import MagicMock, patch import torch from fairse...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_multi_corpus_sampled_dataset.py
tests/test_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. import unittest from collections import OrderedDict import numpy as np import torch from fairseq.data import LanguagePairDataset, TokenBlockD...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/test_constraints.py
tests/test_constraints.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 sys import torch import unittest from fairseq.token_generation_constraints import * def tensorize(constraints: List[List[int]]) -> t...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/gpu/test_binaries_gpu.py
tests/gpu/test_binaries_gpu.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 contextlib import logging import os import tempfile import unittest from io import StringIO import torch from fairseq import options f...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/gpu/__init__.py
tests/gpu/__init__.py
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/speech_recognition/test_vggtransformer.py
tests/speech_recognition/test_vggtransformer.py
#!/usr/bin/env python3 # import models/encoder/decoder to be tested from examples.speech_recognition.models.vggtransformer import ( TransformerDecoder, VGGTransformerEncoder, VGGTransformerModel, vggtransformer_1, vggtransformer_2, vggtransformer_base, ) # import base test class from .asr_test...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/speech_recognition/test_data_utils.py
tests/speech_recognition/test_data_utils.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 unittest import torch from examples.speech_recognition.data import data_utils class DataUtilsTest(unittest.Te...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/speech_recognition/asr_test_base.py
tests/speech_recognition/asr_test_base.py
#!/usr/bin/env python3 import argparse import os import unittest from inspect import currentframe, getframeinfo import numpy as np import torch from fairseq.data import data_utils as fairseq_data_utils from fairseq.data.dictionary import Dictionary from fairseq.models import ( BaseFairseqModel, FairseqDecoder...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/speech_recognition/__init__.py
tests/speech_recognition/__init__.py
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/speech_recognition/test_collaters.py
tests/speech_recognition/test_collaters.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 unittest import numpy as np import torch from examples.speech_recognition.data.collaters import Seq2SeqCollater...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/tests/speech_recognition/test_cross_entropy.py
tests/speech_recognition/test_cross_entropy.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 examples.speech_recognition.criterions.cross_entropy_acc import CrossEntropyWithAccCriterion from .asr_test_base i...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/docs/conf.py
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...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/__init__.py
examples/__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. __version__ = '0.9.0' import examples.noisychannel # noqa
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/byte_level_bpe/get_bitext.py
examples/byte_level_bpe/get_bitext.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.path as op import argparse import os from multiprocessing import cpu_count from collections import namedtuple from typing import Op...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/byte_level_bpe/gru_transformer.py
examples/byte_level_bpe/gru_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. # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the r...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/constrained_decoding/normalize.py
examples/constrained_decoding/normalize.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 sys from sacremoses.normalize import MosesPunctNormalizer def main(args): normalizer = MosesPunctNormal...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/constrained_decoding/tok.py
examples/constrained_decoding/tok.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 sys import sacremoses def main(args): """Tokenizes, preserving tabs""" mt = sacremoses.MosesTokenize...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/paraphraser/paraphrase.py
examples/paraphraser/paraphrase.py
#!/usr/bin/env python3 -u import argparse import fileinput import logging import os import sys from fairseq.models.transformer import TransformerModel logging.getLogger().setLevel(logging.INFO) def main(): parser = argparse.ArgumentParser(description='') parser.add_argument('--en2fr', required=True, ...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/megatron_11b/detok.py
examples/megatron_11b/detok.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. import argparse import fileinput import sacremoses def main(): parser = argparse.ArgumentParser(description=''...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/wav2vec/wav2vec_featurize.py
examples/wav2vec/wav2vec_featurize.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. """ Helper script to pre-compute embeddings for a wav2letter++ dataset """ import argparse import glob import os from ...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/wav2vec/vq-wav2vec_featurize.py
examples/wav2vec/vq-wav2vec_featurize.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. """ Helper script to pre-compute embeddings for a wav2letter++ dataset """ import pprint import glob, os, argparse im...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/wav2vec/wav2vec_manifest.py
examples/wav2vec/wav2vec_manifest.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. """ Data pre-processing: build vocabularies and binarize training data. """ import argparse import glob import os impor...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/wav2vec/libri_labels.py
examples/wav2vec/libri_labels.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. """ Helper script to pre-compute embeddings for a wav2letter++ dataset """ import argparse import os def main(): ...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/__init__.py
examples/simultaneous_translation/__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 . import criterions, models, eval # noqa
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/models/transformer_monotonic_attention.py
examples/simultaneous_translation/models/transformer_monotonic_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 torch import torch.nn as nn import torch.nn.functional as F from fairseq.models import ( register_model, register_model_archit...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/models/__init__.py
examples/simultaneous_translation/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 importlib import os for file in os.listdir(os.path.dirname(__file__)): if file.endswith('.py') and not file.startswith('_'): ...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/utils/latency.py
examples/simultaneous_translation/utils/latency.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 LatencyMetric(object): @staticmethod def length_from_padding_mask(padding_mask, batch_first: bool = False): ...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/utils/__init__.py
examples/simultaneous_translation/utils/__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 importlib import os # automatically import any Python files in the criterions/ directory for file in os.listdir(os.path.dirname(__fil...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/utils/functions.py
examples/simultaneous_translation/utils/functions.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 def exclusive_cumprod(tensor, dim: int, eps: float = 1e-10): """ Implementing exclusive cumprod. There is cumprod i...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/criterions/label_smoothed_cross_entropy_latency_augmented.py
examples/simultaneous_translation/criterions/label_smoothed_cross_entropy_latency_augmented.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.criterions import register_criterion from fairseq.criterions.label_smoothed_cross_entropy import ( LabelSmoothedCrossEntropyC...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/criterions/__init__.py
examples/simultaneous_translation/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 importlib import os for file in os.listdir(os.path.dirname(__file__)): if file.endswith(".py") and not file.startswith("_"): ...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/eval/client.py
examples/simultaneous_translation/eval/client.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 requests from typing import Optional from scorers import build_scorer class SimulSTEvaluationService(object): DEFAULT_HOSTNAME = ...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/eval/eval_latency.py
examples/simultaneous_translation/eval/eval_latency.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 examples.simultaneous_translation.utils.latency import LatencyInference import argparse import torch import json LATENCY_METRICS = [ ...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/eval/__init__.py
examples/simultaneous_translation/eval/__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.
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/eval/evaluate.py
examples/simultaneous_translation/eval/evaluate.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 from client import SimulSTEvaluationService, SimulSTLocalEvaluationService from fairseq.registry import REGISTRIES from agent...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/eval/server.py
examples/simultaneous_translation/eval/server.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 sys import json from tornado import web, ioloop from scorers import build_scorer DEFAULT_HOSTNAME = 'localhost' DEFAULT...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/eval/agents/word_splitter.py
examples/simultaneous_translation/eval/agents/word_splitter.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. class SubwordSplitter(object): def process_line(self, string): raise NotImplementedError def split(self, string): ra...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/eval/agents/__init__.py
examples/simultaneous_translation/eval/agents/__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 importlib import os from fairseq import registry build_agent, register_agent, MONOTONIC_AGENT = registry.setup_registry('--agent-type'...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/eval/agents/simul_trans_text_agent.py
examples/simultaneous_translation/eval/agents/simul_trans_text_agent.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 . simul_trans_agent import SimulTransAgent from . import DEFAULT_EOS, GET from . import register_agent from . word_splitter import SPLITT...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/eval/agents/agent.py
examples/simultaneous_translation/eval/agents/agent.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 GET, SEND, DEFAULT_EOS import time from multiprocessing.pool import ThreadPool as Pool from functools import partial class Age...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/eval/agents/simul_trans_agent.py
examples/simultaneous_translation/eval/agents/simul_trans_agent.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 . agent import Agent from . import DEFAULT_EOS, GET, SEND from fairseq import checkpoint_utils, utils, tasks import os import json clas...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/eval/scorers/scorer.py
examples/simultaneous_translation/eval/scorers/scorer.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 vizseq.scorers.bleu import BLEUScorer from vizseq.scorers.ter import TERScorer from vizseq.scorers.meteor import METEORScorer from exampl...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/eval/scorers/text_scorer.py
examples/simultaneous_translation/eval/scorers/text_scorer.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 . scorer import SimulScorer from . import register_scorer @register_scorer("text") class SimulTextScorer(SimulScorer): def __init__...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/eval/scorers/__init__.py
examples/simultaneous_translation/eval/scorers/__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 importlib import os from fairseq import registry ( build_scorer, register_scorer, SCORER_REGISTRIES ) = registry.setup_regi...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/modules/monotonic_multihead_attention.py
examples/simultaneous_translation/modules/monotonic_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.functional as F import torch.nn as nn from fairseq import utils from fairseq.modules import Multihe...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/modules/__init__.py
examples/simultaneous_translation/modules/__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 importlib import os from fairseq import registry ( build_monotonic_attention, register_monotonic_attention, MONOTONIC_ATTE...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/simultaneous_translation/modules/monotonic_transformer_layer.py
examples/simultaneous_translation/modules/monotonic_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 fairseq.modules import ( LayerNorm, TransformerEncoderLayer, TransformerDecoderLayer ) from . import build_monotonic_attenti...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/backtranslation/deduplicate_lines.py
examples/backtranslation/deduplicate_lines.py
#!/usr/bin/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 argparse import fileinput import hashlib from multiprocessing import Pool import sys def get_hashes_and_lines(raw_...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/backtranslation/extract_bt_data.py
examples/backtranslation/extract_bt_data.py
#!/usr/bin/env python # 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 fileinput from tqdm import tqdm def main(): parser = argparse.ArgumentParser(description=(...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/roberta/preprocess_RACE.py
examples/roberta/preprocess_RACE.py
#!/usr/bin/env python # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import argparse import json import os import re class InputExample: def __init__(self, paragrap...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/roberta/multiprocessing_bpe_encoder.py
examples/roberta/multiprocessing_bpe_encoder.py
#!/usr/bin/env python # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import argparse import contextlib import sys from collections import Counter from multiprocessing im...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/roberta/commonsense_qa/commonsense_qa_task.py
examples/roberta/commonsense_qa/commonsense_qa_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 json import os import numpy as np import torch from fairseq.data import ( data_utils, Dictionary, encoders, IdDataset...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/roberta/commonsense_qa/__init__.py
examples/roberta/commonsense_qa/__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 . import commonsense_qa_task # noqa
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/roberta/wsc/wsc_utils.py
examples/roberta/wsc/wsc_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 functools import lru_cache import json def convert_sentence_to_json(sentence): if '_' in sentence: prefix, rest = sentence....
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/roberta/wsc/wsc_task.py
examples/roberta/wsc/wsc_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 json import os import tempfile import numpy as np import torch import torch.nn.functional as F from fairseq import utils from fairseq...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/roberta/wsc/wsc_criterion.py
examples/roberta/wsc/wsc_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 import torch.nn.functional as F from fairseq import utils from fairseq.data import encoders from fairseq.criterions...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/roberta/wsc/__init__.py
examples/roberta/wsc/__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 . import wsc_criterion # noqa from . import wsc_task # noqa
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/unsupervised_quality_estimation/meteor.py
examples/unsupervised_quality_estimation/meteor.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 os import sys import subprocess import tempfile import math from itertools import combinations from collections import...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/unsupervised_quality_estimation/repeat_lines.py
examples/unsupervised_quality_estimation/repeat_lines.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 sys def _normalize_spaces(line): return ' '.join(line.split()) def main(): parser = argparse.ArgumentParser...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/unsupervised_quality_estimation/aggregate_scores.py
examples/unsupervised_quality_estimation/aggregate_scores.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 numpy as np import sys aggregate_funcs = { 'std': np.std, 'var': np.var, 'median': np.median, 'mean':...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/translation_moe/score.py
examples/translation_moe/score.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...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/translation_moe/src/logsumexp_moe.py
examples/translation_moe/src/logsumexp_moe.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 LogSumExpMoE(torch.autograd.Function): """Standard LogSumExp forward pass, but use *posterior* for the backward. ...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false
ofirpress/shortformer
https://github.com/ofirpress/shortformer/blob/edc411ff896ae042c01d939a32c1e4a33e238083/examples/translation_moe/src/mean_pool_gating_network.py
examples/translation_moe/src/mean_pool_gating_network.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 class MeanPoolGatingNetwork(torch.nn.Module): """A simple mean-pooling gating network for s...
python
MIT
edc411ff896ae042c01d939a32c1e4a33e238083
2026-01-05T07:14:08.244122Z
false