Downloads · 30 days
65
0% of all-time downloads
0x7o/keyt5-large
keyt5-large is a machine learning model from 0x7o. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
[](https://github.com/0x7o/text2keywords "Go to GitHub repo") [](https://github.com/0x7o/text2keywords) [](https://github.com/0x7o/text2keywords)
Downloads · 30 days
65
0% of all-time downloads
All-time downloads
956K
Public
Parameters
738M
5.9 GB on disk
Likes
4
Public
Click a slice to open those files.
.bin3 GB · 50%
From the Hugging Face model README
Supported languages: ru
Github - text2keywords
Pretraining Large version | Pretraining Base version
Example usage (the code returns a list with keywords. duplicates are possible):
pip install transformers sentencepiece
from itertools import groupby
import torch
from transformers import T5ForConditionalGeneration, T5Tokenizer
model_name = "0x7194633/keyt5-large" # or 0x7194633/keyt5-base
tokenizer = T5Tokenizer.from_pretrained(model_name)
model = T5ForConditionalGeneration.from_pretrained(model_name)
def generate(text, **kwargs):
inputs = tokenizer(text, return_tensors='pt')
with torch.no_grad():
hypotheses = model.generate(**inputs, num_beams=5, **kwargs)
s = tokenizer.decode(hypotheses[0], skip_special_tokens=True)
s = s.replace('; ', ';').replace(' ;', ';').lower().split(';')[:-1]
s = [el for el, _ in groupby(s)]
return s
article = """Reuters сообщил об отмене 3,6 тыс. авиарейсов из-за «омикрона» и погоды
Наибольшее число отмен авиарейсов 2 января пришлось на американские авиакомпании
SkyWest и Southwest, у каждой — более 400 отмененных рейсов. При этом среди
отмененных 2 января авиарейсов — более 2,1 тыс. рейсов в США. Также свыше 6400
рейсов были задержаны."""
print(generate(article, top_p=1.0, max_length=64))
# ['авиаперевозки', 'отмена авиарейсов', 'отмена рейсов', 'отмена авиарейсов', 'отмена рейсов', 'отмена авиарейсов']
Go to the training notebook and learn more about it: