# Fine-tune a model on translation:

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tune-a-model-on-translation%2F8443%3E%5C
**Category:** Beginners\
**Created:** [July 17, 2021, 6:33am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tune-a-model-on-translation%2F8443 "2021-07-17T06:33:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaryaAI](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/maryaai/32/14313_2.png) [@MaryaAI](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FMaryaAI)%5C
**Post date:** [July 17, 2021, 6:33am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tune-a-model-on-translation%2F8443%2F1 "2021-07-17T06:33:32Z")

</div>

when passing all along with datasets to the **Seq2SeqTrainercall** I got :  
HTTPError: 400 Client Error: Bad Request for url: [https://huggingface.co/api/repos/create](https://huggingface.co/api/repos/create) - Only regular characters and ‘-’, ‘\_’, ‘.’ accepted

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsgugger)%5C
**Post date:** [July 17, 2021, 8:07am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tune-a-model-on-translation%2F8443%2F2 "2021-07-17T08:07:32Z")

</div>

You should post relevant code when asking for help, otherwise no one can really understand what’s going on. In this instance, the problem is very likely when your define your `Seq2SeqTrainingArguments`, so please share how you defined those, or if you used your code as a script, what arguments you passed to it,

---

<div class="post-metadata">

**Author:** ![MaryaAI](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/maryaai/32/14313_2.png) [@MaryaAI](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FMaryaAI)%5C
**Post date:** [July 17, 2021, 9:17am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tune-a-model-on-translation%2F8443%2F4 "2021-07-17T09:17:58Z")

</div>

Hi sgugger, Thanks for the advice, I just tried the same code from [How to fine-tune a model on translation](https://github.com/huggingface/notebooks/blob/master/examples/translation.ipynb)

```auto
model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)

batch_size = 16

args = Seq2SeqTrainingArguments(

    "test-translation",

    evaluation_strategy = "epoch",

    learning_rate=2e-5,

    per_device_train_batch_size=batch_size,

    per_device_eval_batch_size=batch_size,

    weight_decay=0.01,

    save_total_limit=3,

    num_train_epochs=1,

    predict_with_generate=True,

    fp16=True,

    push_to_hub=True,

    push_to_hub_model_id=f"{model_checkpoint}-finetuned-{source_lang}-to-{target_lang}",

)
data_collator = DataCollatorForSeq2Seq(tokenizer, model=model)

trainer = Seq2SeqTrainer(

    model,

    args,

    train_dataset=tokenized_datasets["train"],

    eval_dataset=tokenized_datasets["validation"],

    data_collator=data_collator,

    tokenizer=tokenizer,

    compute_metrics=compute_metrics

)

```

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsgugger)%5C
**Post date:** [July 17, 2021, 2:09pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tune-a-model-on-translation%2F8443%2F5 "2021-07-17T14:09:04Z")

</div>

Once interpreted, what is the value of `f"{model_checkpoint}-finetuned-{source_lang}-to-{target_lang}"`? Apparently since there is some special character in it according to the error message.

---

<div class="post-metadata">

**Author:** ![MaryaAI](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/maryaai/32/14313_2.png) [@MaryaAI](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FMaryaAI)%5C
**Post date:** [July 17, 2021, 3:19pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tune-a-model-on-translation%2F8443%2F6 "2021-07-17T15:19:07Z")

</div>

The value is:  
Helsinki-NLP/opus-mt-en-ro-finetuned-en-to-ro

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsgugger)%5C
**Post date:** [July 17, 2021, 3:25pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tune-a-model-on-translation%2F8443%2F7 "2021-07-17T15:25:29Z")

</div>

Ah yes, the / is not going to work. You should remove it or replace it by a /. Will adapt the notebooks next week!

---

<div class="post-metadata">

**Author:** ![MaryaAI](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/maryaai/32/14313_2.png) [@MaryaAI](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FMaryaAI)%5C
**Post date:** [July 17, 2021, 3:29pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tune-a-model-on-translation%2F8443%2F8 "2021-07-17T15:29:05Z")

</div>

Thanks a lot 💐 💐 💐
