simpleT5 库 | 根据英文摘要内容生成标题
simpleT5 是基于 PyTorch 实现的 T5 模型库,旨在为用户提供一种简单、易用、可定制的 T5 模型工具。T5(Text-to-Text Transfer Transformer)是一种基于 Transformer 架构的自然语言处理模型,由 Google Brain 团队开发。T5 模型采用了 encoder-decoder 架构,其中 encoder 将输入文本编码为向量,decoder 则从该向量生成目标文本。
simpleT5 的设计目标是尽可能地减少 T5 模型的使用门槛,以方便用户在自然语言处理任务中快速应用 T5 模型,从而节省大量的模型开发时间和成本。
simpleT5 提供了一个简单的 API 接口,用户只需要提供输入文本和模型参数,即可轻松地使用 T5 模型进行文本转换任务,如文本摘要、机器翻译、对话系统等。simpleT5 还提供了一些预训练模型,包括 T5-small、T5-base 和 T5-large 等不同规模的模型,用户可以根据任务需求选择合适的模型。
除此之外,simpleT5 还提供了一些有用的工具和功能,如文本预处理、数据集加载、训练日志记录等,以帮助用户更轻松地进行模型训练和调试。simpleT5 的开发者们还提供了详细的文档和示例代码,以帮助用户更快地上手使用该库。
总之,simpleT5 为用户提供了一种快速、方便、可定制的 T5 模型工具,可以帮助用户在自然语言处理任务中更加高效地应用 T5 模型,节省大量的开发时间和成本。
今天以huggingface中公开的模型 snrspeaks/t5-one-line-summary为例, 展示 「根据传入的摘要内容生成对应的标题」。
安装
!pip3 install --upgrade simplet5
快速上手
# pip install --upgrade simplet5
from simplet5 import SimpleT5
model = SimpleT5()
model.load_model("t5","snrspeaks/t5-one-line-summary")
Run
Global seed set to 42
Downloading: 100%| | 0.00/1.36k [00:00<?, ?B/s]
Downloading: 100%| | 0.00/850M [00:00<?, ?B/s]
Downloading: 100%| | 0.00/1.84k [00:00<?, ?B/s]
Downloading: 100%| | 0.00/773k [00:00<?, ?B/s]
Downloading: 100%| | 0.00/1.32M [00:00<?, ?B/s]
Downloading: 100%| | 0.00/1.74k [00:00<?, ?B/s]
根据英文摘要生成标题
abstract = """We describe a system called Overton, whose main design goal is to support engineers in building, monitoring, and improving production
machine learning systems. Key challenges engineers face are monitoring fine-grained quality, diagnosing errors in sophisticated applications, and
handling contradictory or incomplete supervision data. Overton automates the life cycle of model construction, deployment, and monitoring by providing a
set of novel high-level, declarative abstractions. Overton's vision is to shift developers to these higher-level tasks instead of lower-level machine learning tasks.
In fact, using Overton, engineers can build deep-learning-based applications without writing any code in frameworks like TensorFlow. For over a year,
Overton has been used in production to support multiple applications in both near-real-time applications and back-of-house processing. In that time,
Overton-based applications have answered billions of queries in multiple languages and processed trillions of records reducing errors 1.7-2.9 times versus production systems.
"""
model.predict(abstract)
Run
['Overton: Building, Deploying, and Monitoring Deep Machine Learning Systems']
根据摘要生成多个标题
abstract = """We describe a system called Overton, whose main design goal is to support engineers in building, monitoring, and improving production
machine learning systems. Key challenges engineers face are monitoring fine-grained quality, diagnosing errors in sophisticated applications, and
handling contradictory or incomplete supervision data. Overton automates the life cycle of model construction, deployment, and monitoring by providing a
set of novel high-level, declarative abstractions. Overton's vision is to shift developers to these higher-level tasks instead of lower-level machine learning tasks.
In fact, using Overton, engineers can build deep-learning-based applications without writing any code in frameworks like TensorFlow. For over a year,
Overton has been used in production to support multiple applications in both near-real-time applications and back-of-house processing. In that time,
Overton-based applications have answered billions of queries in multiple languages and processed trillions of records reducing errors 1.7-2.9 times versus production systems.
"""
#根据摘要生成5个标题
n = 5
model.predict(abstract,
num_return_sequences=n,
num_beams=n+1)
Run
['Overton: Building, Deploying, and Monitoring Deep Machine Learning Systems',
'Overton: Building, Deployment, and Improving Production Machine Learning Systems',
'Overton: Building, Deploying, and Monitoring Machine Learning Systems for Engineers',
'Overton: Building, Deploying, and Monitoring Machine Learning Systems',
'Overton: Building, Deployment, and Monitoring Deep Machine Learning Systems']
更多模型
精选文章
管理世界 | 用正则表达式、文本向量化、线性回归算法从md&a数据中计算 「企业融资约束指标」
FinBERT | 金融文本BERT模型,可情感分析、识别ESG和FLS类型
JM2022综述 | 黄金领域: 为营销研究(新洞察)采集网络数据