Skip to content

Commit

Permalink
docs: sync for 1.3 (#1833)
Browse files Browse the repository at this point in the history
* docs: update default value of variable in run_relevance_eval (GITBOOK-368)

* docs: No subject (GITBOOK-369)

* docs: Environment documentation (GITBOOK-370)

* docs: Explanations (GITBOOK-371)

---------

Co-authored-by: Xander Song <xsong@arize.com>
Co-authored-by: Jason Lopatecki <jason@arize.com>
  • Loading branch information
3 people authored Nov 30, 2023
1 parent 1d88efd commit 4d01e83
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 1 deletion.
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.
2 changes: 2 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* [Phoenix: AI Observability & Evaluation](README.md)
* [Example Notebooks](notebooks.md)
* [Environments](environments.md)

## 🔑 Quickstart

Expand All @@ -28,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
2 changes: 1 addition & 1 deletion docs/api/evals.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def run_relevance_eval(
template: Union[ClassificationPromptTemplate, PromptTemplate, str] = RAG_RELEVANCY_PROMPT_TEMPLATE,
rails: List[str] = list(RAG_RELEVANCY_PROMPT_RAILS_MAP.values()),
system_instruction: Optional[str] = None,
query_column_name: str = "query",
query_column_name: str = "input",
document_column_name: str = "reference",
) -> List[List[str]]:
```
Expand Down
73 changes: 73 additions & 0 deletions docs/environments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
description: >-
The Phoenix app can be run in various notebook environments such as colab and
SageMaker as well as be served via the terminal or a docker container
---

# Environments

Phoenix app is first and foremost an application that can be run just in in your notebook! This makes it an extremely flexible app since it can be accessed directly as you iterate on your AI-powered app!\


### Notebooks

Currently phoenix supports local, colab, and SageMaker notebooks.

{% hint style="warning" %}
Note, phoenix only supports running the phoenix server via the notebook for SageMaker notebooks. It cannot setup proxy requests for SageMaker studio since there is no support of jupyter-server-proxy
{% endhint %}

#### SageMaker

With SageMaker notebooks, phoenix leverages the [jupyter-server-proy](https://github.com/jupyterhub/jupyter-server-proxy) to host the server under `proxy/6006.`Note, that phoenix will automatically try to detect that you are running in SageMaker but you can declare the notebook runtime via a parameter to `launch_app` or an environment variable

{% tabs %}
{% tab title="Environment Variable" %}
```python
import os

os.envoron["PHOENIX_NOTEBOOK_ENV"] = "sagemaker"
```
{% endtab %}

{% tab title="Launch Parameter" %}
```python
import phoenix as px

px.launch_app(notebook_environment="sagemaker")
```
{% endtab %}
{% endtabs %}

### Container

{% hint style="info" %}
Container images are still actively being worked on. If you are interested in hosted phoenix, please get in touch!
{% endhint %}

Phoenix server images are now available via [Docker Hub](https://hub.docker.com/r/arizephoenix/phoenix). The hosted phoenix server runs as a trace collector and can be used if you want observability for LLM traces via docker compose or simply want a long-running phoenix instance.

If you deploy the phoenix server (collector) to a remote machine, you will have to make sure to configure the remote endpoint as the collector endpoint. (This feature is only available after phoenix **1.3.x**)

{% tabs %}
{% tab title="Environment Variable" %}
```python
import os

os.envoron["PHOENIX_COLLECTOR_ENDPOINT"] = "https://my-phoenix.io"
```
{% endtab %}

{% tab title="Second Tab" %}
```python
from phoenix.trace.tracer import Tracer
from phoenix.trace.exporter import HttpExporter
from phoenix.trace.openai.instrumentor import OpenAIInstrumentor


tracer = Tracer(exporter=HttpExporter(endpoint="https://my-phoenix.io"))
OpenAIInstrumentor(tracer).instrument()
```
{% endtab %}
{% endtabs %}

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 4d01e83

Please sign in to comment.