eli5.llm

explain_prediction_openai_client(client: OpenAI, doc: str | list[dict], *, model: str, **kwargs)[source]

Calls OpenAI client, obtaining response for doc (a string, or a list of messages), with logprobs enabled, and explains the prediction, highlighting tokens proportionally to the log probability. More likely tokens are highlighted in green, while unlikely tokens are highlighted in red. . Other keyword arguments are passed to OpenAI client, with model keyword argument required.

explain_prediction_openai_completion(completion: ChatCompletion, doc=None)[source]

Creates an explanation of the ChatCompletion’s logprobs highlighting them proportionally to the log probability. More likely tokens are highlighted in green, while unlikely tokens are highlighted in red. doc argument is ignored.

explain_prediction_openai_logprobs(logprobs: ChoiceLogprobs, doc=None)[source]

Creates an explanation of the logprobs (available as .choices[idx].logprobs on a ChatCompletion object), highlighting them proportionally to the log probability. More likely tokens are highlighted in green, while unlikely tokens are highlighted in red. doc argument is ignored.