diff --git a/python/NN4K/__init__.py b/python/NN4K/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/NN4K/executor/__init__.py b/python/NN4K/executor/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/NN4K/executor/base.py b/python/NN4K/executor/base.py new file mode 100644 index 00000000..fa897ba7 --- /dev/null +++ b/python/NN4K/executor/base.py @@ -0,0 +1,54 @@ +from abc import ABC, abstractmethod + + +class ModelExecutor(ABC): + """ + 对应xflow AntLLM + """ + + @classmethod + def from_config(cls, + args='sys', + **kwargs): + pass + + def __init__(self, + backend_model, + backend_tokenizer, + init_args, + **kwargs): + self.backend_model = backend_model + self.backend_tokenizer = backend_tokenizer + self.init_args = init_args + self.kwargs = kwargs + + +class LLMExecutor(ModelExecutor): + + @abstractmethod + def sft_train(self, args=None, callbacks=None, **kwargs): + raise NotImplementedError("") + + @abstractmethod + def rl_tuning(self, args=None, callbacks=None, **kwargs): + raise NotImplementedError("") + + @abstractmethod + def batch_inference(self, args, **kwargs): + pass + + @abstractmethod + def inference(self, input, inference_args, **kwargs): + raise NotImplementedError() + + +class HfLLMExecutor(ModelExecutor): + + pass + + +class DeepKEExecutor(ModelExecutor): + + pass + + diff --git a/python/NN4K/executor/deepke/__init__.py b/python/NN4K/executor/deepke/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/NN4K/executor/hugging_face/__init__.py b/python/NN4K/executor/hugging_face/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/NN4K/invoker/__init__.py b/python/NN4K/invoker/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/NN4K/invoker/base.py b/python/NN4K/invoker/base.py new file mode 100644 index 00000000..8415fce6 --- /dev/null +++ b/python/NN4K/invoker/base.py @@ -0,0 +1,50 @@ +# coding: utf-8 +# Copyright (c) Antfin, Inc. All rights reserved. +import sys +from abc import ABC + + + +class ModelInvoker(ABC): + """ + 对应 xflow ModelHubEntry + """ + + def submit_sft(self, submit_mode='k8s'): + pass + + def submit_rl_tuning(self, submit_mode='k8s'): + pass + + def deploy(cls, args, deploy_mode='k8s'): + pass + + def inference(self, input, **kwargs): + """ + 这个是从已有的服务中获取inference + Args: + args: + **kwargs: + + Returns: + + """ + pass + + + @classmethod + def from_config(cls, args='sys'): + return cls() + + + +class OpenAI(ModelInvoker): + + def __init__(self, token): + self.token = token + pass + + def inference(self, input, **kwargs): + import requests + requests.post(url="https://api.openai.com", params={"input": input, "token": self.token}) +