mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-08-12 21:25:53 +00:00
* Add RoBERTa for RLHF Stage 2 & 3 (test) RoBERTa for RLHF Stage 2 & 3 (still in testing) * Revert "Add RoBERTa for RLHF Stage 2 & 3 (test)" This reverts commit06741d894d
. * Add RoBERTa for RLHF stage 2 & 3 1. add roberta folder under model folder 2. add roberta option in train_reward_model.py 3. add some test in testci * add test for reward model training * Update test_ci.sh * Revert "Update test_ci.sh" This reverts commit 9c7352b81766f3177d31eeec0ec178a301df966a. * Add RoBERTa for RLHF Stage 2 & 3 (test) RoBERTa for RLHF Stage 2 & 3 (still in testing) * Revert "Add RoBERTa for RLHF Stage 2 & 3 (test)" This reverts commit06741d894d
. * Add RoBERTa for RLHF stage 2 & 3 1. add roberta folder under model folder 2. add roberta option in train_reward_model.py 3. add some test in testci * Update test_ci.sh * Revert "Update test_ci.sh" This reverts commit 9c7352b81766f3177d31eeec0ec178a301df966a. * update roberta with coati
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from typing import Optional
|
|
|
|
from transformers.models.roberta.configuration_roberta import RobertaConfig
|
|
from transformers.models.roberta.modeling_roberta import RobertaForCausalLM
|
|
|
|
from ..base import Actor
|
|
|
|
class RoBERTaActor(Actor):
|
|
"""
|
|
RoBERTa Actor model.
|
|
|
|
Args:
|
|
pretrained (str): Pretrained model name or path.
|
|
config (RoBERTaConfig): Model config.
|
|
checkpoint (bool): Enable gradient checkpointing.
|
|
lora_rank (int): Rank of the low-rank approximation.
|
|
lora_train_bias (str): LoRA bias training mode.
|
|
"""
|
|
|
|
|
|
def __init__(self,
|
|
pretrained: Optional[str] = None,
|
|
config: Optional[RobertaConfig] = None,
|
|
checkpoint: bool = False,
|
|
lora_rank: int = 0,
|
|
lora_train_bias: str = 'none') -> None:
|
|
if pretrained is not None:
|
|
model = RobertaForCausalLM.from_pretrained(pretrained)
|
|
elif config is not None:
|
|
model = RobertaForCausalLM(config)
|
|
else:
|
|
model = RobertaForCausalLM(RobertaConfig())
|
|
if checkpoint:
|
|
model.gradient_checkpointing_enable()
|
|
super().__init__(model, lora_rank, lora_train_bias)
|