Skip to content

Commit

Permalink
Add RoBERTa to the model suite (#2279)
Browse files Browse the repository at this point in the history
Summary:
https://huggingface.co/FacebookAI/xlm-roberta-base

Pull Request resolved: #2279

Reviewed By: aaronenyeshi

Differential Revision: D59490274

Pulled By: xuzhao9

fbshipit-source-id: 1720f09e04603fc07c1825c2fb2f9062cda50701
  • Loading branch information
Rohanjames1997 authored and facebook-github-bot committed Jul 8, 2024
1 parent ff1b8eb commit afdc319
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions torchbenchmark/models/hf_Roberta_base/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from torchbenchmark.tasks import NLP
from torchbenchmark.util.framework.huggingface.model_factory import HuggingFaceModel

class Model(HuggingFaceModel):
task = NLP.LANGUAGE_MODELING
DEFAULT_TRAIN_BSIZE = 4
DEFAULT_EVAL_BSIZE = 1

def __init__(self, test, device, batch_size=None, extra_args=[]):
super().__init__(name="hf_Roberta_base", test=test, device=device, batch_size=batch_size, extra_args=extra_args)
14 changes: 14 additions & 0 deletions torchbenchmark/models/hf_Roberta_base/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])

if __name__ == '__main__':
pip_install_requirements()
patch_transformers()
model_name = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
cache_model(model_name)
8 changes: 8 additions & 0 deletions torchbenchmark/models/hf_Roberta_base/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
devices:
NVIDIA A100-SXM4-40GB:
eval_batch_size: 8
eval_benchmark: false
eval_deterministic: false
eval_nograd: true
train_benchmark: false
train_deterministic: false
2 changes: 2 additions & 0 deletions torchbenchmark/models/hf_Roberta_base/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sentencepiece
datasets
6 changes: 6 additions & 0 deletions torchbenchmark/util/framework/huggingface/basic_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
"AutoModelForMaskedLM",
),
"hf_Bert": (512, 512, "BertConfig()", "AutoModelForMaskedLM"),
"hf_Roberta_base": (
512,
512,
'AutoConfig.from_pretrained("xlm-roberta-base")',
"AutoModelForMaskedLM",
),
# see https://huggingface.co/bert-large-cased
"hf_Bert_large": (
512,
Expand Down

0 comments on commit afdc319

Please sign in to comment.