Giter VIP home page Giter VIP logo

Comments (6)

fengzuo97 avatar fengzuo97 commented on May 18, 2024

generate函数的确有优化的空间,没有用到past,利用到past,速度还快很多

from gpt2-chinese.

Morizeyao avatar Morizeyao commented on May 18, 2024

merge了fengzuo97的PR,试试看呢?

from gpt2-chinese.

DevelMayCry-MrChen avatar DevelMayCry-MrChen commented on May 18, 2024

我想问问你们的数据集从哪里来的呢 能上传一个数据集的样本吗

from gpt2-chinese.

Morizeyao avatar Morizeyao commented on May 18, 2024

中文数据集在项目README文档中有

from gpt2-chinese.

HamQ avatar HamQ commented on May 18, 2024

要是有教程把 GPT2-ML 的1.5 中文模型 转成本项目的Pytorch格式就好了

from gpt2-chinese.

ScottishFold007 avatar ScottishFold007 commented on May 18, 2024

要是有教程把 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.