Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Jsonformer derive from PreTrainedModel #32

Open
fkarg opened this issue Jul 3, 2023 · 0 comments
Open

Make Jsonformer derive from PreTrainedModel #32

fkarg opened this issue Jul 3, 2023 · 0 comments

Comments

@fkarg
Copy link

fkarg commented Jul 3, 2023

As far as I understand it, this is currently not the case.

Having Jsonformer derive from PreTrainedModel would enable immediate use with e.g. pipeline and other ecosystem building blocks that require a PreTrainedModel.

It might even be possible to automatically derive directly from the (more specialized) base class loaded using from_pretrained (and automatically loading the tokenizer from the same path except specified otherwise). That way, almost no functions would need to be changed. Other ideas:

  • implement forward manually. This is probably tedious
  • automatically load all functions from the other model and set them, e.g. along the lines of
from inspect import getmembers, isfunction

    # somewhere in Jsonformer.__init__, probably
    for name, func in dict(getmembers(self.model, isfunction)):
        setattr(self, name, func)

Edit: Thinking about it some more (and understanding the PreTrainedModel interface better), it's probably not that easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant