diff --git a/src/documentation/elo_qa_eval.ipynb b/src/documentation/elo_qa_eval.ipynb index bd8b79e45..eadccb98f 100644 --- a/src/documentation/elo_qa_eval.ipynb +++ b/src/documentation/elo_qa_eval.ipynb @@ -23,7 +23,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 28, "metadata": {}, "outputs": [], "source": [ @@ -72,14 +72,14 @@ "\n", "The IL will read the input dataset and produce outputs for each model, which will be stored in a `run_repository`.\n", "\n", - "The result from the previous step can now be evaluated, in this case with an ELO evaluator (`EloQaEvaluator`). The evaluation is stored in the `eval_repository`.\n", + "The result from the previous step can now be evaluated, in this case with an incremental evaluator (`IncrementalEvaluator`), with a QA specific ELO evaluation logic. The evaluation is stored in the `eval_repository`.\n", "\n", "Finally, the evaluations are aggregated and stored in the `aggregation_repository`. The aggregation contains the ELO score and winning rate of each model along with additional metadata." ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 29, "metadata": {}, "outputs": [], "source": [ @@ -99,7 +99,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 30, "metadata": {}, "outputs": [], "source": [ @@ -146,7 +146,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 31, "metadata": {}, "outputs": [], "source": [ @@ -157,7 +157,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 32, "metadata": {}, "outputs": [], "source": [ @@ -174,20 +174,20 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 33, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Example ID = 18a61dbe-d2d1-4652-8bfa-2940a38ec74b\n", - "Input = chunk=\"Surface micromachining\\n\\nSurface micromachining builds microstructures by deposition and etching structural layers over a substrate.[1] This is different from Bulk micromachining, in which a silicon substrate wafer is selectively etched to produce structures.\\n\\nLayers\\n\\nGenerally, polysilicon is used as one of the substrate layers while silicon dioxide is used as a sacrificial layer. The sacrificial layer is removed or etched out to create any necessary void in the thickness direction. Added layers tend to vary in size from 2-5 micrometres. The main advantage of this machining process is the ability to build electronic and mechanical components (functions) on the same substrate. Surface micro-machined components are smaller compared to their bulk micro-machined counterparts.\\n\\nAs the structures are built on top of the substrate and not inside it, the substrate's properties are not as important as in bulk micro-machining. Expensive silicon wafers can be replaced by cheaper substrates, such as glass or plastic. The size of the substrates may be larger than a silicon wafer, and surface micro-machining is used to produce thin-film transistors on large area glass substrates for flat panel displays. This technology can also be used for the manufacture of thin film solar cells, which can be deposited on glass, polyethylene terepthalate substrates or other non-rigid materials.\\n\\nFabrication process\\n\\nMicro-machining starts with a silicon wafer or other substrate upon which new layers are grown. These layers are selectively etched by photo-lithography; either a wet etch involving an acid, or a dry etch involving an ionized gas (or plasma). Dry etching can combine chemical etching with physical etching or ion bombardment. Surface micro-machining involves as many layers as are needed with a different mask (producing a different pattern) on each layer. Modern integrated circuit fabrication uses this technique and can use as many as 100 layers. Micro-machining is a younger technology and usually uses no more than 5 or 6 layers. Surface micro-machining uses developed technology (although sometimes not enough for demanding applications) which is easily repeatable for volume production.\" question='What is micromachining?' language=Language(iso_639_1='en')\n", - "Expected output = \"Surface micromachining builds microstructures by deposition and etching structural layers over a substrate. This is different from Bulk micromachining, in which a silicon substrate wafer is selectively etched to produce structures.\"\n", - "\n", - "Example ID = f5cdcb1f-38e4-4bfd-b170-9744237bd0d9\n", + "Example ID = 2a5e8455-2289-45d0-a4ff-af0dc92014c9\n", "Input = chunk=\"\\nSilicon is a chemical element; it has symbol Si and atomic number 14. It is a hard, brittle crystalline solid with a blue-grey metallic luster, and is a non metal and semiconductor. It is a member of group 14 in the periodic table: carbon is above it; and germanium, tin, lead, and flerovium are below it. It is relatively unreactive.\\n\\nBecause of its high chemical affinity for oxygen, it was not until 1823 that Jöns Jakob Berzelius was first able to prepare it and characterize it in pure form. Its oxides form a family of anions known as silicates. Its melting and boiling points of 1414 °C and 3265 °C, respectively, are the second highest among all the metalloids and nonmetals, being surpassed only by boron.[a]\\n\\nSilicon is the eighth most common element in the universe by mass, but very rarely occurs as the pure element in the Earth's crust. It is widely distributed in space in cosmic dusts, planetoids, and planets as various forms of silicon dioxide (silica) or silicates. More than 90% of the Earth's crust is composed of silicate minerals, making silicon the second most abundant element in the Earth's crust (about 28% by mass), after oxygen. \\n\" question='What is silicon?' language=Language(iso_639_1='en')\n", "Expected output = \"Silicon is a chemical element.\"\n", + "\n", + "Example ID = b8d5eabf-4fc7-4077-9e69-0a259e552e98\n", + "Input = chunk=\"Surface micromachining\\n\\nSurface micromachining builds microstructures by deposition and etching structural layers over a substrate.[1] This is different from Bulk micromachining, in which a silicon substrate wafer is selectively etched to produce structures.\\n\\nLayers\\n\\nGenerally, polysilicon is used as one of the substrate layers while silicon dioxide is used as a sacrificial layer. The sacrificial layer is removed or etched out to create any necessary void in the thickness direction. Added layers tend to vary in size from 2-5 micrometres. The main advantage of this machining process is the ability to build electronic and mechanical components (functions) on the same substrate. Surface micro-machined components are smaller compared to their bulk micro-machined counterparts.\\n\\nAs the structures are built on top of the substrate and not inside it, the substrate's properties are not as important as in bulk micro-machining. Expensive silicon wafers can be replaced by cheaper substrates, such as glass or plastic. The size of the substrates may be larger than a silicon wafer, and surface micro-machining is used to produce thin-film transistors on large area glass substrates for flat panel displays. This technology can also be used for the manufacture of thin film solar cells, which can be deposited on glass, polyethylene terepthalate substrates or other non-rigid materials.\\n\\nFabrication process\\n\\nMicro-machining starts with a silicon wafer or other substrate upon which new layers are grown. These layers are selectively etched by photo-lithography; either a wet etch involving an acid, or a dry etch involving an ionized gas (or plasma). Dry etching can combine chemical etching with physical etching or ion bombardment. Surface micro-machining involves as many layers as are needed with a different mask (producing a different pattern) on each layer. Modern integrated circuit fabrication uses this technique and can use as many as 100 layers. Micro-machining is a younger technology and usually uses no more than 5 or 6 layers. Surface micro-machining uses developed technology (although sometimes not enough for demanding applications) which is easily repeatable for volume production.\" question='What is micromachining?' language=Language(iso_639_1='en')\n", + "Expected output = \"Surface micromachining builds microstructures by deposition and etching structural layers over a substrate. This is different from Bulk micromachining, in which a silicon substrate wafer is selectively etched to produce structures.\"\n", "\n" ] } @@ -215,15 +215,15 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 34, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Running: 2it [00:09, 4.79s/it]\n", - "Running: 2it [00:16, 8.17s/it]\n" + "Running: 2it [00:28, 14.27s/it]\n", + "Running: 2it [00:18, 9.47s/it]\n" ] } ], @@ -245,7 +245,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 35, "metadata": {}, "outputs": [], "source": [ @@ -265,46 +265,46 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Run overview IDs saved in the run repository: ['40acbcce-d908-4749-a454-172286e47532', '59339760-1fd7-4606-af14-332eeed32950']\n", + "Run overview IDs saved in the run repository: ['0085d52d-e0d9-41c4-aef5-b94aa3ca7249', '6371ddc0-f8dc-4f49-9c70-c2da8247f1cb']\n", "\n", - "Run Overview ID = 40acbcce-d908-4749-a454-172286e47532\n", - "Dataset ID = e30b678e-fa7f-45ea-8e48-21860a8aa23c\n", - "Start time = 2024-05-17 12:06:39.347886+00:00\n", - "End time = 2024-05-17 12:06:55.694959+00:00\n", + "Run Overview ID = 0085d52d-e0d9-41c4-aef5-b94aa3ca7249\n", + "Dataset ID = 93cb78ca-cd30-45f7-ae69-f401d1855f24\n", + "Start time = 2024-05-17 12:51:11.421102+00:00\n", + "End time = 2024-05-17 12:51:30.362788+00:00\n", "Failed example count = 0\n", "Successful example count = 2\n", "Description = \"QA with model luminous-supreme-control-20240215\"\n", "\n", - "Example ID=18a61dbe-d2d1-4652-8bfa-2940a38ec74b\n", - "Related Run ID=40acbcce-d908-4749-a454-172286e47532\n", - "Output=\"answer='Surface micromachining is a process of building microstructures by deposition and etching structural layers over a substrate.' highlights=[ScoredTextHighlight(start=24, end=131, score=1.0)]\"\n", - "\n", - "Example ID=f5cdcb1f-38e4-4bfd-b170-9744237bd0d9\n", - "Related Run ID=40acbcce-d908-4749-a454-172286e47532\n", + "Example ID=2a5e8455-2289-45d0-a4ff-af0dc92014c9\n", + "Related Run ID=0085d52d-e0d9-41c4-aef5-b94aa3ca7249\n", "Output=\"answer='Silicon is a chemical element with symbol Si and atomic number 14. It is a hard, brittle crystalline solid with a blue-grey metallic luster, and is a non metal and semiconductor.' highlights=[ScoredTextHighlight(start=71, end=182, score=1.0)]\"\n", "\n", - "Run Overview ID = 59339760-1fd7-4606-af14-332eeed32950\n", - "Dataset ID = e30b678e-fa7f-45ea-8e48-21860a8aa23c\n", - "Start time = 2024-05-17 12:06:29.753340+00:00\n", - "End time = 2024-05-17 12:06:39.347388+00:00\n", + "Example ID=b8d5eabf-4fc7-4077-9e69-0a259e552e98\n", + "Related Run ID=0085d52d-e0d9-41c4-aef5-b94aa3ca7249\n", + "Output=\"answer='Surface micromachining is a process of building microstructures by deposition and etching structural layers over a substrate.' highlights=[ScoredTextHighlight(start=24, end=131, score=1.0)]\"\n", + "\n", + "Run Overview ID = 6371ddc0-f8dc-4f49-9c70-c2da8247f1cb\n", + "Dataset ID = 93cb78ca-cd30-45f7-ae69-f401d1855f24\n", + "Start time = 2024-05-17 12:50:42.869074+00:00\n", + "End time = 2024-05-17 12:51:11.420707+00:00\n", "Failed example count = 0\n", "Successful example count = 2\n", "Description = \"QA with model luminous-base-control-20240215\"\n", "\n", - "Example ID=18a61dbe-d2d1-4652-8bfa-2940a38ec74b\n", - "Related Run ID=59339760-1fd7-4606-af14-332eeed32950\n", - "Output=\"answer='Micromachining is a process of building microstructures by deposition and etching structural layers over a substrate.' highlights=[ScoredTextHighlight(start=24, end=131, score=1.0)]\"\n", - "\n", - "Example ID=f5cdcb1f-38e4-4bfd-b170-9744237bd0d9\n", - "Related Run ID=59339760-1fd7-4606-af14-332eeed32950\n", + "Example ID=2a5e8455-2289-45d0-a4ff-af0dc92014c9\n", + "Related Run ID=6371ddc0-f8dc-4f49-9c70-c2da8247f1cb\n", "Output=\"answer='Silicon is a chemical element with symbol Si and atomic number 14. It is a hard, brittle crystalline solid with a blue-grey metallic luster, and is a non metal and semiconductor.' highlights=[ScoredTextHighlight(start=71, end=182, score=1.0)]\"\n", + "\n", + "Example ID=b8d5eabf-4fc7-4077-9e69-0a259e552e98\n", + "Related Run ID=6371ddc0-f8dc-4f49-9c70-c2da8247f1cb\n", + "Output=\"answer='Micromachining is a process of building microstructures by deposition and etching structural layers over a substrate.' highlights=[ScoredTextHighlight(start=24, end=131, score=1.0)]\"\n", "\n" ] } @@ -329,12 +329,14 @@ "# Step 2 – Run Evaluation\n", "\n", "Now that we have generated the answers of all models for all examples in the `dataset_repository`, the next step is to evaluate those answers.\n", - "The evaluation is done by an `Evaluator`. Here we are interested in the ELO score, which can be calculated using the `IncrementalEloQaEvaluator`. For each example, the `IncrementalEloQaEvaluator` takes the two answers of two different models and uses Llama to decide which answer is better. It further has the capability to later add additional runs or models without repeating old comparisons, which will come in handy later. You can also implement your own `Evaluator` to exactly match your use case." + "The evaluation is done by an `Evaluator`. In this notebook we choose an `IncrementalEvaluator` which has the capability to later add additional runs or models without repeating old comparisons, which will come in handy later.\n", + "\n", + "Since we are interested in the ELO score, we use an ELO evaluation logic, which, in general, compares two outputs against each other and chooses fitting better option. In order to deem which of the two options is \"better\", we need to provide a use case specific evaluation logic, in our QA case an `EloQaEvaluationLogic`, and a \"referee mo del\" which compares and grades the individual outputs. Here we choose Llama3." ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 37, "metadata": {}, "outputs": [ { @@ -352,7 +354,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 38, "metadata": {}, "outputs": [], "source": [ @@ -371,14 +373,14 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Evaluating: 2it [00:00, 3.29it/s]\n" + "Evaluating: 2it [00:00, 3.00it/s]\n" ] } ], @@ -388,7 +390,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 40, "metadata": {}, "outputs": [], "source": [ @@ -411,31 +413,31 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 41, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Evaluation Overview ID = ef2da6c0-3c84-4414-9aa8-be878afd18f6\n", - "Start time = 2024-05-17 12:06:55.727219+00:00\n", - "End time = 2024-05-17 12:06:56.337819+00:00\n", + "Evaluation Overview ID = 0fddc8bf-7785-4a6b-9541-4407f47a5e1b\n", + "Start time = 2024-05-17 12:51:30.400083+00:00\n", + "End time = 2024-05-17 12:51:31.071905+00:00\n", "Successful examples = 2\n", "Failed examples = 0\n", "Description = \"ELO QA evaluation\"\n", "Run Overviews={\n", - "Run Overview ID = 40acbcce-d908-4749-a454-172286e47532\n", - "Dataset ID = e30b678e-fa7f-45ea-8e48-21860a8aa23c\n", - "Start time = 2024-05-17 12:06:39.347886+00:00\n", - "End time = 2024-05-17 12:06:55.694959+00:00\n", + "Run Overview ID = 0085d52d-e0d9-41c4-aef5-b94aa3ca7249\n", + "Dataset ID = 93cb78ca-cd30-45f7-ae69-f401d1855f24\n", + "Start time = 2024-05-17 12:51:11.421102+00:00\n", + "End time = 2024-05-17 12:51:30.362788+00:00\n", "Failed example count = 0\n", "Successful example count = 2\n", "Description = \"QA with model luminous-supreme-control-20240215\"\n", - ", Run Overview ID = 59339760-1fd7-4606-af14-332eeed32950\n", - "Dataset ID = e30b678e-fa7f-45ea-8e48-21860a8aa23c\n", - "Start time = 2024-05-17 12:06:29.753340+00:00\n", - "End time = 2024-05-17 12:06:39.347388+00:00\n", + ", Run Overview ID = 6371ddc0-f8dc-4f49-9c70-c2da8247f1cb\n", + "Dataset ID = 93cb78ca-cd30-45f7-ae69-f401d1855f24\n", + "Start time = 2024-05-17 12:50:42.869074+00:00\n", + "End time = 2024-05-17 12:51:11.420707+00:00\n", "Failed example count = 0\n", "Successful example count = 2\n", "Description = \"QA with model luminous-base-control-20240215\"\n", @@ -461,7 +463,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 42, "metadata": {}, "outputs": [ { @@ -481,7 +483,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 43, "metadata": {}, "outputs": [], "source": [ @@ -497,7 +499,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 44, "metadata": {}, "outputs": [], "source": [ @@ -523,23 +525,23 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 45, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Aggregation Overview ID = 5bf4c3bf-de54-4a90-bede-ce1235c9aff7\n", - "Start time = 2024-05-17 12:06:56.366455+00:00\n", - "End time = 2024-05-17 12:06:56.367808+00:00\n", + "Aggregation Overview ID = 294f86d5-8f3f-41b3-a698-93ed7b0541d9\n", + "Start time = 2024-05-17 12:51:31.103016+00:00\n", + "End time = 2024-05-17 12:51:31.103599+00:00\n", "Successful example count = 2\n", "Count of examples crashed during evaluation = 0\n", "Description = \"ELO QA aggregation\"\n", - "IDs of aggregated Evaluation Overviews = ['ef2da6c0-3c84-4414-9aa8-be878afd18f6']\n", - "IDs of aggregated Run Overviews = ['40acbcce-d908-4749-a454-172286e47532', '59339760-1fd7-4606-af14-332eeed32950']\n", + "IDs of aggregated Evaluation Overviews = ['0fddc8bf-7785-4a6b-9541-4407f47a5e1b']\n", + "IDs of aggregated Run Overviews = ['0085d52d-e0d9-41c4-aef5-b94aa3ca7249', '6371ddc0-f8dc-4f49-9c70-c2da8247f1cb']\n", "Statistics = {\n", - "scores={'40acbcce-d908-4749-a454-172286e47532': PlayerScore(elo=1509.7170402138256, elo_standard_error=0.028612685604210077, win_rate=0.75, num_matches=2), '59339760-1fd7-4606-af14-332eeed32950': PlayerScore(elo=1490.2829597861742, elo_standard_error=0.02861268397674558, win_rate=0.25, num_matches=2)}\n", + "scores={'0085d52d-e0d9-41c4-aef5-b94aa3ca7249': PlayerScore(elo=1509.6540797133814, elo_standard_error=0.02804020086655017, win_rate=0.75, num_matches=2), '6371ddc0-f8dc-4f49-9c70-c2da8247f1cb': PlayerScore(elo=1490.3459202866186, elo_standard_error=0.02804019879068547, win_rate=0.25, num_matches=2)}\n", "}\n", "\n" ] @@ -566,15 +568,15 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Running: 2it [00:20, 10.12s/it]\n", - "Running: 2it [00:14, 7.11s/it]\n" + "Running: 2it [00:06, 3.26s/it]\n", + "Running: 2it [00:14, 7.14s/it]\n" ] } ], @@ -598,7 +600,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 47, "metadata": {}, "outputs": [], "source": [ @@ -611,28 +613,28 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 48, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Run Overview ID = 7df4764c-e873-4aff-9ec5-52cb001a9382\n", - "Dataset ID = e30b678e-fa7f-45ea-8e48-21860a8aa23c\n", - "Start time = 2024-05-17 12:06:56.394123+00:00\n", - "End time = 2024-05-17 12:07:16.635122+00:00\n", + "Run Overview ID = 62ee87e2-060a-4a06-83dd-05865f0de5bc\n", + "Dataset ID = 93cb78ca-cd30-45f7-ae69-f401d1855f24\n", + "Start time = 2024-05-17 12:51:37.666619+00:00\n", + "End time = 2024-05-17 12:51:51.952182+00:00\n", "Failed example count = 0\n", "Successful example count = 2\n", - "Description = \"New QA with model luminous-base-control-20230501\"\n", + "Description = \"New QA with model luminous-supreme-control-20230501\"\n", "\n", - "Run Overview ID = 9be1b687-0e07-4214-8967-49baa351587f\n", - "Dataset ID = e30b678e-fa7f-45ea-8e48-21860a8aa23c\n", - "Start time = 2024-05-17 12:07:16.635290+00:00\n", - "End time = 2024-05-17 12:07:30.865449+00:00\n", + "Run Overview ID = 7ad75316-133a-47fb-931c-76ae19b7de9a\n", + "Dataset ID = 93cb78ca-cd30-45f7-ae69-f401d1855f24\n", + "Start time = 2024-05-17 12:51:31.129344+00:00\n", + "End time = 2024-05-17 12:51:37.665864+00:00\n", "Failed example count = 0\n", "Successful example count = 2\n", - "Description = \"New QA with model luminous-supreme-control-20230501\"\n", + "Description = \"New QA with model luminous-base-control-20230501\"\n", "\n" ] } @@ -655,14 +657,14 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 49, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Evaluating: 2it [00:03, 1.93s/it]\n" + "Evaluating: 2it [00:04, 2.25s/it]\n" ] } ], @@ -674,7 +676,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 50, "metadata": {}, "outputs": [], "source": [ @@ -698,14 +700,14 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 51, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Evaluation overviews to aggregate: ['842bc7cb-d898-4023-afba-0b390b705ff4', 'ef2da6c0-3c84-4414-9aa8-be878afd18f6']\n" + "Evaluation overviews to aggregate: ['0fddc8bf-7785-4a6b-9541-4407f47a5e1b', '447071ed-12b5-4e51-a7df-f1495bb60475']\n" ] } ], @@ -721,7 +723,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 52, "metadata": {}, "outputs": [], "source": [ @@ -733,7 +735,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 53, "metadata": {}, "outputs": [], "source": [ @@ -759,23 +761,23 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 54, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Aggregation Overview ID = 71c31442-8e5b-4ce0-89f6-5df5bba259dc\n", - "Start time = 2024-05-17 12:07:34.778145+00:00\n", - "End time = 2024-05-17 12:07:34.780775+00:00\n", + "Aggregation Overview ID = d611c0a4-a467-4d41-8134-4b832f160593\n", + "Start time = 2024-05-17 12:51:56.524543+00:00\n", + "End time = 2024-05-17 12:51:56.527208+00:00\n", "Successful example count = 4\n", "Count of examples crashed during evaluation = 0\n", "Description = \"ELO QA aggregation\"\n", - "IDs of aggregated Evaluation Overviews = ['842bc7cb-d898-4023-afba-0b390b705ff4', 'ef2da6c0-3c84-4414-9aa8-be878afd18f6']\n", - "IDs of aggregated Run Overviews = ['7df4764c-e873-4aff-9ec5-52cb001a9382', '40acbcce-d908-4749-a454-172286e47532', '9be1b687-0e07-4214-8967-49baa351587f', '59339760-1fd7-4606-af14-332eeed32950']\n", + "IDs of aggregated Evaluation Overviews = ['447071ed-12b5-4e51-a7df-f1495bb60475', '0fddc8bf-7785-4a6b-9541-4407f47a5e1b']\n", + "IDs of aggregated Run Overviews = ['0085d52d-e0d9-41c4-aef5-b94aa3ca7249', '62ee87e2-060a-4a06-83dd-05865f0de5bc', '7ad75316-133a-47fb-931c-76ae19b7de9a', '6371ddc0-f8dc-4f49-9c70-c2da8247f1cb']\n", "Statistics = {\n", - "scores={'40acbcce-d908-4749-a454-172286e47532': PlayerScore(elo=1509.189099417823, elo_standard_error=0.1344337229545878, win_rate=0.5833333333333334, num_matches=6), '9be1b687-0e07-4214-8967-49baa351587f': PlayerScore(elo=1499.8609033022822, elo_standard_error=0.18459654247004761, win_rate=0.5, num_matches=6), '7df4764c-e873-4aff-9ec5-52cb001a9382': PlayerScore(elo=1518.2546091514266, elo_standard_error=0.15278799424990525, win_rate=0.6666666666666666, num_matches=6), '59339760-1fd7-4606-af14-332eeed32950': PlayerScore(elo=1472.6955463281204, elo_standard_error=0.12521054058850456, win_rate=0.25, num_matches=6)}\n", + "scores={'0085d52d-e0d9-41c4-aef5-b94aa3ca7249': PlayerScore(elo=1509.1774437244123, elo_standard_error=0.1431452490296327, win_rate=0.5833333333333334, num_matches=6), '62ee87e2-060a-4a06-83dd-05865f0de5bc': PlayerScore(elo=1499.9260938098137, elo_standard_error=0.1520122994958684, win_rate=0.5, num_matches=6), '7ad75316-133a-47fb-931c-76ae19b7de9a': PlayerScore(elo=1518.3519208020473, elo_standard_error=0.15541509713088503, win_rate=0.6666666666666666, num_matches=6), '6371ddc0-f8dc-4f49-9c70-c2da8247f1cb': PlayerScore(elo=1472.5447069748268, elo_standard_error=0.12629615824891977, win_rate=0.25, num_matches=6)}\n", "}\n", "\n" ] diff --git a/src/intelligence_layer/evaluation/evaluation/evaluator/elo_evaluator.py b/src/intelligence_layer/evaluation/evaluation/evaluator/elo_evaluator.py index e7271288d..5a1a065c1 100644 --- a/src/intelligence_layer/evaluation/evaluation/evaluator/elo_evaluator.py +++ b/src/intelligence_layer/evaluation/evaluation/evaluator/elo_evaluator.py @@ -7,7 +7,9 @@ from intelligence_layer.core import Input, Output from intelligence_layer.evaluation.dataset.domain import Example, ExpectedOutput -from intelligence_layer.evaluation.evaluation.evaluator.evaluator import EvaluationLogic +from intelligence_layer.evaluation.evaluation.evaluator.incremental_evaluator import ( + IncrementalEvaluationLogic, +) from intelligence_layer.evaluation.run.domain import SuccessfulExampleOutput @@ -53,7 +55,9 @@ class EloGradingInput(BaseModel): second_completion: str -class EloEvaluationLogic(EvaluationLogic[Input, Output, ExpectedOutput, Matches]): +class EloEvaluationLogic( + IncrementalEvaluationLogic[Input, Output, ExpectedOutput, Matches] +): def __init__(self) -> None: super().__init__() self._previous_run_output_ids: list[set[str]] = [] @@ -63,40 +67,6 @@ def set_previous_run_output_ids( ) -> None: self._previous_run_output_ids = previous_run_output_ids - @final - def do_evaluate( - self, - example: Example[Input, ExpectedOutput], - *output: SuccessfulExampleOutput[Output], - ) -> Matches: - """Executes the evaluation for this specific example. - - Responsible for comparing the input & expected output of a task to the - actually generated output. The difference to the standard :class:`EvaluationLogic`'s `do_evaluate` is that - this method will, in addition, send the collection of already evaluated outputs to `do_incremental_evaluate`. - - Args: - example: Input data of :class:`Example` to produce the output. - *output: Outputs of the :class:`Task`. - - Returns: - :class:`Matches`: The summary of the pairwise comparisons between the provided outputs. - """ - - already_evaluated_outputs = [] - for run_output_ids in self._previous_run_output_ids: - already_evaluated_outputs.append( - [ - current_output - for current_output in output - if current_output.run_id in run_output_ids - ] - ) - - return self.do_incremental_evaluate( - example, list(output), already_evaluated_outputs - ) - @final def do_incremental_evaluate( self, diff --git a/src/intelligence_layer/examples/__init__.py b/src/intelligence_layer/examples/__init__.py index 3c4391876..ba1e36532 100644 --- a/src/intelligence_layer/examples/__init__.py +++ b/src/intelligence_layer/examples/__init__.py @@ -57,9 +57,6 @@ from .qa.multiple_chunk_retriever_qa import ( MultipleChunkRetrieverQaOutput as MultipleChunkRetrieverQaOutput, ) -from .qa.elo_qa_evaluation_logic import ( - EloQaEvaluationLogic as EloQaEvaluationLogic, -) from .qa.retriever_based_qa import EnrichedSubanswer as EnrichedSubanswer from .qa.retriever_based_qa import RetrieverBasedQa as RetrieverBasedQa from .qa.retriever_based_qa import RetrieverBasedQaInput as RetrieverBasedQaInput diff --git a/tests/evaluation/test_elo_evaluation_logic.py b/tests/evaluation/test_elo_evaluation_logic.py index 74e35ee1b..196c2d217 100644 --- a/tests/evaluation/test_elo_evaluation_logic.py +++ b/tests/evaluation/test_elo_evaluation_logic.py @@ -1,4 +1,4 @@ -from typing import Sequence, Tuple +from typing import Sequence from dotenv import load_dotenv from pytest import fixture