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

[Question] Can not import BERT model because config lacks Task field #29

Open
1 task done
Gelassen opened this issue Aug 9, 2023 · 0 comments
Open
1 task done
Labels
question Further information is requested

Comments

@Gelassen
Copy link

Gelassen commented Aug 9, 2023

What is your question?

I need Chinese BERT-like classifier to split Chinese sentence into separate words on the mobile client. Mobile client allows to use custom models, but only in the tensorflow lite format. It is possible to convert pytorch models into tensorflow lite format, but I have to know input shape of the model.

I wrote a simple python script to do this, but faced with several issues I haven't solved yet.

How can I get shape for SequenceLabelingModel ? Seems SequenceLabelingModel is used for this babert model

What have you tried?

  1. Load model as a plain pytorch model and get its parameters:
def loadModel():
    model = torch.load("/home/gelassen/Downloads/chinese_babert-base/pytorch_model.bin")
    model_shape = list(model.parameters())[0].shape 
    print(model_shape)
    print("Model shape" + model_shape)

loadModel()
  1. Load model via Model.from_config() factory method:
def buildAdaseqModel() -> nn.Module:
    return Model.from_config("/home/gelassen/Downloads/chinese_babert-base/config.json")

Code (if necessary)

No response

What's your environment?

  • AdaSeq Version (master):
  • ModelScope Version (master):
  • PyTorch Version (default one, supplied with adaseq):
  • OS (e.g., Ubuntu 22.04):
  • Python version: Python 3.10.12
  • CUDA/cuDNN version: Driver Version: 470.199.02 CUDA Version: 11.4
  • GPU models and configuration: NVIDIA GeForce GTX 860M
  • Any other relevant information:

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Gelassen Gelassen added the question Further information is requested label Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant