Skip to content

Commit

Permalink
docs: Explanations (GITBOOK-371)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Lopatecki authored and mikeldking committed Dec 1, 2023
1 parent d8a529b commit 5130410
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
Binary file added docs/.gitbook/assets/explanation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* [Code Generation Eval](llm-evals/running-pre-tested-evals/code-generation-eval.md)
* [Summarization Eval](llm-evals/running-pre-tested-evals/summarization-eval.md)
* [Reference Link Evals](llm-evals/running-pre-tested-evals/reference-link-evals.md)
* [Evals With Explanations](llm-evals/evals-with-explanations.md)
* [Building Your Own Evals](llm-evals/building-your-own-evals.md)
* [Benchmarking Retrieval (RAG)](llm-evals/benchmarking-retrieval-rag.md)

Expand Down
42 changes: 42 additions & 0 deletions docs/llm-evals/evals-with-explanations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Evals With Explanations

{% embed url="https://colab.research.google.com/github/Arize-ai/phoenix/blob/main/tutorials/evals/evaluate_relevance_classifications.ipynb?#scrollTo=zUtDrplhZZJu&uniqifier=1" %}
See "Classifications with Explanations Section"
{% endembed %}

It can be hard to understand in many cases why an LLM responds in a specific way. The explanation feature of Phoneix allows you to get a Eval output and an explanation from the LLM at the same time. We have found this incredibly useful for debugging LLM Evals.

<pre class="language-python"><code class="lang-python">from phoenix.experimental.evals import (
RAG_RELEVANCY_PROMPT_RAILS_MAP,
RAG_RELEVANCY_PROMPT_TEMPLATE,
OpenAIModel,
download_benchmark_dataset,
llm_classify,
)

model = OpenAIModel(
model_name="gpt-4",
temperature=0.0,
)

#The rails is used to hold the output to specific values based on the template
#It will remove text such as ",,," or "..."
#Will ensure the binary value expected from the template is returned
rails = list(RAG_RELEVANCY_PROMPT_RAILS_MAP.values())
relevance_classifications = llm_classify(
dataframe=df,
template=RAG_RELEVANCY_PROMPT_TEMPLATE,
model=model,
rails=rails,
<a data-footnote-ref href="#user-content-fn-1">provide_explanation=True</a>
)
#relevance_classifications is a Dataframe with columns 'label' and 'explanation'
</code></pre>

The flag above can be set with any of the templates or your own custom templates. The example below is from a relevance Evaluation.&#x20;

<figure><img src="../.gitbook/assets/explanation.png" alt=""><figcaption></figcaption></figure>



[^1]: set to get an explanation out

0 comments on commit 5130410

Please sign in to comment.