python js 性能_TensorFlow官方推荐的Node.js版QA,达到Python版本两倍性能

【导读】TensorFlow.js是将TensorFlow产品化的重要工具之一。本文介绍HuggingFace的开源QA项目,它基于TensorFlow.js,达到了Python版本两倍以上的性能。

TensorFlow.js是TensorFlow的Node.js版本,由于Node.js在工业界的广泛应用,TensorFlow.js成为了AI学术界与工业界之间的重要桥梁之一。近期,TensorFlow官方Twitter推荐了HuggingFace开源的项目Question Answering for Node.js,该项目基于TensorFlow.js实现,使用DistilBERT模型构建了QA系统:

5496bb97b056fe8a42d1115e08a3163d

说到HuggingFace大家应该并不陌生, 他们近期开源了许多高质量的AI项目,收到了Yann LeCun的极大赞赏:

2e760615d9f0d59564ed54440a2ff40f

Question Answering for Node.js项目的Github地址如下:

https://github.com/huggingface/node-question-answering

安装

与许多其他Node.js库一样,我们可以通过一行命令一键安装Question Answering for Node.js:

npm install question-answering

示例

该示例在本地运行模型,所以你需要先下载模型和词汇文件:

npx question-answering download

调用代码:

import { QAClient } from "question-answering";

const text = `

Super Bowl 50 was an American football game to determine the champion of the National Football League (NFL) for the 2015 season.

The American Football Conference (AFC) champion Denver Broncos defeated the National Football Conference (NFC) champion Carolina Panthers 24–10 to earn their third Super Bowl title. The game was played on February 7, 2016, at Levi's Stadium in the San Francisco Bay Area at Santa Clara, California.

As this was the 50th Super Bowl, the league emphasized the "golden anniversary" with various gold-themed initiatives, as well as temporarily suspending the tradition of naming each Super Bowl game with Roman numerals (under which the game would have been known as "Super Bowl L"), so that the logo could prominently feature the Arabic numerals 50.

`;

const question = "Who won the Super Bowl?";

const qaClient = await QAClient.fromOptions();

const answer = await qaClient.predict(question, text);

console.log(answer); // { text: 'Denver Broncos', score: 0.3 }

更多相关信息请参考项目Github首页:

https://github.com/huggingface/node-question-answering

e762251865320d69089b4ee3cfd1c4ef

专知,专业可信的人工智能知识分发,让认知协作更快更好!欢迎注册登录专知www.zhuanzhi.ai,获取5000+AI主题干货知识资料!

c0ec931d5f7d089f9d6877301cca41ea

欢迎微信扫一扫加入专知人工智能知识星球群,获取最新AI专业干货知识教程资料和与专家交流咨询!

96962d1957ddf7f7a74b59fa30e93e64

点击“阅读原文”,了解使用专知,查看获取5000+AI主题知识资料

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值