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

Change gen_ai.response.finish_reasons type from array to string, use it on metrics #1291

Closed

Conversation

lmolkova
Copy link
Contributor

Fixes #1277

Changes

While OpenAI supports returning multiple completions (and therefore could have multiple finish reasons), I did not find models outside of OpenAI that return multiple choices and many SDKs (e.g. vercel) don't support returning multiple choices.

So effectively there is usually one finish reason.
Having an array for it:

  • complicates querying
  • makes usage of finish reason on metrics more complicated

This PR:

  • turns finish reasons attribute into a string (comma-separated if there is more than one)
  • adds it to metrics.

Having comma-separated list has high-ish theoretical cardinality in edge cases, but results in best experience for common case.
I'm suggesting to start with it and consider making it opt-in on metrics if it's proven to be problematic.

Merge requirement checklist

@@ -266,8 +274,9 @@ This metric SHOULD be specified with [ExplicitBucketBoundaries] of
| [`gen_ai.system`](/docs/attributes-registry/gen-ai.md) | string | The Generative AI product as identified by the client or server instrumentation. [2] | `openai` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [3] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` if the operation ended in an error | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [4] | `80`; `8080`; `443` | `Conditionally Required` If `sever.address` is set. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`gen_ai.response.finish_reason`](/docs/attributes-registry/gen-ai.md) | string | The reason(s) the model stopped generating tokens. [5] | `stop`; `stop,length` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@achandrasekar any thoughts/objections? on adding finish_reason attribute to LLM server metrics?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Adding a finish_reason attribute makes sense. It would be useful in a lot of cases including benchmarking where we can see if we generated to the max_length or stopped early due to the EOS token.

@lmolkova lmolkova changed the title Change gen_ai.responmse.finish_reasons type from array to string, use it on metrics Change gen_ai.response.finish_reasons type from array to string, use it on metrics Jul 29, 2024
@lmolkova
Copy link
Contributor Author

lmolkova commented Sep 3, 2024

I'm going to close this PR and pursue other ways that work better for batching and multiple choices outlined here

#1277 (comment)

@lmolkova lmolkova closed this Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GenAI: do we need to support multiple finish reasons?
2 participants