transformer,nlp,gpt2,打卡第二次

from transformers import pipeline, set_seed
from transformers import Conversation
import time

tic=time.time()
conversational_pipeline = pipeline("conversational")
que_list=["Going to the movies tonight - any suggestions?","What's the last book you have read?","What's your name?","What the hell is going on in America?","Do you think Trump is a good president?"]
conv=[]
for i in range(len(que_list)):
    conv.append(Conversation(que_list[i]))
conversational_pipeline(conv)
toc=time.time()
t=toc-tic

我们输入了五条语句,发现和只有一条语句的用时都是32s左右,说明处理生成是比较快的,但是在请求这个函数的时候比较耗时。
还有就是conversational_pipeline(conv)这个函数会把生成的语句返回给conv自己。
结果是这样的

[Conversation id: 04ba410e-5972-4d72-baea-47755802920d 
user >> Going to the movies tonight - any suggestions? 
bot >> The Big Lebowski 
, Conversation id: b11ad338-d37a-4ae7-93e8-6ebcfb0e6f61 
user >> What's the last book you have read? 
bot >> The Last Question 
, Conversation id: e92a8c91-871c-4d90-9fdb-07362e8e6b15 
user >> What's your name? 
bot >> I'm not sure, but I think it's a reference to the movie The Big Lebowski. 
, Conversation id: 319711a7-953e-45b5-8e0f-a7b2050bfac6 
user >> What the hell is going on in America? 
bot >> The same thing that's going on in Europe. 
, Conversation id: 68a39529-867e-45ec-9671-8566d9fd0da6 
user >> Do you think Trump is a good president? 
bot >> I think he's a great president. 
]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

朝不闻道,夕不可死

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值