Training a pre-trained NER model with new data
Closed this issue · 4 comments
Hi,
I was trying to re-train a custom trained NER model. But while running the function to train the loaded model, I get "null reference exception" as the dictionary, MapEntityTypeToTag (in AveragePerceptronEntityRecognizer class) is null. This dictionary seems to be only initialised when you train a fresh model. Is there any other way to load a trained model and then retrain it using new samples?
To Reproduce
Storage.Current = new DiskStorage(<Path to directory where NER model was saved during training>);
var documents = new List<IDocument>();
documents.AddRange(ReadFile(<path to file containing new data>));
var model = await AveragePerceptronEntityRecognizer.FromStoreAsync(language: language, version: version, tag: <ModelTag>);
model.Train(documents); //getting null reference exception here
await model.StoreAsync();
Additional context
I was successfully able to train a fresh model and then test it on some sample data. But while loading the trained model and re-training it with new dataset (even with the same dataset as old training dataset) causes error.
I'm interested in this issue as I am about to try and train my own NER model. If you have a sample project for training/retraining, would you be willing to share? I will try and share back and results, including doing a pull request if I can solve the retrain-related error you are reporting.
Hi @shv07,
Can you try replacing this line
var model = await AveragePerceptronEntityRecognizer.FromStoreAsync(language: language, version: version, tag: <ModelTag>);
With this:
var aper = new AveragePerceptronEntityRecognizer(language, version, tag, new string[] { "Person", "Organization", "Location" }, ignoreCase:false );
Of course replacing the entity names with the list you have.
If you could share your code/data, I could add a better example for it on the repository!
Hello everyone, I will also be interested in training a pre-trained model but there is no documentation for it.
I have tried TrainWikiNER
but it seems to break on
var pos = await AveragePerceptronTagger.FromStoreAsync(language, -1, "");
Could someone point me to some sample code where we can achieve that ?
How should we provide our custom tagget entities ?