-
Notifications
You must be signed in to change notification settings - Fork 203
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
Help with NER usage #8
Comments
Hello, This library has been designed to offer compatibility with the Pytorch models that are trained from the Huggingface's Transformers library (https://github.com/huggingface/transformers). These models include the official Huggingface pretrained and finetuned models (https://huggingface.co/transformers/pretrained_models.html) and the community models (https://huggingface.co/models) They require the following:
In order to use this Rust implementation there are 3 alternatives:
For the 3rd option, the name of the parameters is assumes the same conventions as the models from the Python Transformers library. In order to load weights from a different definition, additional pre-processing steps will be required. These include:
I hope this helps, |
Hello! Thank you for such descriptive answer. I need NER for russian language, so can't use base models from Huggingface.
The pytorch version contains exactly the same files, needed for this crate. I converted it with modified Now NER example fails with:
I think the problem is with wrong label ids and count. Thank you. |
I dumped some values from
So
And it tries to get So I looked at
Maybe some of these keys are exactly |
Hello, I believe the Pytorch model you are trying to use for NER does not contain the set of weights required for the task. The The NER models seem to be stored in another page: http://docs.deeppavlov.ai/en/master/features/models/ner.html. I have tried downloading the model, but could not find a Pytorch version. However, I validated that the Deeppavlov models would be compatible with this Rust implementation. If you run replace the conversion script with the following section : weights = torch.load('path/to/rubert_cased_L-12_H-768_A-12_pt/pytorch_model.bin')
nps = {}
for k, v in weights.items():
nps[k.replace('cls.seq_relationship', 'classifier')] = np.ascontiguousarray(v.cpu().numpy())
np.savez(target_path / 'model.npz', **nps) And add the following to the "num_labels": 2,
"label2id": {
"O": 0,
"B-MISC": 1
},
"id2label": {
"0": "O",
"1": "B-MISC"
} You should be able to run the model. However, as this is not the correct last layer for NER, this will run but not yield any useful result. If you can find a Pytorch version of the NER model, or successfully convert the Tensorflow weights to Pytorch - I'd be glad to help further. Thank you, |
Hello, The Deeppavlov team has uploaded models in the Huggingface repository: https://huggingface.co/DeepPavlov. As far as I could see, this does not include a NER model yet. I will close this issue for now. Please re-open when you have found a NER model to use and need support for loading the weights. Thank you |
Hello, I have this learned model:
https://github.com/deepmipt/DeepPavlov/blob/0.8.0/deeppavlov/configs/ner/ner_ontonotes_bert_mult.json
In downloads section it mentions two items: BERT model and NER. Is it possible to use NER model with this crate? It requires vocab.txt, but list of files is:
The text was updated successfully, but these errors were encountered: