初始化项目,由ModelHub XC社区提供模型
Model: robowaifudev/megatron-gpt2-345m Source: Original Platform
This commit is contained in:
34
.gitattributes
vendored
Normal file
34
.gitattributes
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.model filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||||
|
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||||
134
README.md
Normal file
134
README.md
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
---
|
||||||
|
language:
|
||||||
|
- en
|
||||||
|
tags:
|
||||||
|
- gpt2
|
||||||
|
license: apache-2.0
|
||||||
|
widget:
|
||||||
|
- text: It was a bright cold day in April, and the clocks were striking thirteen. Winston Smith,
|
||||||
|
datasets:
|
||||||
|
- wikitext
|
||||||
|
- openwebtext
|
||||||
|
- spacemanidol/cc-stories
|
||||||
|
model-index:
|
||||||
|
- name: megatron-gpt2-345m
|
||||||
|
results:
|
||||||
|
- task:
|
||||||
|
type: text-generation
|
||||||
|
name: Text generation
|
||||||
|
dataset:
|
||||||
|
name: WikiText-103
|
||||||
|
type: wikitext
|
||||||
|
metrics:
|
||||||
|
- type: wikitext
|
||||||
|
value: 19.31
|
||||||
|
name: Perplexity
|
||||||
|
- task:
|
||||||
|
type: text-generation
|
||||||
|
name: Text generation
|
||||||
|
dataset:
|
||||||
|
name: WikiText-2
|
||||||
|
type: wikitext
|
||||||
|
metrics:
|
||||||
|
- type: wikitext
|
||||||
|
value: 17.151
|
||||||
|
name: Perplexity
|
||||||
|
- task:
|
||||||
|
type: text-generation
|
||||||
|
name: Text generation
|
||||||
|
dataset:
|
||||||
|
name: LAMBADA
|
||||||
|
type: lambada
|
||||||
|
metrics:
|
||||||
|
- type: lambada
|
||||||
|
value: 5.509
|
||||||
|
name: Perplexity
|
||||||
|
- type: lambada
|
||||||
|
value: 68.31%
|
||||||
|
name: Accuracy
|
||||||
|
---
|
||||||
|
|
||||||
|
<!---
|
||||||
|
# ##############################################################################################
|
||||||
|
#
|
||||||
|
# Copyright (c) 2021-, 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 applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# ##############################################################################################
|
||||||
|
-->
|
||||||
|
|
||||||
|
This is an archive of [nvidia/megatron-gpt2-345m](https://huggingface.co/nvidia/megatron-gpt2-345m) that contains readily available model weights (375M). Its performance on Wikitext-103 is 19.31.<sup>1</sup> In comparison, the performance of GPT2-large (1.5B) is 17.48 and GPT2-medium (762M) is 22.05.<sup>2</sup>
|
||||||
|
|
||||||
|
### References
|
||||||
|
|
||||||
|
1. Shoeybi, Mohammad, et al. Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism. arXiv, 2019, [https://doi.org/10.48550/ARXIV.1909.08053](https://doi.org/10.48550/ARXIV.1909.08053).
|
||||||
|
2. Alec Radford, et al. Language Models are Unsupervised Multitask Learners. OpenAI, 2019. [https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf](https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf).
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
[Megatron](https://arxiv.org/pdf/1909.08053.pdf) is a large, powerful transformer developed by the Applied Deep Learning Research team at NVIDIA. This particular Megatron model was trained from a generative, left-to-right transformer in the style of GPT-2. This model was trained on text sourced from Wikipedia, RealNews, OpenWebText, and CC-Stories. It contains 345 million parameters.
|
||||||
|
|
||||||
|
Find more information at [https://github.com/NVIDIA/Megatron-LM](https://github.com/NVIDIA/Megatron-LM)
|
||||||
|
|
||||||
|
# How to run Megatron GPT2 using Transformers
|
||||||
|
|
||||||
|
## Text generation
|
||||||
|
|
||||||
|
The following code shows how to use the Megatron GPT2 checkpoint and Transformers to generate text.
|
||||||
|
|
||||||
|
```python
|
||||||
|
import os
|
||||||
|
import torch
|
||||||
|
|
||||||
|
from transformers import GPT2Tokenizer, GPT2LMHeadModel
|
||||||
|
|
||||||
|
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
|
||||||
|
model = GPT2LMHeadModel.from_pretrained("robowaifudev/megatron-gpt2-345m")
|
||||||
|
|
||||||
|
if torch.cuda.is_available():
|
||||||
|
device = torch.device("cuda")
|
||||||
|
model.half()
|
||||||
|
else:
|
||||||
|
device = torch.device("cpu")
|
||||||
|
model.to(device)
|
||||||
|
model.eval()
|
||||||
|
|
||||||
|
# Generate
|
||||||
|
prompt = (
|
||||||
|
"It was a bright cold day in April, and the clocks were striking thirteen. Winston Smith,"
|
||||||
|
)
|
||||||
|
input_ids = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
||||||
|
output = model.generate(
|
||||||
|
input_ids=input_ids,
|
||||||
|
max_length=len(input_ids) + 128,
|
||||||
|
do_sample=True,
|
||||||
|
top_k=64,
|
||||||
|
top_p=0.9,
|
||||||
|
temperature=0.8,
|
||||||
|
num_return_sequences=2,
|
||||||
|
repetition_penalty=1.025
|
||||||
|
)
|
||||||
|
|
||||||
|
# Output the text
|
||||||
|
print("Prompt:", prompt)
|
||||||
|
print("*" * 3)
|
||||||
|
for i, sentence in enumerate(output):
|
||||||
|
text = tokenizer.decode(sentence, clean_up_tokenization_spaces=True)
|
||||||
|
print(f"{i}:", text)
|
||||||
|
print("*" * 3)
|
||||||
|
```
|
||||||
|
|
||||||
|
# Original code
|
||||||
|
|
||||||
|
The original Megatron code can be found here: [https://github.com/NVIDIA/Megatron-LM](https://github.com/NVIDIA/Megatron-LM).
|
||||||
82
config.json
Normal file
82
config.json
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
{
|
||||||
|
"vocab_size": 50257,
|
||||||
|
"n_positions": 1024,
|
||||||
|
"n_embd": 1024,
|
||||||
|
"n_layer": 24,
|
||||||
|
"n_head": 16,
|
||||||
|
"n_inner": 4096,
|
||||||
|
"activation_function": "gelu_new",
|
||||||
|
"resid_pdrop": 0.1,
|
||||||
|
"embd_pdrop": 0.1,
|
||||||
|
"attn_pdrop": 0.1,
|
||||||
|
"layer_norm_epsilon": 1e-05,
|
||||||
|
"initializer_range": 0.02,
|
||||||
|
"summary_type": "cls_index",
|
||||||
|
"summary_use_proj": true,
|
||||||
|
"summary_activation": null,
|
||||||
|
"summary_first_dropout": 0.1,
|
||||||
|
"summary_proj_to_labels": true,
|
||||||
|
"scale_attn_weights": true,
|
||||||
|
"use_cache": true,
|
||||||
|
"scale_attn_by_inverse_layer_idx": false,
|
||||||
|
"reorder_and_upcast_attn": false,
|
||||||
|
"bos_token_id": 50256,
|
||||||
|
"eos_token_id": 50256,
|
||||||
|
"return_dict": true,
|
||||||
|
"output_hidden_states": false,
|
||||||
|
"output_attentions": false,
|
||||||
|
"torchscript": false,
|
||||||
|
"torch_dtype": null,
|
||||||
|
"use_bfloat16": false,
|
||||||
|
"pruned_heads": {},
|
||||||
|
"tie_word_embeddings": true,
|
||||||
|
"is_encoder_decoder": false,
|
||||||
|
"is_decoder": false,
|
||||||
|
"cross_attention_hidden_size": null,
|
||||||
|
"add_cross_attention": false,
|
||||||
|
"tie_encoder_decoder": false,
|
||||||
|
"max_length": 20,
|
||||||
|
"min_length": 0,
|
||||||
|
"do_sample": false,
|
||||||
|
"early_stopping": false,
|
||||||
|
"num_beams": 1,
|
||||||
|
"num_beam_groups": 1,
|
||||||
|
"diversity_penalty": 0.0,
|
||||||
|
"temperature": 1.0,
|
||||||
|
"top_k": 50,
|
||||||
|
"top_p": 1.0,
|
||||||
|
"repetition_penalty": 1.0,
|
||||||
|
"length_penalty": 1.0,
|
||||||
|
"no_repeat_ngram_size": 0,
|
||||||
|
"encoder_no_repeat_ngram_size": 0,
|
||||||
|
"bad_words_ids": null,
|
||||||
|
"num_return_sequences": 1,
|
||||||
|
"chunk_size_feed_forward": 0,
|
||||||
|
"output_scores": false,
|
||||||
|
"return_dict_in_generate": false,
|
||||||
|
"forced_bos_token_id": null,
|
||||||
|
"forced_eos_token_id": null,
|
||||||
|
"remove_invalid_values": false,
|
||||||
|
"architectures": ["GPT2LMHeadModel"],
|
||||||
|
"finetuning_task": null,
|
||||||
|
"id2label": {
|
||||||
|
"0": "LABEL_0",
|
||||||
|
"1": "LABEL_1"
|
||||||
|
},
|
||||||
|
"label2id": {
|
||||||
|
"LABEL_0": 0,
|
||||||
|
"LABEL_1": 1
|
||||||
|
},
|
||||||
|
"tokenizer_class": null,
|
||||||
|
"prefix": null,
|
||||||
|
"pad_token_id": null,
|
||||||
|
"sep_token_id": null,
|
||||||
|
"decoder_start_token_id": null,
|
||||||
|
"task_specific_params": null,
|
||||||
|
"problem_type": null,
|
||||||
|
"_name_or_path": "",
|
||||||
|
"transformers_version": "4.15.0",
|
||||||
|
"n_ctx": 1024,
|
||||||
|
"gradient_checkpointing": false,
|
||||||
|
"model_type": "gpt2"
|
||||||
|
}
|
||||||
50001
merges.txt
Normal file
50001
merges.txt
Normal file
File diff suppressed because it is too large
Load Diff
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:4e338f7590f064836b6b72a71d909216b69dae71ea197550d813219e6068d3e2
|
||||||
|
size 734846850
|
||||||
3
pytorch_model.bin
Normal file
3
pytorch_model.bin
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:12fa6afe8f5a50cf32070b7d401a66916f549d587a22a0412e8b83c1f386a8c5
|
||||||
|
size 735011993
|
||||||
1
tokenizer.json
Normal file
1
tokenizer.json
Normal file
File diff suppressed because one or more lines are too long
1
vocab.json
Normal file
1
vocab.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user