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
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/tagging_models/losses/focal_loss.py
import torch import torch.nn as nn import torch.nn.functional as F class FocalLoss(nn.Module): '''Multi-class Focal loss implementation''' def __init__(self, gamma=2, weight=None,ignore_index=-100): super(FocalLoss, self).__init__() self.gamma = gamma self.weight = weight self.i...
707
28.5
84
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/tagging_models/losses/__init__.py
2
0
0
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/transfo_xl_denoise/tokenization_transfo_xl_denoise.py
# coding=utf-8 # Copyright 2022 IDEA-CCNL and The HuggingFace Inc. team. 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....
2,805
32.807229
107
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/transfo_xl_denoise/generate.py
import torch import torch.nn.functional as F from fengshen.models.transfo_xl_denoise.tokenization_transfo_xl_denoise import TransfoXLDenoiseTokenizer from fengshen.models.transfo_xl_denoise.modeling_transfo_xl_denoise import TransfoXLDenoiseModel from fengshen.utils import top_k_logits, get_masks_and_position_ids def...
2,934
42.80597
117
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/transfo_xl_denoise/configuration_transfo_xl_denoise.py
# coding=utf-8 # Copyright 2022 IDEA-CCNL and The HuggingFace Inc. team. 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....
5,820
47.508333
112
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/transfo_xl_denoise/__init__.py
0
0
0
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/transfo_xl_denoise/modeling_transfo_xl_denoise.py
# coding=utf-8 # Copyright 2022 IDEA-CCNL The HuggingFace Inc. team. 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 # ...
33,182
42.094805
120
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/zen1/tokenization.py
# coding=utf-8 # This file is derived from the code at # https://github.com/huggingface/transformers/blob/master/transformers/tokenization_bert.py # # Original copyright notice: # # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the ...
18,927
42.116173
179
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/zen1/modeling.py
# coding: utf-8 # Copyright 2019 Sinovation Ventures AI Institute # # 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 app...
54,948
49.597606
171
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/zen1/ngram_utils.py
# coding: utf-8 # Copyright 2019 Sinovation Ventures AI Institute # # 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 app...
4,929
45.074766
161
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/zen1/__init__.py
from .ngram_utils import ZenNgramDict, NGRAM_DICT_NAME from .modeling import ZenConfig, ZenModel, ZenForPreTraining, ZenForTokenClassification, ZenForSequenceClassification from .tokenization import BertTokenizer, BasicTokenizer, WordpieceTokenizer version = "0.1.0" __all__ = ['ZenNgramDict', 'NGRAM_DICT_NAME', "ZenCon...
488
68.857143
120
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/zen1/configuration_zen1.py
# coding=utf-8 # Copyright 2022 IDEA-CCNL and The HuggingFace Inc. team. 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....
3,783
45.716049
91
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/tcbert/modeling_tcbert.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
13,919
36.929155
130
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/tcbert/__init__.py
0
0
0
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/albert/modeling_albert.py
# coding=utf-8 # Copyright 2018 Google AI, Google Brain 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.0 # # U...
56,887
40.706745
168
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/transfo_xl_paraphrase/generate.py
import torch import torch.nn.functional as F from fengshen.models.transfo_xl_paraphrase import TransfoXLModel from fengshen.utils import top_k_logits, get_masks_and_position_ids from transformers import T5Tokenizer def get_batch(context_tokens, mem_length, batch_size=1): tokens = context_tokens tokens = token...
3,069
42.857143
117
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/transfo_xl_paraphrase/__init__.py
from fengshen.models.transfo_xl_denoise.modeling_transfo_xl_denoise import TransfoXLDenoiseModel as TransfoXLModel from .generate import paraphrase_generate
157
51.666667
114
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/auto/tokenization_auto.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
21,569
46.933333
126
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/auto/configuration_auto.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
17,004
41.091584
141
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/auto/modeling_auto.py
# coding=utf-8 # Copyright 2018 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.0 # # Unless required by applicable...
8,518
30.205128
119
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/auto/__init__.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
2,003
34.157895
119
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/auto/auto_factory.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
35,460
53.978295
119
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/auto/dynamic.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
9,861
40.788136
119
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron_t5/configuration_megatron_t5.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
10,955
41.796875
119
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron_t5/tokenization_megatron_t5.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
1,172
34.545455
111
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron_t5/__init__.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
1,425
27.52
74
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron_t5/modeling_megatron_t5.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
90,226
42.23287
143
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/roformer/configuration_roformer.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
6,869
50.268657
119
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/roformer/tokenization_roformer.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
675
38.764706
74
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/roformer/__init__.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
1,785
29.793103
74
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/roformer/modeling_roformer.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
82,128
41.009719
213
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/layers/flash_attention.py
# Based on: https://github.com/HazyResearch/flash-attention/blob/4a6eaa9f27df6fff7ffb2c24e894938a687dd870/flash_attn/flash_attn_interface.py import torch import torch.nn as nn import torch.nn.functional as F import flash_attn_cuda def _flash_attn_forward( q, k, v, out, cu_seqlens_q, cu_seqle...
4,804
24.833333
140
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/layers/positional_embeddings.py
# Copyright (c) 2021, EleutherAI # # 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 applicable law or agreed to in writi...
7,894
44.373563
142
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/layers/fused_bias_dropout.py
# Copyright (c) 2021, EleutherAI contributors # This file is based on code by the authors denoted below and has been modified from its original version. # # 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 L...
1,871
32.428571
106
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/layers/utils.py
# Copyright (c) 2021 EleutherAI # This file is based on code by the authors denoted below and has been modified from its original version. # # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in complianc...
11,316
37.104377
139
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/layers/norms.py
# Copyright (c) 2021, EleutherAI # # 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 applicable law or agreed to in writi...
2,075
31.4375
85
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/layers/init_functions.py
# Copyright (c) 2021, EleutherAI # # 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 applicable law or agreed to in writi...
4,653
31.545455
118
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/layers/transformer.py
# Copyright (c) 2021 EleutherAI # This file is based on code by the authors denoted below and has been modified from its original version. # # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in complianc...
29,401
35.031863
159
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/layers/gmlp.py
# Copyright (c) 2021, EleutherAI # This file is based on code by the authors denoted below and has been modified from its original version. # # 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 # #...
4,997
34.197183
106
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/layers/fused_softmax.py
# Copyright (c) 2021, EleutherAI # This file is based on code by the authors denoted below and has been modified from its original version. # # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in complian...
6,992
32.946602
138
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/layers/activations.py
# Copyright (c) 2021, EleutherAI # This file is based on code by the authors denoted below and has been modified from its original version. # # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in complian...
4,034
29.338346
106
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/layers/word_embeddings.py
# Copyright (c) 2021, EleutherAI # # 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 applicable law or agreed to in writi...
8,382
37.810185
145
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/mpu/mappings.py
# Copyright (c) 2021, EleutherAI # This file is based on code by the authors denoted below and has been modified from its original version. # # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in complian...
5,182
25.854922
106
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/mpu/initialize.py
# Copyright (c) 2021, EleutherAI # This file is based on code by the authors denoted below and has been modified from its original version. # # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in complian...
10,377
33.478405
106
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/mpu/cross_entropy.py
# Copyright (c) 2021, EleutherAI # This file is based on code by the authors denoted below and has been modified from its original version. # # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in complian...
4,799
39.677966
106
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/mpu/utils.py
# Copyright (c) 2021, EleutherAI # This file is based on code by the authors denoted below and has been modified from its original version. # # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in complian...
3,041
34.788235
106
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/mpu/data.py
# Copyright (c) 2020, 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
3,886
31.123967
85
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/mpu/layers.py
# Copyright (c) 2021, EleutherAI # This file is based on code by the authors denoted below and has been modified from its original version. # # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in complian...
17,089
35.284501
154
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/mpu/random.py
# Copyright (c) 2021, EleutherAI # # 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 applicable law or agreed to in writi...
1,563
40.157895
116
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/mpu/__init__.py
# Copyright (c) 2020, 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
2,238
39.709091
84
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/fused_kernels/setup.py
from setuptools import setup, find_packages from torch.utils import cpp_extension from torch.utils.cpp_extension import BuildExtension, CUDAExtension from pathlib import Path import subprocess def _get_cuda_bare_metal_version(cuda_dir): raw_output = subprocess.check_output( [cuda_dir + "/bin/nvcc", "-V"],...
2,105
29.521739
78
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/fused_kernels/__init__.py
# Copyright (c) 2020, 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
1,534
33.111111
137
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/megatron/fused_kernels/tests/test_fused_kernels.py
import math import torch from torch.nn import LayerNorm from megatron.model.fused_softmax import FusedScaleMaskSoftmax from megatron.model.gpt2_model import gpt2_attention_mask_func def test_load_fused_kernels(): try: import scaled_masked_softmax_cuda import scaled_upper_triang_masked_softmax_cu...
9,169
29.875421
87
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/ubert/modeling_ubert.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
30,911
39.673684
160
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/ubert/__init__.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
685
37.111111
74
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/uniex/__init__.py
from .modeling_uniex import UniEXPipelines
42
42
42
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/uniex/modeling_uniex.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
96,133
46.995007
191
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/GAVAE/gans_model.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.utils.data import Dataset, DataLoader import numpy as np class MyDataset(Dataset): def __init__(self, x, y): self.x = x self.y = y self.len = self.x.size(0) def __getitem__(self, index): return self...
14,922
29.769072
115
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/GAVAE/GAVAEModel.py
# -*- encoding: utf-8 -*- ''' Copyright 2022 The International Digital Economy Academy (IDEA). CCNL team. 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.o...
2,706
38.808824
96
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/zen2/tokenization.py
# coding=utf-8 # This file is derived from the code at # https://github.com/huggingface/transformers/blob/master/transformers/tokenization_bert.py # # Original copyright notice: # # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the ...
19,799
41.950108
179
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/zen2/modeling.py
# coding: utf-8 # Copyright 2019 Sinovation Ventures AI Institute # # 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 app...
72,687
51.444444
187
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/zen2/ngram_utils.py
# coding: utf-8 # Copyright 2019 Sinovation Ventures AI Institute # # 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 app...
8,874
44.984456
142
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/zen2/configuration_zen2.py
# coding=utf-8 # Copyright 2022 IDEA-CCNL and The HuggingFace Inc. team. 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....
3,783
45.716049
91
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/zen2/__init__.py
from .configuration_zen2 import ZenConfig from .modeling import ZenForPreTraining, ZenForTokenClassification, ZenForSequenceClassification, ZenForQuestionAnswering, ZenModel, ZenForMaskedLM from .tokenization import BertTokenizer, BasicTokenizer, WordpieceTokenizer, _is_whitespace, whitespace_tokenize, convert_to_unico...
925
70.230769
174
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/llama/configuration_llama.py
# coding=utf-8 # Copyright 2022 EleutherAI and The HuggingFace Inc. team. 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...
5,106
45.427273
118
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/llama/modeling_llama.py
# coding=utf-8 # Copyright 2022 EleutherAI The HuggingFace Inc. team. 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 #...
17,756
42.736453
198
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/deepVAE/latent_connector.py
# coding=utf-8 # Copyright 2022 IDEA-CCNL The HuggingFace Inc. team. 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 # ...
18,993
45.214112
144
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/deepVAE/utils.py
# coding=utf-8 # Copyright 2022 IDEA-CCNL The HuggingFace Inc. team. 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 # ...
5,630
40.711111
116
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/deepVAE/deep_vae.py
# coding=utf-8 # Copyright 2022 IDEA-CCNL The HuggingFace Inc. team. 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 # ...
14,648
55.559846
182
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/deepVAE/configuration_della.py
# coding=utf-8 # Copyright 2022 IDEA-CCNL and The HuggingFace Inc. team. 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....
5,872
43.832061
122
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/deepVAE/__init__.py
# coding=utf-8 # Copyright 2022 IDEA-CCNL The HuggingFace Inc. team. 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 # ...
665
40.625
74
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/deberta_v2/modeling_deberta_v2.py
# 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...
66,327
39.99382
127
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/unimc/modeling_unimc.py
# coding=utf-8 # Copyright 2021 The IDEA 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 required by a...
27,338
40.360061
158
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/unimc/__init__.py
from .modeling_unimc import UniMCPipelines
42
42
42
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/PPVAE/utils.py
from torch.utils.data import Dataset class CustomDataset(Dataset): def __init__(self, data) -> None: super().__init__() self.data = data def __len__(self): return len(self.data) def __getitem__(self, index): # Get data d = self.data[index] return d class E...
1,264
32.289474
94
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/PPVAE/pluginVAE.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.utils.data import DataLoader from transformers.modeling_utils import PreTrainedModel from transformers.configuration_utils import PretrainedConfig from fengshen.models.DAVAE.DAVAEModel import DAVAEModel from fengshen.models.PPVAE.utils impor...
6,649
35.740331
120
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/PPVAE/__init__.py
# coding=utf-8 # Copyright 2022 IDEA-CCNL The HuggingFace Inc. team. 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 # ...
665
40.625
74
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/deltalm/modeling_deltalm.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import copy import math import random import torch import torch.nn as nn import torch.utils.checkpoint from torch.nn import CrossEntropyLoss from typing import List, Optional, Tuple, Union from transformers.modeling_utils import PreTrainedModel from transformers.activati...
77,342
48.834407
150
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/deltalm/configuration_deltalm.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """ deltalm model configuration""" import warnings from transformers.configuration_utils import PretrainedConfig from transformers.utils import logging logger = logging.get_logger(__name__) BART_PRETRAINED_CONFIG_ARCHIVE_MAP = { "IDEA/Deltalm": "https://huggingface.c...
3,663
33.895238
118
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/deltalm/tokenizer_deltalm.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import re import warnings from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from transformers.tokenization_utils import PreTrainedTokenizer from transformers.utils import logging SPIECE_UNDERLINE = "▁"...
14,738
44.490741
167
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/transfo_xl_reasoning/generate.py
# encoding=utf-8 from typing import List, Union import torch from torch.nn.utils.rnn import pad_sequence from transformers import T5Tokenizer from fengshen.models.transfo_xl_reasoning import TransfoXLModel from fengshen.utils import sample_sequence_batch def en_to_zh(sentence:str): en_pun = u",.!?[]()<>\"\"''" ...
3,642
29.107438
90
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/models/transfo_xl_reasoning/__init__.py
# encoding=utf-8 from fengshen.models.transfo_xl_denoise.modeling_transfo_xl_denoise import TransfoXLDenoiseModel as TransfoXLModel from .generate import deduction_generate, abduction_generate
192
63.333333
114
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/tokenizer/tokenizer.py
# coding=utf-8
15
7
14
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/tokenizer/sentencepiece/shuffle_corpus.py
import sys import os from tqdm import tqdm sys.path.append('../../') if __name__ == '__main__': from data.fs_datasets import load_dataset dataset = load_dataset('wudao_180g', num_proc=100) print('dataset loaded', flush=True) shuffle_ds = dataset['train'].shuffle(seed=42, writer_batch_size=1000) pr...
574
29.263158
78
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/transfo_xl_utils.py
# encoding=utf-8 import torch, math import torch.nn.functional as F def top_k_logits(logits, top_k=0, top_p=0.0, filter_value=-float('Inf')): # This function has been mostly taken from huggingface conversational ai code at # https://medium.com/huggingface/how-to-build-a-state-of-the-art-conversational-ai-with...
11,388
44.374502
147
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/convert_diffusers_to_original_stable_diffusion.py
# coding=utf8 # Script for converting a HF Diffusers saved pipeline to a Stable Diffusion checkpoint. # *Only* converts the UNet, VAE, and Text Encoder. # Does not convert optimizer state or any other thing. import argparse import os.path as osp import torch # =================# # UNet Conversion # # ==============...
8,919
36.79661
115
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/convert_py_to_npy.py
import argparse import torch import glob import os import numpy as np class MMapIndexDataset(): def __init__(self, datapath): self.idxfp = np.load(datapath + '.npy', mmap_mode='r') self.binfp = np.memmap(datapath + '.bin', dtype='long', mode='r') def __len__(self): return self.idxfp.s...
1,823
32.163636
100
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/utils.py
# coding=utf-8 import jieba import torch def jieba_tokenize(str): return jieba.lcut(str) _UCODE_RANGES = ( ("\u3400", "\u4db5"), # CJK Unified Ideographs Extension A, release 3.0 ("\u4e00", "\u9fa5"), # CJK Unified Ideographs, release 1.1 ("\u9fa6", "\u9fbb"), # CJK Unified Ideographs, release 4....
2,431
31.426667
86
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/make_delta.py
""" Code is modified from https://github.com/lm-sys/FastChat/blob/main/fastchat/model/make_delta.py. Make the delta weights by subtracting base weights. Usage: python3 -m make_delta --base ~/model_weights/llama-13b --target ~/model_weights/ziya-13b --delta ~/model_weights/ziya-13b-delta """ import argparse import to...
2,132
35.775862
127
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/universal_checkpoint.py
from pytorch_lightning.callbacks import ModelCheckpoint import os class UniversalCheckpoint(ModelCheckpoint): @staticmethod def add_argparse_args(parent_args): parser = parent_args.add_argument_group('universal checkpoint callback') parser.add_argument('--monitor', default='step', type=str) ...
2,013
46.952381
91
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/huggingface_spider.py
from huggingface_hub import HfApi, login, ModelFilter login() api = HfApi() fs_filter = ModelFilter(author='IDEA-CCNL') models = api.list_models(filter=fs_filter, sort='downloads', direction=-1) downloads = 0 likes = 0 for model in models: downloads += model.downloads likes += model.likes created_at = api.l...
452
33.846154
74
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/convert_tf_checkpoint_to_pytorch.py
"""Convert ALBERT checkpoint.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert # from models.transformers.modeling_albert_bright import AlbertCon...
2,736
42.444444
118
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/__init__.py
from .universal_checkpoint import UniversalCheckpoint from .utils import chinese_char_tokenize from .transfo_xl_utils import top_k_logits, sample_sequence_batch, sample_sequence, get_masks_and_position_ids __all__ = ['UniversalCheckpoint', 'chinese_char_tokenize', 'top_k_logits', 'sample_sequence_batch', 'sample_sequen...
355
70.2
148
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/apply_delta.py
""" Code is modified from https://github.com/lm-sys/FastChat/blob/main/fastchat/model/apply_delta.py Apply the delta weights on top of a base model. Usage: python3 -m fastchat.model.apply_delta --base ~/model_weights/llama-7b --target ~/model_weights/vicuna-7b --delta lmsys/vicuna-7b-delta-v1.1 """ import argparse im...
6,611
36.782857
139
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/llama_convert/fs_to_hf.py
from transformers.models.llama import LlamaForCausalLM, LlamaTokenizer, LlamaConfig from fengshen.models.megatron import mpu from fengshen.models.llama.modeling_llama import LlamaForCausalLM as FengshenLlama from fengshen.models.llama.configuration_llama import LlamaConfig as FengshenConfig import argparse import torch...
3,811
36.009709
110
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/llama_convert/convert_fs_llama_tp.py
import argparse import os import json import torch from fengshen.models.llama.configuration_llama import LlamaConfig __HF_NORM_PREFIX__ = "llama.final_layer_norm" __HF_EMBED_IN_KEY__ = "llama.embed_in.word_embeddings.weight" __HF_EMBED_OUT_KEY__ = "embed_out.final_linear.weight" __HF_LAYER_PREFIX__ = "llama.layers" _...
6,643
34.72043
92
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/llama_convert/hf_to_fs.py
from transformers.models.llama import LlamaForCausalLM, LlamaTokenizer, LlamaConfig from fengshen.models.megatron import mpu from fengshen.models.llama.modeling_llama import LlamaForCausalLM as FengshenLlama from fengshen.models.llama.configuration_llama import LlamaConfig as FengshenConfig import argparse import torch...
5,921
38.218543
109
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/llama_convert/merge_lt_mp_to_hf.py
import argparse import os import json import torch from fengshen_inner.models.llama.configuration_llama import LlamaConfig as FengshenConfig from fengshen_inner.models.llama.modeling_llama import LlamaForCausalLM as FengshenLlama from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer from fengshen_inner...
6,335
37.4
125
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/utils/llama_convert/fs_merge_weight.py
from fengshen_inner.models.llama.modeling_llama import LlamaForCausalLM as FengshenLlama from fengshen_inner.models.llama.configuration_llama import LlamaConfig as FengshenConfig from fengshen_inner.models.megatron import mpu import argparse def merge_data(module): if hasattr(module, "merge"): module.merg...
911
28.419355
89
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/data/__init__.py
# coding=utf-8
15
7
14
py