Coder Social home page Coder Social logo

t5-pegasus-pytorch's Introduction

t5-pegasus pytorch

追一科技开源的t5-pegasus的pytorch版本

下载

how to use

pytorch1.7.0 + transformers4.3.3

from tokenizer import T5PegasusTokenizer
from transformers.models.mt5.modeling_mt5 import MT5ForConditionalGeneration

model_path = './'
model = MT5ForConditionalGeneration.from_pretrained(model_path)
tokenizer = T5PegasusTokenizer.from_pretrained(model_path)
text = '蓝蓝的天上有一朵白白的云'
ids = tokenizer.encode(text, return_tensors='pt')
output = model.generate(ids,
                            decoder_start_token_id=tokenizer.cls_token_id,
                            eos_token_id=tokenizer.sep_token_id,
                            max_length=30).numpy()[0]
print(''.join(tokenizer.decode(output[1:])).replace(' ', ''))

huggingface model hub

模型名 MODEL_NAME
t5-pegasus-base imxly/t5-pegasus
t5-pegasus-small imxly/t5-pegasus-small

对比bert4keras的原版

python test.py

输出

原文:蓝蓝的天上有一朵白白的云
bert4keras预测蓝蓝的天上有一朵白白的云是蓝蓝的天上有一朵白白的云创作的网络小说发表于
torch预测蓝蓝的天上有一朵白白的云是蓝蓝的天上有一朵白白的云创作的网络小说发表于

t5-pegasus-pytorch's People

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.