Skip to content

Commit 125b6d5

Browse files
authored
Add sweepable estimator to NER (#6965)
1 parent 48b6fbe commit 125b6d5

File tree

5 files changed

+75
-3
lines changed

5 files changed

+75
-3
lines changed

src/Microsoft.ML.AutoML/CodeGen/estimator-schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
"TextClassifcation",
7575
"SentenceSimilarity",
7676
"ObjectDetection",
77-
"QuestionAnswering"
77+
"QuestionAnswering",
78+
"NamedEntityRecognition"
7879
]
7980
},
8081
"nugetDependencies": {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"$schema": "./search-space-schema.json#",
3+
"name": "named_entity_recognition_option",
4+
"search_space": [
5+
{
6+
"name": "PredictionColumnName",
7+
"type": "string",
8+
"default": "predictedLabel"
9+
},
10+
{
11+
"name": "LabelColumnName",
12+
"type": "string",
13+
"default": "Label"
14+
},
15+
{
16+
"name": "Sentence1ColumnName",
17+
"type": "string",
18+
"default": "Sentence"
19+
},
20+
{
21+
"name": "BatchSize",
22+
"type": "integer",
23+
"default": 32
24+
},
25+
{
26+
"name": "MaxEpochs",
27+
"type": "integer",
28+
"default": 10
29+
},
30+
{
31+
"name": "Architecture",
32+
"type": "bertArchitecture",
33+
"default": "BertArchitecture.Roberta"
34+
}
35+
]
36+
}

src/Microsoft.ML.AutoML/CodeGen/search-space-schema.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@
167167
"text_classification_option",
168168
"sentence_similarity_option",
169169
"object_detection_option",
170-
"question_answering_option"
170+
"question_answering_option",
171+
"named_entity_recognition_option"
171172
]
172173
},
173174
"option_name": {
@@ -238,7 +239,8 @@
238239
"AnswerIndexStartColumnName",
239240
"predictedAnswerColumnName",
240241
"TopKAnswers",
241-
"TargetType"
242+
"TargetType",
243+
"PredictionColumnName"
242244
]
243245
},
244246
"option_type": {

src/Microsoft.ML.AutoML/CodeGen/trainer-estimators.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,13 @@
539539
"usingStatements": [ "Microsoft.ML", "Microsoft.ML.Trainers", "Microsoft.ML.TorchSharp" ],
540540
"searchOption": "question_answering_option"
541541
},
542+
{
543+
"functionName": "NamedEntityRecognition",
544+
"estimatorTypes": [ "MultiClassification" ],
545+
"nugetDependencies": [ "Microsoft.ML", "Microsoft.ML.TorchSharp" ],
546+
"usingStatements": [ "Microsoft.ML", "Microsoft.ML.Trainers", "Microsoft.ML.TorchSharp" ],
547+
"searchOption": "named_entity_recognition_option"
548+
},
542549
{
543550
"functionName": "ForecastBySsa",
544551
"estimatorTypes": [ "Forecasting" ],
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Text;
8+
using Microsoft.ML.TorchSharp;
9+
using Microsoft.ML.TorchSharp.NasBert;
10+
11+
namespace Microsoft.ML.AutoML.CodeGen
12+
{
13+
internal partial class NamedEntityRecognitionMulti
14+
{
15+
public override IEstimator<ITransformer> BuildFromOption(MLContext context, NamedEntityRecognitionOption param)
16+
{
17+
return context.MulticlassClassification.Trainers.NamedEntityRecognition(
18+
labelColumnName: param.LabelColumnName,
19+
outputColumnName: param.PredictionColumnName,
20+
sentence1ColumnName: param.Sentence1ColumnName,
21+
batchSize: param.BatchSize,
22+
maxEpochs: param.MaxEpochs,
23+
architecture: BertArchitecture.Roberta);
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)