Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ OpenSPG核心能力模型包括:

# Cite

None

# License

[Apache License 2.0](LICENSE)
30 changes: 27 additions & 3 deletions python/nn4k/nn4k/executor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,34 @@ def execute_sft(self, args=None, callbacks=None, **kwargs):
"""
raise NotImplementedError(f"{self.__class__.__name__} does not support SFT.")

def execute_rl_tuning(self, args=None, callbacks=None, **kwargs):

class AlignExecutor(LLMExecutor):
"""An executor for X-Alignment"""

@classmethod
def from_config(cls, nn_config: Union[str, dict]) -> "NNExecutor":
return super().from_config(nn_config)

def execute_rm(self, args=None, callbacks=None, **kwargs):
"""
The entry point of SFT execution in a certain pod.
Execute reward model(rm) training.
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support execute_rm yet."
)

def execute_dpo(self, args=None, callbacks=None, **kwargs):
"""
Execute DPO training.
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support execute_dpo yet."
)

def execute_ppo(self, args=None, callbacks=None, **kwargs):
"""
Execute PPO training.
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support RL-Tuning."
f"{self.__class__.__name__} does not support execute_ppo yet."
)
44 changes: 36 additions & 8 deletions python/nn4k/nn4k/invoker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


class SubmitMode(Enum):
Local = "local"
K8s = "k8s"
Docker = "docker"

Expand Down Expand Up @@ -138,14 +139,6 @@ def submit_sft(self, submit_mode: SubmitMode = SubmitMode.K8s):
"""
raise NotImplementedError(f"{self.__class__.__name__} does not support SFT.")

def submit_rl_tuning(self, submit_mode: SubmitMode = SubmitMode.K8s):
"""
Submit remote RL-Tuning execution.
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support RL-Tuning."
)

def local_inference(self, data, **kwargs):
"""
Implement local inference for local invoker.
Expand Down Expand Up @@ -184,3 +177,38 @@ def from_config(cls, nn_config: dict) -> "LLMInvoker":
"""
invoker = cls(nn_config)
return invoker


class AlignInvoker(NNInvoker):
"""A invoker for X-Alignment tuning"""
@classmethod
def from_config(cls, nn_config: Union[str, dict]) -> "NNInvoker":
"""
Create an instance from `nn_config`.
"""
invoker = cls(nn_config)
return invoker

def submit_rm(self, submit_mode: SubmitMode = SubmitMode.K8s):
"""
Submit remote tuning execution for reward model(rm).
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support submit_rm yet."
)

def submit_dpo(self, submit_mode: SubmitMode = SubmitMode.K8s):
"""
Submit remote execution for DPO.
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support submit_dpo yet."
)

def submit_ppo(self, submit_mode: SubmitMode = SubmitMode.K8s):
"""
Submit remote execution for PPO.
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not support submit_ppo yet."
)
Loading