-
-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
44 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
""" | ||
Plugin init to add KD support to Axolotl. | ||
""" | ||
from axolotl.integrations.base import BasePlugin | ||
|
||
from .args import KDArgs # pylint: disable=unused-import. # noqa: F401 | ||
|
||
|
||
class KDPlugin(BasePlugin): | ||
""" | ||
Plugin for KD support in Axolotl. | ||
""" | ||
|
||
def get_input_args(self): | ||
return "axolotl.integrations.kd.KDArgs" | ||
|
||
def get_trainer_cls(self, cfg): | ||
if cfg.kd_trainer: | ||
from .trainer import AxolotlKDTrainer | ||
|
||
return AxolotlKDTrainer | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
Plugin args for KD support. | ||
""" | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class KDArgs(BaseModel): | ||
""" | ||
Input args for knowledge distillation. | ||
""" | ||
|
||
kd_trainer: Optional[bool] = None # whether to use KD trainer | ||
kd_ce_alpha: Optional[ | ||
float | ||
] = None # loss coefficient for cross-entropy loss during KD | ||
kd_alpha: Optional[float] = None # loss coefficient for KD loss | ||
kd_temperature: Optional[float] = None # temperature for sampling during KD |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters