Downloads · 30 days
94
6% of all-time downloads
ai-forever/charllama-2.6B
charllama-2.6B is a machine learning model from ai-forever. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This repository contains a pre-trained language model based on the Llama architecture, utilizing character-level tokenization. The model was developed for experiments in generating Russian-language accentual-syllabic…
Downloads · 30 days
94
6% of all-time downloads
All-time downloads
1.5K
Public
Repo size
21.1 GB
Likes
7
Public
Click a slice to open those files.
.bin10.6 GB · 100%
From the Hugging Face model README
This repository contains a pre-trained language model based on the Llama architecture, utilizing character-level tokenization. The model was developed for experiments in generating Russian-language accentual-syllabic poetry, as described in our paper: "Generation of Russian Poetry of Different Genres and Styles Using Neural Networks with Character-Level Tokenization". Note that for practical applications, fine-tuning on a specific dataset is recommended.
2,641,199,664The model was pretrained on a mixed dataset of approximately 100GB of Russian and English texts, with a focus on Russian-language content. The dataset includes diverse domains such as fiction and poetry across various genres and styles. All texts were accentuated.
The model employs character-by-character tokenization. To use the tokenizer, install it via:
pip install git+https://github.com/Koziev/character-tokenizer
The tokenizer includes special tokens <s> and </s>.
To use the model with the transformers library, follow this example:
import torch
import transformers
import charactertokenizer
generation_args = {'max_length': 1024,
'num_return_sequences': 1,
'do_sample': True,
'no_repeat_ngram_size': 10,
'temperature': 0.8,
'top_p': 0.6,
'top_k': 0,
}
device = "cuda:0"
model_dir = 'ai-forever/charllama-2.6B'
tokenizer = charactertokenizer.CharacterTokenizer.from_pretrained(model_dir)
model = transformers.AutoModelForCausalLM.from_pretrained(model_dir)
model.to(device)
# Poetry completion
prompt = chr(8) + 'У бу́рных чу́вств неи́стовый коне́ц'
input_ids = tokenizer(prompt, return_tensors='pt').input_ids
out_ids = model.generate(input_ids=input_ids.to(device),
eos_token_id=tokenizer.eos_token_id,
**generation_args).tolist()
prompt_len = len(input_ids[0])
for seq in out_ids:
seq = seq[1:]
output = tokenizer.decode(seq)
if '</s>' in output:
output = output[:output.find('</s>')].strip()
text = output
print('-'*80)
print(text)
Example output (may vary):
У бу́рных чу́вств неи́стовый коне́ц,
И в э́том не́т ни ка́пельки сомне́нья.
Прихо́дит сро́к, и го́рестный вене́ц
Наде́нет на себя́ душа́ смире́нно.
И не помо́гут в э́том Небеса́,
И не поми́лует Судьба́ - подру́га.
И бу́дет на душе́ твое́й тоска́,
И ста́нет в жи́зни нестерпи́мо ту́го.
The model may generate inappropriate content, including hate speech, offensive language, or biased outputs reflecting the training data. Use with caution and consider post-processing or filtering mechanisms.
If you use this model in your research, please cite it as follows (citation details will be available soon):
citation information will be available soon