python_code
stringlengths
0
992k
repo_name
stringlengths
8
46
file_path
stringlengths
5
162
#!/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. """ Replabel transforms for use with wav2letter's ASG criterion. """ def replabel_symbol(i): """ Replabel sy...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/data/replabels.py
# Copyright (c) Facebook, Inc. and 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 .asr_dataset import AsrDataset __all__ = [ 'AsrDataset', ]
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/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. """ This module contains collection of classes which implement collate functionalities for various tasks. Collaters should know wh...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/data/collaters.py
# Copyright (c) Facebook, Inc. and 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 calc_mean_invstddev(feature): if len(feature.size()) != 2: raise ValueError("We expect the input feature to be ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/data/data_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import numpy as np from fairseq.data import FairseqDataset from . import data_utils from .collaters import Seq2SeqCollater class ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/data/asr_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 __future__ import absolute_import, division, print_function, unicode_literals import logging import math import torch import torch.nn.f...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/criterions/cross_entropy_acc.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import numpy as np import torch from fairseq import utils from fairseq.criterions import FairseqCriterion...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/criterions/ASG_loss.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 logging import math from itertools import groupby import torch import torch.nn.functional as F from fairseq im...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/criterions/CTC_loss.py
import importlib import os # ASG loss requires wav2letter blacklist = set() try: import wav2letter except ImportError: blacklist.add("ASG_loss.py") for file in os.listdir(os.path.dirname(__file__)): if file.endswith(".py") and not file.startswith("_") and file not in blacklist: criterion_name = f...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/speech_recognition/criterions/__init__.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...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 json import os import re class InputExample: def __init__(self, paragrap...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/roberta/preprocess_RACE.py
# Copyright (c) Facebook, Inc. and 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....
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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. import math import torch import torch.nn.functional as F from fairseq import utils from fairseq.data import encoders from fairseq.criterions...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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. from . import wsc_criterion # noqa from . import wsc_task # noqa
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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. import json import os import tempfile import numpy as np import torch import torch.nn.functional as F from fairseq import utils from fairseq...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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. from . import commonsense_qa_task # noqa
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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. import json import os import numpy as np import torch from fairseq.data import ( data_utils, Dictionary, encoders, IdDataset...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/examples/roberta/commonsense_qa/commonsense_qa_task.py
#!/usr/bin/env python """Helper script to compare two argparse.Namespace objects.""" from argparse import Namespace # noqa def main(): ns1 = eval(input('Namespace 1: ')) ns2 = eval(input('Namespace 2: ')) def keys(ns): ks = set() for k in dir(ns): if not k.startswith('_'): ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/compare_namespaces.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. """ Split a large file into a train and valid set while respecting document boundaries. Documents should be separated by...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/split_train_valid_docs.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 ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/wav2vec_featurize.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Use this script in order to build symmetric alignments for your translation dataset. This script depends on fast_align and mosesdecoder too...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/build_sym_alignment.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. from __future__ import absolute_import, division, print_function, unicode_literals import argparse ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/spm_decode.py
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import os import re import shutil import sys pt_regexp = re.compile(r'checkpoint(\d+|_\d+_\d+|_[a-z]+...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/rm_pt.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. """ Count the number of documents and average number of lines and tokens per document in a large file. Documents should ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/count_docs.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. from __future__ import absolute_import, division, print_function, unicode_literals import argparse i...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/spm_encode.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. """ Split a large file into shards while respecting document boundaries. Documents should be separated by a single empty...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/shard_docs.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. from __future__ import absolute_import, division, print_function, unicode_literals import sys impor...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/spm_train.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 collections import torch import os import re def average_checkpoints(inputs): """Loads che...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/average_checkpoints.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...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/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. import argparse from fairseq.data import data_utils, Dictionary, indexed_dataset def get_parser(): parser = argp...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/scripts/read_binarized.py
import setuptools setuptools.setup( name="infoxlm", version="0.0.1", author="Zewen", author_email="chizewen@outlook.com", description="infoxlm", url="https://github.com/CZWin32768/XLM-Align", packages=setuptools.find_packages(), install_requires=[], classifiers=( "Programming Language :: Python :...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/setup.py
import infoxlm from fairseq_cli.train import cli_main if __name__ == "__main__": cli_main()
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/train.py
import infoxlm.tasks import infoxlm.models import infoxlm.criterions
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/__init__.py
import torch from fairseq import utils @torch.no_grad() def concat_all_gather(tensor): """ Performs all_gather operation on the provided tensors. *** Warning ***: torch.distributed.all_gather has no gradient. """ if torch.cuda.device_count() > 1: return varsize_tensor_all_gather(tensor) else: outp...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/utils.py
import os from fairseq.tasks import register_task, FairseqTask from fairseq.data.dictionary import Dictionary from infoxlm.data import mlm_utils from infoxlm.data.dict_dataset import DictDataset from infoxlm.tasks.mlm import Mlm @register_task("tlm") class Tlm(Mlm): @staticmethod def add_args(parser): Mlm.a...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/tasks/tlm.py
import os from functools import lru_cache import numpy as np import torch from fairseq import utils from fairseq.data.data_utils import process_bpe_symbol from fairseq.data.dictionary import Dictionary from fairseq.tasks import FairseqTask, register_task from infoxlm.data import mlm_utils from infoxlm.data.dict_data...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/tasks/xlm_align.py
import os from fairseq.tasks import register_task, FairseqTask from fairseq.data.dictionary import Dictionary from infoxlm.data import mlm_utils @register_task("mlm") class Mlm(FairseqTask): @staticmethod def add_args(parser): mlm_utils.add_mlm_args(parser) parser.add_argument('data', help='colon separa...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/tasks/mlm.py
import argparse import importlib import os from fairseq.tasks import TASK_REGISTRY # automatically import any Python files in the tasks/ directory for file in os.listdir(os.path.dirname(__file__)): if file.endswith('.py') and not file.startswith('_'): task_name = file[:file.find('.py')] importlib.import_m...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/tasks/__init__.py
import os import torch from functools import lru_cache from fairseq.tasks import register_task, FairseqTask from fairseq.data.dictionary import Dictionary from fairseq.data import FairseqDataset from fairseq import utils from infoxlm.data import mlm_utils from infoxlm.data.dict_dataset import DictDataset from infoxlm...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/tasks/infoxlm.py
import logging import torch import torch.nn as nn import torch.nn.functional as F from fairseq import checkpoint_utils from fairseq import utils from fairseq.models import ( BaseFairseqModel, register_model, register_model_architecture, ) from fairseq.models.roberta import ( RobertaModel, RobertaEncoder, ...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/models/roberta.py
import torch import torch.nn as nn import torch.nn.functional as F from fairseq import checkpoint_utils from fairseq import utils from fairseq.models import ( BaseFairseqModel, register_model, register_model_architecture, ) from fairseq.models.roberta import ( RobertaModel, roberta_base_architecture, robe...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/models/xlm_align.py
import argparse import importlib import os from fairseq.models import MODEL_REGISTRY, ARCH_MODEL_INV_REGISTRY # automatically import any Python files in the models/ directory models_dir = os.path.dirname(__file__) for file in os.listdir(models_dir): path = os.path.join(models_dir, file) if not file.startswith('_...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/models/__init__.py
import logging import torch import torch.nn as nn import torch.nn.functional as F from fairseq import checkpoint_utils from fairseq import utils from fairseq.models import ( BaseFairseqModel, register_model, register_model_architecture, ) from fairseq.models.roberta import ( RobertaModel, roberta_base_arch...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/models/infoxlm.py
import torch from fairseq.data import FairseqDataset class TLMDataset(FairseqDataset): def __init__(self, src_dataset, tgt_dataset, bos, eos): assert len(src_dataset) == len(tgt_dataset) self.src_dataset = src_dataset self.tgt_dataset = tgt_dataset self.bos = bos self.eos = eos self._sizes...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/data/tlm_dataset.py
import torch from fairseq.data import BaseWrapperDataset from fairseq.data import (data_utils, TokenBlockDataset, PrependTokenDataset, PadDataset, TruncateDataset, NumelDataset, NumSamplesDataset, NestedDictionaryDataset, MaskTokensDataset, AppendTokenDataset, ) from infoxlm.data.mlm_utils import get_mlm_datas...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/data/offset_dataset.py
import torch from fairseq.data import (data_utils, TokenBlockDataset, PrependTokenDataset, PadDataset, TruncateDataset, NumelDataset, NumSamplesDataset, NestedDictionaryDataset, MaskTokensDataset, AppendTokenDataset, ) from fairseq.data.encoders.utils import get_whole_word_mask def get_mlm_dataset(args, datas...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/data/mlm_utils.py
import torch from fairseq.data import (data_utils, TokenBlockDataset, PrependTokenDataset, PadDataset, TruncateDataset, NumelDataset, NumSamplesDataset, NestedDictionaryDataset, MaskTokensDataset, AppendTokenDataset, ) from fairseq.data.encoders.utils import get_whole_word_mask from infoxlm.data.mlm_utils impo...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/data/xlm_align.py
import numpy as np import os import torch from threading import Thread from fairseq.data import data_utils, FairseqDataset, FairseqIterableDataset class DictIterDataset(FairseqIterableDataset): def __init__(self, defn, sizes=None): self.defn = defn for v in self.defn.values(): if not isinstance(v, (F...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/data/dict_dataset.py
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/data/__init__.py
import numpy as np import torch from fairseq.data import data_utils, FairseqDataset, MaskTokensDataset, TruncateDataset, BaseWrapperDataset from infoxlm.data.dict_dataset import DictDataset def get_xlco_dataset(args, dataset_path, vocab, mask_idx, combine=False): dataset = data_utils.load_indexed_dataset( data...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/data/xlco_dataset.py
import collections import logging import math import torch import numpy as np from torch import nn from torch.nn import functional as F from torch import distributed from fairseq import utils from fairseq.criterions import FairseqCriterion, register_criterion from fairseq.data.data_utils import process_bpe_symbol fr...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/criterions/xlm_align.py
import os import importlib # automatically import any Python files in the criterions/ directory for file in os.listdir(os.path.dirname(__file__)): if file.endswith('.py') and not file.startswith('_'): module = file[:file.find('.py')] importlib.import_module('infoxlm.criterions.' + module)
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/criterions/__init__.py
import collections import logging import math import torch from torch import nn from torch.nn import functional as F from torch import distributed from fairseq import utils from fairseq.criterions import FairseqCriterion, register_criterion logger = logging.getLogger(__name__) @register_criterion('xlco') class Xl...
EXA-1-master
exa/models/unilm-master/infoxlm/src-infoxlm/infoxlm/criterions/xlco.py
import deltalm from fairseq_cli.preprocess import cli_main if __name__ == "__main__": cli_main()
EXA-1-master
exa/models/unilm-master/deltalm/preprocess.py
import deltalm from fairseq_cli.generate import cli_main if __name__ == "__main__": cli_main()
EXA-1-master
exa/models/unilm-master/deltalm/generate.py
import deltalm from fairseq_cli.interactive import cli_main if __name__ == "__main__": cli_main()
EXA-1-master
exa/models/unilm-master/deltalm/interactive.py
import deltalm from fairseq_cli.train import cli_main if __name__ == "__main__": cli_main()
EXA-1-master
exa/models/unilm-master/deltalm/train.py
import deltalm.models
EXA-1-master
exa/models/unilm-master/deltalm/deltalm/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os from typing import Any, Dict, List, Optional, Tuple import torch import torch.nn as nn from torch import Tensor from fairseq import...
EXA-1-master
exa/models/unilm-master/deltalm/deltalm/models/deltalm.py
import argparse import importlib import os from fairseq.models import MODEL_REGISTRY, ARCH_MODEL_INV_REGISTRY # automatically import any Python files in the models/ directory models_dir = os.path.dirname(__file__) for file in os.listdir(models_dir): path = os.path.join(models_dir, file) if not file.startswith('_'...
EXA-1-master
exa/models/unilm-master/deltalm/deltalm/models/__init__.py
#!/usr/bin/env python3 from setuptools import find_packages, setup setup( name="markuplmft", version="0.1", author="MarkupLM Team", packages=find_packages(), python_requires=">=3.7", extras_require={"dev": ["flake8", "isort", "black"]}, )
EXA-1-master
exa/models/unilm-master/markuplm/setup.py
from __future__ import absolute_import, division, print_function import argparse import logging import os import random import glob import timeit import numpy as np import torch from torch.utils.data import (DataLoader, RandomSampler, SequentialSampler) from torch.utils.data.distributed import DistributedSampler from...
EXA-1-master
exa/models/unilm-master/markuplm/examples/fine_tuning/run_websrc/run.py
import csv import json import argparse import os.path as osp import os from operator import itemgetter def parse_args(): parser = argparse.ArgumentParser() parser.add_argument("--root_dir", default=None, type=str, required=True, help="The root directory of the raw WebSRC dataset; The o...
EXA-1-master
exa/models/unilm-master/markuplm/examples/fine_tuning/run_websrc/dataset_generation.py
from __future__ import absolute_import, division, print_function import json import logging import math import collections from io import open from os import path as osp from tqdm import tqdm import bs4 from bs4 import BeautifulSoup as bs from transformers.models.bert.tokenization_bert import BasicTokenizer, whitespac...
EXA-1-master
exa/models/unilm-master/markuplm/examples/fine_tuning/run_websrc/utils.py
import argparse import collections import json import os import re import string import sys from copy import deepcopy from bs4 import BeautifulSoup class EvalOpts: r""" The options which the matrix evaluation process needs. Arguments: data_file (str): the SQuAD-style json file of the dataset...
EXA-1-master
exa/models/unilm-master/markuplm/examples/fine_tuning/run_websrc/utils_evaluate.py
from __future__ import absolute_import, division, print_function import argparse import logging import os import random import glob import timeit import numpy as np import torch from torch.utils.data import (DataLoader, RandomSampler, SequentialSampler) from torch.utils.data.distributed import DistributedSampler from...
EXA-1-master
exa/models/unilm-master/markuplm/examples/fine_tuning/run_websrc/draft.py
from __future__ import absolute_import, division, print_function import argparse import logging import os import random import glob import numpy as np from torch.utils.data import (DataLoader, RandomSampler, SequentialSampler) from torch.utils.data.distributed import DistributedSampler from tensorboardX import Summar...
EXA-1-master
exa/models/unilm-master/markuplm/examples/fine_tuning/run_swde/run.py
# coding=utf-8 # Copyright 2021 The Google Research Authors. # # 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
EXA-1-master
exa/models/unilm-master/markuplm/examples/fine_tuning/run_swde/prepare_data.py
# coding=utf-8 # Copyright 2021 The Google Research Authors. # # 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
EXA-1-master
exa/models/unilm-master/markuplm/examples/fine_tuning/run_swde/pack_data.py
# coding=utf-8 # Copyright 2021 The Google Research Authors. # # 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
EXA-1-master
exa/models/unilm-master/markuplm/examples/fine_tuning/run_swde/constants.py
import tqdm from torch.utils.data import Dataset from markuplmft.data.tag_utils import tags_dict import pickle import os import constants class SwdeFeature(object): def __init__(self, html_path, input_ids, token_type_ids, attention_mask, ...
EXA-1-master
exa/models/unilm-master/markuplm/examples/fine_tuning/run_swde/utils.py
import os import sys import constants def page_hits_level_metric( vertical, target_website, sub_output_dir, prev_voted_lines ): """Evaluates the hit level prediction result with precision/recall/f1.""" all_precisions = [] all_recall = [] all_f1 = [] lines = prev_v...
EXA-1-master
exa/models/unilm-master/markuplm/examples/fine_tuning/run_swde/eval_utils.py
from transformers import CONFIG_MAPPING, MODEL_FOR_QUESTION_ANSWERING_MAPPING, \ MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING, MODEL_NAMES_MAPPING, TOKENIZER_MAPPING from transformers.convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS, RobertaConverter from transformers.file_utils import PRESET_MIRROR_DICT from .mode...
EXA-1-master
exa/models/unilm-master/markuplm/markuplmft/__init__.py
EXA-1-master
exa/models/unilm-master/markuplm/markuplmft/models/__init__.py
# coding=utf-8 # Copyright 2018 The Microsoft Research Asia MarkupLM Team Authors and the HuggingFace Inc. team. # # 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 copy of the License at # # http://www.apache.org/...
EXA-1-master
exa/models/unilm-master/markuplm/markuplmft/models/markuplm/modeling_markuplm.py
# coding=utf-8 # Copyright 2018 The Microsoft Research Asia MarkupLM Team Authors. # # 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
EXA-1-master
exa/models/unilm-master/markuplm/markuplmft/models/markuplm/tokenization_markuplm.py
# flake8: noqa # There's no way to ignore "F401 '...' imported but unused" warnings in this # module, but to preserve other warnings. So, don't check this module at all. # Copyright 2020 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use thi...
EXA-1-master
exa/models/unilm-master/markuplm/markuplmft/models/markuplm/__init__.py
# coding=utf-8 # Copyright 2010, The Microsoft Research Asia MarkupLM Team authors # # 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
EXA-1-master
exa/models/unilm-master/markuplm/markuplmft/models/markuplm/configuration_markuplm.py
# coding=utf-8 # Copyright 2018 The Microsoft Research Asia MarkupLM Team Authors. # # 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
EXA-1-master
exa/models/unilm-master/markuplm/markuplmft/models/markuplm/tokenization_markuplm_fast.py
tags_dict = {'a': 0, 'abbr': 1, 'acronym': 2, 'address': 3, 'altGlyph': 4, 'altGlyphDef': 5, 'altGlyphItem': 6, 'animate': 7, 'animateColor': 8, 'animateMotion': 9, 'animateTransform': 10, 'applet': 11, 'area': 12, 'article': 13, 'aside': 14, 'audio': 15, 'b': 16, 'base': 17, 'basefont': 18, '...
EXA-1-master
exa/models/unilm-master/markuplm/markuplmft/data/tag_utils.py
EXA-1-master
exa/models/unilm-master/markuplm/markuplmft/data/__init__.py
#!/usr/bin/env python3 from setuptools import find_packages, setup setup( name="layoutlmft", version="0.1", author="LayoutLM Team", url="https://github.com/microsoft/unilm/tree/master/layoutlmft", packages=find_packages(), python_requires=">=3.7", extras_require={"dev": ["flake8", "isort", "...
EXA-1-master
exa/models/unilm-master/layoutlmft/setup.py
import os import re import numpy as np from transformers.utils import logging logger = logging.get_logger(__name__) PREFIX_CHECKPOINT_DIR = "checkpoint" _re_checkpoint = re.compile(r"^" + PREFIX_CHECKPOINT_DIR + r"\-(\d+)$") def get_last_checkpoint(folder): content = os.listdir(folder) checkpoints = [ ...
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/evaluation.py
from collections import OrderedDict from transformers import CONFIG_MAPPING, MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING, MODEL_NAMES_MAPPING, TOKENIZER_MAPPING from transformers.convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS, BertConverter, XLMRobertaConverter from transformers.models.auto.modeling_auto import auto...
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/__init__.py
from dataclasses import dataclass from typing import Dict, Optional, Tuple import torch from transformers.file_utils import ModelOutput @dataclass class ReOutput(ModelOutput): loss: Optional[torch.FloatTensor] = None logits: torch.FloatTensor = None hidden_states: Optional[Tuple[torch.FloatTensor]] = No...
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/utils.py
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/__init__.py
from dataclasses import dataclass, field from typing import Optional @dataclass class ModelArguments: """ Arguments pertaining to which model/config/tokenizer we are going to fine-tune from. """ model_name_or_path: str = field( metadata={"help": "Path to pretrained model or model identifier f...
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/model_args.py
# coding=utf-8 from transformers.models.layoutlm.tokenization_layoutlm import LayoutLMTokenizer from transformers.utils import logging logger = logging.get_logger(__name__) VOCAB_FILES_NAMES = {"vocab_file": "vocab.txt"} PRETRAINED_VOCAB_FILES_MAP = { "vocab_file": { "microsoft/layoutlmv2-base-uncased":...
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/layoutlmv2/tokenization_layoutlmv2.py
from .configuration_layoutlmv2 import LayoutLMv2Config from .modeling_layoutlmv2 import LayoutLMv2ForRelationExtraction, LayoutLMv2ForTokenClassification, LayoutLMv2Model from .tokenization_layoutlmv2 import LayoutLMv2Tokenizer from .tokenization_layoutlmv2_fast import LayoutLMv2TokenizerFast
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/layoutlmv2/__init__.py
# -*- coding: utf-8 -*- def add_layoutlmv2_config(cfg): _C = cfg # ----------------------------------------------------------------------------- # Config definition # ----------------------------------------------------------------------------- _C.MODEL.MASK_ON = True # When using pre-trained m...
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/layoutlmv2/detectron2_config.py
# coding=utf-8 import math import torch import torch.nn.functional as F import torch.utils.checkpoint from torch import nn from torch.nn import CrossEntropyLoss import detectron2 from detectron2.modeling import META_ARCH_REGISTRY from transformers import PreTrainedModel from transformers.modeling_outputs import ( ...
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/layoutlmv2/modeling_layoutlmv2.py
# coding=utf-8 from transformers.models.layoutlm.tokenization_layoutlm_fast import LayoutLMTokenizerFast from transformers.utils import logging from .tokenization_layoutlmv2 import LayoutLMv2Tokenizer logger = logging.get_logger(__name__) VOCAB_FILES_NAMES = {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer....
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/layoutlmv2/tokenization_layoutlmv2_fast.py
# coding=utf-8 from transformers.models.layoutlm.configuration_layoutlm import LayoutLMConfig from transformers.utils import logging logger = logging.get_logger(__name__) LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP = { "layoutlmv2-base-uncased": "https://huggingface.co/microsoft/layoutlmv2-base-uncased/resolve/main...
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/layoutlmv2/configuration_layoutlmv2.py
# coding=utf-8 from transformers.utils import logging from ..layoutlmv2 import LayoutLMv2Config logger = logging.get_logger(__name__) LAYOUTXLM_PRETRAINED_CONFIG_ARCHIVE_MAP = { "layoutxlm-base": "https://huggingface.co/layoutxlm-base/resolve/main/config.json", "layoutxlm-large": "https://huggingface.co/lay...
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/layoutxlm/configuration_layoutxlm.py
# coding=utf-8 from transformers import XLMRobertaTokenizerFast from transformers.file_utils import is_sentencepiece_available from transformers.utils import logging if is_sentencepiece_available(): from .tokenization_layoutxlm import LayoutXLMTokenizer else: LayoutXLMTokenizer = None logger = logging.get_l...
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/layoutxlm/tokenization_layoutxlm_fast.py
# coding=utf-8 from transformers import XLMRobertaTokenizer from transformers.utils import logging logger = logging.get_logger(__name__) SPIECE_UNDERLINE = "▁" VOCAB_FILES_NAMES = {"vocab_file": "sentencepiece.bpe.model"} PRETRAINED_VOCAB_FILES_MAP = { "vocab_file": { "layoutxlm-base": "https://huggin...
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/layoutxlm/tokenization_layoutxlm.py
from .configuration_layoutxlm import LayoutXLMConfig from .modeling_layoutxlm import LayoutXLMForRelationExtraction, LayoutXLMForTokenClassification, LayoutXLMModel from .tokenization_layoutxlm import LayoutXLMTokenizer from .tokenization_layoutxlm_fast import LayoutXLMTokenizerFast
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/layoutxlm/__init__.py
# coding=utf-8 from transformers.utils import logging from ..layoutlmv2 import LayoutLMv2ForRelationExtraction, LayoutLMv2ForTokenClassification, LayoutLMv2Model from .configuration_layoutxlm import LayoutXLMConfig logger = logging.get_logger(__name__) LAYOUTXLM_PRETRAINED_MODEL_ARCHIVE_LIST = [ "layoutxlm-base...
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/layoutxlm/modeling_layoutxlm.py
from transformers.models.layoutlm import *
EXA-1-master
exa/models/unilm-master/layoutlmft/layoutlmft/models/layoutlm/__init__.py