Skip to content

.Net: Bug:Microsoft.SemanticKernel.Connectors.Onnx private async IAsyncEnumerable<string> RunInferenceAsyncthe Chinese is not garbled #10209

Open
@yuydev

Description

Describe the bug
Microsoft.SemanticKernel.Connectors.Onnx private async IAsyncEnumerable RunInferenceAsync(ChatHistory chatHistory, PromptExecutionSettings? executionSettings, [EnumeratorCancellation] CancellationToken cancellationToken) the Chinese is not garbled

generator.ComputeLogits();
generator.GenerateNextToken();

var outputTokens = generator.GetSequence(0);
var newToken = outputTokens.Slice(outputTokens.Length - 1, 1);
string output = this.GetTokenizer().Decode(newToken);

if (removeNextTokenStartingWithSpace && output[0] == ' ')
{
removeNextTokenStartingWithSpace = false;
output = output.TrimStart();
}

/** After the modification, the Chinese is not garbled
generator.ComputeLogits();
generator.GenerateNextToken();

var outputTokens = generator.GetSequence(0);
var seq = outputTokens[^1];

var _tokenizer = GetTokenizer();
using var tokenizerStream = _tokenizer.CreateStream();
string output = tokenizerStream.Decode(seq);
return output; */

Platform

  • OS: [Windows,]
  • IDE: [Visual Studio]
  • Language: [C#, ]
  • Source: [e.g. NuGet package version 0.1.0, pip package version 0.1.0, main branch of repository]

Additional context
Add any other context about the problem here.

Metadata

Assignees

Labels

.NETIssue or Pull requests regarding .NET codebugSomething isn't working

Type

Projects

  • Status

    Sprint: In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions