fix: LLMTrainer supports lr param
This commit is contained in:
1 parent
edf3a83e3c
commit
a02401aa75
1 file changed
+2
-2
@@ -580,11 +580,11 @@ class ConversationDataset(Dataset):
|
|||||||
class LLMTrainer:
|
class LLMTrainer:
|
||||||
"""LLM训练器"""
|
"""LLM训练器"""
|
||||||
|
|
||||||
def __init__(self, model: nn.Module, device: str = 'cpu', use_amp: bool = None):
|
def __init__(self, model: nn.Module, device: str = 'cpu', lr: float = 0.0001, use_amp: bool = None):
|
||||||
self.model = model.to(device)
|
self.model = model.to(device)
|
||||||
self.device = device
|
self.device = device
|
||||||
self.criterion = nn.CrossEntropyLoss(ignore_index=0)
|
self.criterion = nn.CrossEntropyLoss(ignore_index=0)
|
||||||
self.optimizer = optim.AdamW(model.parameters(), lr=0.0001, weight_decay=0.01)
|
self.optimizer = optim.AdamW(model.parameters(), lr=lr, weight_decay=0.01)
|
||||||
self.scheduler = optim.lr_scheduler.CosineAnnealingLR(self.optimizer, T_max=100)
|
self.scheduler = optim.lr_scheduler.CosineAnnealingLR(self.optimizer, T_max=100)
|
||||||
|
|
||||||
# 混合精度训练
|
# 混合精度训练
|
||||||
|
|||||||
Reference in new issue
Block a user