|
1 | 1 | {
|
2 | 2 | "cells": [
|
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "7c249b40", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "# Using Azure OpenAI Endpoints\n" |
| 9 | + ] |
| 10 | + }, |
3 | 11 | {
|
4 | 12 | "cell_type": "markdown",
|
5 | 13 | "id": "2e63f667",
|
|
12 | 20 | " src=\"https://colab.research.google.com/assets/colab-badge.svg\">\n",
|
13 | 21 | " </a>\n",
|
14 | 22 | " <br>\n",
|
15 |
| - " <h1> Quickstart </h1>\n", |
16 | 23 | "</p>\n",
|
17 | 24 | "\n",
|
18 |
| - "welcome to the ragas quickstart. We're going to get you up and running with ragas as qickly as you can so that you can go back to improving your Retrieval Augmented Generation pipelines while this library makes sure your changes are improving your entire pipeline.\n", |
19 |
| - "\n", |
20 |
| - "to kick things of lets start with the data\n", |
21 | 25 | "\n",
|
22 |
| - "> **Note:** this guide is for folks who are using the Azure OpenAI endpoints. Check the [quickstart guide](../quickstart.ipynb) if your using OpenAI endpoints." |
23 |
| - ] |
24 |
| - }, |
25 |
| - { |
26 |
| - "cell_type": "code", |
27 |
| - "execution_count": 1, |
28 |
| - "id": "57585b55", |
29 |
| - "metadata": {}, |
30 |
| - "outputs": [], |
31 |
| - "source": [ |
32 |
| - "# if using colab uncomment this\n", |
33 |
| - "#!pip install ragas" |
| 26 | + "> **Note:** this guide is for folks who are using the Azure OpenAI endpoints. Check the [quickstart guide](../../getstarted/evaluation.md) if your using OpenAI endpoints." |
34 | 27 | ]
|
35 | 28 | },
|
36 | 29 | {
|
37 | 30 | "cell_type": "markdown",
|
38 |
| - "id": "06c9fc7d", |
| 31 | + "id": "e54b5e01", |
39 | 32 | "metadata": {},
|
40 | 33 | "source": [
|
41 |
| - "## The Data\n", |
42 |
| - "\n", |
43 |
| - "Ragas performs a `ground_truth` free evaluation of your RAG pipelines. This is because for most people building a gold labeled dataset which represents in the distribution they get in production is a very expensive process.\n", |
44 |
| - "\n", |
45 |
| - "**Note:** *While originially ragas was aimed at `ground_truth` free evalutions there is some aspects of the RAG pipeline that need `ground_truth` in order to measure. We're in the process of building a testset generation features that will make it easier. Checkout [issue#136](https://github.com/explodinggradients/ragas/issues/136) for more details.*\n", |
46 |
| - "\n", |
47 |
| - "Hence to work with ragas all you need are the following data\n", |
48 |
| - "- question: `list[str]` - These are the questions you RAG pipeline will be evaluated on. \n", |
49 |
| - "- answer: `list[str]` - The answer generated from the RAG pipeline and give to the user.\n", |
50 |
| - "- contexts: `list[list[str]]` - The contexts which where passed into the LLM to answer the question.\n", |
51 |
| - "- ground_truths: `list[list[str]]` - The ground truth answer to the questions. (only required if you are using context_recall)\n", |
52 |
| - "\n", |
53 |
| - "Ideally your list of questions should reflect the questions your users give, including those that you have been problamatic in the past.\n", |
54 |
| - "\n", |
55 |
| - "Here we're using an example dataset from on of the baselines we created for the [Financial Opinion Mining and Question Answering (fiqa) Dataset](https://sites.google.com/view/fiqa/) we created. If you want to want to know more about the baseline, feel free to check the `experiements/baseline` section" |
| 34 | + "### Load sample dataset" |
56 | 35 | ]
|
57 | 36 | },
|
58 | 37 | {
|
|
106 | 85 | "fiqa_eval"
|
107 | 86 | ]
|
108 | 87 | },
|
109 |
| - { |
110 |
| - "cell_type": "markdown", |
111 |
| - "id": "84aa640f", |
112 |
| - "metadata": {}, |
113 |
| - "source": [ |
114 |
| - "## Metrics\n", |
115 |
| - "\n", |
116 |
| - "Ragas provides you with a few metrics to evaluate the different aspects of your RAG systems namely\n", |
117 |
| - "\n", |
118 |
| - "1. metrics to evaluate retrieval: offers `context_precision` and `context_recall` which give you the measure of the performance of your retrieval system. \n", |
119 |
| - "2. metrics to evaluate generation: offers `faithfulness` which measures hallucinations and `answer_relevancy` which measures how to-the-point the answers are to the question.\n", |
120 |
| - "\n", |
121 |
| - "The harmonic mean of these 4 aspects gives you the **ragas score** which is a single measure of the performance of your QA system across all the important aspects.\n", |
122 |
| - "\n", |
123 |
| - "\n", |
124 |
| - "\n", |
125 |
| - "Lets learn a bit more about the metrics available\n", |
126 |
| - "\n", |
127 |
| - "1. **Faithfulness**: measures the information consistency of the generated answer against the given context. If any claims are made in the answer that cannot be deduced from context is penalized. It is calculated from `answer` and `retrieved context`.\n", |
128 |
| - "\n", |
129 |
| - "2. **Context Precision**: measures how relevant retrieved contexts are to the question. Ideally, the context should only contain information necessary to answer the question. The presence of redundant information in the context is penalized. It is calculated from `question` and `retrieved context`.\n", |
130 |
| - "\n", |
131 |
| - "3. **Context Recall**: measures the recall of the retrieved context using annotated answer as ground truth. Annotated answer is taken as proxy for ground truth context. It is calculated from `ground truth` and `retrieved context`.\n", |
132 |
| - "\n", |
133 |
| - "4. **Answer Relevancy**: refers to the degree to which a response directly addresses and is appropriate for a given question or context. This does not take the factuality of the answer into consideration but rather penalizes the present of redundant information or incomplete answers given a question. It is calculated from `question` and `answer`.\n", |
134 |
| - "\n", |
135 |
| - "5. **Aspect Critiques**: Designed to judge the submission against defined aspects like harmlessness, correctness, etc. You can also define your own aspect and validate the submission against your desired aspect. The output of aspect critiques is always binary. It is calculated from `answer`.\n", |
136 |
| - "\n", |
137 |
| - "The final `ragas_score` is the harmonic mean of individual metric scores.\n", |
138 |
| - "\n", |
139 |
| - "\n", |
140 |
| - "> **Note:** by default these metrics are using OpenAI's API to compute the score. If you using this metric make sure you set the environment key `OPENAI_API_KEY` with your API key. You can also try other LLMs for evaluation, check the [llm guide](./guides/llms.ipynb) to learn more\n", |
141 |
| - "\n", |
142 |
| - "If you're interested in learning more about the metrics, feel free to check the [metrics docs](https://github.com/explodinggradients/ragas/blob/main/docs/metrics.md)" |
143 |
| - ] |
144 |
| - }, |
145 | 88 | {
|
146 | 89 | "cell_type": "markdown",
|
147 | 90 | "id": "c77789bb",
|
|
262 | 205 | "id": "8d6ecd5a",
|
263 | 206 | "metadata": {},
|
264 | 207 | "source": [
|
265 |
| - "## Evaluation\n", |
| 208 | + "### Evaluation\n", |
266 | 209 | "\n",
|
267 | 210 | "Running the evalutation is as simple as calling evaluate on the `Dataset` with the metrics of your choice."
|
268 | 211 | ]
|
|
0 commit comments