repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
libai
libai-main/projects/text_classification/dataset/download_glue_data.py
# flake8: noqa """ Script for downloading all GLUE data. Modify from https://github.com/nyu-mll/GLUE-baselines/blob/master/download_glue_data.py Note: for legal reasons, we are unable to host MRPC. You can either use the version hosted by the SentEval team, which is already tokenized, or you can download the original ...
6,858
37.318436
190
py
libai
libai-main/projects/text_classification/dataset/__init__.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
697
37.777778
74
py
libai
libai-main/projects/text_classification/dataset/clue_dataset.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
4,576
35.03937
95
py
libai
libai-main/projects/text_classification/configs/config.py
from omegaconf import OmegaConf from libai.config import get_config from libai.config import LazyCall from libai.data.build import build_nlp_test_loader, build_nlp_train_loader from libai.tokenizer import BertTokenizer from projects.text_classification.modeling.model import ModelForSequenceClassification from projects...
2,416
27.77381
86
py
libai
libai-main/projects/text_classification/modeling/model.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
2,753
34.307692
94
py
libai
libai-main/projects/text_classification/modeling/load_megatron_weight.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
5,294
35.770833
100
py
libai
libai-main/projects/MAE/train_net.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
3,384
35.010638
99
py
libai
libai-main/projects/MAE/configs/mae_pretraining.py
from flowvision.transforms import transforms, InterpolationMode from flowvision.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD from libai.config import LazyCall, get_config from configs.models.mae_vit_base_patch16 import model from data.pretraining_imagenet import PretrainingImageNetDataset from uti...
3,073
28.84466
91
py
libai
libai-main/projects/MAE/configs/mae_finetune.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
3,855
28.212121
99
py
libai
libai-main/projects/MAE/configs/models/vit_base_patch16.py
from libai.config import LazyCall from modeling.vit import VisionTransformer model = LazyCall(VisionTransformer)( img_size=224, patch_size=16, in_chans=3, embed_dim=768, depth=12, num_heads=12, mlp_ratio=4, drop_path_rate=0.1, global_pool=True, )
286
15.882353
42
py
libai
libai-main/projects/MAE/configs/models/vit_large_patch16.py
from .vit_base_patch16 import model model.embed_dim = 1024 model.depth = 24 model.num_heads = 16
99
13.285714
35
py
libai
libai-main/projects/MAE/configs/models/mae_vit_huge_patch14.py
from .mae_vit_base_patch16 import model model.patch_size = 14 model.embed_dim = 1280 model.depth = 32 model.num_heads = 16
125
14.75
39
py
libai
libai-main/projects/MAE/configs/models/vit_huge_patch14.py
from .vit_base_patch16 import model model.patch_size = 14 model.embed_dim = 1280 model.depth = 32 model.num_heads = 16 model.drop_path_rate = 0.2
148
15.555556
35
py
libai
libai-main/projects/MAE/configs/models/mae_vit_large_patch16.py
from .mae_vit_base_patch16 import model model.embed_dim = 1024 model.depth = 24 model.num_heads = 16
103
13.857143
39
py
libai
libai-main/projects/MAE/configs/models/mae_vit_base_patch16.py
from functools import partial from libai.config import LazyCall from libai.layers import LayerNorm from modeling.mae import MaskedAutoencoderViT model = LazyCall(MaskedAutoencoderViT)( img_size=224, patch_size=16, in_chans=3, embed_dim=768, depth=12, num_heads=12, decoder_embed_dim=512, ...
476
18.875
45
py
libai
libai-main/projects/MAE/utils/lr_decay.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
3,656
32.550459
96
py
libai
libai-main/projects/MAE/utils/weight_convert.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
3,986
31.153226
95
py
libai
libai-main/projects/MAE/utils/scheduler.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
3,271
29.018349
99
py
libai
libai-main/projects/MAE/data/pretraining_imagenet.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
1,033
33.466667
74
py
libai
libai-main/projects/MAE/modeling/mae.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
14,102
35.44186
100
py
libai
libai-main/projects/MAE/modeling/pos_embed.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
2,675
33.307692
84
py
libai
libai-main/projects/MAE/modeling/cross_entropy.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
1,285
36.823529
74
py
libai
libai-main/projects/MAE/modeling/vit.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
2,860
31.885057
98
py
libai
libai-main/projects/PaLM/palm_model.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
11,389
34.154321
95
py
libai
libai-main/projects/PaLM/tools/download_demo_dataset.py
import argparse from libai.utils.file_utils import get_data_from_cache VOCAB_URL = "https://oneflow-static.oss-cn-beijing.aliyuncs.com/ci-files/dataset/libai/gpt_dataset/gpt2-vocab.json" # noqa MERGE_FILE_URL = "https://oneflow-static.oss-cn-beijing.aliyuncs.com/ci-files/dataset/libai/gpt_dataset/gpt2-merges.txt" #...
1,366
41.71875
145
py
libai
libai-main/projects/PaLM/configs/palm_pretrain.py
from libai.config import LazyCall, get_config from .models.palm_small import model from libai.evaluation import PPLEvaluator graph = get_config("common/models/graph.py").graph train = get_config("common/train.py").train optim = get_config("common/optim.py").optim data = get_config("common/data/gpt_dataset.py") datalo...
967
32.37931
73
py
libai
libai-main/projects/PaLM/configs/models/palm_small.py
from libai.config import LazyCall from projects.PaLM.palm_model import PaLM palm_cfg = dict( vocab_size=50304, dim=768, depth=12, dim_head=64, num_heads=12, ffn_mult=4, initializer_range=0.02, layernorm_eps=1e-12, amp_enabled=False, ) model = LazyCall(PaLM)(cfg=palm_cfg)
310
17.294118
41
py
libai
libai-main/projects/PaLM/configs/models/palm_8b.py
from .palm_small import model model.cfg.dim = 4096 model.cfg.depth = 32 model.cfg.dim_head = 256 model.cfg.num_heads = 16
123
16.714286
29
py
libai
libai-main/projects/PaLM/configs/models/palm_30b.py
from .palm_small import model model.cfg.dim = 6144 model.cfg.depth = 48 model.cfg.dim_head = 256 model.cfg.num_heads = 24
123
16.714286
29
py
libai
libai-main/projects/PaLM/configs/models/palm_62b.py
from .palm_small import model model.cfg.dim = 8192 model.cfg.depth = 64 model.cfg.dim_head = 256 model.cfg.num_heads = 32
123
16.714286
29
py
libai
libai-main/projects/PaLM/configs/models/palm_16b.py
from .palm_small import model model.cfg.dim = 4096 model.cfg.depth = 64 model.cfg.dim_head = 256 model.cfg.num_heads = 16
123
16.714286
29
py
libai
libai-main/projects/SimCSE/evaluator.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
1,690
32.156863
81
py
libai
libai-main/projects/SimCSE/config/config_simcse_sup.py
from omegaconf import OmegaConf from configs.common.data.bert_dataset import tokenization from configs.common.models.bert import cfg as simcse_cfg from configs.common.models.graph import graph from configs.common.optim import optim from configs.common.train import train from libai.config import LazyCall from libai.dat...
2,934
27.77451
77
py
libai
libai-main/projects/SimCSE/config/config_simcse_unsup.py
from omegaconf import OmegaConf from configs.common.data.bert_dataset import tokenization from configs.common.models.bert import cfg as simcse_cfg from configs.common.models.graph import graph from configs.common.optim import optim from configs.common.train import train from libai.config import LazyCall from libai.dat...
2,966
28.67
81
py
libai
libai-main/projects/SimCSE/dataset/dataset.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
7,829
32.896104
99
py
libai
libai-main/projects/SimCSE/utils/load_huggingface_weight.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
7,362
44.732919
99
py
libai
libai-main/projects/SimCSE/modeling/bert_for_simcse.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
1,396
40.088235
88
py
libai
libai-main/projects/SimCSE/modeling/model_utils.py
import oneflow as flow from oneflow import nn import libai def cosine_similarity(x, y, dim=-1): return flow.sum(x * y, dim=dim) / (flow.linalg.norm(x, dim=dim) * flow.linalg.norm(y, dim=dim)) class MLPLayer(nn.Module): def __init__(self, cfg): super().__init__() self.dense = libai.layers.Li...
601
25.173913
99
py
libai
libai-main/projects/SimCSE/modeling/simcse_unsup.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
3,946
37.320388
94
py
libai
libai-main/projects/SimCSE/modeling/simcse_sup.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
4,318
36.232759
94
py
libai
libai-main/projects/CLIP/clip/simple_tokenizer.py
# -------------------------------------------------------- # Borrow code from: # https://github.com/openai/CLIP/tree/main/clip/simple_tokenizer.py # -------------------------------------------------------- import gzip import html import os from functools import lru_cache import ftfy import regex as re from libai.uti...
5,324
32.074534
119
py
libai
libai-main/projects/CLIP/clip/clip.py
# -------------------------------------------------------- # Borrow code from: # https://github.com/openai/CLIP/tree/main/clip/clip.py # -------------------------------------------------------- import hashlib import os import urllib import warnings from typing import List, Union import oneflow as flow import torch fr...
7,197
34.99
168
py
libai
libai-main/projects/CLIP/clip/model.py
# -------------------------------------------------------- # Borrow code from: # https://github.com/openai/CLIP/tree/main/clip/model.py # -------------------------------------------------------- from collections import OrderedDict from typing import Dict, Tuple, Union import numpy as np import oneflow as flow import ...
25,690
34.731572
100
py
libai
libai-main/projects/CLIP/clip/__init__.py
from .clip import load, tokenize
33
16
32
py
libai
libai-main/projects/CLIP/clip/ops.py
# -------------------------------------------------------- # Reference: # https://github.com/pyflow/pyflow/blob/1.7/flow/nn/functional.py#L4041 # -------------------------------------------------------- import warnings from typing import Optional, Tuple import oneflow as flow import oneflow.nn.functional as F from on...
12,264
43.6
100
py
libai
libai-main/projects/CLIP/tests/test_multi_head_attn.py
import os import sys import unittest import numpy as np import oneflow as flow import torch from torch.nn.functional import multi_head_attention_forward as multi_head_attention_forward_torch sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))) from clip.ops import multi_head_atten...
3,149
33.23913
100
py
libai
libai-main/projects/CLIP/tests/test_clip.py
import os import sys import unittest import oneflow as flow sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))) from clip.model import CLIP, ModifiedResNet, Transformer # noqa: E402 class TestCLIP(unittest.TestCase): def test_modified_resnet(self): net = ModifiedRe...
2,094
27.69863
95
py
libai
libai-main/projects/GLM/modeling_glm.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. All rights reserved. # Copyright 2022 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...
19,130
38.202869
98
py
libai
libai-main/projects/GLM/infer_glm.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. All rights reserved. # Copyright 2022 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...
2,213
33.59375
97
py
libai
libai-main/projects/GLM/tokenizer/glm_tokenizer.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. All rights reserved. # Copyright 2022 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...
15,872
36.792857
100
py
libai
libai-main/projects/GLM/layers/position_embedding.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. All rights reserved. # Copyright 2022 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...
2,439
35.969697
87
py
libai
libai-main/projects/GLM/layers/embedding_layer.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. All rights reserved. # Copyright 2022 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...
3,541
35.895833
97
py
libai
libai-main/projects/GLM/layers/transformer_layer.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. All rights reserved. # Copyright 2022 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...
4,684
34.225564
99
py
libai
libai-main/projects/GLM/layers/attention_layer.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. All rights reserved. # Copyright 2022 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...
4,610
31.935714
91
py
libai
libai-main/projects/GLM/configs/glm_inference.py
from omegaconf import DictConfig from libai.config import LazyCall from projects.GLM.modeling_glm import GLMModel cfg = dict( num_layers=48, vocab_size=30592, hidden_size=4096, num_attention_heads=64, max_sequence_length=1024, embedding_dropout_prob=0.0, attention_dropout_prob=0.0, out...
1,514
23.435484
46
py
libai
libai-main/projects/GLM/utils/glm_loader.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
6,333
38.836478
96
py
libai
libai-main/projects/NeRF/evaluation/nerf_evaluator.py
import copy import math import os from collections import OrderedDict from datetime import datetime import cv2 import flowvision.transforms as T import imageio import numpy as np import oneflow as flow from PIL import Image from libai.evaluation.cls_evaluator import ClsEvaluator from libai.utils import distributed as...
5,641
33.613497
100
py
libai
libai-main/projects/NeRF/datasets/__init__.py
from .nerf_dataset import BlenderDataset, LLFFDataset
54
26.5
53
py
libai
libai-main/projects/NeRF/datasets/nerf_dataset.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
32,893
36.379545
99
py
libai
libai-main/projects/NeRF/configs/config_nerf_for_rendering.py
from projects.NeRF.configs.config_nerf import ( train, dataset, dataloader, graph, model, LazyCall, build_image_test_loader, ) from projects.NeRF.evaluation.nerf_evaluator import NerfVisEvaluator from libai.data.samplers import SingleRoundSampler # NOTE: Used for generating MP4 format files...
1,712
33.26
92
py
libai
libai-main/projects/NeRF/configs/config_model.py
from omegaconf import DictConfig from libai.config import LazyCall from projects.NeRF.modeling.System import NerfSystem cfg = dict( D=8, W=256, in_channels_xyz=63, in_channels_dir=27, skips=[4], N_samples=64, use_disp=False, perturb=1.0, noise_std=0.0, N_importance=128, ch...
427
16.12
52
py
libai
libai-main/projects/NeRF/configs/config_nerf.py
from omegaconf import OmegaConf import oneflow as flow import oneflow.nn as nn from libai.data.build import build_image_train_loader, build_image_test_loader from libai.config import LazyCall, get_config from libai.optim import get_default_optimizer_params from libai.scheduler.lr_scheduler import WarmupCosineAnnealin...
5,666
31.382857
98
py
libai
libai-main/projects/NeRF/optimizers/Radam.py
import math import oneflow as flow from oneflow.optim import Optimizer class RAdam(Optimizer): def __init__( self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, weight_decay=0, degenerated_to_sgd=True ): if not 0.0 <= lr: raise ValueError("Invalid learning rate: {}".format(lr)) ...
4,573
39.122807
100
py
libai
libai-main/projects/NeRF/optimizers/Ranger.py
import math import oneflow as flow from oneflow.optim import Optimizer class Ranger(Optimizer): def __init__( self, params, lr=1e-3, alpha=0.5, k=6, N_sma_threshhold=5, betas=(0.95, 0.999), eps=1e-5, weight_decay=0, ): # paramete...
5,082
34.298611
92
py
libai
libai-main/projects/NeRF/optimizers/__init__.py
from .Radam import RAdam from .Ranger import Ranger
52
16.666667
26
py
libai
libai-main/projects/NeRF/modeling/NeRF.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
5,175
34.210884
99
py
libai
libai-main/projects/NeRF/modeling/System.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
18,288
38.415948
100
py
libai
libai-main/projects/Couplets/distribute_infer.py
import os import sys dir_path = os.path.abspath(os.path.dirname(__file__)) # noqa sys.path.append(dir_path) # noqa import oneflow as flow # noqa from dataset.mask import make_sequence_mask # noqa from tokenizer.tokenizer import CoupletsTokenizer # noqa from libai.data.structures import DistTensorData # noqa fr...
3,590
31.351351
98
py
libai
libai-main/projects/Couplets/infer.py
import os import sys dir_path = os.path.abspath(os.path.dirname(__file__)) sys.path.append(dir_path) import oneflow as flow # noqa from dataset.mask import make_padding_mask, make_sequence_mask # noqa from modeling.model import Seq2Seq # noqa from tokenizer.tokenizer import CoupletsTokenizer # noqa from libai.co...
2,739
36.534247
98
py
libai
libai-main/projects/Couplets/dataset/dataset.py
import os import oneflow as flow from dataset.mask import make_padding_mask, make_sequence_mask from oneflow.utils.data import Dataset from tokenizer.tokenizer import CoupletsTokenizer from libai.data.structures import DistTensorData, Instance class CoupletsDataset(Dataset): def __init__(self, path, is_train=Tr...
2,414
37.951613
100
py
libai
libai-main/projects/Couplets/dataset/mask.py
import numpy as np def make_padding_mask(q_ids, kv_ids, pad_id): q = (np.array(q_ids) != pad_id).reshape(-1, 1) kv = (np.array(kv_ids) != pad_id).reshape(1, -1) padding_mask = (q * kv).astype(float) return padding_mask def make_sequence_mask(ids): seqlen = len(ids) sequence_mask = np.triu(np...
382
24.533333
66
py
libai
libai-main/projects/Couplets/tokenizer/tokenizer.py
import collections def load_vocab(vocab_file): vocab = collections.OrderedDict() index = 0 with open(vocab_file, "r", encoding="utf-8") as reader: while True: token = reader.readline() token = token.strip("\n") if not token: break voc...
1,361
27.978723
62
py
libai
libai-main/projects/Couplets/configs/config.py
import os import sys dir_path = os.path.abspath(os.path.dirname(__file__)) dir_path = "/".join(dir_path.split("/")[:-1]) sys.path.append(dir_path) from omegaconf import OmegaConf # noqa from dataset.dataset import CoupletsDataset # noqa from modeling.model import Seq2Seq # noqa from libai.config import get_confi...
2,244
25.104651
82
py
libai
libai-main/projects/Couplets/modeling/model.py
import oneflow as flow from oneflow import nn from libai.layers.cross_entropy import ParallelCrossEntropyLoss from libai.utils import distributed as dist from .transformer_model import TransformerModel class Seq2SeqLoss(nn.Module): def __init__(self): super().__init__() self.lm_loss = ParallelCr...
5,603
36.610738
98
py
libai
libai-main/projects/Couplets/modeling/transformer_model.py
import math import oneflow as flow from oneflow import nn from libai.config import configurable from libai.layers import ( LayerNorm, Linear, SinePositionalEmbedding, TransformerLayer, VocabEmbedding, ) from libai.models.utils import init_method_normal, scaled_init_method_normal from libai.utils i...
10,592
35.527586
95
py
libai
libai-main/projects/MT5/mt5_model.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
18,295
40.487528
97
py
libai
libai-main/projects/MT5/train_net.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
3,832
33.845455
98
py
libai
libai-main/projects/MT5/layers/logits_layer.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
1,958
35.962264
96
py
libai
libai-main/projects/MT5/layers/mask_layer.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
2,225
33.78125
91
py
libai
libai-main/projects/MT5/layers/loss_layer.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
2,691
34.421053
86
py
libai
libai-main/projects/MT5/layers/transformer_layer.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
10,004
38.082031
99
py
libai
libai-main/projects/MT5/layers/embed_layer.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
4,294
34.204918
95
py
libai
libai-main/projects/MT5/layers/attention_layer.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
13,441
37.849711
99
py
libai
libai-main/projects/MT5/layers/lm_head_layer.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
1,310
34.432432
84
py
libai
libai-main/projects/MT5/layers/mlp_layer.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
3,629
27.582677
76
py
libai
libai-main/projects/MT5/configs/mt5_base.py
from omegaconf import DictConfig from libai.config import LazyCall from projects.MT5.mt5_model import MT5Model, MT5ForPreTraining cfg = dict( vocab_size=250112, hidden_size=768, hidden_layers=12, num_attention_heads=12, head_size=64, intermediate_size=2048, hidden_dropout_prob=0.1, att...
737
22.806452
62
py
libai
libai-main/projects/MT5/configs/t5_inference.py
from .mt5_base import cfg from libai.config import LazyCall from libai.tokenizer import T5Tokenizer from projects.MT5.mt5_model import MT5Model, MT5ForPreTraining from configs.common.train import train from configs.common.data.t5_dataset import tokenization cfg.update( model_type="t5", is_encoder_decoder=True,...
1,182
24.170213
62
py
libai
libai-main/projects/MT5/configs/mt5_small.py
from omegaconf import DictConfig from libai.config import LazyCall from projects.MT5.mt5_model import MT5Model, MT5ForPreTraining cfg = dict( vocab_size=250112, hidden_size=512, hidden_layers=8, num_attention_heads=6, head_size=64, intermediate_size=1024, hidden_dropout_prob=0.1, atten...
736
22.774194
62
py
libai
libai-main/projects/MT5/configs/mt5_large.py
from omegaconf import DictConfig from libai.config import LazyCall from projects.MT5.mt5_model import MT5Model, MT5ForPreTraining cfg = dict( vocab_size=250112, hidden_size=1024, hidden_layers=24, num_attention_heads=16, head_size=64, intermediate_size=2816, hidden_dropout_prob=0.1, at...
739
22.870968
62
py
libai
libai-main/projects/MT5/configs/mt5_pretrain.py
from libai.config import LazyCall from libai.evaluation import PPLEvaluator from libai.scheduler import WarmupExponentialLR from configs.common.train import train from configs.common.data.t5_dataset import dataloader, tokenization from configs.common.models.graph import graph from configs.common.optim import optim from...
2,284
30.736111
69
py
libai
libai-main/projects/MT5/utils/mt5_loader.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
14,821
48.07947
100
py
libai
libai-main/projects/MT5/utils/mt5_metrc_printer.py
import datetime import logging import time from libai.utils.events import EventWriter, get_event_storage class MT5MetricPrinter(EventWriter): """ Print **MT5** metrics to the terminal, including iteration time, ETA, memory, all losses, and the learning rate. It also applies smoothing using a window o...
4,601
39.725664
98
py
libai
libai-main/projects/QQP/dataset/qqp_dataset.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
3,895
38.755102
95
py
libai
libai-main/projects/QQP/dataset/data_utils.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
3,632
28.778689
98
py
libai
libai-main/projects/QQP/dataset/data.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
2,374
36.698413
95
py
libai
libai-main/projects/QQP/dataset/download_qqp_data.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
1,660
38.547619
135
py
libai
libai-main/projects/QQP/tokenizer/bert_tokenization.py
# coding=utf-8 # Copyright 2018 The Google AI Language 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 # # Unless required by ...
21,129
32.862179
84
py
libai
libai-main/projects/QQP/tokenizer/tokenizer.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
5,981
30.819149
92
py
libai
libai-main/projects/QQP/configs/config_qqp.py
from omegaconf import OmegaConf from configs.common.data.bert_dataset import tokenization from configs.common.models.bert import cfg as qqp_cfg from configs.common.optim import optim from configs.common.train import train from configs.common.models.graph import graph from libai.config import LazyCall from libai.data.b...
2,277
26.119048
74
py
libai
libai-main/projects/QQP/modeling/model.py
# coding=utf-8 # Copyright 2021 The OneFlow Authors. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
2,934
35.234568
94
py