Views
No views yet
DeepPavlov/rubert-base-cased pretrained weights and
fine-tuned on the first 99% of "Rossiya Segodnya" news dataset for 2 epochs.1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
3MODEL_NAME = "dmitry-vorobiev/rubert_ria_headlines"
4
5tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
6model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME)
7
8text = "Скопируйте текст статьи / новости"
9
10encoded_batch = tokenizer.prepare_seq2seq_batch(
11 [text],
12 return_tensors="pt",
13 padding="max_length",
14 truncation=True,
15 max_length=512)
16
17output_ids = model.generate(
18 input_ids=encoded_batch["input_ids"],
19 max_length=36,
20 no_repeat_ngram_size=3,
21 num_beams=5,
22 top_k=0
23)
24
25headline = tokenizer.decode(output_ids[0],
26 skip_special_tokens=True,
27 clean_up_tokenization_spaces=False)
28print(headline)1export XLA_USE_BF16=1
2export XLA_TENSOR_ALLOCATOR_MAXSIZE=100000000
3
4python nlp_headline_rus/src/train_seq2seq.py \
5 --do_train \
6 --tie_encoder_decoder \
7 --max_source_length 512 \
8 --max_target_length 32 \
9 --val_max_target_length 48 \
10 --tpu_num_cores 8 \
11 --per_device_train_batch_size 24 \
12 --gradient_accumulation_steps 1 \
13 --learning_rate 5e-4 \
14 --adam_epsilon 1e-6 \
15 --weight_decay 1e-5 \