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 |
|---|---|---|---|---|---|---|---|---|
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/truncated_bptt/__init__.py | examples/truncated_bptt/__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 transformer_xl_model, truncated_bptt_lm_task # noqa
| python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/truncated_bptt/transformer_xl_model.py | examples/truncated_bptt/transformer_xl_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 logging
from dataclasses import dataclass, field
from typing import Dict, List, Optional
import torch
from fairseq.dataclass import Fa... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/truncated_bptt/truncated_bptt_lm_task.py | examples/truncated_bptt/truncated_bptt_lm_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 logging
import os
from dataclasses import dataclass, field
from typing import List, Optional, Tuple
import torch
from fairseq import u... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/hubert/update_ckpt.py | examples/hubert/update_ckpt.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
src_ckpt = "/checkpoint/wnhsu/w2v/archived/hubert_base_ls960_it2.pt"
ref_ckpt = "/checkpoint/wnhsu/w2v/hubert_icassp_oss_v3/iter... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/hubert/measure_teacher_quality.py | examples/hubert/measure_teacher_quality.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 os.path as op
import re
from tabulate import tabulate
from collections import Counter
def comp_purity(p_xy, axis):... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/hubert/simple_kmeans/dump_hubert_feature.py | examples/hubert/simple_kmeans/dump_hubert_feature.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
import fairseq
import soundfile as sf
import torch
import torch.nn.functional as F
from feature_utils im... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/hubert/simple_kmeans/feature_utils.py | examples/hubert/simple_kmeans/feature_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 logging
import os
import sys
import tqdm
from npy_append_array import NpyAppendArray
logging.basicConfig(
format="%(asctime)s | ... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/hubert/simple_kmeans/dump_w2v2_feature.py | examples/hubert/simple_kmeans/dump_w2v2_feature.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
import fairseq
import soundfile as sf
import torch
import torch.nn.functional as F
from feature_utils im... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/hubert/simple_kmeans/dump_mfcc_feature.py | examples/hubert/simple_kmeans/dump_mfcc_feature.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
import soundfile as sf
import torch
import torchaudio
from feature_utils import get_path_iterator, dump_... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/hubert/simple_kmeans/dump_km_label.py | examples/hubert/simple_kmeans/dump_km_label.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
import numpy as np
import joblib
import torch
import tqdm
logging.basicConfig(
format="%(asctime)s ... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/hubert/simple_kmeans/dump_hubert_feature_s2t.py | examples/hubert/simple_kmeans/dump_hubert_feature_s2t.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 csv
import io
import logging
import os
import os.path as op
import sys
from dump_hubert_feature import HubertFeatureReader
from featur... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/hubert/simple_kmeans/learn_kmeans.py | examples/hubert/simple_kmeans/learn_kmeans.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
import numpy as np
from sklearn.cluster import MiniBatchKMeans
import joblib
logging.basicConfig(
f... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/latent_depth/latent_depth_src/multilingual_translation_latent_depth.py | examples/latent_depth/latent_depth_src/multilingual_translation_latent_depth.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.tasks import register_task
from fairseq.tasks.multilingual_translation import MultilingualTranslationTask
from fairseq.utils impo... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/latent_depth/latent_depth_src/__init__.py | examples/latent_depth/latent_depth_src/__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 multilingual_translation_latent_depth # noqa
from .loss import latent_depth # noqa
from .models import latent_multilingual_tra... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/latent_depth/latent_depth_src/loss/latent_depth.py | examples/latent_depth/latent_depth_src/loss/latent_depth.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 torch.nn.modules.loss import _Loss
class LatentLayersKLLoss(_Loss):
def __init__(self, args):
sup... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/latent_depth/latent_depth_src/loss/__init__.py | examples/latent_depth/latent_depth_src/loss/__init__.py | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false | |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/latent_depth/latent_depth_src/models/latent_multilingual_transformer.py | examples/latent_depth/latent_depth_src/models/latent_multilingual_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.
from fairseq.models import register_model, register_model_architecture
from fairseq.models.multilingual_transformer import MultilingualTransfo... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/latent_depth/latent_depth_src/models/latent_transformer.py | examples/latent_depth/latent_depth_src/models/latent_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.
from typing import Any, Dict, Optional
import torch.nn as nn
from fairseq.models.fairseq_encoder import EncoderOut
from fairseq.models.transf... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/latent_depth/latent_depth_src/models/__init__.py | examples/latent_depth/latent_depth_src/models/__init__.py | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false | |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/latent_depth/latent_depth_src/modules/latent_layers.py | examples/latent_depth/latent_depth_src/modules/latent_layers.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 LayerSelect(nn.Module):
"""Compute samples (from a Gumbel-Sigmoid distribution) which is used a... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/latent_depth/latent_depth_src/modules/__init__.py | examples/latent_depth/latent_depth_src/modules/__init__.py | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false | |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/fb_convert_beit_cp.py | examples/data2vec/fb_convert_beit_cp.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 torch
from omegaconf import OmegaConf
from fairseq.criterions.model_criterion import ModelCrit... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/__init__.py | examples/data2vec/__init__.py | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false | |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/scripts/convert_audioset_labels.py | examples/data2vec/scripts/convert_audioset_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.
import argparse
import os
def get_parser():
parser = argparse.ArgumentParser(description="convert audioset labels... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/scripts/text/unprocess_data.py | examples/data2vec/scripts/text/unprocess_data.py | import json
import os
import tqdm
from fairseq.data import Dictionary, data_utils
def load_dictionary(dict_path):
return Dictionary.load(dict_path)
def load_dataset(split_path, src_dict):
dataset = data_utils.load_indexed_dataset(
split_path,
src_dict,
combine=False, # set to true fo... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/scripts/text/glue.py | examples/data2vec/scripts/text/glue.py | from valids import parser, main as valids_main
import os.path as osp
args = parser.parse_args()
args.target = "valid_accuracy"
args.best_biggest = True
args.best = True
args.last = 0
args.path_contains = None
res = valids_main(args, print_output=False)
grouped = {}
for k, v in res.items():
k = osp.dirname(k)
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/scripts/text/valids.py | examples/data2vec/scripts/text/valids.py | import os, argparse, re, json, copy, math
from collections import OrderedDict
import numpy as np
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('base', help='base log path')
parser.add_argument('--file_name', default='train.log', help='the log file name')
parser.add_argument... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/scripts/text/glue_lr.py | examples/data2vec/scripts/text/glue_lr.py | import os.path as osp
import re
from collections import defaultdict
from valids import parser, main as valids_main
TASK_TO_METRIC = {
"cola": "mcc",
"qnli": "accuracy",
"mrpc": "acc_and_f1",
"rte": "accuracy",
"sst_2": "accuracy",
"mnli": "accuracy",
"qqp": "acc_and_f1",
"sts_b": "pea... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/tasks/image_pretraining.py | examples/data2vec/tasks/image_pretraining.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import logging
import sys
import o... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/tasks/mae_image_pretraining.py | examples/data2vec/tasks/mae_image_pretraining.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import logging
import sys
from ty... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/tasks/audio_classification.py | examples/data2vec/tasks/audio_classification.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import logging
import os
import nu... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/tasks/__init__.py | examples/data2vec/tasks/__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 .image_pretraining import ImagePretrainingTask, ImagePretrainingConfig
from .image_classification import ImageClassificationTask, ImageCl... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/tasks/image_classification.py | examples/data2vec/tasks/image_classification.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import os.path as osp
import loggi... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/tasks/multimodal.py | examples/data2vec/tasks/multimodal.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import sys
from dataclasses impor... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/tasks/mae_image_classification.py | examples/data2vec/tasks/mae_image_classification.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import logging
import sys
import t... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/data2vec_vision.py | examples/data2vec/models/data2vec_vision.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.
# The code in this file is adapted from the BeiT implementation which can be found here:
# https://github.com/microsoft/unilm/tree/master/beit... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/data2vec_text_classification.py | examples/data2vec/models/data2vec_text_classification.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.
# The code in this file is adapted from the BeiT implementation which can be found here:
# https://github.com/microsoft/unilm/tree/master/beit... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/data2vec_audio.py | examples/data2vec/models/data2vec_audio.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
from dataclasses import dataclass, field
from typing import Optional
from omegaconf import II
import torch
import... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/utils.py | examples/data2vec/models/utils.py | import math
import torch
def get_alibi(
max_positions: int,
attention_heads: int,
):
def get_slopes(n):
def get_slopes_power_of_2(n):
start = 2 ** (-(2 ** -(math.log2(n) - 3)))
ratio = start
return [start * ratio ** i for i in range(n)]
# In the paper, w... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/audio_classification.py | examples/data2vec/models/audio_classification.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 re
from dataclasses import dataclass, field
from typing import Any, Optional
import torch
import torc... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/mae.py | examples/data2vec/models/mae.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.
# The code in this file is adapted from the BeiT implementation which can be found here:
# https://github.com/microsoft/unilm/tree/master/beit... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/__init__.py | examples/data2vec/models/__init__.py | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false | |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/data2vec_text.py | examples/data2vec/models/data2vec_text.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 dataclasses import dataclass, field
from typing import Optional
import logging
import math
import torch
import torch.nn as nn
import tor... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/mae_image_classification.py | examples/data2vec/models/mae_image_classification.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.
# The code in this file is adapted from the BeiT implementation which can be found here:
# https://github.com/microsoft/unilm/tree/master/beit... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/data2vec_image_classification.py | examples/data2vec/models/data2vec_image_classification.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.
# The code in this file is adapted from the BeiT implementation which can be found here:
# https://github.com/microsoft/unilm/tree/master/beit... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/data2vec2.py | examples/data2vec/models/data2vec2.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
from dataclasses import dataclass, field
from typing import Optional, Callable
from functools import partial
import... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/modalities/audio.py | examples/data2vec/models/modalities/audio.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 partial
import torch
import torch.nn as nn
import numpy as np
from dataclasses import dataclass, field
from typing impor... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/modalities/modules.py | examples/data2vec/models/modalities/modules.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
import numpy as np
from dataclasses import dataclass
from fairseq.modules i... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/modalities/__init__.py | examples/data2vec/models/modalities/__init__.py | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false | |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/modalities/images.py | examples/data2vec/models/modalities/images.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
import numpy as np
from functools import partial
from dataclasses import da... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/modalities/text.py | examples/data2vec/models/modalities/text.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 dataclasses import dataclass
from functools import partial
from typing import Callable, Dict, Optional
import torch.nn as nn... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/models/modalities/base.py | examples/data2vec/models/modalities/base.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 numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from collections import named... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/data/path_dataset.py | examples/data2vec/data/path_dataset.py | import glob
import os
from typing import List, Optional, Tuple
import logging
import numpy as np
import torchvision.transforms.functional as TF
import PIL
from PIL import Image
from torchvision.datasets import VisionDataset
logger = logging.getLogger(__name__)
class PathDataset(VisionDataset):
def __init__(
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/data/add_class_target_dataset.py | examples/data2vec/data/add_class_target_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from fairseq.data import BaseWrapperDataset, data_utils
class AddClassTargetDataset(BaseWrapperDataset):
def __init__(
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/data/modality.py | examples/data2vec/data/modality.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
from enum import Enum, auto
clas... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/data/mae_image_dataset.py | examples/data2vec/data/mae_image_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from functools import partial
import logging
import math
import random
import time
import numpy as np
import os
import torch
from torchvis... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/data/__init__.py | examples/data2vec/data/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .image_dataset import ImageDataset
from .path_dataset import PathDataset
from .mae_image_dataset import MaeImageDataset
from .mae_finetun... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/data/image_dataset.py | examples/data2vec/data/image_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 logging
import numpy as np
import os
from typing import Optional, Callable, Set
import torch
from torchvision.datasets.vision impor... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/data2vec/data/mae_finetuning_image_dataset.py | examples/data2vec/data/mae_finetuning_image_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 logging
import numpy as np
import os
import torch
from torchvision import datasets, transforms
from timm.data import create_transf... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/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 | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/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.MosesTokeniz... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/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, help=... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/criss/save_encoder.py | examples/criss/save_encoder.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 numpy as np
import torch
from fairseq import check... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/criss/sentence_retrieval/encoder_analysis.py | examples/criss/sentence_retrieval/encoder_analysis.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 glob
import numpy as np
DIM = 1024
def compute_dist(source_embs, target_embs, k=5, return... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/criss/mining/mine.py | examples/criss/mining/mine.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 glob
from subprocess import check_call
try:
import faiss
has_faiss = True
except Imp... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/locallaunch.py | examples/MMPT/locallaunch.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
from omegaconf import OmegaConf
from mmpt.utils import recursive_config, overwrite_dir
from mmpt_cli.localjob impor... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/setup.py | examples/MMPT/setup.py | import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="mmpt",
version="0.0.1",
author="Hu Xu, Po-yao Huang",
author_email="huxu@fb.com",
description="A package for multimodal pretraining.",
long_description=long_description,
long_descr... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/scripts/video_feature_extractor/shard_feature.py | examples/MMPT/scripts/video_feature_extractor/shard_feature.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 os
import pickle
from mmpt.utils import ShardedTensor
class Shard(object):
def __init__(
self,
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/scripts/video_feature_extractor/preprocessing.py | examples/MMPT/scripts/video_feature_extractor/preprocessing.py | # Copyright Howto100m authors.
# Copyright (c) Facebook, Inc. All Rights Reserved
import torch as th
class Normalize(object):
def __init__(self, mean, std):
self.mean = th.FloatTensor(mean).view(1, 3, 1, 1)
self.std = th.FloatTensor(std).view(1, 3, 1, 1)
def __call__(self, tensor):
t... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/scripts/video_feature_extractor/random_sequence_shuffler.py | examples/MMPT/scripts/video_feature_extractor/random_sequence_shuffler.py | # Copyright (c) Facebook, Inc. All Rights Reserved
import numpy as np
from torch.utils.data.sampler import Sampler
class RandomSequenceSampler(Sampler):
def __init__(self, n_sample, seq_len):
self.n_sample = n_sample
self.seq_len = seq_len
def _pad_ind(self, ind):
zeros = np.zeros(... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/scripts/video_feature_extractor/model.py | examples/MMPT/scripts/video_feature_extractor/model.py | # Copyright (c) Howto100M authors and Facebook, Inc. All Rights Reserved
import torch as th
from torch import nn
class GlobalAvgPool(nn.Module):
def __init__(self):
super(GlobalAvgPool, self).__init__()
def forward(self, x):
return th.mean(x, dim=[-2, -1])
def get_model(args):
assert ... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/scripts/video_feature_extractor/pathbuilder.py | examples/MMPT/scripts/video_feature_extractor/pathbuilder.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 urllib.parse
import json
import pandas as pd
from tqdm import tqdm
# TODO: extending to other datasets.
supported_formats =... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/scripts/video_feature_extractor/extract.py | examples/MMPT/scripts/video_feature_extractor/extract.py | # Copyright Howto100M authors.
# Copyright (c) Facebook, Inc. All Rights Reserved
import torch as th
import torch.nn.functional as F
import math
import numpy as np
import argparse
from torch.utils.data import DataLoader
from model import get_model
from preprocessing import Preprocessing
from random_sequence_shuffler ... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/scripts/video_feature_extractor/videoreader.py | examples/MMPT/scripts/video_feature_extractor/videoreader.py | # Copyright Howto100M authors.
# Copyright (c) Facebook, Inc. All Rights Reserved
import torch as th
import pandas as pd
import os
import numpy as np
import ffmpeg
import random
from torch.utils.data import Dataset
class VideoLoader(Dataset):
"""modified from how2's video_feature_extractor."""
def __init__(... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/scripts/text_token_extractor/pretokenization.py | examples/MMPT/scripts/text_token_extractor/pretokenization.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 pickle
import os
import argparse
import numpy as np
from torch.utils.data import Dataset, DataLoader
from mmpt.processors import PKLJS... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/__init__.py | examples/MMPT/mmpt/__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.
try:
# fairseq user dir
from .datasets import FairseqMMDataset
from .losses import FairseqCriterion
from .models import Fairseq... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/tasks/fairseqmmtask.py | examples/MMPT/mmpt/tasks/fairseqmmtask.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.
"""
make a general fairseq task for MM pretraining.
"""
import random
from fairseq.tasks import LegacyFairseqTask, register_task
from .task ... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/tasks/milncetask.py | examples/MMPT/mmpt/tasks/milncetask.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 .task import Task
class MILNCETask(Task):
def reshape_subsample(self, sample):
if (
hasattr(self.... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/tasks/retritask.py | examples/MMPT/mmpt/tasks/retritask.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
import pickle
import random
from tqdm import tqdm
from torch.utils.data import DataLoader
from torch.utils.data.distrib... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/tasks/task.py | examples/MMPT/mmpt/tasks/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 torch
from .. import tasks
from .. import models
from .. import losses
from ..datasets import MMDataset
from .. import processors
cla... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/tasks/vlmtask.py | examples/MMPT/mmpt/tasks/vlmtask.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 .task import Task
class VLMTask(Task):
"""A VLM task for reproducibility.
the collator split subsamples into two s... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/tasks/__init__.py | examples/MMPT/mmpt/tasks/__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 .task import *
from .vlmtask import *
from .retritask import *
try:
from .fairseqmmtask import *
except ImportError:
pass
try:
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/losses/nce.py | examples/MMPT/mmpt/losses/nce.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.
"""
softmax-based NCE loss, used by this project.
"""
import torch
from torch import nn
from .loss import Loss
class NCE(Loss):
def _... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/losses/fairseqmmloss.py | examples/MMPT/mmpt/losses/fairseqmmloss.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.
"""
TODO (huxu): a general fairseq criterion for all your pre-defined losses.
"""
from fairseq.criterions import FairseqCriterion, register_c... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/losses/loss.py | examples/MMPT/mmpt/losses/loss.py | # Copyright (c) Facebook, Inc. All Rights Reserved
import torch
from torch import nn
class Loss(object):
def __call__(self, *args, **kwargs):
raise NotImplementedError
# Dummy Loss for testing.
class DummyLoss(Loss):
def __init__(self):
self.loss = nn.CrossEntropyLoss()
def __call__(s... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/losses/__init__.py | examples/MMPT/mmpt/losses/__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 .loss import *
from .nce import *
try:
from .fairseqmmloss import *
except ImportError:
pass
try:
from .expnce import *
exce... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/datasets/fairseqmmdataset.py | examples/MMPT/mmpt/datasets/fairseqmmdataset.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.
"""
TODO (huxu): fairseq wrapper class for all dataset you defined: mostly MMDataset.
"""
from collections import OrderedDict
from torch.util... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/datasets/mmdataset.py | examples/MMPT/mmpt/datasets/mmdataset.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 collections import OrderedDict
from torch.utils.data import Dataset
from torch.utils.data.dataloader import default_collat... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/datasets/__init__.py | examples/MMPT/mmpt/datasets/__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 .mmdataset import *
try:
from .fairseqmmdataset import *
except ImportError:
pass
| python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/models/transformermodel.py | examples/MMPT/mmpt/models/transformermodel.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/models/fairseqmmmodel.py | examples/MMPT/mmpt/models/fairseqmmmodel.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.models import (
BaseFairseqModel,
register_model,
register_model_architecture
)
@register_model("mmmodel")
class Fa... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/models/mmfusion.py | examples/MMPT/mmpt/models/mmfusion.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/models/mmfusionnlg.py | examples/MMPT/mmpt/models/mmfusionnlg.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors, Facebook AI Research authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the L... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | true |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/models/__init__.py | examples/MMPT/mmpt/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.
from .mmfusion import *
from .transformermodel import *
from .mmfusionnlg import *
try:
from .fairseqmmmodel import *
except ImportError:
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/utils/load_config.py | examples/MMPT/mmpt/utils/load_config.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 omegaconf
from omegaconf import OmegaConf
def load_config(args=None, config_file=None, overwrite_fairseq=False):
"""TODO... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/utils/shardedtensor.py | examples/MMPT/mmpt/utils/shardedtensor.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 pickle
import numpy as np
class ShardedTensor(object):
def __init__(self, data, starts):
self.data = data
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/utils/__init__.py | examples/MMPT/mmpt/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 random
import numpy as np
import torch
from .shardedtensor import *
from .load_config import *
def set_seed(seed=43211):
random.s... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/modules/mm.py | examples/MMPT/mmpt/modules/mm.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/modules/vectorpool.py | examples/MMPT/mmpt/modules/vectorpool.py | # Copyright (c) Facebook, Inc. All Rights Reserved
import torch
import os
import numpy as np
import pickle
from . import retri
from ..utils import get_local_rank
class VectorPool(object):
"""
Base class of retrieval space.
"""
def __init__(self, config):
from transformers import AutoConfig
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/MMPT/mmpt/modules/retri.py | examples/MMPT/mmpt/modules/retri.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
import numpy as np
import pickle
import time
try:
import faiss
except ImportError:
pass
from collections import defaultdict... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.