课堂作业-文本摘要网页端的demo

NLP文本摘要网页demo

介绍
本作业来自在国科大进行教授自然语言处理的
清华教授刘洋老师所布置,由成员蒋茂苇、姜文康共同完成。 
软件架构
  • 文本摘要模型初步来自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文件夹放置Html文件
    
  • static文件夹(配置静态资源文件夹,里面一般配置网页所需的js/css文件)
    
  • 核心部分: nlpfc.py与summarization.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】
Generative 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 .
 Abstractive Output: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.
  • flask_sever.py文件是服务端文件,可通过直接在windows系统下的[cmd]终端或者Linux\Macos系统下的[Terminal]终端运行,运行指令[ python flask_sever.py ]

  • 在这里插入图片描述

  • 通过flask自动生成的链接【http://127.0.0.1:5000/】,在游览器输入栏复制粘贴该链接,进入用户界面。

  • 在这里插入图片描述

  • 通过在文本输入栏里面输入相关英文(中文摘要的版本在近期进行开源),然后点击提交按钮。结果如下:

  • 在这里插入图片描述

安装教程
  1. 本项目编写在window10与macos上编写,通过vscodeIDE进行编写,实际运行无效考虑IDE环境,有Python运行环境即可所以本项目也可以部署在服务器。
  2. pip install flask,
    pip install summa,
    然后根据运行提升缺什么包,安装什么包就可以了。
  3. 一些参考资料放入 文本摘要.txt 文件中,供给参考

关于textrank的笔记整理放在博客中了:textrank从头到尾的实现

成员名单

蒋茂苇 2021E8014782027(主要负责代码工程)
姜文康 2021E8016082019 (主要负责文献查阅整理)

参考资料

https://blog.csdn.net/weixin_43332715/article/details/121762719
整理在博客之中

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值