Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: Inconsistent Temperature data type in PromptExecutionSettings classes #8541

Open
akordowski opened this issue Sep 5, 2024 · 8 comments
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code

Comments

@akordowski
Copy link
Contributor

Working with SK it came to my attention that the data type of the Temperature property in PromptExecutionSettings classes is inconsistent. Some have the data type float others have double.

Is that intentional? When not wouldn't it make sense to have the same data type in all PromptExecutionSettings classes? As the expected values are mostly in range of -1.0 to 1.0 it would make sens to use the float data type (float 32bit vs double 64 bit). If wished I could provide PR for this issue. Thank you for consideration.

float

double

@akordowski akordowski added the bug Something isn't working label Sep 5, 2024
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage labels Sep 5, 2024
@evchaki evchaki removed the triage label Sep 9, 2024
@evchaki
Copy link
Contributor

evchaki commented Sep 9, 2024

@akordowski - thanks for reaching out on this. Each connector has its own data type and matches the type by the underlining service. We abstract on top of these.

@akordowski
Copy link
Contributor Author

@evchaki Thank you for your reponse.

Each connector has its own data type and matches the type by the underlining service. We abstract on top of these.

After investigating the source code this statement is not quite true. For the OpenAIPromptExecutionSettings class the double values are cast from double to float as you can see below:

var options = new ChatCompletionOptions
{
MaxTokens = executionSettings.MaxTokens,
Temperature = (float?)executionSettings.Temperature,
TopP = (float?)executionSettings.TopP,
FrequencyPenalty = (float?)executionSettings.FrequencyPenalty,
PresencePenalty = (float?)executionSettings.PresencePenalty,
Seed = executionSettings.Seed,
EndUserId = executionSettings.User,
TopLogProbabilityCount = executionSettings.TopLogprobs,
IncludeLogProbabilities = executionSettings.Logprobs,
};

And for the GeminiPromptExecutionSettings and MistralAIPromptExecutionSettings classes the values are converted to JSON strings. As we know that the values are at so low range that we don't have to expect an overflow, I would recommend to streamline the data type for a cleaner design. It may not have not that big impact on memory, but why to cast double to float when there is no explicit necessity for it. What do you think?

Copy link

github-actions bot commented Dec 9, 2024

This issue is stale because it has been open for 90 days with no activity.

@github-actions github-actions bot added the stale Issue is stale because it has been open for 90 days with no activity label Dec 9, 2024
@akordowski
Copy link
Contributor Author

@evchaki Any remarks regarding my response?

@github-actions github-actions bot removed the stale Issue is stale because it has been open for 90 days with no activity label Dec 10, 2024
@dmytrostruk
Copy link
Member

@akordowski I think your concerns are valid. On the other hand, I'm not sure if it will be possible to update property type at this point, since it's going to be a breaking change. The alternative solution would be to mark current property as obsolete and introduce another one with correct type, but we will have to use new name for that property, and this is a problem, because temperature is a correct name, and I can't think about an alternative name as for now.

@akordowski
Copy link
Contributor Author

@dmytrostruk Thank you for your response.

I'm not sure if it will be possible to update property type at this point, since it's going to be a breaking change.

  • Do you see the breaking change on the property type side or otherwise?
  • To my knowledge the temperature values can not exced the float 32bit value, which implications do you see?

The only errors I can imagine would be compile/cast errors. As the SK project is still experimental I find it justified to fix the issue and don't drag the "technical" debt in future versions. The changes could be communicated through release notes or something similar.

If the team is willing to accept a fix regarding this issue I would love to provide a PR. Feel free to let me know. Thank you!

@dmytrostruk
Copy link
Member

@akordowski Thanks for your reply!

Do you see the breaking change on the property type side or otherwise?

That's correct, property type.

The only errors I can imagine would be compile/cast errors. As the SK project is still experimental I find it justified to fix the issue and don't drag the "technical" debt in future versions. The changes could be communicated through release notes or something similar.

While some of SK functionality is marked as experimental, the functionality for execution settings, and specifically Temperature property is not experimental. We are trying to avoid delivering compilation errors for non-experimental functionality, unless it's something critical or it is experimental.

I'm not sure this issue is critical in the way that we want to provide a breaking change for it, but we can discuss it with internal team and make some decision. I think this property was added at the very early stage of Semantic Kernel, so maybe back then it wasn't clear which values it will accept in the future.

If the team is willing to accept a fix regarding this issue I would love to provide a PR

Your contribution is much appreciated and in case we decide to proceed with this change, we will definitely let you know.

Thank you!

@akordowski
Copy link
Contributor Author

@dmytrostruk Thank you for the clarification.

We are trying to avoid delivering compilation errors for non-experimental functionality, unless it's something critical or it is experimental.

I would like to point out, that I already expierienced some breaking changes (as you can read here #8658) which were more sever than a data type change. But I understand and respect the teams decision.

but we can discuss it with internal team and make some decision.

Thank you very much! Looking forward to the teams decision.

@markwallace-microsoft markwallace-microsoft moved this to Sprint: Planned in Semantic Kernel Dec 11, 2024
@markwallace-microsoft markwallace-microsoft moved this from Sprint: Planned to Needs Triage in Semantic Kernel Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code
Projects
Status: Needs Triage
Development

No branches or pull requests

4 participants