Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Allow flan-t5 models in ParlAI with fp16 improvment (#4875)
Browse files Browse the repository at this point in the history
* allow flan t5 models

* enable fp16
  • Loading branch information
dexterju27 authored Nov 11, 2022
1 parent 122e7bd commit c4d7b08
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions parlai/agents/hugging_face/t5.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ def check_hf_version(v: Tuple[int, int]) -> bool:
def build_t5(opt: Opt) -> T5ForConditionalGeneration:
if not check_hf_version(HF_VERSION):
raise RuntimeError('Must use transformers package >= 4.3 to use t5')
torch_dtype = torch.float16 if opt['fp16'] else torch.float32
return T5ForConditionalGeneration.from_pretrained(
opt['t5_model_arch'], dropout_rate=opt['t5_dropout']
opt['t5_model_arch'], dropout_rate=opt['t5_dropout'], torch_dtype=torch_dtype
)


Expand Down Expand Up @@ -86,7 +87,18 @@ def add_cmdline_args(
'--t5-model-arch',
type=str,
default='t5-base',
choices=["t5-small", "t5-base", "t5-large", "t5-3b", "t5-11b"],
choices=[
"t5-small",
"t5-base",
"t5-large",
"t5-3b",
"t5-11b",
"google/flan-t5-small",
"google/flan-t5-base",
"google/flan-t5-large",
"google/flan-t5-xl",
"google/flan-t5-xxl",
],
)
group.add_argument(
'--t5-model-parallel',
Expand Down

0 comments on commit c4d7b08

Please sign in to comment.