You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Exception is thrown if you try to to use the BertOnnxTextEmbeddingGenerationService with a mpnet embedding model.
Microsoft.ML.OnnxRuntime.OnnxRuntimeException HResult=0x80131500 Message=[ErrorCode:InvalidArgument] Input name: 'token_type_ids' is not in the metadata Source=Microsoft.ML.OnnxRuntime StackTrace: at Microsoft.ML.OnnxRuntime.InferenceSession.LookupInputMetadata(String nodeName) at Microsoft.ML.OnnxRuntime.InferenceSession.LookupUtf8Names[T](IReadOnlyCollection``1 values, NameExtractor``1 nameExtractor, MetadataLookup metaLookup) at Microsoft.ML.OnnxRuntime.InferenceSession.Run(RunOptions runOptions, IReadOnlyCollection``1 inputNames, IReadOnlyCollection``1 inputValues, IReadOnlyCollection``1 outputNames) at Microsoft.SemanticKernel.Connectors.Onnx.BertOnnxTextEmbeddingGenerationService.<GenerateEmbeddingsAsync>d__18.MoveNext() at Microsoft.SemanticKernel.Embeddings.EmbeddingGenerationExtensions.<GenerateEmbeddingAsync>d__2``2.MoveNext() at Program.<>c.<<<Main>$>b__0_1>d.MoveNext()
It seems the BertOnnxTextEmbeddingGenerationService tries to fill the input token_type_ids even if the model does not declare it, e.g. the mpnet models.
Create a test project with a service collection and register the embedding service and the kernel (builder.Services.AddBertOnnxTextEmbeddingGeneration) for the previously downloaded model with its vocabulary
Use the service (await textEmbeddingGenerationService.GenerateEmbeddingAsync("this is an example")
Exception is thrown
Expected behavior
Embedding is just working or configuration is possible. Something without the need to export the model with the additional input
github-actionsbot
changed the title
Bug: Input name: 'token_type_ids' is not in the metadata
.Net: Bug: Input name: 'token_type_ids' is not in the metadata
Apr 12, 2025
Describe the bug
Exception is thrown if you try to to use the BertOnnxTextEmbeddingGenerationService with a mpnet embedding model.
Microsoft.ML.OnnxRuntime.OnnxRuntimeException HResult=0x80131500 Message=[ErrorCode:InvalidArgument] Input name: 'token_type_ids' is not in the metadata Source=Microsoft.ML.OnnxRuntime StackTrace: at Microsoft.ML.OnnxRuntime.InferenceSession.LookupInputMetadata(String nodeName) at Microsoft.ML.OnnxRuntime.InferenceSession.LookupUtf8Names[T](IReadOnlyCollection``1 values, NameExtractor``1 nameExtractor, MetadataLookup metaLookup) at Microsoft.ML.OnnxRuntime.InferenceSession.Run(RunOptions runOptions, IReadOnlyCollection``1 inputNames, IReadOnlyCollection``1 inputValues, IReadOnlyCollection``1 outputNames) at Microsoft.SemanticKernel.Connectors.Onnx.BertOnnxTextEmbeddingGenerationService.<GenerateEmbeddingsAsync>d__18.MoveNext() at Microsoft.SemanticKernel.Embeddings.EmbeddingGenerationExtensions.<GenerateEmbeddingAsync>d__2``2.MoveNext() at Program.<>c.<<<Main>$>b__0_1>d.MoveNext()
It seems the BertOnnxTextEmbeddingGenerationService tries to fill the input
token_type_ids
even if the model does not declare it, e.g. the mpnet models.To Reproduce
Steps to reproduce the behavior:
builder.Services.AddBertOnnxTextEmbeddingGeneration
) for the previously downloaded model with its vocabularyawait textEmbeddingGenerationService.GenerateEmbeddingAsync("this is an example")
Expected behavior
Embedding is just working or configuration is possible. Something without the need to export the model with the additional input
Screenshots

Platform
The text was updated successfully, but these errors were encountered: