dotnet / dotnet/machinelearning-modelbuilder

Consider improving understandability of Exceptions (consumption)

Open
#1,610 4 comments 0 reactions 0 assignees View on GitHub
Reported by: Customer Stale
Dominant language
Dockerfile
Stars
285
Forks
66
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
Consuming models may raise exceptions which may be difficult to understand and pinpoint the issue.

For example, my case I reveice "Index was outside the bounds of the array." an then "Destination is too short"

In StackTrace I can see it it related ngrams, and thus, probably string values in my data. In this case, I was not able to find the reason yet even if exception happens regularly in some cases. It might be related to calling the model from multiple threads.

```
at Microsoft.ML.Data.NgramBufferBuilder.AddNgrams(VBuffer`1& src, Int32 icol, UInt32 keyMax)
at Microsoft.ML.Transforms.Text.NgramExtractingTransformer.Mapper.<>c__DisplayClass11_0.b__2(VBuffer`1& dst)
at Microsoft.ML.Transforms.LpNormNormalizingTransformer.Mapper.<>c__DisplayClass8_0.b__5(VBuffer`1& dst)
at Microsoft.ML.Data.ColumnConcatenatingTransformer.Mapper.BoundColumn.<>c__DisplayClass20_0`1.b__0(VBuffer`1& dst)
at Microsoft.ML.Data.ColumnConcatenatingTransformer.Mapper.BoundColumn.<>c__DisplayClass20_0`1.b__0(VBuffer`1& dst)
at Microsoft.ML.Data.SchemaBindablePredictorWrapperBase.<>c__DisplayClass19_0`2.b__0(TDst& dst)
at Microsoft.ML.Data.PredictedLabelScorerBase.EnsureCachedPosition[TScore](Int64& cachedPosition, TScore& score, DataViewRow boundRow, ValueGetter`1 scoreGetter)
at Microsoft.ML.Data.MulticlassClassificationScorer.<>c__DisplayClass16_0.b__0(UInt32& dst)
at Microsoft.ML.Transforms.KeyToValueMappingTransformer.Mapper.KeyToValueMap`2.<>c__DisplayClass8_0.b__0(TValue& dst)
at Microsoft.ML.Data.TypedCursorable`1.TypedRowBase.<>c__DisplayClass9_0`2.b__0(TRow row)
at Microsoft.ML.Data.TypedCursorable`1.TypedRowBase.FillValues(TRow row)
at Microsoft.ML.Data.TypedCursorable`1.RowImplementation.FillValues(TRow row)
at Microsoft.ML.PredictionEngineBase`2.FillValues(TDst prediction)
at Microsoft.ML.PredictionEngine`2.Predict(TSrc example, TDst& prediction)
at Microsoft.ML.PredictionEngineBase`2.Predict(TSrc example)
```
```

at System.ThrowHelper.ThrowArgumentException_DestinationTooShort()
at System.Span`1.CopyTo(Span`1 destination)
at Microsoft.ML.Data.BufferBuilder`1.GetResult(VBuffer`1& buffer)
at Microsoft.ML.Data.NgramBufferBuilder.GetResult(VBuffer`1& dst)
at Microsoft.ML.Transforms.Text.NgramExtractingTransformer.Mapper.<>c__DisplayClass11_0.b__2(VBuffer`1& dst)
at Microsoft.ML.Transforms.LpNormNormalizingTransformer.Mapper.<>c__DisplayClass8_0.b__5(VBuffer`1& dst)
at Microsoft.ML.Data.ColumnConcatenatingTransformer.Mapper.BoundColumn.<>c__DisplayClass20_0`1.b__0(VBuffer`1& dst)
at Microsoft.ML.Data.ColumnConcatenatingTransformer.Mapper.BoundColumn.<>c__DisplayClass20_0`1.b__0(VBuffer`1& dst)
at Microsoft.ML.Data.SchemaBindablePredictorWrapperBase.<>c__DisplayClass19_0`2.b__0(TDst& dst)
at Microsoft.ML.Data.PredictedLabelScorerBase.EnsureCachedPosition[TScore](Int64& cachedPosition, TScore& score, DataViewRow boundRow, ValueGetter`1 scoreGetter)
at Microsoft.ML.Data.MulticlassClassificationScorer.<>c__DisplayClass16_0.b__0(UInt32& dst)
at Microsoft.ML.Transforms.KeyToValueMappingTransformer.Mapper.KeyToValueMap`2.<>c__DisplayClass8_0.b__0(TValue& dst)
at Microsoft.ML.Data.TypedCursorable`1.TypedRowBase.<>c__DisplayClass9_0`2.b__0(TRow row)
at Microsoft.ML.Data.TypedCursorable`1.TypedRowBase.FillValues(TRow row)
at Microsoft.ML.Data.TypedCursorable`1.RowImplementation.FillValues(TRow row)
at Microsoft.ML.PredictionEngineBase`2.FillValues(TDst prediction)
at Microsoft.ML.PredictionEngine`2.Predict(TSrc example, TDst& prediction)
at Microsoft.ML.PredictionEngineBase`2.Predict(TSrc example)
```

**Describe the solution you'd like**
Unsure. Maybe showing, something like "Column XXX throwed an exception" and then putting the actual Exception inside the InnerException?

Or, maybe Model Builder could include a "Create debuggable model" which would add the necessary source code the debug such issues without manual setup?

Or, a guide on how to enable debuggability manually, such as by downloading Microsoft.ML source code and referencing directly from local project?

**Describe alternatives you've considered**
I might try adding Microsoft.ML source code directly to my project and reference it from there. Are there any known issues doing this, such as version mismatch?

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.