mod allegro
This commit is contained in:
parent
33eff363bc
commit
967b10e153
|
|
@ -9,12 +9,14 @@ tokenizer = MarianTokenizer.from_pretrained(model_name)
|
||||||
# Załaduj dane (przykład dla tłumaczenia z języka rumuńskiego na angielski)
|
# Załaduj dane (przykład dla tłumaczenia z języka rumuńskiego na angielski)
|
||||||
dataset = load_dataset("wmt16", "ro-en")
|
dataset = load_dataset("wmt16", "ro-en")
|
||||||
|
|
||||||
# Przetwórz dane do formatu odpowiedniego dla modelu
|
|
||||||
def tokenize_function(examples):
|
def tokenize_function(examples):
|
||||||
# Jeśli 'translation' to lista słowników, np. [{'en': 'text1', 'ro': 'text1_translated'}, ...]
|
# Tokenizacja
|
||||||
return tokenizer([example['en'] for example in examples['translation']],
|
tokenized = tokenizer([example['en'] for example in examples['translation']],
|
||||||
[example['ro'] for example in examples['translation']],
|
[example['ro'] for example in examples['translation']],
|
||||||
truncation=True, padding='max_length', max_length=128)
|
truncation=True, padding='max_length', max_length=128)
|
||||||
|
# Ustawienie labels
|
||||||
|
tokenized['labels'] = tokenized['input_ids'].copy()
|
||||||
|
return tokenized
|
||||||
|
|
||||||
tokenized_datasets = dataset.map(tokenize_function, batched=True)
|
tokenized_datasets = dataset.map(tokenize_function, batched=True)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue