Downloads · 30 days
19
3% of all-time downloads
radi-cho/poetry-bg
poetry-bg is a text generation model from radi-cho. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
Pretrained model using causal language modeling (CLM) objective based on GPT-2. <br/ Developed by Radostin Cholakov as a part of the AzBuki.ML initiatives.
Downloads · 30 days
19
3% of all-time downloads
All-time downloads
596
Public
Repo size
4.3 GB
Likes
0
Public
Click a slice to open those files.
.bin1.4 GB · 50%
From the Hugging Face model README
Pretrained model using causal language modeling (CLM) objective based on GPT-2. <br/> Developed by Radostin Cholakov as a part of the AzBuki.ML initiatives.
>>> from transformers import AutoModel, AutoTokenizer
>>>
>>> model_id = "radi-cho/poetry-bg"
>>> tokenizer = AutoTokenizer.from_pretrained(model_id)
>>> model = AutoModel.from_pretrained(model_id, trust_remote_code=True)
>>>
>>> input_ids = tokenizer.encode(
>>> "[HED]Суетата на живота[NEL][BDY]",
>>> add_special_tokens=False,
>>> return_tensors='pt')
>>>
>>> output_ids = model.generate(
>>> input_ids,
>>> do_sample=True,
>>> max_length=250,
>>> top_p=0.98,
>>> top_k=0,
>>> pad_token_id=2,
>>> eos_token_id=50258)
>>>
>>> output = tokenizer.decode(output_ids[0])
>>>
>>> output = output.replace('[NEL]', '\n')
>>> output = output.replace('[BDY]', '\n')
>>> output = output.replace('[HED]', '')
>>> output = output.replace('[SEP]', '')
>>>
>>> print(output)
Суетата на живота
Да страдам ли?
Да страдам ли за това?
Не, не за това, че умирам...
Но само за това,
че миговете ми са рани.
Аз съм сам и търся утеха.
We introduced 3 custom tokens in the tokenizer - [NEL], [BDY], [HED]
[HED] denotes where the title of the poem begins;[BDY] denotes where the body of the poem begins;[NEL] marks the end of a verse and should be decoded as a new line;[SEP] (with id 50258) is the end of sequence token.