dotnet / dotnet/machinelearning-modelbuilder

Named Entity Recognition: Generated code to retrain is not working

Open
#2,877 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dockerfile
Stars
285
Forks
66
PR merge metrics
No merged PRs in 30d

Description

**System Information (please complete the following information):**
- Model Builder Version (available in Manage Extensions dialog): 17.18.2.2415501
- Visual Studio Version: 17.9.2

Train function generated by Builder is not working for "Named Entity Recognition" and cause exception:

> System.ArgumentOutOfRangeException: 'Cannot map column (name: Label, type: Key) in data to the user-defined type, Microsoft.ML.Data.VBuffer`1[System.UInt32]. Arg_ParamName_Name'

Using builder, a was able to generate Named Entity Recognition mlnet model. Builder generated *.training.cs file with "Train" function:
```
///
/// Train a new model with the provided dataset.
///
/// File path for saving the model. Should be similar to "C:\YourPath\ModelName.mlnet"
/// Path to the data file for training.
/// Separator character for delimited training file.
/// Boolean if training file has a header.
public static void Train(string outputModelPath, string inputDataFilePath = RetrainFilePath, char separatorChar = RetrainSeparatorChar, bool hasHeader = RetrainHasHeader, bool allowQuoting = RetrainAllowQuoting)
{
var mlContext = new MLContext();
var data = LoadIDataViewFromFile(mlContext, inputDataFilePath, separatorChar, hasHeader, true);
var model = RetrainModel(mlContext, data);
SaveModel(mlContext, model, data, outputModelPath);
}
```
Trying to use this function cause an exception on:
```
///
/// Retrain model using the pipeline generated as part of the training process.
///
///
///
///
public static ITransformer RetrainModel(MLContext mlContext, IDataView trainData)
{
var pipeline = BuildPipeline(mlContext);
var model = pipeline.Fit(trainData); // <-HERE AN EXCEPTION IS THROWN

return model;
}
```

> System.ArgumentOutOfRangeException: 'Cannot map column (name: Label, type: Key) in data to the user-defined type, Microsoft.ML.Data.VBuffer`1[System.UInt32]. Arg_ParamName_Name'

Here is the example dataset i made for the sake of this post but every data set i have tried is not working:
[test data example.txt](https://github.com/dotnet/machinelearning-modelbuilder/files/14549394/test.data.example.txt)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.