# Reproducing DistilRoBERTa

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Freproducing-distilroberta%2F5217%3E%5C
**Category:** Models\
**Created:** [March 30, 2021, 7:41pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Freproducing-distilroberta%2F5217 "2021-03-30T19:41:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidHarrison](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/davidharrison/32/1445_2.png) [@DavidHarrison](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FDavidHarrison)%5C
**Post date:** [March 30, 2021, 7:41pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Freproducing-distilroberta%2F5217%2F1 "2021-03-30T19:41:54Z")

</div>

I’ve been trying to retrain DistilRoBERTa from the information given [here](https://huggingface.co/distilroberta-base) along with the example code/documentation [here](https://github.com/huggingface/transformers/tree/master/examples/research_projects/distillation).

I’m a bit unclear on the exact configuration used to train the DistilRoBERTa model. I have been assuming it uses the same configuration as the DistilBERT model with minor changes, though some things, such as the loss coefficients are still a bit ambiguous.

**Would it be possible to share the exact command/configuration to train DistilRoBERTa?**

I’ve been able to replicate DistilRoBERTa to similar evaluation MLM perplexity but there still seems to be a small but statistically significant difference, I can share the full config if it’s helpful.

Thank you!

---

<div class="post-metadata">

**Author:** ![DavidHarrison](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/davidharrison/32/1445_2.png) [@DavidHarrison](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FDavidHarrison)%5C
**Post date:** [March 30, 2021, 7:43pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Freproducing-distilroberta%2F5217%2F2 "2021-03-30T19:43:36Z")

</div>

@VictorSanh it was [mentioned](https://github.com/huggingface/transformers/issues/10974#issuecomment-810525398) that you might be the best person to ask about this.

---

<div class="post-metadata">

**Author:** ![VictorSanh](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/victorsanh/32/21405_2.png) [@VictorSanh](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FVictorSanh)%5C
**Post date:** [March 31, 2021, 2:06am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Freproducing-distilroberta%2F5217%2F3 "2021-03-31T02:06:07Z")

</div>

Hi @DavidHarrison ,  
Here’s the exact configuration I used for DistilRoBERTa:

```
{
    "force": true,
    "dump_path": "serialization_dir/distilroberta-base",
    "data_file": "data/dump_openwebtext.roberta-base.pickle",
    "student_type": "roberta",
    "student_config": "training_configs/roberta-base.json",
    "student_pretrained_weights": "serialization_dir/tf_roberta-base_0247911.pth",
    "teacher_type": "roberta",
    "teacher_name": "roberta-base",
    "temperature": 2.0,
    "alpha_ce": 5.0,
    "alpha_mlm": 2.0,
    "alpha_clm": 0.0,
    "alpha_mse": 0.0,
    "alpha_cos": 1.0,
    "mlm": true,
    "mlm_mask_prop": 0.15,
    "word_mask": 0.8,
    "word_keep": 0.1,
    "word_rand": 0.1,
    "mlm_smoothing": 0.7,
    "token_counts": "data/token_counts_openwebtext.roberta-base.pickle",
    "restrict_ce_to_mask": false,
    "freeze_pos_embs": true,
    "freeze_token_type_embds": true,
    "n_epoch": 4,
    "batch_size": 5,
    "group_by_size": true,
    "gradient_accumulation_steps": 100,
    "warmup_prop": 0.05,
    "weight_decay": 0.0,
    "learning_rate": 0.00025,
    "adam_epsilon": 1e-06,
    "max_grad_norm": 5.0,
    "initializer_range": 0.02,
    "fp16": false,
    "fp16_opt_level": "O1",
    "n_gpu": 8,
    "local_rank": 0,
    "seed": 56,
    "log_interval": 400,
    "checkpoint_interval": 20000,
    "world_size": 8,
    "n_gpu_per_node": 8,
    "global_rank": 0,
    "n_nodes": 1,
    "node_id": 0,
    "multi_gpu": true,
    "is_master": true,
    "multi_node": false
} 

```

Victor

---

<div class="post-metadata">

**Author:** ![DavidHarrison](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/davidharrison/32/1445_2.png) [@DavidHarrison](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FDavidHarrison)%5C
**Post date:** [March 31, 2021, 6:23pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Freproducing-distilroberta%2F5217%2F4 "2021-03-31T18:23:26Z")

</div>

Thank you @VictorSanh!

---

<div class="post-metadata">

**Author:** ![theyorubayesian](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/theyorubayesian/32/2855_2.png) [@theyorubayesian](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftheyorubayesian)%5C
**Post date:** [July 1, 2021, 3:56pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Freproducing-distilroberta%2F5217%2F5 "2021-07-01T15:56:41Z")

</div>

Hi @VictorSanh ,

For DistillGPT2, I know both the CLM loss and the distillation loss are used. Can you clarify whether the MSE loss is also used? Or the Cosine distance loss?

---

<div class="post-metadata">

**Author:** ![VictorSanh](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/victorsanh/32/21405_2.png) [@VictorSanh](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FVictorSanh)%5C
**Post date:** [July 2, 2021, 8:15am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Freproducing-distilroberta%2F5217%2F6 "2021-07-02T08:15:14Z")

</div>

Hey @theyorubayesian !  
Very much the same as distilroberta. we used the cosine loss, no mse loss!  
Victor
