{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# QASPER evaluation"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/ag2435/anaconda3/envs/arxiv-agent/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n"
]
}
],
"source": [
"import json\n",
"import os\n",
"import plotly.express as px\n",
"import plotly.graph_objects as go\n",
"import dataset_reader\n",
"from transformers.tokenization_utils_base import BatchEncoding\n",
"from datetime import date\n",
"from tqdm import tqdm"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"input_paths = {\n",
" 'train': 'original_data/qasper-train-dev-v0.3/qasper-train-v0.3.json',\n",
" 'dev': 'original_data/qasper-train-dev-v0.3/qasper-dev-v0.3.json',\n",
" 'test': 'original_data/qasper-test-and-evaluator-v0.3/qasper-test-v0.3.json',\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"output_path = 'data'\n",
"split = 'dev'\n",
"input_path = input_paths[split]\n",
"assert split in input_path"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"reader = dataset_reader.QasperReader(include_global_attention_mask=False)\n",
"instances = list(reader._read(input_path))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"defaultdict(int,\n",
" {'number of documents': 281,\n",
" 'number of questions': 1005,\n",
" 'number of answers': 1764,\n",
" 'questions with multiple answers': 744,\n",
" 'extractive questions': 962,\n",
" 'extractive questions with multiple spans': 406,\n",
" 'multiple_evidence_spans_count': 536,\n",
" 'answers with table or figure as evidence': 212,\n",
" 'freeform answers': 431,\n",
" 'yes/no questions': 208,\n",
" 'answers with no evidence': 212,\n",
" 'unanswerable questions': 163,\n",
" 'number of truncated contexts': 15})"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"reader._stats"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# filter instances that have valid html\n",
"from arxiv_agent.tools.paper.utils import get_soup\n",
"from functools import cache\n",
"from time import sleep\n",
"\n",
"@cache\n",
"def has_html(arxiv_id):\n",
" sleep(0.1)\n",
" try:\n",
" ERROR_MSG = \"Conversion to HTML had a Fatal error and exited abruptly. This document may be truncated or damaged.\"\n",
" soup = get_soup(arxiv_id)\n",
" return ERROR_MSG not in soup.text\n",
" except Exception as e:\n",
" return False"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"has_html(instances[0]['metadata']['article_id'])"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"has_html(\"2003.03106\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"alignmentgroup": "True",
"bingroup": "x",
"hovertemplate": "variable=0
value=%{x}
count=%{y}",
"legendgroup": "0",
"marker": {
"color": "#636efa",
"pattern": {
"shape": ""
}
},
"name": "0",
"offsetgroup": "0",
"orientation": "v",
"showlegend": true,
"type": "histogram",
"x": [
5733,
5733,
5731,
5730,
4513,
4516,
4518,
5774,
5773,
9106,
9105,
3078,
3086,
3078,
3700,
3700,
7140,
7139,
7137,
7139,
6328,
6323,
6266,
6262,
6268,
6265,
4365,
4363,
4364,
4364,
5011,
5008,
5009,
5013,
5012,
5023,
5011,
2844,
2845,
2852,
2845,
5833,
5836,
5802,
2088,
1901,
1887,
1887,
6574,
6576,
6576,
3748,
3757,
3306,
3308,
2717,
2714,
2712,
2712,
8783,
8776,
8779,
3293,
3294,
3295,
6143,
6144,
6144,
3295,
3297,
3292,
4405,
4407,
4406,
5519,
5518,
5970,
5971,
5980,
5974,
9547,
9551,
9545,
9546,
9549,
3071,
3068,
3069,
3071,
3071,
3069,
3071,
2525,
2528,
2529,
3443,
3317,
3314,
3315,
8898,
8899,
8897,
8908,
8910,
8900,
7094,
7094,
7092,
7094,
5009,
5008,
4775,
4787,
4774,
4784,
4781,
4752,
4749,
4750,
4749,
2445,
2438,
2440,
3587,
3589,
3586,
3587,
5803,
5796,
5791,
5793,
5793,
7004,
7010,
4490,
4488,
4492,
2360,
2365,
2364,
2356,
8719,
5391,
5393,
3235,
3234,
3236,
3235,
5710,
5716,
5722,
5704,
5219,
5223,
5227,
16384,
5040,
5038,
5038,
2439,
2442,
2457,
2992,
2993,
3329,
3327,
6000,
6000,
4292,
4290,
4293,
5760,
5754,
5759,
5655,
5656,
7139,
7134,
6456,
3187,
3187,
3190,
4163,
4156,
6353,
3565,
3568,
3567,
3566,
2043,
2040,
2044,
2398,
2389,
3818,
3816,
11074,
11074,
11068,
5279,
1920,
4290,
4291,
4287,
4290,
4288,
4289,
4291,
2406,
1725,
6755,
6756,
6747,
6747,
1350,
1352,
7931,
7934,
3908,
3257,
3260,
3258,
3259,
3311,
3313,
3311,
3315,
7236,
7227,
3216,
3212,
4236,
4234,
3354,
3362,
3357,
2981,
4021,
4019,
6001,
2785,
2786,
2784,
2785,
5133,
5138,
3868,
3863,
3861,
1821,
1822,
1823,
1825,
6591,
6584,
6037,
3126,
3126,
3125,
1924,
11591,
6053,
6055,
2829,
2830,
1607,
1606,
1326,
1312,
1316,
1315,
5716,
5717,
5715,
1355,
1354,
6947,
5796,
6755,
4012,
4651,
4648,
2859,
4779,
4777,
3529,
6541,
5796,
5582,
4467,
4469,
4476,
4466,
4469,
4469,
4469,
4472,
4472,
4472,
4482,
4473,
3970,
3963,
3967,
3972,
3965,
3965,
3962,
3966,
2272,
2267,
2264,
2265,
2263,
2262,
2268,
6080,
6079,
6078,
6078,
6076,
6075,
6032,
6035,
6032,
6038,
6034,
6035,
3171,
3170,
3167,
3169,
3170,
3170,
3534,
3536,
3531,
3530,
3535,
3531,
3359,
3344,
3346,
3349,
3347,
3345,
6846,
6845,
6845,
6848,
6847,
6849,
2368,
2356,
2357,
2357,
2358,
2358,
10482,
10479,
10480,
10486,
10488,
10488,
3688,
3688,
3687,
3686,
3690,
3687,
2963,
2966,
2964,
2961,
2961,
2964,
2970,
2974,
2966,
2970,
2965,
5805,
5803,
5805,
5805,
5806,
3078,
3083,
3077,
3079,
3078,
3077,
3076,
3078,
3080,
3081,
6430,
6431,
6434,
6427,
6455,
3311,
3310,
3316,
3313,
3312,
4734,
4730,
4729,
4731,
4731,
2707,
2709,
2707,
2709,
2709,
3225,
3224,
3225,
3228,
3225,
8185,
8189,
8180,
8180,
8188,
6247,
6252,
6252,
6252,
6254,
2887,
2890,
2885,
2887,
2887,
3792,
3808,
3791,
3798,
3794,
5706,
5708,
5702,
5705,
5717,
5376,
5378,
5377,
5377,
5378,
3218,
3222,
3214,
3216,
3226,
2539,
2541,
2539,
2537,
2539,
2542,
2548,
2542,
2546,
5168,
5169,
5169,
5171,
2625,
2632,
2629,
2625,
5654,
5655,
5653,
5654,
5388,
5383,
5383,
5393,
3920,
3916,
3915,
3915,
5922,
5917,
5917,
5918,
10339,
10339,
10340,
10341,
6080,
6084,
6085,
6080,
6774,
6785,
6771,
6770,
5603,
5602,
5601,
5599,
4814,
4821,
4816,
4820,
4136,
4138,
4136,
4133,
6096,
6102,
6095,
6106,
3676,
3675,
3674,
3676,
2708,
2699,
2701,
2700,
3666,
3669,
3668,
3666,
5435,
5433,
5427,
5429,
2961,
2960,
2961,
2972,
5848,
5858,
5846,
5844,
5849,
5845,
5846,
5847,
5540,
5543,
5542,
5547,
3397,
3396,
3397,
3394,
8311,
8315,
8315,
8312,
2588,
2592,
2590,
2596,
5011,
5009,
5013,
5012,
6658,
6662,
6659,
6664,
8070,
8072,
8071,
8069,
5888,
5891,
5890,
5902,
4291,
4288,
4285,
4286,
6038,
6040,
6036,
6040,
6057,
6055,
6056,
6076,
6059,
6063,
6055,
5273,
5277,
5274,
5281,
5283,
5275,
5282,
4648,
4647,
4645,
4646,
4645,
4646,
5362,
5374,
5366,
16384,
16384,
16384,
16384,
16384,
16384,
5123,
5123,
5125,
5123,
5125,
5125,
4048,
4053,
4047,
2352,
2351,
2350,
2206,
2208,
2208,
6689,
6686,
6688,
8231,
8235,
8238,
5167,
5170,
5171,
5173,
5173,
5171,
2398,
2401,
2403,
16384,
16384,
16384,
5427,
5434,
5429,
2649,
2646,
2642,
4696,
4697,
4696,
5791,
5790,
5795,
5788,
5789,
5790,
2001,
2002,
2004,
6642,
6649,
6649,
4812,
4813,
4817,
5693,
5690,
5693,
4395,
4393,
4391,
3775,
3777,
3776,
2829,
2826,
2825,
7396,
7397,
7413,
5952,
5945,
5950,
1679,
1680,
1675,
4004,
4009,
4006,
4003,
4004,
4005,
3382,
3385,
3387,
3383,
3386,
3385,
5598,
5591,
5589,
5697,
5694,
5696,
5700,
5701,
5696,
16384,
16384,
16384,
6748,
6745,
6745,
4425,
4425,
4425,
3747,
3736,
3732,
3982,
3979,
3977,
6320,
6321,
6321,
3600,
3600,
3598,
3600,
3604,
3604,
3604,
3603,
3399,
3390,
3389,
3392,
3392,
5204,
5198,
5205,
5200,
5197,
1591,
1581,
1580,
1578,
1580,
5245,
5247,
5243,
5243,
5247,
3630,
3626,
3621,
3623,
3623,
3164,
3166,
3168,
3163,
3172,
5815,
5813,
5815,
5820,
5813,
5815,
5811,
5812,
5815,
4730,
4733,
4729,
4728,
7209,
7213,
7212,
7211,
5846,
5848,
5847,
5846,
2562,
2558,
2560,
2556,
2558,
2567,
4925,
4932,
4928,
4928,
2476,
2480,
5594,
5588,
5586,
5587,
5585,
5585,
6345,
6347,
6602,
6604,
6605,
6606,
6601,
6601,
2579,
2582,
4335,
4337,
4340,
4337,
6748,
6746,
2977,
2980,
9890,
9891,
4386,
4392,
5310,
5308,
5313,
5314,
4040,
4045,
3517,
3516,
2192,
2189,
2190,
2188,
2188,
2191,
7173,
7171,
7173,
7182,
7232,
7236,
3163,
3163,
3162,
3161,
3165,
3164,
16384,
16384,
5582,
5584,
5580,
5588,
5585,
5583,
2817,
2814,
5069,
5072,
2988,
2988,
10441,
10446,
6473,
6470,
8290,
8288,
4108,
4097,
4095,
4102,
3610,
3616,
5276,
5283,
5270,
5272,
5271,
5272,
2548,
2548,
3370,
3367,
3367,
3366,
3679,
3684,
3690,
3677,
3779,
3782,
3779,
3780,
3890,
3892,
3893,
3896,
3897,
3894,
919,
924,
5276,
5276,
7310,
7310,
7316,
7308,
3975,
3977,
3974,
3984,
6001,
6003,
6009,
5996,
2727,
2723,
2715,
2713,
4367,
4370,
3091,
3089,
3061,
3058,
4907,
4912,
6586,
6593,
3045,
3043,
5984,
5978,
5980,
5986,
6352,
6359,
6354,
6355,
3437,
3444,
6259,
6252,
6776,
6776,
3057,
3047,
4755,
4759,
5615,
5617,
5619,
5617,
5621,
5614,
5616,
5758,
5756,
5761,
5757,
5757,
2111,
2113,
2118,
2112,
2112,
4682,
4681,
4683,
4684,
4683,
4547,
4551,
4546,
4550,
4549,
6552,
6562,
6553,
6555,
6552,
6433,
6434,
6437,
6430,
6432,
4966,
4965,
4967,
4967,
4964,
10870,
10869,
10871,
10867,
10881
],
"xaxis": "x",
"yaxis": "y"
}
],
"layout": {
"barmode": "relative",
"legend": {
"title": {
"text": "variable"
},
"tracegroupgap": 0
},
"template": {
"data": {
"bar": [
{
"error_x": {
"color": "#2a3f5f"
},
"error_y": {
"color": "#2a3f5f"
},
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "bar"
}
],
"barpolar": [
{
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "barpolar"
}
],
"carpet": [
{
"aaxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"baxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"type": "carpet"
}
],
"choropleth": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "choropleth"
}
],
"contour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "contour"
}
],
"contourcarpet": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "contourcarpet"
}
],
"heatmap": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "heatmap"
}
],
"heatmapgl": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "heatmapgl"
}
],
"histogram": [
{
"marker": {
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "histogram"
}
],
"histogram2d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "histogram2d"
}
],
"histogram2dcontour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "histogram2dcontour"
}
],
"mesh3d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "mesh3d"
}
],
"parcoords": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "parcoords"
}
],
"pie": [
{
"automargin": true,
"type": "pie"
}
],
"scatter": [
{
"fillpattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
},
"type": "scatter"
}
],
"scatter3d": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatter3d"
}
],
"scattercarpet": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattercarpet"
}
],
"scattergeo": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergeo"
}
],
"scattergl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergl"
}
],
"scattermapbox": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermapbox"
}
],
"scatterpolar": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolar"
}
],
"scatterpolargl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolargl"
}
],
"scatterternary": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterternary"
}
],
"surface": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "surface"
}
],
"table": [
{
"cells": {
"fill": {
"color": "#EBF0F8"
},
"line": {
"color": "white"
}
},
"header": {
"fill": {
"color": "#C8D4E3"
},
"line": {
"color": "white"
}
},
"type": "table"
}
]
},
"layout": {
"annotationdefaults": {
"arrowcolor": "#2a3f5f",
"arrowhead": 0,
"arrowwidth": 1
},
"autotypenumbers": "strict",
"coloraxis": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"colorscale": {
"diverging": [
[
0,
"#8e0152"
],
[
0.1,
"#c51b7d"
],
[
0.2,
"#de77ae"
],
[
0.3,
"#f1b6da"
],
[
0.4,
"#fde0ef"
],
[
0.5,
"#f7f7f7"
],
[
0.6,
"#e6f5d0"
],
[
0.7,
"#b8e186"
],
[
0.8,
"#7fbc41"
],
[
0.9,
"#4d9221"
],
[
1,
"#276419"
]
],
"sequential": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"sequentialminus": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
]
},
"colorway": [
"#636efa",
"#EF553B",
"#00cc96",
"#ab63fa",
"#FFA15A",
"#19d3f3",
"#FF6692",
"#B6E880",
"#FF97FF",
"#FECB52"
],
"font": {
"color": "#2a3f5f"
},
"geo": {
"bgcolor": "white",
"lakecolor": "white",
"landcolor": "#E5ECF6",
"showlakes": true,
"showland": true,
"subunitcolor": "white"
},
"hoverlabel": {
"align": "left"
},
"hovermode": "closest",
"mapbox": {
"style": "light"
},
"paper_bgcolor": "white",
"plot_bgcolor": "#E5ECF6",
"polar": {
"angularaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"radialaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"scene": {
"xaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"yaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"zaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
}
},
"shapedefaults": {
"line": {
"color": "#2a3f5f"
}
},
"ternary": {
"aaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"baxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"caxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"title": {
"x": 0.05
},
"xaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
},
"yaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
}
}
},
"title": {
"text": "Histogram of question + context token lengths (total=1005)"
},
"xaxis": {
"anchor": "y",
"domain": [
0,
1
],
"title": {
"text": "value"
}
},
"yaxis": {
"anchor": "x",
"domain": [
0,
1
],
"title": {
"text": "count"
}
}
}
}
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# plot histogram of full_text lengths\n",
"question_token_lengths = []\n",
"for inst in instances:\n",
" question_token_lengths.append(len(inst['question_with_context']))\n",
" \n",
"px.histogram(question_token_lengths, \n",
" title=f'Histogram of question + context token lengths (total={len(question_token_lengths)})')"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# arxiv id to year\n",
"def article_id_to_date(article_id):\n",
" year = article_id[:2]\n",
" month = article_id[2:4]\n",
" dt = date(int('20' + year), int(month), 1)\n",
" return dt"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"datetime.date(2020, 1, 1)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"article_id_to_date('2001.0001')"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"# get year distribution\n",
"years = []\n",
"for inst in instances:\n",
" dt = article_id_to_date(inst['metadata']['article_id'])\n",
" # print(dt)\n",
" years.append(dt)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"alignmentgroup": "True",
"bingroup": "x",
"hovertemplate": "variable=0
value=%{x}
count=%{y}",
"legendgroup": "0",
"marker": {
"color": "#636efa",
"pattern": {
"shape": ""
}
},
"name": "0",
"offsetgroup": "0",
"orientation": "v",
"showlegend": true,
"type": "histogram",
"x": [
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2016-09-01",
"2016-09-01",
"2018-01-01",
"2018-01-01",
"2018-11-01",
"2018-11-01",
"2018-11-01",
"2019-09-01",
"2019-09-01",
"2017-04-01",
"2017-04-01",
"2017-04-01",
"2017-04-01",
"2019-09-01",
"2019-09-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2017-08-01",
"2017-08-01",
"2017-08-01",
"2017-08-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2019-09-01",
"2019-09-01",
"2016-05-01",
"2016-05-01",
"2016-05-01",
"2016-05-01",
"2018-04-01",
"2018-04-01",
"2018-09-01",
"2019-01-01",
"2016-12-01",
"2016-12-01",
"2016-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-10-01",
"2019-10-01",
"2016-03-01",
"2016-03-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2018-08-01",
"2018-08-01",
"2018-08-01",
"2019-06-01",
"2019-06-01",
"2019-06-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2020-04-01",
"2020-04-01",
"2016-11-01",
"2016-11-01",
"2016-11-01",
"2016-11-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2016-04-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2018-02-01",
"2018-02-01",
"2018-02-01",
"2018-02-01",
"2018-02-01",
"2018-02-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2017-10-01",
"2017-10-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2018-02-01",
"2018-02-01",
"2018-02-01",
"2018-02-01",
"2018-02-01",
"2020-04-01",
"2020-04-01",
"2017-10-01",
"2017-10-01",
"2017-10-01",
"2016-12-01",
"2016-12-01",
"2016-12-01",
"2016-12-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2019-06-01",
"2019-06-01",
"2019-06-01",
"2018-12-01",
"2016-11-01",
"2016-11-01",
"2016-11-01",
"2019-04-01",
"2019-04-01",
"2019-04-01",
"2019-11-01",
"2019-11-01",
"2017-06-01",
"2017-06-01",
"2019-09-01",
"2019-09-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2016-09-01",
"2016-09-01",
"2016-09-01",
"2016-04-01",
"2016-04-01",
"2016-12-01",
"2016-12-01",
"2016-08-01",
"2019-04-01",
"2019-04-01",
"2019-04-01",
"2019-12-01",
"2019-12-01",
"2016-03-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2017-02-01",
"2017-02-01",
"2017-02-01",
"2019-04-01",
"2019-04-01",
"2016-06-01",
"2016-06-01",
"2018-02-01",
"2018-02-01",
"2018-02-01",
"2019-09-01",
"2019-11-01",
"2017-12-01",
"2017-12-01",
"2017-12-01",
"2017-12-01",
"2017-12-01",
"2017-12-01",
"2017-12-01",
"2018-05-01",
"2019-07-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2020-01-01",
"2020-01-01",
"2019-09-01",
"2019-09-01",
"2017-01-01",
"2019-04-01",
"2019-04-01",
"2019-04-01",
"2019-04-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2019-09-01",
"2019-09-01",
"2016-04-01",
"2016-04-01",
"2016-08-01",
"2016-08-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2016-06-01",
"2018-03-01",
"2018-03-01",
"2019-10-01",
"2017-01-01",
"2017-01-01",
"2017-01-01",
"2017-01-01",
"2019-12-01",
"2019-12-01",
"2017-09-01",
"2017-09-01",
"2017-09-01",
"2018-06-01",
"2018-06-01",
"2018-06-01",
"2018-06-01",
"2018-11-01",
"2018-11-01",
"2018-06-01",
"2016-10-01",
"2016-10-01",
"2016-10-01",
"2020-03-01",
"2018-11-01",
"2018-05-01",
"2018-05-01",
"2019-04-01",
"2019-04-01",
"2019-09-01",
"2019-09-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2018-01-01",
"2018-01-01",
"2019-07-01",
"2020-02-01",
"2017-10-01",
"2018-04-01",
"2019-11-01",
"2019-11-01",
"2018-12-01",
"2019-11-01",
"2019-11-01",
"2018-11-01",
"2019-09-01",
"2017-01-01",
"2018-06-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2016-11-01",
"2016-11-01",
"2016-11-01",
"2016-11-01",
"2016-11-01",
"2016-11-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2017-07-01",
"2017-07-01",
"2017-07-01",
"2017-07-01",
"2017-07-01",
"2017-07-01",
"2018-06-01",
"2018-06-01",
"2018-06-01",
"2018-06-01",
"2018-06-01",
"2018-06-01",
"2019-04-01",
"2019-04-01",
"2019-04-01",
"2019-04-01",
"2019-04-01",
"2019-04-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2017-03-01",
"2017-03-01",
"2017-03-01",
"2017-03-01",
"2017-03-01",
"2017-03-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2017-06-01",
"2017-06-01",
"2017-06-01",
"2017-06-01",
"2017-06-01",
"2019-02-01",
"2019-02-01",
"2019-02-01",
"2019-02-01",
"2019-02-01",
"2019-02-01",
"2019-02-01",
"2019-02-01",
"2019-02-01",
"2019-02-01",
"2016-04-01",
"2016-04-01",
"2016-04-01",
"2016-04-01",
"2016-04-01",
"2019-05-01",
"2019-05-01",
"2019-05-01",
"2019-05-01",
"2019-05-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2017-07-01",
"2017-07-01",
"2017-07-01",
"2017-07-01",
"2017-07-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2020-04-01",
"2020-04-01",
"2020-04-01",
"2020-04-01",
"2020-04-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2017-06-01",
"2017-06-01",
"2017-06-01",
"2017-06-01",
"2017-06-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2016-12-01",
"2016-12-01",
"2016-12-01",
"2016-12-01",
"2016-12-01",
"2019-07-01",
"2019-07-01",
"2019-07-01",
"2019-07-01",
"2019-07-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2015-03-01",
"2015-03-01",
"2015-03-01",
"2015-03-01",
"2018-04-01",
"2018-04-01",
"2018-04-01",
"2018-04-01",
"2016-11-01",
"2016-11-01",
"2016-11-01",
"2016-11-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-06-01",
"2019-06-01",
"2019-06-01",
"2019-06-01",
"2019-03-01",
"2019-03-01",
"2019-03-01",
"2019-03-01",
"2017-12-01",
"2017-12-01",
"2017-12-01",
"2017-12-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-06-01",
"2018-06-01",
"2018-06-01",
"2018-06-01",
"2019-03-01",
"2019-03-01",
"2019-03-01",
"2019-03-01",
"2018-06-01",
"2018-06-01",
"2018-06-01",
"2018-06-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2018-08-01",
"2018-08-01",
"2018-08-01",
"2018-08-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2017-02-01",
"2017-02-01",
"2017-02-01",
"2017-02-01",
"2018-05-01",
"2018-05-01",
"2018-05-01",
"2018-05-01",
"2018-07-01",
"2018-07-01",
"2018-07-01",
"2018-07-01",
"2017-06-01",
"2017-06-01",
"2017-06-01",
"2017-06-01",
"2019-06-01",
"2019-06-01",
"2019-06-01",
"2019-06-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2018-11-01",
"2018-11-01",
"2018-11-01",
"2018-11-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2018-04-01",
"2018-04-01",
"2018-04-01",
"2018-04-01",
"2019-05-01",
"2019-05-01",
"2019-05-01",
"2019-05-01",
"2019-05-01",
"2019-05-01",
"2019-05-01",
"2016-03-01",
"2016-03-01",
"2016-03-01",
"2016-03-01",
"2016-03-01",
"2016-03-01",
"2016-03-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2016-10-01",
"2016-10-01",
"2016-10-01",
"2016-01-01",
"2016-01-01",
"2016-01-01",
"2016-01-01",
"2016-01-01",
"2016-01-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2016-10-01",
"2016-10-01",
"2016-10-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2016-10-01",
"2016-10-01",
"2016-10-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2017-08-01",
"2017-08-01",
"2017-08-01",
"2017-05-01",
"2017-05-01",
"2017-05-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2019-03-01",
"2019-03-01",
"2019-03-01",
"2019-03-01",
"2019-03-01",
"2019-03-01",
"2017-03-01",
"2017-03-01",
"2017-03-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-07-01",
"2019-07-01",
"2019-07-01",
"2017-03-01",
"2017-03-01",
"2017-03-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2017-07-01",
"2017-07-01",
"2017-07-01",
"2019-03-01",
"2019-03-01",
"2019-03-01",
"2019-12-01",
"2019-12-01",
"2019-12-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2018-01-01",
"2018-01-01",
"2018-01-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2016-11-01",
"2016-11-01",
"2016-11-01",
"2016-04-01",
"2016-04-01",
"2016-04-01",
"2018-02-01",
"2018-02-01",
"2018-02-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2016-05-01",
"2016-05-01",
"2016-05-01",
"2016-05-01",
"2016-05-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2020-03-01",
"2019-01-01",
"2019-01-01",
"2019-01-01",
"2019-01-01",
"2019-01-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2019-11-01",
"2016-05-01",
"2016-05-01",
"2016-05-01",
"2016-05-01",
"2016-05-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-01-01",
"2019-01-01",
"2019-01-01",
"2019-01-01",
"2019-01-01",
"2019-01-01",
"2019-01-01",
"2019-01-01",
"2019-01-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2018-09-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2018-03-01",
"2018-03-01",
"2018-03-01",
"2018-03-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-05-01",
"2019-05-01",
"2019-05-01",
"2019-05-01",
"2019-06-01",
"2019-06-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2018-10-01",
"2018-05-01",
"2018-05-01",
"2017-06-01",
"2017-06-01",
"2017-06-01",
"2017-06-01",
"2019-09-01",
"2019-09-01",
"2020-04-01",
"2020-04-01",
"2019-08-01",
"2019-08-01",
"2019-06-01",
"2019-06-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2017-05-01",
"2017-05-01",
"2020-03-01",
"2020-03-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2020-01-01",
"2019-10-01",
"2019-10-01",
"2018-05-01",
"2018-05-01",
"2018-05-01",
"2018-05-01",
"2018-05-01",
"2018-05-01",
"2020-03-01",
"2020-03-01",
"2017-04-01",
"2017-04-01",
"2017-04-01",
"2017-04-01",
"2017-04-01",
"2017-04-01",
"2020-03-01",
"2020-03-01",
"2016-08-01",
"2016-08-01",
"2019-06-01",
"2019-06-01",
"2019-01-01",
"2019-01-01",
"2018-05-01",
"2018-05-01",
"2018-06-01",
"2018-06-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-11-01",
"2019-11-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-07-01",
"2019-07-01",
"2016-08-01",
"2016-08-01",
"2016-08-01",
"2016-08-01",
"2017-05-01",
"2017-05-01",
"2017-05-01",
"2017-05-01",
"2019-06-01",
"2019-06-01",
"2019-06-01",
"2019-06-01",
"2017-12-01",
"2017-12-01",
"2017-12-01",
"2017-12-01",
"2017-12-01",
"2017-12-01",
"2020-01-01",
"2020-01-01",
"2018-08-01",
"2018-08-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-10-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-02-01",
"2019-02-01",
"2019-02-01",
"2019-02-01",
"2018-01-01",
"2018-01-01",
"2018-01-01",
"2018-01-01",
"2018-01-01",
"2018-01-01",
"2019-09-01",
"2019-09-01",
"2016-03-01",
"2016-03-01",
"2017-03-01",
"2017-03-01",
"2019-06-01",
"2019-06-01",
"2019-09-01",
"2019-09-01",
"2018-05-01",
"2018-05-01",
"2018-05-01",
"2018-05-01",
"2019-03-01",
"2019-03-01",
"2019-03-01",
"2019-03-01",
"2017-09-01",
"2017-09-01",
"2017-06-01",
"2017-06-01",
"2017-05-01",
"2017-05-01",
"2019-12-01",
"2019-12-01",
"2018-08-01",
"2018-08-01",
"2020-04-01",
"2020-04-01",
"2020-04-01",
"2020-04-01",
"2020-04-01",
"2020-04-01",
"2020-04-01",
"2019-05-01",
"2019-05-01",
"2019-05-01",
"2019-05-01",
"2019-05-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2020-02-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2017-09-01",
"2017-09-01",
"2017-09-01",
"2017-09-01",
"2017-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-09-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2019-08-01",
"2017-01-01",
"2017-01-01",
"2017-01-01",
"2017-01-01",
"2017-01-01",
"2019-07-01",
"2019-07-01",
"2019-07-01",
"2019-07-01",
"2019-07-01"
],
"xaxis": "x",
"yaxis": "y"
}
],
"layout": {
"barmode": "relative",
"legend": {
"title": {
"text": "variable"
},
"tracegroupgap": 0
},
"margin": {
"t": 60
},
"template": {
"data": {
"bar": [
{
"error_x": {
"color": "#2a3f5f"
},
"error_y": {
"color": "#2a3f5f"
},
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "bar"
}
],
"barpolar": [
{
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "barpolar"
}
],
"carpet": [
{
"aaxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"baxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"type": "carpet"
}
],
"choropleth": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "choropleth"
}
],
"contour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "contour"
}
],
"contourcarpet": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "contourcarpet"
}
],
"heatmap": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "heatmap"
}
],
"heatmapgl": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "heatmapgl"
}
],
"histogram": [
{
"marker": {
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "histogram"
}
],
"histogram2d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "histogram2d"
}
],
"histogram2dcontour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "histogram2dcontour"
}
],
"mesh3d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "mesh3d"
}
],
"parcoords": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "parcoords"
}
],
"pie": [
{
"automargin": true,
"type": "pie"
}
],
"scatter": [
{
"fillpattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
},
"type": "scatter"
}
],
"scatter3d": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatter3d"
}
],
"scattercarpet": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattercarpet"
}
],
"scattergeo": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergeo"
}
],
"scattergl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergl"
}
],
"scattermapbox": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermapbox"
}
],
"scatterpolar": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolar"
}
],
"scatterpolargl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolargl"
}
],
"scatterternary": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterternary"
}
],
"surface": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "surface"
}
],
"table": [
{
"cells": {
"fill": {
"color": "#EBF0F8"
},
"line": {
"color": "white"
}
},
"header": {
"fill": {
"color": "#C8D4E3"
},
"line": {
"color": "white"
}
},
"type": "table"
}
]
},
"layout": {
"annotationdefaults": {
"arrowcolor": "#2a3f5f",
"arrowhead": 0,
"arrowwidth": 1
},
"autotypenumbers": "strict",
"coloraxis": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"colorscale": {
"diverging": [
[
0,
"#8e0152"
],
[
0.1,
"#c51b7d"
],
[
0.2,
"#de77ae"
],
[
0.3,
"#f1b6da"
],
[
0.4,
"#fde0ef"
],
[
0.5,
"#f7f7f7"
],
[
0.6,
"#e6f5d0"
],
[
0.7,
"#b8e186"
],
[
0.8,
"#7fbc41"
],
[
0.9,
"#4d9221"
],
[
1,
"#276419"
]
],
"sequential": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"sequentialminus": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
]
},
"colorway": [
"#636efa",
"#EF553B",
"#00cc96",
"#ab63fa",
"#FFA15A",
"#19d3f3",
"#FF6692",
"#B6E880",
"#FF97FF",
"#FECB52"
],
"font": {
"color": "#2a3f5f"
},
"geo": {
"bgcolor": "white",
"lakecolor": "white",
"landcolor": "#E5ECF6",
"showlakes": true,
"showland": true,
"subunitcolor": "white"
},
"hoverlabel": {
"align": "left"
},
"hovermode": "closest",
"mapbox": {
"style": "light"
},
"paper_bgcolor": "white",
"plot_bgcolor": "#E5ECF6",
"polar": {
"angularaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"radialaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"scene": {
"xaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"yaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"zaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
}
},
"shapedefaults": {
"line": {
"color": "#2a3f5f"
}
},
"ternary": {
"aaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"baxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"caxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"title": {
"x": 0.05
},
"xaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
},
"yaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
}
}
},
"xaxis": {
"anchor": "y",
"domain": [
0,
1
],
"title": {
"text": "value"
}
},
"yaxis": {
"anchor": "x",
"domain": [
0,
1
],
"title": {
"text": "count"
}
}
}
}
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"px.histogram(years,)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Save instances to JSON"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"# recursively check the type of each field in the dataset\n",
"def check_type(data, level=0):\n",
" tabs = '\\t' * level\n",
" if isinstance(data, dict):\n",
" for key, value in data.items():\n",
" print(f'{tabs}{key}: {type(value)}')\n",
" check_type(value, level + 1)\n",
" elif isinstance(data, list):\n",
" for i in data:\n",
" check_type(i, level + 1)\n",
" else:\n",
" pass\n",
" # print(f'{tabs}{type(data)}')\n",
" # if isinstance(data, BatchEncoding):\n",
" # print(f'{tabs}{data[:100]}')"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"question_with_context: \n",
"paragraph_indices: \n",
"evidence: \n",
"answer: \n",
"metadata: \n",
"\tquestion: \n",
"\tquestion_tokens: \n",
"\tparagraphs: \n",
"\tcontext_tokens: \n",
"\tquestion_id: \n",
"\tarticle_id: \n",
"\tall_answers: \n",
"\t\t\ttext: \n",
"\t\t\ttype: \n",
"\t\t\ttext: \n",
"\t\t\ttype: \n",
"\tall_evidence: \n",
"\tall_evidence_masks: \n"
]
}
],
"source": [
"check_type(instances[0])"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
" 0%| | 0/1005 [00:00, ?it/s]huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
"To disable this warning, you can either:\n",
"\t- Avoid using `tokenizers` before the fork if possible\n",
"\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n",
"100%|██████████| 1005/1005 [01:27<00:00, 11.45it/s]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of instances: 1005\n",
"Number of instances with html: 978\n"
]
}
],
"source": [
"# save instances to file\n",
"with open(os.path.join(output_path, f'{split}_instances_with_html.json'), 'w') as f:\n",
" # pretty print json\n",
" instances_with_html = [inst for inst in tqdm(instances) if has_html(inst['metadata']['article_id'])]\n",
" print(f'Number of instances: {len(instances)}')\n",
" print(f'Number of instances with html: {len(instances_with_html)}')\n",
" json.dump(instances_with_html, f, indent=4)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "arxiv-agent",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}