text stringlengths 5 22M | id stringlengths 12 177 | metadata dict | __index_level_0__ int64 0 1.37k |
|---|---|---|---|
#!/bin/bash
# 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.
#echo 'Cloning Moses github repository (for tokenization scripts)...'
#git clone https://github.com/moses-smt/m... | COCO-LM/fairseq/examples/multilingual/data_scripts/download_iwslt_and_extract.sh/0 | {
"file_path": "COCO-LM/fairseq/examples/multilingual/data_scripts/download_iwslt_and_extract.sh",
"repo_id": "COCO-LM",
"token_count": 3164
} | 167 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
from typing import Any, Dict, Optional, List, Tuple
import torch
import torch.nn as nn
from fairseq import metrics, utils
from... | COCO-LM/fairseq/examples/pointer_generator/pointer_generator_src/transformer_pg.py/0 | {
"file_path": "COCO-LM/fairseq/examples/pointer_generator/pointer_generator_src/transformer_pg.py",
"repo_id": "COCO-LM",
"token_count": 9904
} | 168 |
#!/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... | COCO-LM/fairseq/examples/roberta/preprocess_RACE.py/0 | {
"file_path": "COCO-LM/fairseq/examples/roberta/preprocess_RACE.py",
"repo_id": "COCO-LM",
"token_count": 1679
} | 169 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import importlib
import os
from fairseq import registry
build_agent, register_agent, MONOTONIC_AGENT, _ = registry.setup_registry(
"--a... | COCO-LM/fairseq/examples/simultaneous_translation/eval/agents/__init__.py/0 | {
"file_path": "COCO-LM/fairseq/examples/simultaneous_translation/eval/agents/__init__.py",
"repo_id": "COCO-LM",
"token_count": 207
} | 170 |
from functools import partial
import torch
import math
import torch.nn.functional as F
from . import register_monotonic_attention
from .monotonic_multihead_attention import (
MonotonicMultiheadAttentionWaitK,
MonotonicMultiheadAttentionHardAligned,
MonotonicMultiheadAttentionInfiniteLookback,
)
def fixe... | COCO-LM/fairseq/examples/simultaneous_translation/modules/fixed_pre_decision.py/0 | {
"file_path": "COCO-LM/fairseq/examples/simultaneous_translation/modules/fixed_pre_decision.py",
"repo_id": "COCO-LM",
"token_count": 4429
} | 171 |
#!/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 flashlight's ASG criterion.
"""
def replabel_symbol(i):
"""
Replabel sy... | COCO-LM/fairseq/examples/speech_recognition/data/replabels.py/0 | {
"file_path": "COCO-LM/fairseq/examples/speech_recognition/data/replabels.py",
"repo_id": "COCO-LM",
"token_count": 853
} | 172 |
# Speech-to-Text (S2T) Modeling
[https://www.aclweb.org/anthology/2020.aacl-demo.6](https://www.aclweb.org/anthology/2020.aacl-demo.6.pdf)
Speech recognition (ASR) and speech-to-text translation (ST) with fairseq.
## Data Preparation
S2T modeling data consists of source speech features, target text and other optiona... | COCO-LM/fairseq/examples/speech_to_text/README.md/0 | {
"file_path": "COCO-LM/fairseq/examples/speech_to_text/README.md",
"repo_id": "COCO-LM",
"token_count": 1350
} | 173 |
#!/bin/bash
# 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.
SRCS=(
"de"
"fr"
)
TGT=en
ROOT=$(dirname "$0")
SCRIPTS=$ROOT/../../scripts
SPM_TRAIN=$SCRIPTS/spm_trai... | COCO-LM/fairseq/examples/translation/prepare-iwslt17-multilingual.sh/0 | {
"file_path": "COCO-LM/fairseq/examples/translation/prepare-iwslt17-multilingual.sh",
"repo_id": "COCO-LM",
"token_count": 2341
} | 174 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import sys
def _normalize_spaces(line):
return " ".join(line.split())
def main():
parser = argparse.ArgumentParser... | COCO-LM/fairseq/examples/unsupervised_quality_estimation/repeat_lines.py/0 | {
"file_path": "COCO-LM/fairseq/examples/unsupervised_quality_estimation/repeat_lines.py",
"repo_id": "COCO-LM",
"token_count": 296
} | 175 |
#!/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 flashlight (previously called wav2letter++) dataset
"""
import argpa... | COCO-LM/fairseq/examples/wav2vec/libri_labels.py/0 | {
"file_path": "COCO-LM/fairseq/examples/wav2vec/libri_labels.py",
"repo_id": "COCO-LM",
"token_count": 888
} | 176 |
/*
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
*/
/*
Kernel implementation for blocking repeated n-grams.
*/
#include <cuda.h>
#include <cuda_runtime.h>
#include <math.h>
#include <torch/extension.h>
#include <vector>
// Ban repeated ngrams of length = 'no_repeat_ngram_size'
__global__ void ... | COCO-LM/fairseq/fairseq/clib/cuda/ngram_repeat_block_cuda_kernel.cu/0 | {
"file_path": "COCO-LM/fairseq/fairseq/clib/cuda/ngram_repeat_block_cuda_kernel.cu",
"repo_id": "COCO-LM",
"token_count": 1159
} | 177 |
# Copyright (c) Facebook, Inc. and 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
from fairseq import metrics, utils
from fairseq.criteri... | COCO-LM/fairseq/fairseq/criterions/model_criterion.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/criterions/model_criterion.py",
"repo_id": "COCO-LM",
"token_count": 2119
} | 178 |
# Copyright (c) Facebook, Inc. and 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.path as op
import re
from typing import Dict, List, Optional, Tuple
import numpy as np
import t... | COCO-LM/fairseq/fairseq/data/audio/speech_to_text_dataset.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/data/audio/speech_to_text_dataset.py",
"repo_id": "COCO-LM",
"token_count": 9088
} | 179 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from fairseq.data.encoders import register_bpe
SPACE = chr(32)
SPACE_ESCAPE = chr(9601)
@register_bpe("characters")
class Characters(obje... | COCO-LM/fairseq/fairseq/data/encoders/characters.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/data/encoders/characters.py",
"repo_id": "COCO-LM",
"token_count": 264
} | 180 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import itertools
import logging
import math
import operator
import os
import queue
import time
from threading import Thread
import numpy as n... | COCO-LM/fairseq/fairseq/data/iterators.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/data/iterators.py",
"repo_id": "COCO-LM",
"token_count": 10366
} | 181 |
# Copyright (c) Facebook, Inc. and 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 datetime
import hashlib
import logging
import time
from bisect import bisect_right
from collections import OrderedDict, defaultdict
fro... | COCO-LM/fairseq/fairseq/data/multilingual/sampled_multi_dataset.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/data/multilingual/sampled_multi_dataset.py",
"repo_id": "COCO-LM",
"token_count": 8831
} | 182 |
# Copyright (c) Facebook, Inc. and 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 collections import OrderedDict
from typing import Dict, Sequence
import numpy as np
from . import FairseqDataset, Langua... | COCO-LM/fairseq/fairseq/data/round_robin_zip_datasets.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/data/round_robin_zip_datasets.py",
"repo_id": "COCO-LM",
"token_count": 2818
} | 183 |
# Copyright (c) Facebook, Inc. and 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 dataclasses import _MISSING_TYPE, dataclass, field
from typing import Any, List, Optional
import torch
from fairseq.dataclas... | COCO-LM/fairseq/fairseq/dataclass/configs.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/dataclass/configs.py",
"repo_id": "COCO-LM",
"token_count": 13696
} | 184 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""isort:skip_file"""
from .multihead_attention import ModelParallelMultiheadAttention
from .transformer_layer import (
ModelParallelTrans... | COCO-LM/fairseq/fairseq/model_parallel/modules/__init__.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/model_parallel/modules/__init__.py",
"repo_id": "COCO-LM",
"token_count": 157
} | 185 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from fairseq import utils
from fairseq.models import (
FairseqLanguageModel,
register_model,
register_model_architecture,
)
from f... | COCO-LM/fairseq/fairseq/models/fconv_lm.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/models/fconv_lm.py",
"repo_id": "COCO-LM",
"token_count": 2308
} | 186 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq.iterative_refinement_generator import DecoderOut
from fairseq.... | COCO-LM/fairseq/fairseq/models/nat/levenshtein_transformer.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/models/nat/levenshtein_transformer.py",
"repo_id": "COCO-LM",
"token_count": 9868
} | 187 |
#!/usr/bin/env python3
# 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 mat... | COCO-LM/fairseq/fairseq/models/speech_to_text/modules/emformer.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/models/speech_to_text/modules/emformer.py",
"repo_id": "COCO-LM",
"token_count": 33288
} | 188 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
class BeamableMM(nn.Module):
"""This module provides an optimized MM for beam decoding with attention... | COCO-LM/fairseq/fairseq/modules/beamable_mm.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/modules/beamable_mm.py",
"repo_id": "COCO-LM",
"token_count": 786
} | 189 |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name="lig... | COCO-LM/fairseq/fairseq/modules/lightconv_layer/setup.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/modules/lightconv_layer/setup.py",
"repo_id": "COCO-LM",
"token_count": 246
} | 190 |
# Copyright (c) Facebook, Inc. and 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 Callable, Optional
import torch
import torch.nn as nn
from fairseq import utils
from fairseq.modules import LayerNorm, Mul... | COCO-LM/fairseq/fairseq/modules/transformer_sentence_encoder_layer.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/modules/transformer_sentence_encoder_layer.py",
"repo_id": "COCO-LM",
"token_count": 2314
} | 191 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from fairseq import utils
from fairseq.dataclass.utils import gen_parser_from_dataclass
class FairseqOptimizer(object):
def... | COCO-LM/fairseq/fairseq/optim/fairseq_optimizer.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/optim/fairseq_optimizer.py",
"repo_id": "COCO-LM",
"token_count": 2596
} | 192 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch.optim
from . import LegacyFairseqOptimizer, register_optimizer
@register_optimizer("sgd")
class SGD(LegacyFairseqOptimizer):
... | COCO-LM/fairseq/fairseq/optim/sgd.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/optim/sgd.py",
"repo_id": "COCO-LM",
"token_count": 595
} | 193 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import itertools
import logging
import os
from collections import OrderedDict
import numpy as np
from fairseq import tokenizer, utils
from fa... | COCO-LM/fairseq/fairseq/tasks/cross_lingual_lm.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/tasks/cross_lingual_lm.py",
"repo_id": "COCO-LM",
"token_count": 3113
} | 194 |
# Copyright (c) Facebook, Inc. and 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
from fairseq.data.legacy.masked_lm_dictionary import MaskedLMDictionary
from fairseq.tasks.translation impor... | COCO-LM/fairseq/fairseq/tasks/translation_from_pretrained_xlm.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq/tasks/translation_from_pretrained_xlm.py",
"repo_id": "COCO-LM",
"token_count": 393
} | 195 |
#!/usr/bin/env python3 -u
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Train a new model on one or across multiple GPUs.
"""
import argparse
import logging
import math
import os
impor... | COCO-LM/fairseq/fairseq_cli/train.py/0 | {
"file_path": "COCO-LM/fairseq/fairseq_cli/train.py",
"repo_id": "COCO-LM",
"token_count": 7866
} | 196 |
try:
import torch
import fused_xentropy_cuda
from .softmax_xentropy import SoftmaxCrossEntropyLoss
del torch
del fused_xentropy_cuda
del softmax_xentropy
except ImportError as err:
print("cannot import kernels, please install the package")
| COCO-LM/fairseq/fused_ops/fused_ops/xentropy/__init__.py/0 | {
"file_path": "COCO-LM/fairseq/fused_ops/fused_ops/xentropy/__init__.py",
"repo_id": "COCO-LM",
"token_count": 95
} | 197 |
#!/bin/bash
if [ $# -ne 1 ]; then
echo "usage: $0 GENERATE_PY_OUTPUT"
exit 1
fi
GEN=$1
SYS=$GEN.sys
REF=$GEN.ref
if [ $(tail -n 1 $GEN | grep BLEU | wc -l) -ne 1 ]; then
echo "not done generating"
exit
fi
grep ^H $GEN | awk -F '\t' '{print $NF}' | perl -ple 's{(\S)-(\S)}{$1 ##AT##-##AT## $2}g' > $S... | COCO-LM/fairseq/scripts/compound_split_bleu.sh/0 | {
"file_path": "COCO-LM/fairseq/scripts/compound_split_bleu.sh",
"repo_id": "COCO-LM",
"token_count": 223
} | 198 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import unittest
import torch
import torch.nn as nn
from fairseq.modules.checkpoint_activations import checkpoint_wrapper
from torch.utils.che... | COCO-LM/fairseq/tests/test_activation_checkpointing.py/0 | {
"file_path": "COCO-LM/fairseq/tests/test_activation_checkpointing.py",
"repo_id": "COCO-LM",
"token_count": 1316
} | 199 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import unittest
from unittest import mock
class TestIOPath(unittest.TestCase):
def test_no_iopath(self):
from .test_reproducibi... | COCO-LM/fairseq/tests/test_iopath.py/0 | {
"file_path": "COCO-LM/fairseq/tests/test_iopath.py",
"repo_id": "COCO-LM",
"token_count": 365
} | 200 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import unittest
import torch
from fairseq.modules.sparse_multihead_attention import SparseMultiheadAttention
class TestSparseMultiheadAtten... | COCO-LM/fairseq/tests/test_sparse_multihead_attention.py/0 | {
"file_path": "COCO-LM/fairseq/tests/test_sparse_multihead_attention.py",
"repo_id": "COCO-LM",
"token_count": 2337
} | 201 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# Set pretrained model name, from ['cocolm-base', 'cocolm-large']
MODEL_NAME=$1
# Path to SQuAD dataset 'path/to/squad2_data'
DATASET_PATH=$2
# Output path for results and fine-tuned model
OUT_PATH=$3
mkdir -p $DATASET_PATH
# Train datset
exp... | COCO-LM/huggingface/run_squad.sh/0 | {
"file_path": "COCO-LM/huggingface/run_squad.sh",
"repo_id": "COCO-LM",
"token_count": 858
} | 202 |
# CSWin-Transformer, CVPR 2022
[](https://paperswithcode.com/sota/semantic-segmentation-on-ade20k?p=cswin-transformer-a-general-vision)
[
model = dict(
type='EncoderDecoder',
pretrained=None,
backbone=dict(
type='CSWin',
embed_dim=64,
patch_size=4,
depth=[1, 2, 21, 1],
num_heads=[2,4,8,16],
split_size=[1,2,7,7],
mlp_rati... | CSWin-Transformer/segmentation/configs/_base/upernet_cswin.py/0 | {
"file_path": "CSWin-Transformer/segmentation/configs/_base/upernet_cswin.py",
"repo_id": "CSWin-Transformer",
"token_count": 708
} | 204 |
site_name: ClimaX
repo_name: microsoft/ClimaX
repo_url: https://github.com/microsoft/ClimaX
markdown_extensions:
- attr_list
- tables
- admonition
- md_in_html
- pymdownx.details
- pymdownx.superfences
- pymdownx.tabbed:
alternate_style: true
- pymdownx.highlight:
anchor_linenums: true
- ... | ClimaX/mkdocs.yml/0 | {
"file_path": "ClimaX/mkdocs.yml",
"repo_id": "ClimaX",
"token_count": 720
} | 205 |
year_strings = [
'185001010600-187001010000',
'187001010600-189001010000',
'189001010600-191001010000',
'191001010600-193001010000',
'193001010600-195001010000',
'195001010600-197001010000',
'197001010600-199001010000',
'199001010600-201001010000',
'201001010600-201501010000',
]
pr... | ClimaX/snakemake_configs/HAMMOZ/Snakefile/0 | {
"file_path": "ClimaX/snakemake_configs/HAMMOZ/Snakefile",
"repo_id": "ClimaX",
"token_count": 1076
} | 206 |
datadir: /data/CMIP6/MPI-ESM
server_prefix: http://esgf-data1.llnl.gov/thredds/fileServer/css03_data/CMIP6/CMIP
name: u_component_of_wind
cmip_name: ua
era_name: u
output_type: 6hrPlevPt
run: r1i1p1f1
version: v20190815
res:
- 1.40625
# - 5.625
| ClimaX/snakemake_configs/MPI-ESM/config_u_component_of_wind.yml/0 | {
"file_path": "ClimaX/snakemake_configs/MPI-ESM/config_u_component_of_wind.yml",
"repo_id": "ClimaX",
"token_count": 124
} | 207 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
from pytorch_lightning.cli import LightningCLI
from climax.climate_projection.module import ClimateProjectionModule
from climax.climate_projection.datamodule import ClimateBenchDataModule
def main():
# Initialize Lightning with t... | ClimaX/src/climax/climate_projection/train.py/0 | {
"file_path": "ClimaX/src/climax/climate_projection/train.py",
"repo_id": "ClimaX",
"token_count": 561
} | 208 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import numpy as np
NAME_TO_VAR = {
"2m_temperature": "t2m",
"10m_u_component_of_wind": "u10",
"10m_v_component_of_wind": "v10",
"mean_sea_level_pressure": "msl",
"surface_pressure": "sp",
"toa_incident_solar_radiation": "... | ClimaX/src/climax/utils/data_utils.py/0 | {
"file_path": "ClimaX/src/climax/utils/data_utils.py",
"repo_id": "ClimaX",
"token_count": 1843
} | 209 |
"""
Copyright (C) 2019 NVIDIA Corporation. All rights reserved.
Licensed under the CC BY-NC-SA 4.0 license (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
"""
import torch
import torch.nn as nn
import numpy as np
import torch.nn.functional as F
from models.networks.base_network import BaseNetwork
from ... | CoCosNet/models/networks/discriminator.py/0 | {
"file_path": "CoCosNet/models/networks/discriminator.py",
"repo_id": "CoCosNet",
"token_count": 3780
} | 210 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import os
import numpy as np
import torch
import torchvision.utils as vutils
import sys
from collections import OrderedDict
from options.train_options import TrainOptions
import data
from util.iter_counter import IterationCounter
from util.util i... | CoCosNet/train.py/0 | {
"file_path": "CoCosNet/train.py",
"repo_id": "CoCosNet",
"token_count": 2325
} | 211 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from evaluator.CodeBLEU.parser import DFG_python, DFG_java, DFG_ruby, DFG_go, DFG_php, DFG_javascript, DFG_csharp
from evaluator.CodeBLEU.parser import (remove_comments_and_docstrings,
tree_to_token_index,
... | CodeBERT/CodeReviewer/code/evaluator/CodeBLEU/dataflow_match.py/0 | {
"file_path": "CodeBERT/CodeReviewer/code/evaluator/CodeBLEU/dataflow_match.py",
"repo_id": "CodeBERT",
"token_count": 2439
} | 212 |
import os
import torch
import logging
import argparse
import random
import numpy as np
from tqdm import tqdm
import multiprocessing
import time
from itertools import cycle
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from torch.utils.data import ConcatDataset
from torch.utils.data.distribut... | CodeBERT/CodeReviewer/code/run_finetune_cls.py/0 | {
"file_path": "CodeBERT/CodeReviewer/code/run_finetune_cls.py",
"repo_id": "CodeBERT",
"token_count": 5419
} | 213 |
import re, json
import os, random
import torch, logging
from copy import deepcopy as cp
from torch.utils.data import Dataset
from tokenizers import ByteLevelBPETokenizer
from transformers import T5Tokenizer, RobertaTokenizer
import nltk
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(mess... | CodeBERT/CodeReviewer/code/utils.py/0 | {
"file_path": "CodeBERT/CodeReviewer/code/utils.py",
"repo_id": "CodeBERT",
"token_count": 15950
} | 214 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch.nn as nn
import torch
class Model(nn.Module):
def __init__(self, encoder):
super(Model, self).__init__()
self.encoder = encoder
def forward(self, code_inputs=None, attn_mask=None,position_idx=None... | CodeBERT/GraphCodeBERT/codesearch/model.py/0 | {
"file_path": "CodeBERT/GraphCodeBERT/codesearch/model.py",
"repo_id": "CodeBERT",
"token_count": 568
} | 215 |
# coding=utf-8
# Copyright 2020 The Allen Institute for AI team 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/licenses/LICENSE-2... | CodeBERT/LongCoder/longcoder.py/0 | {
"file_path": "CodeBERT/LongCoder/longcoder.py",
"repo_id": "CodeBERT",
"token_count": 35772
} | 216 |
# 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... | CodeBERT/UniXcoder/downstream-tasks/clone-detection/BCB/run.py/0 | {
"file_path": "CodeBERT/UniXcoder/downstream-tasks/clone-detection/BCB/run.py",
"repo_id": "CodeBERT",
"token_count": 7374
} | 217 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch.nn as nn
import torch
class Model(nn.Module):
def __init__(self, encoder):
super(Model, self).__init__()
self.encoder = encoder
def forward(self, code_inputs=None, nl_inputs=None):
if cod... | CodeBERT/UniXcoder/downstream-tasks/code-search/model.py/0 | {
"file_path": "CodeBERT/UniXcoder/downstream-tasks/code-search/model.py",
"repo_id": "CodeBERT",
"token_count": 410
} | 218 |
# coding=utf-8
# Copyright 2020 Microsoft and the Hugging Face 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/licenses/LICENSE-2.0
#
# Unless require... | CodeT/DIVERSE/code/src/deberta_model.py/0 | {
"file_path": "CodeT/DIVERSE/code/src/deberta_model.py",
"repo_id": "CodeT",
"token_count": 28029
} | 219 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: config.sample.py
Description: unittest configuration for Python SDK of the Cognitive Face API.
- Copy `config.sample.py` to `config.py`.
- Change the `BASE_URL` if necessary.
- Assign the `KEY` with a valid Subscription Key.
"""
# Subscription Key for calling th... | Cognitive-Face-Python/cognitive_face/tests/config.sample.py/0 | {
"file_path": "Cognitive-Face-Python/cognitive_face/tests/config.sample.py",
"repo_id": "Cognitive-Face-Python",
"token_count": 201
} | 220 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: util.py
Description: util module for Python SDK sample.
"""
from threading import Thread
import io
import operator
import os.path
from PIL import Image
import wx
try:
import cognitive_face as CF
except ImportError:
import sys
ROOT_DIR = os.path.dirn... | Cognitive-Face-Python/sample/util.py/0 | {
"file_path": "Cognitive-Face-Python/sample/util.py",
"repo_id": "Cognitive-Face-Python",
"token_count": 2584
} | 221 |
export CUDA_VISIBLE_DEVICES=0
python t5_run_train.py \
--model_name_or_path ./checkpoint/Com/MainExp_pretrain_set1_seed1/checkpoint-100000 \
--subtask Com \
--method MainExp \
--train_file finetune \
--max_steps 50000 \
--save_steps 50000 \
--batch_size 8 \
--ebatch_size 16 \
--gas 1 \
--seed 1 \
--set set1 | ContextualSP/abstraction_probing/code/t5_code/Com_MainExp_finetune.sh/0 | {
"file_path": "ContextualSP/abstraction_probing/code/t5_code/Com_MainExp_finetune.sh",
"repo_id": "ContextualSP",
"token_count": 123
} | 222 |
import subprocess
import argparse
import os
def run_command(bash_command):
process = subprocess.Popen(bash_command.split())
output, error = process.communicate()
print(error)
print(output)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--model_name_or_path... | ContextualSP/abstraction_probing/code/t5_code/t5_run_eval.py/0 | {
"file_path": "ContextualSP/abstraction_probing/code/t5_code/t5_run_eval.py",
"repo_id": "ContextualSP",
"token_count": 1231
} | 223 |
description: Adapter Differentiation for MT-NLU Job on AMLK8s
target:
service: amlk8s
# run "amlt target list amlk8s" to list the names of available AMLK8s targets
name: itpeusp100cl
vc: resrchvc
environment:
image: python:3.6
registry: docker.io # any public registry can be specified here
setup:
- ... | ContextualSP/adaptershare/adapter_diff_train.yaml/0 | {
"file_path": "ContextualSP/adaptershare/adapter_diff_train.yaml",
"repo_id": "ContextualSP",
"token_count": 380
} | 224 |
#!/usr/bin/env bash
##############################################################
# This script is used to download resources for MT-DNN experiments
##############################################################
BERT_DIR=$(pwd)/mt_dnn_models
if [ ! -d ${BERT_DIR} ]; then
echo "Create a folder BERT_DIR"
mkdir $... | ContextualSP/adaptershare/download.sh/0 | {
"file_path": "ContextualSP/adaptershare/download.sh",
"repo_id": "ContextualSP",
"token_count": 1059
} | 225 |
#!/usr/bin/env bash
###############################
# Training script for GLUE.
# It supports single and multi-task training
# By Xiaodong
###############################
set -e
if [[ $# -lt 6 ]]; then
echo "It requires 6 args to run the script and the current # of bash args: $#"
echo "run_glue_finetune.sh <... | ContextualSP/adaptershare/experiments/glue/run_glue_finetuning.sh/0 | {
"file_path": "ContextualSP/adaptershare/experiments/glue/run_glue_finetuning.sh",
"repo_id": "ContextualSP",
"token_count": 1396
} | 226 |
import json
from sklearn.metrics import accuracy_score
import argparse
def compute_acc(predicts, labels):
return 100.0 * accuracy_score(labels, predicts)
def load(path):
with open(path, "r") as f:
return json.load(f)
def compute(scores, labels):
lang_map = labels["lang_map"]
label_map = la... | ContextualSP/adaptershare/experiments/xnli/xnli_eval.py/0 | {
"file_path": "ContextualSP/adaptershare/experiments/xnli/xnli_eval.py",
"repo_id": "ContextualSP",
"token_count": 567
} | 227 |
# coding=utf-8
# Copyright (c) Microsoft. All rights reserved.
import copy
import imp
import sys, os
import torch
import tasks
import logging
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim.lr_scheduler import *
from data_utils.utils import AverageMe... | ContextualSP/adaptershare/mt_dnn/model.py/0 | {
"file_path": "ContextualSP/adaptershare/mt_dnn/model.py",
"repo_id": "ContextualSP",
"token_count": 12656
} | 228 |
from utils.data_types import SQLTokenType
import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import BertModel
from collections import defaultdict
from typing import Dict, List
from utils.data_iter import MetaIndex
from models.nn_utils import *
class WTQAlignmentModel(nn.Module):
... | ContextualSP/awakening_latent_grounding/models/wtq_align.py/0 | {
"file_path": "ContextualSP/awakening_latent_grounding/models/wtq_align.py",
"repo_id": "ContextualSP",
"token_count": 4270
} | 229 |
import os
from multiprocessing import Pool
import recognizers_suite as Recognizers
from Levenshtein import ratio
from recognizers_suite import Culture
from utils.data_types import *
def is_float(value: str) -> bool:
try:
float(value)
return True
except:
return False
def is_adjectiv... | ContextualSP/awakening_latent_grounding/utils/nlp_utils.py/0 | {
"file_path": "ContextualSP/awakening_latent_grounding/utils/nlp_utils.py",
"repo_id": "ContextualSP",
"token_count": 4625
} | 230 |
import torch
from torch import nn
class BinaryTreeLstmCell(nn.Module):
def __init__(self, hidden_dim, dropout_prob=None):
super().__init__()
self.h_dim = hidden_dim
self.linear = nn.Linear(in_features=2 * self.h_dim, out_features=5 * self.h_dim)
if dropout_prob is not None:
... | ContextualSP/compositional_generalization/modules/BinaryTreeLstmCell.py/0 | {
"file_path": "ContextualSP/compositional_generalization/modules/BinaryTreeLstmCell.py",
"repo_id": "ContextualSP",
"token_count": 622
} | 231 |
{
"random_seed": 42,
"numpy_seed": 42,
"pytorch_seed": 42,
"dataset_reader": {
"type": "rewrite",
"lazy": false,
"super_mode": "before",
"joint_encoding": true,
"extra_stop_words": ["的", "是", "我", "了", "去"]
},
"train_data_path": "D:\\users\\v-qianl\\Unified-FollowUp\\dataset\\MultiDialogue\\train.txt",
... | ContextualSP/incomplete_utterance_rewriting/configs/multi.jsonnet/0 | {
"file_path": "ContextualSP/incomplete_utterance_rewriting/configs/multi.jsonnet",
"repo_id": "ContextualSP",
"token_count": 618
} | 232 |
#!/usr/bin/env bash
export model_file=../checkpoints/run_task
export config_file=../configs/task.jsonnet
export train_data_path=../dataset/Task/train.txt
export validation_data_path=../dataset/Task/dev.txt
export pretrained_file=../glove/glove.6B.100d.txt
export seed=1
allennlp train -s ${model_file} ${config_file} \
-... | ContextualSP/incomplete_utterance_rewriting/src/train_task.sh/0 | {
"file_path": "ContextualSP/incomplete_utterance_rewriting/src/train_task.sh",
"repo_id": "ContextualSP",
"token_count": 228
} | 233 |
# coding=utf8
from collections import deque, namedtuple
# we'll use infinity as a default distance to nodes.
inf = float('inf')
Edge = namedtuple('Edge', 'start, end, cost')
def make_edge(start, end, cost=1):
return Edge(start, end, cost)
class Graph:
def __init__(self, edges):
# let's check that... | ContextualSP/interactive_text_to_sql/src/context/graph.py/0 | {
"file_path": "ContextualSP/interactive_text_to_sql/src/context/graph.py",
"repo_id": "ContextualSP",
"token_count": 1776
} | 234 |
# coding: utf-8
# from pattern.en import lemma
import spacy
sp_english = spacy.load('en_core_web_sm')
STOP_WORD_LIST = [_.strip() for _ in open('data/common/stop_words.txt', 'r', encoding='utf-8').readlines() if _[0] != '#']
TEMPLATE_KEYWORDS = ['find', 'out', 'the', 'common', 'part', 'of', 'set', 'and', 'everyone',... | ContextualSP/interactive_text_to_sql/src/utils/utils.py/0 | {
"file_path": "ContextualSP/interactive_text_to_sql/src/utils/utils.py",
"repo_id": "ContextualSP",
"token_count": 499
} | 235 |
# import cPickle as pickle
import pickle
import codecs
import contextlib
import gzip
import json
import os
import random
import shutil
import subprocess
import sys
import time
from queue import Queue, Empty
from abc import ABCMeta, abstractmethod
from collections import Mapping, OrderedDict
from os.path import join
fr... | ContextualSP/lemon/executor/gtd/io.py/0 | {
"file_path": "ContextualSP/lemon/executor/gtd/io.py",
"repo_id": "ContextualSP",
"token_count": 7652
} | 236 |
from abc import ABCMeta, abstractmethod
from collections import Sequence
import logging
import os
import random
from dependency.data_directory import DataDirectory
from gtd.utils import random_seed
class Dataset(Sequence, metaclass=ABCMeta):
"""Encapsulates an entire dataset or fetches the data if necessary."""
... | ContextualSP/lemon/executor/strongsup/dataset.py/0 | {
"file_path": "ContextualSP/lemon/executor/strongsup/dataset.py",
"repo_id": "ContextualSP",
"token_count": 664
} | 237 |
import operator
import os
from gtd.utils import EqualityMixin
from functools import reduce
class ExperimentType(EqualityMixin):
"""Defines the configs for an experiment
Args:
configs (list[string]): the config mixins
base (string): the base config e.g. "default-base"
"""
@classmethod
... | ContextualSP/lemon/executor/strongsup/results/entry.py/0 | {
"file_path": "ContextualSP/lemon/executor/strongsup/results/entry.py",
"repo_id": "ContextualSP",
"token_count": 2047
} | 238 |
from strongsup.world import World
from strongsup.rlong.executor import RLongExecutor
from strongsup.rlong.predicates_computer import get_predicates_computer
from strongsup.rlong.state import RLongState
class RLongWorld(World):
"""World for Alchemy, Scene, and Tangrams domains."""
def __init__(self, initial_s... | ContextualSP/lemon/executor/strongsup/rlong/world.py/0 | {
"file_path": "ContextualSP/lemon/executor/strongsup/rlong/world.py",
"repo_id": "ContextualSP",
"token_count": 554
} | 239 |
# import pytest
import sys
sys.path.append('../../../')
from strongsup.rlong.executor import RLongExecutor
from strongsup.rlong.predicate import RLongPredicate
from strongsup.rlong.state import \
RLongAlchemyState, RLongSceneState, RLongTangramsState, RLongUndogramsState
class RLongExecutorTester(object):
... | ContextualSP/lemon/executor/strongsup/tests/rlong/test_executor.py/0 | {
"file_path": "ContextualSP/lemon/executor/strongsup/tests/rlong/test_executor.py",
"repo_id": "ContextualSP",
"token_count": 8292
} | 240 |
# Value interface
from abc import ABCMeta, abstractmethod
class Value(object, metaclass=ABCMeta):
"""A value represents an item in either a denotation (gold or predicted)"""
@abstractmethod
def match(self, other):
"""Return True if the value matches the other value based on the
official c... | ContextualSP/lemon/executor/strongsup/value.py/0 | {
"file_path": "ContextualSP/lemon/executor/strongsup/value.py",
"repo_id": "ContextualSP",
"token_count": 556
} | 241 |
# AI2 Reasoning Challenge
* [evaluator](evaluator/) is the program used by the AI2 Leaderboard to evaluate submitted predictions.
* [data-easy](data-easy/) and [data-challege](data-challenge/) have the files (and scripts to generate them) used for evaluating Leaderboard predictions.
## Example usage
To evaluate dumm... | ContextualSP/lemon/propara_evaluator/aristo-leaderboard/arc/README.md/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/arc/README.md",
"repo_id": "ContextualSP",
"token_count": 180
} | 242 |
#!/bin/bash
set -xe
docker build -t aristo-leaderboard-eval-test .
T=$(mktemp -d /tmp/tmp-XXXXX)
docker run \
-v $T:/output:rw \
-v $PWD:/input:ro \
aristo-leaderboard-eval-test \
./evaluator.py \
--question-answers /input/questions.jsonl \
--predictions /input/predictions.csv \
--output /output/metri... | ContextualSP/lemon/propara_evaluator/aristo-leaderboard/arc/evaluator/test.sh/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/arc/evaluator/test.sh",
"repo_id": "ContextualSP",
"token_count": 200
} | 243 |
#!/bin/bash
set -e
echo ------------------------
echo Building evaluator image
echo ------------------------
echo
set -x
docker build -t eqasc-evaluator .
set +x
echo
echo ------------------------
echo Running evaluator on known predictions and labels
echo ------------------------
echo
tempdir=$(mktemp -d /tmp/tem... | ContextualSP/lemon/propara_evaluator/aristo-leaderboard/eqasc/code/test-with-docker.sh/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/eqasc/code/test-with-docker.sh",
"repo_id": "ContextualSP",
"token_count": 417
} | 244 |
# Locations
NO_LOCATION = 'null' # This location is used of a participant that doesn't exist (was destroyed, or not yet created)
LOCATION_UNKNOWN = 'unk'
# Actions
NO_ACTION = 'NONE'
MOVE = 'MOVE'
CREATE = 'CREATE'
DESTROY = 'DESTROY'
| ContextualSP/lemon/propara_evaluator/aristo-leaderboard/propara/evaluator/process/constants.py/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/propara/evaluator/process/constants.py",
"repo_id": "ContextualSP",
"token_count": 83
} | 245 |
## Test case: Prediction and answer are same
* answers.tsv is the answer to process 1167 from the training set.
* predictions.tsv is a copy of the answer to process 1167.
An evaluation on this prediction should result in an F1 score of 1.0.
| ContextualSP/lemon/propara_evaluator/aristo-leaderboard/propara/evaluator/testfiles-2/README.md/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/propara/evaluator/testfiles-2/README.md",
"repo_id": "ContextualSP",
"token_count": 65
} | 246 |
#!/usr/bin/env python3
import csv
from typing import *
import logging
import sys
import json
EXIT_STATUS_ANSWERS_MALFORMED = 1
EXIT_STATUS_PREDICTIONS_MALFORMED = 2
EXIT_STATUS_PREDICTIONS_EXTRA = 3
EXIT_STATUS_PREDICTION_MISSING = 4
VALID_PREDICTION_VALUES = ['E', 'N']
def calculate_accuracy(answers: Dict[str, str... | ContextualSP/lemon/propara_evaluator/aristo-leaderboard/scitail/evaluator/evaluator.py/0 | {
"file_path": "ContextualSP/lemon/propara_evaluator/aristo-leaderboard/scitail/evaluator/evaluator.py",
"repo_id": "ContextualSP",
"token_count": 2357
} | 247 |
import os, sys
import json
import numpy as np
import re
import inflect
from elasticsearch import Elasticsearch
from elasticsearch import helpers
from tqdm import tqdm
sys.path.append('../')
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--start_index', help='Path to load verifier model')
parse... | ContextualSP/logigan/corpus_construction/elastic_search/build_gen_train.py/0 | {
"file_path": "ContextualSP/logigan/corpus_construction/elastic_search/build_gen_train.py",
"repo_id": "ContextualSP",
"token_count": 2299
} | 248 |
from transformers.tokenization_utils_base import BatchEncoding, PreTrainedTokenizerBase
from typing import Any, Callable, Dict, List, NewType, Optional, Tuple, Union
from transformers.file_utils import PaddingStrategy
import copy
from dataclasses import dataclass
InputDataClass = NewType("InputDataClass", Any)
@datacl... | ContextualSP/logigan/pre-training/gan_dataset.py/0 | {
"file_path": "ContextualSP/logigan/pre-training/gan_dataset.py",
"repo_id": "ContextualSP",
"token_count": 2776
} | 249 |
## Poset Decoding <img src="https://pytorch.org/assets/images/logo-dark.svg" height = "25" align=center />
The official pytorch implementation of our paper [Hierarchical Poset Decoding for Compositional Generalization in Language](https://arxiv.org/pdf/2002.00652.pdf).
If you find our code useful, please consider ci... | ContextualSP/poset_decoding/README.md/0 | {
"file_path": "ContextualSP/poset_decoding/README.md",
"repo_id": "ContextualSP",
"token_count": 650
} | 250 |
import torch
import torch
import torch.nn as nn
import torch.nn.functional as F
class Tree:
def __init__(self, value):
# value = [1] tensor, the value is: output_token_idx
# value of tree root should be [word_to_idx('<sos>')]
self.value = value
self.children = dict()
class Trie:
... | ContextualSP/poset_decoding/sketch_prediction/utils.py/0 | {
"file_path": "ContextualSP/poset_decoding/sketch_prediction/utils.py",
"repo_id": "ContextualSP",
"token_count": 799
} | 251 |
"""Convert list of input into class:`DataPack` expected format."""
import typing
import pandas as pd
import numpy as np
import matchzoo
from matchzoo.engine.base_task import BaseTask
def pack(
df: pd.DataFrame,
task: typing.Union[str, BaseTask] = 'ranking',
) -> 'matchzoo.DataPack':
"""
Pack a :cla... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/data_pack/pack.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/data_pack/pack.py",
"repo_id": "ContextualSP",
"token_count": 1734
} | 252 |
"""WikiQA data loader."""
import typing
import csv
from pathlib import Path
import pandas as pd
import matchzoo
from matchzoo.engine.base_task import BaseTask
_url = "https://download.microsoft.com/download/E/5/F/" \
"E5FCFCEE-7005-4814-853D-DAA7C66507E0/WikiQACorpus.zip"
def load_data(
stage: str = 't... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/datasets/wiki_qa/load_data.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/datasets/wiki_qa/load_data.py",
"repo_id": "ContextualSP",
"token_count": 1284
} | 253 |
"""Accuracy metric for Classification."""
import numpy as np
from matchzoo.engine.base_metric import ClassificationMetric
class Accuracy(ClassificationMetric):
"""Accuracy metric."""
ALIAS = ['accuracy', 'acc']
def __init__(self):
""":class:`Accuracy` constructor."""
def __repr__(self) -> ... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/metrics/accuracy.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/metrics/accuracy.py",
"repo_id": "ContextualSP",
"token_count": 440
} | 254 |
"""An implementation of ConvKNRM Model."""
import typing
import torch
import torch.nn as nn
import torch.nn.functional as F
from matchzoo.engine.param_table import ParamTable
from matchzoo.engine.param import Param
from matchzoo.engine.base_model import BaseModel
from matchzoo.engine import hyper_spaces
from matchzoo... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/models/conv_knrm.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/models/conv_knrm.py",
"repo_id": "ContextualSP",
"token_count": 2516
} | 255 |
from .attention import Attention
from .attention import BidirectionalAttention
from .attention import MatchModule
from .dropout import RNNDropout
from .stacked_brnn import StackedBRNN
from .gaussian_kernel import GaussianKernel
from .matching import Matching
from .bert_module import BertModule
from .character_embedding... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/modules/__init__.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/modules/__init__.py",
"repo_id": "ContextualSP",
"token_count": 140
} | 256 |
"""Build unit from data pack."""
from tqdm import tqdm
import matchzoo as mz
from .units import StatefulUnit
def build_unit_from_data_pack(
unit: StatefulUnit,
data_pack: mz.DataPack, mode: str = 'both',
flatten: bool = True, verbose: int = 1
) -> StatefulUnit:
"""
Build a :class:`StatefulUnit` ... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/preprocessors/build_unit_from_data_pack.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/preprocessors/build_unit_from_data_pack.py",
"repo_id": "ContextualSP",
"token_count": 525
} | 257 |
import nltk
from .unit import Unit
class Tokenize(Unit):
"""Process unit for text tokenization."""
def transform(self, input_: str) -> list:
"""
Process input data from raw terms to list of tokens.
:param input_: raw textual input.
:return tokens: tokenized tokens as a list... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/preprocessors/units/tokenize.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/preprocessors/units/tokenize.py",
"repo_id": "ContextualSP",
"token_count": 158
} | 258 |
"""One hot vectors."""
import numpy as np
def one_hot(indices: int, num_classes: int) -> np.ndarray:
""":return: A one-hot encoded vector."""
vec = np.zeros((num_classes,), dtype=np.int64)
vec[indices] = 1
return vec
| ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/utils/one_hot.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/matchzoo/utils/one_hot.py",
"repo_id": "ContextualSP",
"token_count": 94
} | 259 |
import pytest
from matchzoo.engine.base_model import BaseModel
def test_base_model_abstract_instantiation():
with pytest.raises(TypeError):
model = BaseModel(BaseModel.get_default_params())
assert model
def test_base_model_concrete_instantiation():
class MyBaseModel(BaseModel):
def ... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tests/models/test_base_model.py/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tests/models/test_base_model.py",
"repo_id": "ContextualSP",
"token_count": 244
} | 260 |
<jupyter_start><jupyter_code>%run init.ipynb
preprocessor = mz.models.ArcII.get_default_preprocessor(
filter_mode='df',
filter_low_freq=2,
)
train_pack_processed = preprocessor.fit_transform(train_pack_raw)
dev_pack_processed = preprocessor.transform(dev_pack_raw)
test_pack_processed = preprocessor.transform(te... | ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tutorials/ranking/arcii.ipynb/0 | {
"file_path": "ContextualSP/poset_decoding/traversal_path_prediction/MatchZoo-py/tutorials/ranking/arcii.ipynb",
"repo_id": "ContextualSP",
"token_count": 859
} | 261 |
set seed=1
set config_file=train_configs_bert/concat.none.jsonnet
set model_file=checkpoints_cosql/cosql_bert_concat_none_model
set tables_file=dataset_cosql/tables.json
set database_path=dataset_cosql/database
set dataset_path=dataset_cosql
set train_data_path=dataset_cosql/train.json
set validation_data_path=dataset_... | ContextualSP/semantic_parsing_in_context/bash_files/windows/train_cosql_bert.bat/0 | {
"file_path": "ContextualSP/semantic_parsing_in_context/bash_files/windows/train_cosql_bert.bat",
"repo_id": "ContextualSP",
"token_count": 332
} | 262 |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import json
import argparse
def convert_dataset(valid_file, valid_out_file):
"""
The package `allennlp` requires the validation file as the format of each line containing a json object.
:param valid_file: valid file input, the origi... | ContextualSP/semantic_parsing_in_context/postprocess.py/0 | {
"file_path": "ContextualSP/semantic_parsing_in_context/postprocess.py",
"repo_id": "ContextualSP",
"token_count": 340
} | 263 |
import re
from collections import Counter, defaultdict
from typing import Dict, Tuple, List
from unidecode import unidecode
from semparse.sql.spider_utils import TableColumn, read_dataset_schema, read_dataset_values
# == stop words that will be omitted by ContextGenerator
STOP_WORDS = {"", "", "all", "being", "-", "... | ContextualSP/unified_parser_text_to_sql/semparse/contexts/spider_db_context.py/0 | {
"file_path": "ContextualSP/unified_parser_text_to_sql/semparse/contexts/spider_db_context.py",
"repo_id": "ContextualSP",
"token_count": 6196
} | 264 |
import os
import sys
import json
import sqlite3
from os import listdir, makedirs
from os.path import isfile, isdir, join, split, exists, splitext
from nltk import word_tokenize, tokenize
import traceback
EXIST = {"atis", "geo", "advising", "yelp", "restaurants", "imdb", "academic"}
def convert_fk_index(data):
fk... | ContextualSP/unified_parser_text_to_sql/third_party/spider/preprocess/get_tables.py/0 | {
"file_path": "ContextualSP/unified_parser_text_to_sql/third_party/spider/preprocess/get_tables.py",
"repo_id": "ContextualSP",
"token_count": 2963
} | 265 |
import os
import cv2
import json
import torch
import scipy
import scipy.io as sio
from skimage import io
from torchvision import datasets, transforms
from torchvision.datasets.folder import ImageFolder, default_loader
from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from timm.data import cr... | Cream/AutoFormer/lib/datasets.py/0 | {
"file_path": "Cream/AutoFormer/lib/datasets.py",
"repo_id": "Cream",
"token_count": 4094
} | 266 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.