-
Notifications
You must be signed in to change notification settings - Fork 183
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
LLM semconv: how to capture prompts and completions #829
Comments
@MSNev could you share your take on this? TL;DR: since we cannot immediately use event API in the instrumentation libraries, I want to add |
We actually talked about this a few weeks back as a possible path forward for "span event" support, but as spans only support "standard attributes" (non-nested) any value within this attribute will need to be encoded. So yes I would support the introduction of an tagging @tedsuo and @trask for visibility and any additional thoughts. |
Thanks for the context! The Maybe this might work:
This requires backends to be aware of specific events and their structure if they want to provide any experience on top of them, but it seems it would self-heal with structured log events. We also keep the door open to add |
Ah, I see the problem that not just the backend, but span event -> log event converter inside OTel SDK would have to know the structure. And if we default to json this problem becomes easier since we can deserialize to json tree and put the object onto otlp. I think we can try starting with json as a requirement and if we find we need to support plain text, we'd add mime type attribute? (or the span_event -> log_event would check if it's json and fallback to plain text if it can't deserialize - terrible for perf in general case though) |
Fixed in #980 |
Area(s)
llm, events
Is your change request related to a problem? Please describe.
Prompts and completions are essential part of debugging experience when developing LLM applications.
They could be verbose and contain sensitive information, so they need some opt-in mechanism such as feature-flag, configuration property on the instr library. Specific OTel distros, debugging and diagnostic tools within IDEs may decide to enable the collection by default.
There are multiple ways to capture LLM events: as attributes on spans, as attributes on span events, as log events.
Span Attributes:
Span event attributes:
Log events/logs:
Since logs/event logs are not ready to be used by instrumentation libraries in popular languages used by LLM applications (python, JS), at least the initial version of LLM semconv cannot use them leaving us with attributes vs span events choice.
Describe the solution you'd like
LLM semantic conventions should allow to capture prompts and completions as span events, but also be future-proof and support new log events:
event.body
(similarly toevent.name
).Once/if span events are deprecated, the same conventions could be used to provide back-compat story for the instrumentation libraries or OTel SDKs themselves.
Vendors/exporters may decide to transform such events into log records and would map
event.body
to the corresponding property with higher length limits than attributesWhile these are captured as span events and are sent over the wire along with the spans, vendors/exporters may decide to extract prompts/completions from the event attributes and put them on spans directly to simplify their visualizations and queries.
The text was updated successfully, but these errors were encountered: