Comments (6)
generate函数的确有优化的空间,没有用到past,利用到past,速度还快很多
from gpt2-chinese.
merge了fengzuo97的PR,试试看呢?
from gpt2-chinese.
我想问问你们的数据集从哪里来的呢 能上传一个数据集的样本吗
from gpt2-chinese.
中文数据集在项目README文档中有
from gpt2-chinese.
要是有教程把 GPT2-ML 的1.5 中文模型 转成本项目的Pytorch格式就好了
from gpt2-chinese.
要是有教程把 GPT2-ML 的1.5 中文模型 转成本项目的Pytorch格式就好了
我试过,里面缺个东西,目前转不了,不信你可以试试下面的代码:
"""Convert OpenAI GPT checkpoint."""
import argparse
import logging
import torch
from transformers import CONFIG_NAME, WEIGHTS_NAME, GPT2Config, GPT2Model, load_tf_weights_in_gpt2
logging.basicConfig(level=logging.INFO)
def convert_gpt2_checkpoint_to_pytorch(gpt2_checkpoint_path, gpt2_config_file, pytorch_dump_folder_path):
# Construct model
if gpt2_config_file == "":
config = GPT2Config()
else:
config = GPT2Config.from_json_file(gpt2_config_file)
model = GPT2Model(config)
# Load weights from numpy
load_tf_weights_in_gpt2(model, config, gpt2_checkpoint_path)
# Save pytorch-model
pytorch_weights_dump_path = pytorch_dump_folder_path + "/" + WEIGHTS_NAME
pytorch_config_dump_path = pytorch_dump_folder_path + "/" + CONFIG_NAME
print("Save PyTorch model to {}".format(pytorch_weights_dump_path))
torch.save(model.state_dict(), pytorch_weights_dump_path)
print("Save configuration file to {}".format(pytorch_config_dump_path))
with open(pytorch_config_dump_path, "w", encoding="utf-8") as f:
f.write(config.to_json_string())
if name == "main":
parser = argparse.ArgumentParser()
# Required parameters
parser.add_argument(
"--gpt2_checkpoint_path", default=r'C:\Users\gaochangkuan\Desktop\2020.02.01 Chinese_news_generation_gpt2-ml-Chinse\chinese_model', type=str, help="Path to the TensorFlow checkpoint path."
)
parser.add_argument(
"--pytorch_dump_folder_path", default=r'C:\Users\gaochangkuan\Desktop\2020.02.01 Chinese_news_generation_gpt2-ml-Chinse\chinese_model', type=str, help="Path to the output PyTorch model."
)
parser.add_argument(
"--gpt2_config_file",
default="",
type=str,
help="An optional config json file corresponding to the pre-trained OpenAI model. \n"
"This specifies the model architecture.",
)
args = parser.parse_args([])
convert_gpt2_checkpoint_to_pytorch(args.gpt2_checkpoint_path, args.gpt2_config_file, args.pytorch_dump_folder_path)
`
from gpt2-chinese.
Related Issues (20)
- 小说的模型开放了吗?
- 我的语料文本很多,能不能分开多个train.json HOT 3
- 能不能用gpt3再创造个中文ai,gpt3比gpt2好很多
- 语料库700M,一跑就报This script is extremely slow,请教700M语料大约需要多大的配置
- Mark
- Mark
- GPU9GB能跑起来吗请问
- 是否支持多机多卡分布式训练? HOT 2
- 如何修改訓練結構?
- finetune需要的语料量+output上限 HOT 2
- 求助 HOT 2
- 请问如何实现问答任务 HOT 2
- 语料预处理
- 下载的对联模型使用时为什么生成的是乱码? HOT 1
- 你好,很期待和您沟通,请查收gmail 邮件。
- 请问GPT2-Chinese 参数量有多大呀,跟原版gpt2参数量一样吗?
- BertTokenizer的__init__报NotImplementedError HOT 3
- Using bos_token, but it is not set yet. Using eos_token, but it is not set yet. HOT 1
- train. py encountered an error during runtime. Value Error: invalid literal for int() with base 10: '[SEP]' How to solve it? HOT 1
- 求助求助 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gpt2-chinese.