文本摘要网页演示demo

本项目基于清华刘洋教授的课程,由蒋茂苇、姜文康完成,使用huggingface的transformers和distilbart-cnn-12-6模型进行文本摘要。通过Python-Flask实现前后端交互,用户可在网页端输入英文文本,得到摘要结果。项目支持本地Python环境运行及服务器部署。
摘要由CSDN通过智能技术生成

NLP文本摘要网页demo

开源地址:
nlp文本摘要网页演示demo

介绍
本作业来自在国科大进行教授自然语言处理的清华教授刘洋老师所布置,由成员蒋茂苇、姜文康共同完成。 :two_men_holding_hands: 
软件架构
文本摘要模型初步来自huggingface的transformers,通过API调用sshleifer/distilbart-cnn-12-6模型,[本模型开源地址(http://huggingface.co/sshleifer/distilbart-cnn-12-6),本项目模型推理代码使用Python独立完成。除了在本地IDE环境运行Python文件完成模型推理外,还可以通过模型部署(网页端实现在线模型推理),模型部署实现方式,使用html5+js+css/bootstrap框架完成搭建前端界面,使用Python-Flask框架完成后端服务,通过Python-Flask进行调用推理代码,与加载渲染前端界面,使得模型推理与用户网页衔接起来。
  • 项目框架

  • 文件介绍:Flask 的模板文件默认放在 “templates” 文件夹下, 静态资源文件放在 “static” 目录下。
    
  • Templates文件夹

  •     templates文件夹放置Html文件
    
  • Static文件夹

  • static文件夹(配置静态资源文件夹,里面一般配置网页所需的js/css文件)

  • 核心部分: nlpfc.py是我们实现模型推理的核心函数,如下图所示。

  • nlpfc.py

  • 举个例子

  • 【本项目文本摘要的Input】

The tower is 324 metres (1,063 ft) tall, about the same height
 as an 81-storey building, and the tallest structure in Paris
 Its base is square, measuring 125 metres (410 ft) on each side. 
During its construction, the Eiffel Tower surpassed the Washington
 Monument to become the tallest man-made structure in the world,
 a title it held for 41 years until the Chrysler Building in New York City
was finished in 1930. It was the first structure to reach a height of 300 metres.
 Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is
now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, 
the Eiffel Tower is the second tallest free-standing structure in France after the Millau
 Viaduct.",
})
  • 【本项目文本摘要的Output】
The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building .
 It was the first structure to reach a height of 300 metres . Excluding transmitters, 
it is the second tallest free-standing structure in France after the Millau Viaduct .
  • flask_sever.py文件是服务端文件,可通过直接在windows系统下的[cmd]终端或者Linux\Macos系统下的[Terminal]终端运行,运行指令[ python flask_sever.py ]
    -flask_sever.py运行结果
  • 通过flask自动生成的链接【http://127.0.0.1:5000/】,在游览器输入栏复制粘贴该链接,进入用户界面。
  • 用户界面
  • 通过在文本输入栏里面输入相关英文(中文摘要的版本在近期进行开源),然后点击提交按钮。结果如下:
  • 提交结果
安装教程
  1. 本项目编写在window10上编写,通过vscodeIDE进行编写,实际运行无效考虑IDE环境,有Python运行环境即可所以本项目也可以部署在服务器。
  2. pip install flask,然后根据运行提升缺什么包,安装什么包就可以了。
  3. 一些参考资料放入 文本摘要.txt 文件中,供给参考
  • 参考资料
放松时刻

1GB是一级棒的意思,工资用k来算(1k=1024),1000能多出24块钱

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值