Downloads · 30 days
4
1% of all-time downloads
rmihaylov/pegasus-base-qag-bg
pegasus-base-qag-bg is a machine learning model from rmihaylov. 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.
This model was pretrained on Bulgarian language. It was intorduced in this paper.
Downloads · 30 days
4
1% of all-time downloads
All-time downloads
454
Public
Repo size
1.1 GB
Likes
0
Public
Click a slice to open those files.
.bin555 MB · 100%
From the Hugging Face model README
This model was pretrained on Bulgarian language. It was intorduced in this paper.
The training data is private Bulgarian squad data.
You can use the raw model for generation of question-answer pairs related with given Bulgarian text.
Here is how to use this model in PyTorch:
>>> from transformers import PegasusForConditionalGeneration, AlbertTokenizer
>>>
>>> model_id = "rmihaylov/pegasus-base-qag-bg"
>>> model = PegasusForConditionalGeneration.from_pretrained(model_id)
>>> tokenizer = AlbertTokenizer.from_pretrained(model_id)
>>>
>>> text = """Това, че някой може да заяви на най-силен глас исканията си, не означава те да бъдат удовлетворени, заяви Костадин Ангелов.
Той допълни, че приоритетите на властите са здравето, образование и спорта, давайки знак, че се търси разхлабване на мерките в болничните заведения, връщането на учениците в класните стаи и отварянето на обектите за масов спорт.
"""
>>>
>>> inputs = tokenizer.encode_plus(
>>> text,
>>> return_tensors='pt',
>>> truncation=True,
>>> max_length=512,
>>> return_token_type_ids=False,
>>> return_attention_mask=True)
>>>
>>> outputs = model.generate(**inputs,
>>> max_length=150,
>>> top_p=0.95,
>>> top_k=20,
>>> do_sample=True,
>>> num_return_sequences=10,
>>> num_beams=1,
>>> eos_token_id=50259,
>>> decoder_start_token_id=50257,
>>> return_dict_in_generate=True,
>>> output_scores=True)
>>>
>>> for g in outputs.sequences:
>>> text_gen = tokenizer.decode(g, skip_special_tokens=False)
>>>
>>> if ('[SEP]' not in text_gen) or ('[MASK]' not in text_gen) or ('[CLS]' not in text_gen):
>>> continue
>>>
>>> question, answer = text_gen.replace('[CLS]', '').strip().split('[SEP]')
>>> answer = answer.split('[MASK]')[0].strip()
>>>
>>> if (not answer) or (answer not in text) or (len(answer) <= 1):
>>> continue
>>>
>>> print(f'{question.strip()}\n{answer.strip()}', '\n\n')
Какво трябва да се предприеме, за да се случи?
разхлабване
Какви са приоритетите на управляващите?
здравето, образование и спорта,
Какви усилия има правителството за стимулиране на раждаемостта?
разхлабване на мерките
Какъв е основният проблем, който може да реши?
образование