Former-commit-id: 945d2c6cc73542adf9272ebd9aa332ea2c1c7361
This commit is contained in:
hiyouga
2024-06-11 15:38:38 +08:00
parent 27aece94cf
commit 820b6e7b32
3 changed files with 27 additions and 19 deletions

View File

@@ -1,6 +1,8 @@
from dataclasses import asdict, dataclass, field
from typing import Any, Dict, Literal, Optional
from typing_extensions import Self
@dataclass
class ModelArguments:
@@ -216,3 +218,13 @@ class ModelArguments:
def to_dict(self) -> Dict[str, Any]:
return asdict(self)
@classmethod
def copyfrom(cls, old_arg: Self, **kwargs) -> Self:
arg_dict = old_arg.to_dict()
arg_dict.update(**kwargs)
new_arg = cls(**arg_dict)
new_arg.compute_dtype = old_arg.compute_dtype
new_arg.device_map = old_arg.device_map
new_arg.model_max_length = old_arg.model_max_length
return new_arg