|
331 | 331 | }, |
332 | 332 | { |
333 | 333 | "cell_type": "code", |
334 | | - "execution_count": 6, |
| 334 | + "execution_count": 13, |
335 | 335 | "metadata": {}, |
336 | 336 | "outputs": [ |
337 | 337 | { |
338 | 338 | "name": "stderr", |
339 | 339 | "output_type": "stream", |
340 | 340 | "text": [ |
341 | | - "Average Metric: 138 / 300 (46.0): 100%|██████████| 300/300 [00:02<00:00, 137.82it/s]\n" |
| 341 | + "Average Metric: 138 / 300 (46.0): 100%|██████████| 300/300 [00:00<00:00, 512.74it/s]\n" |
342 | 342 | ] |
343 | 343 | }, |
344 | 344 | { |
345 | 345 | "data": { |
346 | 346 | "text/html": [ |
347 | 347 | "<style type=\"text/css\">\n", |
348 | | - "#T_fe347 th {\n", |
| 348 | + "#T_e09c1 th {\n", |
349 | 349 | " text-align: left;\n", |
350 | 350 | "}\n", |
351 | | - "#T_fe347 td {\n", |
| 351 | + "#T_e09c1 td {\n", |
352 | 352 | " text-align: left;\n", |
353 | 353 | "}\n", |
354 | | - "#T_fe347_row0_col0, #T_fe347_row0_col1, #T_fe347_row0_col2, #T_fe347_row0_col3, #T_fe347_row0_col4, #T_fe347_row0_col5, #T_fe347_row1_col0, #T_fe347_row1_col1, #T_fe347_row1_col2, #T_fe347_row1_col3, #T_fe347_row1_col4, #T_fe347_row1_col5, #T_fe347_row2_col0, #T_fe347_row2_col1, #T_fe347_row2_col2, #T_fe347_row2_col3, #T_fe347_row2_col4, #T_fe347_row2_col5, #T_fe347_row3_col0, #T_fe347_row3_col1, #T_fe347_row3_col2, #T_fe347_row3_col3, #T_fe347_row3_col4, #T_fe347_row3_col5, #T_fe347_row4_col0, #T_fe347_row4_col1, #T_fe347_row4_col2, #T_fe347_row4_col3, #T_fe347_row4_col4, #T_fe347_row4_col5 {\n", |
| 354 | + "#T_e09c1_row0_col0, #T_e09c1_row0_col1, #T_e09c1_row0_col2, #T_e09c1_row0_col3, #T_e09c1_row0_col4, #T_e09c1_row0_col5, #T_e09c1_row1_col0, #T_e09c1_row1_col1, #T_e09c1_row1_col2, #T_e09c1_row1_col3, #T_e09c1_row1_col4, #T_e09c1_row1_col5, #T_e09c1_row2_col0, #T_e09c1_row2_col1, #T_e09c1_row2_col2, #T_e09c1_row2_col3, #T_e09c1_row2_col4, #T_e09c1_row2_col5, #T_e09c1_row3_col0, #T_e09c1_row3_col1, #T_e09c1_row3_col2, #T_e09c1_row3_col3, #T_e09c1_row3_col4, #T_e09c1_row3_col5, #T_e09c1_row4_col0, #T_e09c1_row4_col1, #T_e09c1_row4_col2, #T_e09c1_row4_col3, #T_e09c1_row4_col4, #T_e09c1_row4_col5 {\n", |
355 | 355 | " text-align: left;\n", |
356 | 356 | " white-space: pre-wrap;\n", |
357 | 357 | " word-wrap: break-word;\n", |
358 | 358 | " max-width: 400px;\n", |
359 | 359 | "}\n", |
360 | 360 | "</style>\n", |
361 | | - "<table id=\"T_fe347\">\n", |
| 361 | + "<table id=\"T_e09c1\">\n", |
362 | 362 | " <thead>\n", |
363 | 363 | " <tr>\n", |
364 | 364 | " <th class=\"blank level0\" > </th>\n", |
365 | | - " <th id=\"T_fe347_level0_col0\" class=\"col_heading level0 col0\" >question</th>\n", |
366 | | - " <th id=\"T_fe347_level0_col1\" class=\"col_heading level0 col1\" >example_answer</th>\n", |
367 | | - " <th id=\"T_fe347_level0_col2\" class=\"col_heading level0 col2\" >gold_titles</th>\n", |
368 | | - " <th id=\"T_fe347_level0_col3\" class=\"col_heading level0 col3\" >observations</th>\n", |
369 | | - " <th id=\"T_fe347_level0_col4\" class=\"col_heading level0 col4\" >pred_answer</th>\n", |
370 | | - " <th id=\"T_fe347_level0_col5\" class=\"col_heading level0 col5\" >answer_exact_match</th>\n", |
| 365 | + " <th id=\"T_e09c1_level0_col0\" class=\"col_heading level0 col0\" >question</th>\n", |
| 366 | + " <th id=\"T_e09c1_level0_col1\" class=\"col_heading level0 col1\" >example_answer</th>\n", |
| 367 | + " <th id=\"T_e09c1_level0_col2\" class=\"col_heading level0 col2\" >gold_titles</th>\n", |
| 368 | + " <th id=\"T_e09c1_level0_col3\" class=\"col_heading level0 col3\" >observations</th>\n", |
| 369 | + " <th id=\"T_e09c1_level0_col4\" class=\"col_heading level0 col4\" >pred_answer</th>\n", |
| 370 | + " <th id=\"T_e09c1_level0_col5\" class=\"col_heading level0 col5\" >answer_exact_match</th>\n", |
371 | 371 | " </tr>\n", |
372 | 372 | " </thead>\n", |
373 | 373 | " <tbody>\n", |
374 | 374 | " <tr>\n", |
375 | | - " <th id=\"T_fe347_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n", |
376 | | - " <td id=\"T_fe347_row0_col0\" class=\"data row0 col0\" >Are both Cangzhou and Qionghai in the Hebei province of China?</td>\n", |
377 | | - " <td id=\"T_fe347_row0_col1\" class=\"data row0 col1\" >no</td>\n", |
378 | | - " <td id=\"T_fe347_row0_col2\" class=\"data row0 col2\" >{'Cangzhou', 'Qionghai'}</td>\n", |
379 | | - " <td id=\"T_fe347_row0_col3\" class=\"data row0 col3\" >[['Cangzhou | Cangzhou () is a prefecture-level city in eastern Hebei province, People\\'s Republic of China. At the 2010 census, Cangzhou\\'s built-up (\"or metro\") area...</td>\n", |
380 | | - " <td id=\"T_fe347_row0_col4\" class=\"data row0 col4\" >no</td>\n", |
381 | | - " <td id=\"T_fe347_row0_col5\" class=\"data row0 col5\" >✔️ [True]</td>\n", |
| 375 | + " <th id=\"T_e09c1_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n", |
| 376 | + " <td id=\"T_e09c1_row0_col0\" class=\"data row0 col0\" >Are both Cangzhou and Qionghai in the Hebei province of China?</td>\n", |
| 377 | + " <td id=\"T_e09c1_row0_col1\" class=\"data row0 col1\" >no</td>\n", |
| 378 | + " <td id=\"T_e09c1_row0_col2\" class=\"data row0 col2\" >{'Cangzhou', 'Qionghai'}</td>\n", |
| 379 | + " <td id=\"T_e09c1_row0_col3\" class=\"data row0 col3\" >[['Cangzhou | Cangzhou () is a prefecture-level city in eastern Hebei province, People\\'s Republic of China. At the 2010 census, Cangzhou\\'s built-up (\"or metro\") area...</td>\n", |
| 380 | + " <td id=\"T_e09c1_row0_col4\" class=\"data row0 col4\" >no</td>\n", |
| 381 | + " <td id=\"T_e09c1_row0_col5\" class=\"data row0 col5\" >✔️ [True]</td>\n", |
382 | 382 | " </tr>\n", |
383 | 383 | " <tr>\n", |
384 | | - " <th id=\"T_fe347_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n", |
385 | | - " <td id=\"T_fe347_row1_col0\" class=\"data row1 col0\" >Who conducts the draft in which Marc-Andre Fleury was drafted to the Vegas Golden Knights for the 2017-18 season?</td>\n", |
386 | | - " <td id=\"T_fe347_row1_col1\" class=\"data row1 col1\" >National Hockey League</td>\n", |
387 | | - " <td id=\"T_fe347_row1_col2\" class=\"data row1 col2\" >{'2017 NHL Expansion Draft', '2017–18 Pittsburgh Penguins season'}</td>\n", |
388 | | - " <td id=\"T_fe347_row1_col3\" class=\"data row1 col3\" >[['2017–18 Pittsburgh Penguins season | The 2017–18 Pittsburgh Penguins season will be the 51st season for the National Hockey League ice hockey team that was...</td>\n", |
389 | | - " <td id=\"T_fe347_row1_col4\" class=\"data row1 col4\" >National Hockey League</td>\n", |
390 | | - " <td id=\"T_fe347_row1_col5\" class=\"data row1 col5\" >✔️ [True]</td>\n", |
| 384 | + " <th id=\"T_e09c1_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n", |
| 385 | + " <td id=\"T_e09c1_row1_col0\" class=\"data row1 col0\" >Who conducts the draft in which Marc-Andre Fleury was drafted to the Vegas Golden Knights for the 2017-18 season?</td>\n", |
| 386 | + " <td id=\"T_e09c1_row1_col1\" class=\"data row1 col1\" >National Hockey League</td>\n", |
| 387 | + " <td id=\"T_e09c1_row1_col2\" class=\"data row1 col2\" >{'2017 NHL Expansion Draft', '2017–18 Pittsburgh Penguins season'}</td>\n", |
| 388 | + " <td id=\"T_e09c1_row1_col3\" class=\"data row1 col3\" >[['2017–18 Pittsburgh Penguins season | The 2017–18 Pittsburgh Penguins season will be the 51st season for the National Hockey League ice hockey team that was...</td>\n", |
| 389 | + " <td id=\"T_e09c1_row1_col4\" class=\"data row1 col4\" >National Hockey League</td>\n", |
| 390 | + " <td id=\"T_e09c1_row1_col5\" class=\"data row1 col5\" >✔️ [True]</td>\n", |
391 | 391 | " </tr>\n", |
392 | 392 | " <tr>\n", |
393 | | - " <th id=\"T_fe347_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n", |
394 | | - " <td id=\"T_fe347_row2_col0\" class=\"data row2 col0\" >The Wings entered a new era, following the retirement of which Canadian retired professional ice hockey player and current general manager of the Tampa Bay...</td>\n", |
395 | | - " <td id=\"T_fe347_row2_col1\" class=\"data row2 col1\" >Steve Yzerman</td>\n", |
396 | | - " <td id=\"T_fe347_row2_col2\" class=\"data row2 col2\" >{'2006–07 Detroit Red Wings season', 'Steve Yzerman'}</td>\n", |
397 | | - " <td id=\"T_fe347_row2_col3\" class=\"data row2 col3\" >[['Steve Yzerman | Stephen Gregory \"Steve\" Yzerman ( ; born May 9, 1965) is a Canadian retired professional ice hockey player and current general manager...</td>\n", |
398 | | - " <td id=\"T_fe347_row2_col4\" class=\"data row2 col4\" >Steve Yzerman</td>\n", |
399 | | - " <td id=\"T_fe347_row2_col5\" class=\"data row2 col5\" >✔️ [True]</td>\n", |
| 393 | + " <th id=\"T_e09c1_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n", |
| 394 | + " <td id=\"T_e09c1_row2_col0\" class=\"data row2 col0\" >The Wings entered a new era, following the retirement of which Canadian retired professional ice hockey player and current general manager of the Tampa Bay...</td>\n", |
| 395 | + " <td id=\"T_e09c1_row2_col1\" class=\"data row2 col1\" >Steve Yzerman</td>\n", |
| 396 | + " <td id=\"T_e09c1_row2_col2\" class=\"data row2 col2\" >{'2006–07 Detroit Red Wings season', 'Steve Yzerman'}</td>\n", |
| 397 | + " <td id=\"T_e09c1_row2_col3\" class=\"data row2 col3\" >[['Steve Yzerman | Stephen Gregory \"Steve\" Yzerman ( ; born May 9, 1965) is a Canadian retired professional ice hockey player and current general manager...</td>\n", |
| 398 | + " <td id=\"T_e09c1_row2_col4\" class=\"data row2 col4\" >Steve Yzerman</td>\n", |
| 399 | + " <td id=\"T_e09c1_row2_col5\" class=\"data row2 col5\" >✔️ [True]</td>\n", |
400 | 400 | " </tr>\n", |
401 | 401 | " <tr>\n", |
402 | | - " <th id=\"T_fe347_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n", |
403 | | - " <td id=\"T_fe347_row3_col0\" class=\"data row3 col0\" >What river is near the Crichton Collegiate Church?</td>\n", |
404 | | - " <td id=\"T_fe347_row3_col1\" class=\"data row3 col1\" >the River Tyne</td>\n", |
405 | | - " <td id=\"T_fe347_row3_col2\" class=\"data row3 col2\" >{'Crichton Collegiate Church', 'Crichton Castle'}</td>\n", |
406 | | - " <td id=\"T_fe347_row3_col3\" class=\"data row3 col3\" >[[\"Crichton Collegiate Church | Crichton Collegiate Church is situated about 0.6 mi south west of the hamlet of Crichton in Midlothian, Scotland. Crichton itself is...</td>\n", |
407 | | - " <td id=\"T_fe347_row3_col4\" class=\"data row3 col4\" >Crichton Collegiate Church is located in Midlothian, Scotland, near the hamlet of Crichton, about 7.5 miles south of Edinburgh.</td>\n", |
408 | | - " <td id=\"T_fe347_row3_col5\" class=\"data row3 col5\" >False</td>\n", |
| 402 | + " <th id=\"T_e09c1_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n", |
| 403 | + " <td id=\"T_e09c1_row3_col0\" class=\"data row3 col0\" >What river is near the Crichton Collegiate Church?</td>\n", |
| 404 | + " <td id=\"T_e09c1_row3_col1\" class=\"data row3 col1\" >the River Tyne</td>\n", |
| 405 | + " <td id=\"T_e09c1_row3_col2\" class=\"data row3 col2\" >{'Crichton Collegiate Church', 'Crichton Castle'}</td>\n", |
| 406 | + " <td id=\"T_e09c1_row3_col3\" class=\"data row3 col3\" >[[\"Crichton Collegiate Church | Crichton Collegiate Church is situated about 0.6 mi south west of the hamlet of Crichton in Midlothian, Scotland. Crichton itself is...</td>\n", |
| 407 | + " <td id=\"T_e09c1_row3_col4\" class=\"data row3 col4\" >Crichton Collegiate Church is located in Midlothian, Scotland, near the hamlet of Crichton, about 7.5 miles south of Edinburgh.</td>\n", |
| 408 | + " <td id=\"T_e09c1_row3_col5\" class=\"data row3 col5\" >False</td>\n", |
409 | 409 | " </tr>\n", |
410 | 410 | " <tr>\n", |
411 | | - " <th id=\"T_fe347_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n", |
412 | | - " <td id=\"T_fe347_row4_col0\" class=\"data row4 col0\" >In the 10th Century A.D. Ealhswith had a son called Æthelweard by which English king?</td>\n", |
413 | | - " <td id=\"T_fe347_row4_col1\" class=\"data row4 col1\" >King Alfred the Great</td>\n", |
414 | | - " <td id=\"T_fe347_row4_col2\" class=\"data row4 col2\" >{'Ealhswith', 'Æthelweard (son of Alfred)'}</td>\n", |
415 | | - " <td id=\"T_fe347_row4_col3\" class=\"data row4 col3\" >[['Æthelweard (son of Alfred) | Æthelweard (d. 920 or 922) was the younger son of King Alfred the Great and Ealhswith.'], ['Æthelstan of Kent |...</td>\n", |
416 | | - " <td id=\"T_fe347_row4_col4\" class=\"data row4 col4\" >Alfred the Great</td>\n", |
417 | | - " <td id=\"T_fe347_row4_col5\" class=\"data row4 col5\" >False</td>\n", |
| 411 | + " <th id=\"T_e09c1_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n", |
| 412 | + " <td id=\"T_e09c1_row4_col0\" class=\"data row4 col0\" >In the 10th Century A.D. Ealhswith had a son called Æthelweard by which English king?</td>\n", |
| 413 | + " <td id=\"T_e09c1_row4_col1\" class=\"data row4 col1\" >King Alfred the Great</td>\n", |
| 414 | + " <td id=\"T_e09c1_row4_col2\" class=\"data row4 col2\" >{'Ealhswith', 'Æthelweard (son of Alfred)'}</td>\n", |
| 415 | + " <td id=\"T_e09c1_row4_col3\" class=\"data row4 col3\" >[['Æthelweard (son of Alfred) | Æthelweard (d. 920 or 922) was the younger son of King Alfred the Great and Ealhswith.'], ['Æthelstan of Kent |...</td>\n", |
| 416 | + " <td id=\"T_e09c1_row4_col4\" class=\"data row4 col4\" >Alfred the Great</td>\n", |
| 417 | + " <td id=\"T_e09c1_row4_col5\" class=\"data row4 col5\" >False</td>\n", |
418 | 418 | " </tr>\n", |
419 | 419 | " </tbody>\n", |
420 | 420 | "</table>\n" |
421 | 421 | ], |
422 | 422 | "text/plain": [ |
423 | | - "<pandas.io.formats.style.Styler at 0x7f216eaed6f0>" |
| 423 | + "<pandas.io.formats.style.Styler at 0x7f2163882380>" |
424 | 424 | ] |
425 | 425 | }, |
426 | 426 | "metadata": {}, |
|
453 | 453 | "46.0" |
454 | 454 | ] |
455 | 455 | }, |
456 | | - "execution_count": 6, |
| 456 | + "execution_count": 13, |
457 | 457 | "metadata": {}, |
458 | 458 | "output_type": "execute_result" |
459 | 459 | } |
|
857 | 857 | "\t\treturn self.aggregate(context=deduplicate(flatten([p.observations for p in preds])), question=question)\n", |
858 | 858 | "\t\n", |
859 | 859 | "optimized_aggregator = optimizer.compile(aggregator, trainset=trainset, valset=valset)\n", |
| 860 | + "\n", |
| 861 | + "# Use it!\n", |
| 862 | + "optimized_aggregator(question=\"How many storeys are in the castle that David Gregory inherited?\")\n", |
860 | 863 | "```" |
861 | 864 | ] |
862 | 865 | }, |
|
0 commit comments