File size: 52,495 Bytes
acef88c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"gpuType": "T4"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"source": [
"# Batch Processing for Multiple-Choice Questions"
],
"metadata": {
"id": "bjbqHUTuNFyd"
}
},
{
"cell_type": "markdown",
"source": [
"# 1. Install Litelines"
],
"metadata": {
"id": "B8jIr1KAKQWF"
}
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"id": "cvgtiC0Kcl-z"
},
"outputs": [],
"source": [
"%pip install --quiet --upgrade litelines"
]
},
{
"cell_type": "markdown",
"source": [
"## 2. Download a model and its tokenizer"
],
"metadata": {
"id": "-dLJS16ZNy97"
}
},
{
"cell_type": "code",
"source": [
"# Use cuda for faster inference\n",
"import torch\n",
"\n",
"device = torch.device(\"cuda\") if torch.cuda.is_available() else torch.device(\"cpu\")\n",
"assert device == torch.device(\"cuda\"), \"In the Runtime tab, please Change runtime type to GPU\""
],
"metadata": {
"id": "68zKdmOQcqLo"
},
"execution_count": 2,
"outputs": []
},
{
"cell_type": "code",
"source": [
"from transformers import AutoModelForCausalLM, AutoTokenizer\n",
"\n",
"MODEL_ID = \"Qwen/Qwen2.5-0.5B-Instruct\"\n",
"tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)\n",
"model = AutoModelForCausalLM.from_pretrained(MODEL_ID).to(device)"
],
"metadata": {
"id": "U-a-w5jwc6Xg"
},
"execution_count": 3,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## 3. Prepare the inputs to the LLM"
],
"metadata": {
"id": "ohUnAx9NJ7AV"
}
},
{
"cell_type": "code",
"source": [
"user_inputs = [\"What is the capital of France?\", \"What is the capital of Italy?\", \"What is the capital of Spain?\"]\n",
"alternatives = \"\"\"\n",
"A) Madrid\n",
"B) Paris\n",
"C) Rome\n",
"\"\"\"\n",
"messages = [[{\"role\": \"user\", \"content\": user_input + alternatives}] for user_input in user_inputs]\n",
"formatted_messages = [\n",
" tokenizer.apply_chat_template(message, tokenize=False, add_generation_prompt=True) for message in messages\n",
"]\n",
"inputs = tokenizer(\n",
" formatted_messages,\n",
" return_tensors=\"pt\",\n",
" padding=True,\n",
" truncation=True\n",
").to(device)\n",
"prompt_length = inputs['input_ids'].shape[-1]"
],
"metadata": {
"id": "6YLLQze67KV1"
},
"execution_count": 4,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## 4. Define a processor through a regular expression"
],
"metadata": {
"id": "9LaJrh0PKkcn"
}
},
{
"cell_type": "code",
"source": [
"from litelines.transformers import SchemaProcessor\n",
"\n",
"processor = SchemaProcessor(response_format=r\"A\\.|B\\.|C\\.\", tokenizer=tokenizer)\n",
"processor.show_graph()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 331
},
"id": "sVx6IzInKHoL",
"outputId": "9c3bf54f-95a5-4b7b-e870-dd7a3d2e45dd"
},
"execution_count": 5,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"<IPython.core.display.SVG object>"
],
"image/svg+xml": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"401pt\" height=\"232pt\" viewBox=\"0.00 0.00 401.00 232.00\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 228)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-228 397,-228 397,4 -4,4\"/>\n<text text-anchor=\"middle\" x=\"92\" y=\"-208.8\" font-family=\"Times,serif\" font-size=\"14.00\">Allowed Paths</text>\n<text text-anchor=\"middle\" x=\"92\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">Regular expression: A\\.|B\\.|C\\.</text>\n<!-- 0 -->\n<g id=\"node1\" class=\"node\">\n<title>0</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"109\" cy=\"-83\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"109\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n</g>\n<!-- 1 -->\n<g id=\"node2\" class=\"node\">\n<title>1</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"238\" cy=\"-148\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"238\" y=\"-144.3\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n</g>\n<!-- 0->1 -->\n<g id=\"edge2\" class=\"edge\">\n<title>0->1</title>\n<path fill=\"none\" stroke=\"black\" d=\"M118.83,-98.31C125,-107.68 134.08,-119.14 145,-126 164.59,-138.31 190.49,-143.74 209.81,-146.13\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"209.48,-149.61 219.79,-147.16 210.21,-142.65 209.48,-149.61\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"145.5,-165 145.5,-186 165.5,-186 165.5,-165 145.5,-165\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-165 145.5,-186 165.5,-186 165.5,-165 145.5,-165\"/>\n<text text-anchor=\"start\" x=\"150\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"165.5,-165 165.5,-186 202.5,-186 202.5,-165 165.5,-165\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-165 165.5,-186 202.5,-186 202.5,-165 165.5,-165\"/>\n<text text-anchor=\"start\" x=\"168.5\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-144 145.5,-165 165.5,-165 165.5,-144 145.5,-144\"/>\n<text text-anchor=\"start\" x=\"148.5\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">34</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-144 165.5,-165 202.5,-165 202.5,-144 165.5,-144\"/>\n<text text-anchor=\"start\" x=\"179\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\">C</text>\n</g>\n<!-- 2 -->\n<g id=\"node3\" class=\"node\">\n<title>2</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"238\" cy=\"-83\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"238\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n</g>\n<!-- 0->2 -->\n<g id=\"edge3\" class=\"edge\">\n<title>0->2</title>\n<path fill=\"none\" stroke=\"black\" d=\"M127.13,-83C148.24,-83 184.4,-83 209.44,-83\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"209.74,-86.5 219.74,-83 209.74,-79.5 209.74,-86.5\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"145.5,-104 145.5,-125 165.5,-125 165.5,-104 145.5,-104\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-104 145.5,-125 165.5,-125 165.5,-104 145.5,-104\"/>\n<text text-anchor=\"start\" x=\"150\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"165.5,-104 165.5,-125 202.5,-125 202.5,-104 165.5,-104\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-104 165.5,-125 202.5,-125 202.5,-104 165.5,-104\"/>\n<text text-anchor=\"start\" x=\"168.5\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-83 145.5,-104 165.5,-104 165.5,-83 145.5,-83\"/>\n<text text-anchor=\"start\" x=\"148.5\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">33</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-83 165.5,-104 202.5,-104 202.5,-83 165.5,-83\"/>\n<text text-anchor=\"start\" x=\"179\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\">B</text>\n</g>\n<!-- 3 -->\n<g id=\"node4\" class=\"node\">\n<title>3</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"238\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"238\" y=\"-14.3\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n</g>\n<!-- 0->3 -->\n<g id=\"edge4\" class=\"edge\">\n<title>0->3</title>\n<path fill=\"none\" stroke=\"black\" d=\"M117.98,-67.39C124.03,-57.17 133.28,-44.38 145,-37 164.45,-24.75 190.36,-20.23 209.73,-18.64\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"209.96,-22.13 219.73,-18.03 209.53,-15.15 209.96,-22.13\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"145.5,-58 145.5,-79 165.5,-79 165.5,-58 145.5,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-58 145.5,-79 165.5,-79 165.5,-58 145.5,-58\"/>\n<text text-anchor=\"start\" x=\"150\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"165.5,-58 165.5,-79 202.5,-79 202.5,-58 165.5,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-58 165.5,-79 202.5,-79 202.5,-58 165.5,-58\"/>\n<text text-anchor=\"start\" x=\"168.5\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-37 145.5,-58 165.5,-58 165.5,-37 145.5,-37\"/>\n<text text-anchor=\"start\" x=\"148.5\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">32</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-37 165.5,-58 202.5,-58 202.5,-37 165.5,-37\"/>\n<text text-anchor=\"start\" x=\"179\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\">A</text>\n</g>\n<!-- 4 -->\n<g id=\"node5\" class=\"node\">\n<title>4</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"371\" cy=\"-83\" rx=\"18\" ry=\"18\"/>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"371\" cy=\"-83\" rx=\"22\" ry=\"22\"/>\n<text text-anchor=\"middle\" x=\"371\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">4</text>\n</g>\n<!-- 1->4 -->\n<g id=\"edge5\" class=\"edge\">\n<title>1->4</title>\n<path fill=\"none\" stroke=\"black\" d=\"M256.07,-146.94C275.44,-145.08 307.4,-139.97 331,-126 338.44,-121.6 345.27,-115.32 351.07,-108.91\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"354.08,-110.77 357.83,-100.86 348.72,-106.27 354.08,-110.77\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"274.5,-165 274.5,-186 294.5,-186 294.5,-165 274.5,-165\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-165 274.5,-186 294.5,-186 294.5,-165 274.5,-165\"/>\n<text text-anchor=\"start\" x=\"279\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"294.5,-165 294.5,-186 331.5,-186 331.5,-165 294.5,-165\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-165 294.5,-186 331.5,-186 331.5,-165 294.5,-165\"/>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-144 274.5,-165 294.5,-165 294.5,-144 274.5,-144\"/>\n<text text-anchor=\"start\" x=\"277.5\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">13</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-144 294.5,-165 331.5,-165 331.5,-144 294.5,-144\"/>\n<text text-anchor=\"start\" x=\"311\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\">.</text>\n</g>\n<!-- 2->4 -->\n<g id=\"edge6\" class=\"edge\">\n<title>2->4</title>\n<path fill=\"none\" stroke=\"black\" d=\"M256.13,-83C277.09,-83 313.01,-83 338.9,-83\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"338.97,-86.5 348.97,-83 338.97,-79.5 338.97,-86.5\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"274.5,-104 274.5,-125 294.5,-125 294.5,-104 274.5,-104\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-104 274.5,-125 294.5,-125 294.5,-104 274.5,-104\"/>\n<text text-anchor=\"start\" x=\"279\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"294.5,-104 294.5,-125 331.5,-125 331.5,-104 294.5,-104\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-104 294.5,-125 331.5,-125 331.5,-104 294.5,-104\"/>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-83 274.5,-104 294.5,-104 294.5,-83 274.5,-83\"/>\n<text text-anchor=\"start\" x=\"277.5\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">13</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-83 294.5,-104 331.5,-104 331.5,-83 294.5,-83\"/>\n<text text-anchor=\"start\" x=\"311\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\">.</text>\n</g>\n<!-- 3->4 -->\n<g id=\"edge7\" class=\"edge\">\n<title>3->4</title>\n<path fill=\"none\" stroke=\"black\" d=\"M256.13,-18.25C275.56,-19.25 307.58,-23.1 331,-37 339.15,-41.84 346.42,-49.01 352.4,-56.26\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"349.97,-58.84 358.82,-64.67 355.54,-54.6 349.97,-58.84\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"274.5,-58 274.5,-79 294.5,-79 294.5,-58 274.5,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-58 274.5,-79 294.5,-79 294.5,-58 274.5,-58\"/>\n<text text-anchor=\"start\" x=\"279\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"294.5,-58 294.5,-79 331.5,-79 331.5,-58 294.5,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-58 294.5,-79 331.5,-79 331.5,-58 294.5,-58\"/>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-37 274.5,-58 294.5,-58 294.5,-37 274.5,-37\"/>\n<text text-anchor=\"start\" x=\"277.5\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">13</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-37 294.5,-58 331.5,-58 331.5,-37 294.5,-37\"/>\n<text text-anchor=\"start\" x=\"311\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\">.</text>\n</g>\n<g id=\"node6\" class=\"node\">\n<title/>\n</g>\n<!-- ->0 -->\n<g id=\"edge1\" class=\"edge\">\n<title>->0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M54.19,-83C62.65,-83 72.05,-83 80.6,-83\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"80.83,-86.5 90.83,-83 80.83,-79.5 80.83,-86.5\"/>\n</g>\n</g>\n</svg>"
},
"metadata": {}
}
]
},
{
"cell_type": "markdown",
"source": [
"## 5. Generate a structured response"
],
"metadata": {
"id": "UUkc7wXcOQlN"
}
},
{
"cell_type": "code",
"source": [
"outputs = model.generate(\n",
" inputs.input_ids,\n",
" attention_mask=inputs.attention_mask,\n",
" pad_token_id=tokenizer.eos_token_id,\n",
" logits_processor=[processor],\n",
" temperature=0.1\n",
")\n",
"generated_texts = tokenizer.batch_decode([output[prompt_length:] for output in outputs], skip_special_tokens=True)\n",
"formatted_strings = [f\"Question: {user_inputs[i]+alternatives}\\n\\x1b[34mResponse:\\x1b[0m \\x1b[31m{generated_texts[i]}\\x1b[0m\" for i in range(len(user_inputs))]\n",
"for string in formatted_strings:\n",
" print(string)\n",
" print()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "h9dLX3Xl_9dy",
"outputId": "567cf76e-179c-463c-abb2-ff8522237f3f"
},
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Question: What is the capital of France?\n",
"A) Madrid\n",
"B) Paris\n",
"C) Rome\n",
"\n",
"\u001b[34mResponse:\u001b[0m \u001b[31mB.\u001b[0m\n",
"\n",
"Question: What is the capital of Italy?\n",
"A) Madrid\n",
"B) Paris\n",
"C) Rome\n",
"\n",
"\u001b[34mResponse:\u001b[0m \u001b[31mC.\u001b[0m\n",
"\n",
"Question: What is the capital of Spain?\n",
"A) Madrid\n",
"B) Paris\n",
"C) Rome\n",
"\n",
"\u001b[34mResponse:\u001b[0m \u001b[31mA.\u001b[0m\n",
"\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"## 6. Visualize the selected paths"
],
"metadata": {
"id": "7ANqIJQ_M9fH"
}
},
{
"cell_type": "code",
"source": [
"processor.show_graph(batch_number=0)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 331
},
"id": "Pqo5AVexMnJ6",
"outputId": "116ec551-7bf9-4cd8-ec7a-d393fad7392f"
},
"execution_count": 7,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"<IPython.core.display.SVG object>"
],
"image/svg+xml": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"401pt\" height=\"232pt\" viewBox=\"0.00 0.00 401.00 232.00\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 228)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-228 397,-228 397,4 -4,4\"/>\n<text text-anchor=\"middle\" x=\"92\" y=\"-208.8\" font-family=\"Times,serif\" font-size=\"14.00\">Allowed Paths</text>\n<text text-anchor=\"middle\" x=\"92\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">Regular expression: A\\.|B\\.|C\\.</text>\n<!-- 0 -->\n<g id=\"node1\" class=\"node\">\n<title>0</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"109\" cy=\"-83\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"109\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n</g>\n<!-- 1 -->\n<g id=\"node2\" class=\"node\">\n<title>1</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"238\" cy=\"-148\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"238\" y=\"-144.3\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n</g>\n<!-- 0->1 -->\n<g id=\"edge2\" class=\"edge\">\n<title>0->1</title>\n<path fill=\"none\" stroke=\"black\" d=\"M118.83,-98.31C125,-107.68 134.08,-119.14 145,-126 164.59,-138.31 190.49,-143.74 209.81,-146.13\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"209.48,-149.61 219.79,-147.16 210.21,-142.65 209.48,-149.61\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"145.5,-165 145.5,-186 165.5,-186 165.5,-165 145.5,-165\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-165 145.5,-186 165.5,-186 165.5,-165 145.5,-165\"/>\n<text text-anchor=\"start\" x=\"150\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"165.5,-165 165.5,-186 202.5,-186 202.5,-165 165.5,-165\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-165 165.5,-186 202.5,-186 202.5,-165 165.5,-165\"/>\n<text text-anchor=\"start\" x=\"168.5\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-144 145.5,-165 165.5,-165 165.5,-144 145.5,-144\"/>\n<text text-anchor=\"start\" x=\"148.5\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">34</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-144 165.5,-165 202.5,-165 202.5,-144 165.5,-144\"/>\n<text text-anchor=\"start\" x=\"179\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\">C</text>\n</g>\n<!-- 2 -->\n<g id=\"node3\" class=\"node\">\n<title>2</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"238\" cy=\"-83\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"238\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n</g>\n<!-- 0->2 -->\n<g id=\"edge3\" class=\"edge\">\n<title>0->2</title>\n<path fill=\"none\" stroke=\"red\" stroke-width=\"3\" d=\"M127.13,-83C148.24,-83 184.4,-83 209.44,-83\"/>\n<polygon fill=\"red\" stroke=\"red\" stroke-width=\"3\" points=\"209.74,-86.5 219.74,-83 209.74,-79.5 209.74,-86.5\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"145.5,-104 145.5,-125 165.5,-125 165.5,-104 145.5,-104\"/>\n<polygon fill=\"none\" stroke=\"red\" points=\"145.5,-104 145.5,-125 165.5,-125 165.5,-104 145.5,-104\"/>\n<text text-anchor=\"start\" x=\"150\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"165.5,-104 165.5,-125 202.5,-125 202.5,-104 165.5,-104\"/>\n<polygon fill=\"none\" stroke=\"red\" points=\"165.5,-104 165.5,-125 202.5,-125 202.5,-104 165.5,-104\"/>\n<text text-anchor=\"start\" x=\"168.5\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"red\" points=\"145.5,-83 145.5,-104 165.5,-104 165.5,-83 145.5,-83\"/>\n<text text-anchor=\"start\" x=\"148.5\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">33</text>\n<polygon fill=\"none\" stroke=\"red\" points=\"165.5,-83 165.5,-104 202.5,-104 202.5,-83 165.5,-83\"/>\n<text text-anchor=\"start\" x=\"179\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\">B</text>\n</g>\n<!-- 3 -->\n<g id=\"node4\" class=\"node\">\n<title>3</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"238\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"238\" y=\"-14.3\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n</g>\n<!-- 0->3 -->\n<g id=\"edge4\" class=\"edge\">\n<title>0->3</title>\n<path fill=\"none\" stroke=\"black\" d=\"M117.98,-67.39C124.03,-57.17 133.28,-44.38 145,-37 164.45,-24.75 190.36,-20.23 209.73,-18.64\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"209.96,-22.13 219.73,-18.03 209.53,-15.15 209.96,-22.13\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"145.5,-58 145.5,-79 165.5,-79 165.5,-58 145.5,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-58 145.5,-79 165.5,-79 165.5,-58 145.5,-58\"/>\n<text text-anchor=\"start\" x=\"150\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"165.5,-58 165.5,-79 202.5,-79 202.5,-58 165.5,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-58 165.5,-79 202.5,-79 202.5,-58 165.5,-58\"/>\n<text text-anchor=\"start\" x=\"168.5\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-37 145.5,-58 165.5,-58 165.5,-37 145.5,-37\"/>\n<text text-anchor=\"start\" x=\"148.5\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">32</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-37 165.5,-58 202.5,-58 202.5,-37 165.5,-37\"/>\n<text text-anchor=\"start\" x=\"179\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\">A</text>\n</g>\n<!-- 4 -->\n<g id=\"node5\" class=\"node\">\n<title>4</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"371\" cy=\"-83\" rx=\"18\" ry=\"18\"/>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"371\" cy=\"-83\" rx=\"22\" ry=\"22\"/>\n<text text-anchor=\"middle\" x=\"371\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">4</text>\n</g>\n<!-- 1->4 -->\n<g id=\"edge5\" class=\"edge\">\n<title>1->4</title>\n<path fill=\"none\" stroke=\"black\" d=\"M256.07,-146.94C275.44,-145.08 307.4,-139.97 331,-126 338.44,-121.6 345.27,-115.32 351.07,-108.91\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"354.08,-110.77 357.83,-100.86 348.72,-106.27 354.08,-110.77\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"274.5,-165 274.5,-186 294.5,-186 294.5,-165 274.5,-165\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-165 274.5,-186 294.5,-186 294.5,-165 274.5,-165\"/>\n<text text-anchor=\"start\" x=\"279\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"294.5,-165 294.5,-186 331.5,-186 331.5,-165 294.5,-165\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-165 294.5,-186 331.5,-186 331.5,-165 294.5,-165\"/>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-144 274.5,-165 294.5,-165 294.5,-144 274.5,-144\"/>\n<text text-anchor=\"start\" x=\"277.5\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">13</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-144 294.5,-165 331.5,-165 331.5,-144 294.5,-144\"/>\n<text text-anchor=\"start\" x=\"311\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\">.</text>\n</g>\n<!-- 2->4 -->\n<g id=\"edge6\" class=\"edge\">\n<title>2->4</title>\n<path fill=\"none\" stroke=\"red\" stroke-width=\"3\" d=\"M256.13,-83C277.09,-83 313.01,-83 338.9,-83\"/>\n<polygon fill=\"red\" stroke=\"red\" stroke-width=\"3\" points=\"338.97,-86.5 348.97,-83 338.97,-79.5 338.97,-86.5\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"274.5,-104 274.5,-125 294.5,-125 294.5,-104 274.5,-104\"/>\n<polygon fill=\"none\" stroke=\"red\" points=\"274.5,-104 274.5,-125 294.5,-125 294.5,-104 274.5,-104\"/>\n<text text-anchor=\"start\" x=\"279\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"294.5,-104 294.5,-125 331.5,-125 331.5,-104 294.5,-104\"/>\n<polygon fill=\"none\" stroke=\"red\" points=\"294.5,-104 294.5,-125 331.5,-125 331.5,-104 294.5,-104\"/>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"red\" points=\"274.5,-83 274.5,-104 294.5,-104 294.5,-83 274.5,-83\"/>\n<text text-anchor=\"start\" x=\"277.5\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">13</text>\n<polygon fill=\"none\" stroke=\"red\" points=\"294.5,-83 294.5,-104 331.5,-104 331.5,-83 294.5,-83\"/>\n<text text-anchor=\"start\" x=\"311\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\">.</text>\n</g>\n<!-- 3->4 -->\n<g id=\"edge7\" class=\"edge\">\n<title>3->4</title>\n<path fill=\"none\" stroke=\"black\" d=\"M256.13,-18.25C275.56,-19.25 307.58,-23.1 331,-37 339.15,-41.84 346.42,-49.01 352.4,-56.26\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"349.97,-58.84 358.82,-64.67 355.54,-54.6 349.97,-58.84\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"274.5,-58 274.5,-79 294.5,-79 294.5,-58 274.5,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-58 274.5,-79 294.5,-79 294.5,-58 274.5,-58\"/>\n<text text-anchor=\"start\" x=\"279\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"294.5,-58 294.5,-79 331.5,-79 331.5,-58 294.5,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-58 294.5,-79 331.5,-79 331.5,-58 294.5,-58\"/>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-37 274.5,-58 294.5,-58 294.5,-37 274.5,-37\"/>\n<text text-anchor=\"start\" x=\"277.5\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">13</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-37 294.5,-58 331.5,-58 331.5,-37 294.5,-37\"/>\n<text text-anchor=\"start\" x=\"311\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\">.</text>\n</g>\n<g id=\"node6\" class=\"node\">\n<title/>\n</g>\n<!-- ->0 -->\n<g id=\"edge1\" class=\"edge\">\n<title>->0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M54.19,-83C62.65,-83 72.05,-83 80.6,-83\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"80.83,-86.5 90.83,-83 80.83,-79.5 80.83,-86.5\"/>\n</g>\n</g>\n</svg>"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [
"processor.show_graph(batch_number=1)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 331
},
"id": "sDvGUSXZAaC0",
"outputId": "ca2c16e0-7f96-4fbd-ef3f-570775394d93"
},
"execution_count": 8,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"<IPython.core.display.SVG object>"
],
"image/svg+xml": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"401pt\" height=\"232pt\" viewBox=\"0.00 0.00 401.00 232.00\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 228)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-228 397,-228 397,4 -4,4\"/>\n<text text-anchor=\"middle\" x=\"92\" y=\"-208.8\" font-family=\"Times,serif\" font-size=\"14.00\">Allowed Paths</text>\n<text text-anchor=\"middle\" x=\"92\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">Regular expression: A\\.|B\\.|C\\.</text>\n<!-- 0 -->\n<g id=\"node1\" class=\"node\">\n<title>0</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"109\" cy=\"-83\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"109\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n</g>\n<!-- 1 -->\n<g id=\"node2\" class=\"node\">\n<title>1</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"238\" cy=\"-148\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"238\" y=\"-144.3\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n</g>\n<!-- 0->1 -->\n<g id=\"edge2\" class=\"edge\">\n<title>0->1</title>\n<path fill=\"none\" stroke=\"red\" stroke-width=\"3\" d=\"M118.83,-98.31C125,-107.68 134.08,-119.14 145,-126 164.59,-138.31 190.49,-143.74 209.81,-146.13\"/>\n<polygon fill=\"red\" stroke=\"red\" stroke-width=\"3\" points=\"209.48,-149.61 219.79,-147.16 210.21,-142.65 209.48,-149.61\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"145.5,-165 145.5,-186 165.5,-186 165.5,-165 145.5,-165\"/>\n<polygon fill=\"none\" stroke=\"red\" points=\"145.5,-165 145.5,-186 165.5,-186 165.5,-165 145.5,-165\"/>\n<text text-anchor=\"start\" x=\"150\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"165.5,-165 165.5,-186 202.5,-186 202.5,-165 165.5,-165\"/>\n<polygon fill=\"none\" stroke=\"red\" points=\"165.5,-165 165.5,-186 202.5,-186 202.5,-165 165.5,-165\"/>\n<text text-anchor=\"start\" x=\"168.5\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"red\" points=\"145.5,-144 145.5,-165 165.5,-165 165.5,-144 145.5,-144\"/>\n<text text-anchor=\"start\" x=\"148.5\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">34</text>\n<polygon fill=\"none\" stroke=\"red\" points=\"165.5,-144 165.5,-165 202.5,-165 202.5,-144 165.5,-144\"/>\n<text text-anchor=\"start\" x=\"179\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\">C</text>\n</g>\n<!-- 2 -->\n<g id=\"node3\" class=\"node\">\n<title>2</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"238\" cy=\"-83\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"238\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n</g>\n<!-- 0->2 -->\n<g id=\"edge3\" class=\"edge\">\n<title>0->2</title>\n<path fill=\"none\" stroke=\"black\" d=\"M127.13,-83C148.24,-83 184.4,-83 209.44,-83\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"209.74,-86.5 219.74,-83 209.74,-79.5 209.74,-86.5\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"145.5,-104 145.5,-125 165.5,-125 165.5,-104 145.5,-104\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-104 145.5,-125 165.5,-125 165.5,-104 145.5,-104\"/>\n<text text-anchor=\"start\" x=\"150\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"165.5,-104 165.5,-125 202.5,-125 202.5,-104 165.5,-104\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-104 165.5,-125 202.5,-125 202.5,-104 165.5,-104\"/>\n<text text-anchor=\"start\" x=\"168.5\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-83 145.5,-104 165.5,-104 165.5,-83 145.5,-83\"/>\n<text text-anchor=\"start\" x=\"148.5\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">33</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-83 165.5,-104 202.5,-104 202.5,-83 165.5,-83\"/>\n<text text-anchor=\"start\" x=\"179\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\">B</text>\n</g>\n<!-- 3 -->\n<g id=\"node4\" class=\"node\">\n<title>3</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"238\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"238\" y=\"-14.3\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n</g>\n<!-- 0->3 -->\n<g id=\"edge4\" class=\"edge\">\n<title>0->3</title>\n<path fill=\"none\" stroke=\"black\" d=\"M117.98,-67.39C124.03,-57.17 133.28,-44.38 145,-37 164.45,-24.75 190.36,-20.23 209.73,-18.64\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"209.96,-22.13 219.73,-18.03 209.53,-15.15 209.96,-22.13\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"145.5,-58 145.5,-79 165.5,-79 165.5,-58 145.5,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-58 145.5,-79 165.5,-79 165.5,-58 145.5,-58\"/>\n<text text-anchor=\"start\" x=\"150\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"165.5,-58 165.5,-79 202.5,-79 202.5,-58 165.5,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-58 165.5,-79 202.5,-79 202.5,-58 165.5,-58\"/>\n<text text-anchor=\"start\" x=\"168.5\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-37 145.5,-58 165.5,-58 165.5,-37 145.5,-37\"/>\n<text text-anchor=\"start\" x=\"148.5\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">32</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-37 165.5,-58 202.5,-58 202.5,-37 165.5,-37\"/>\n<text text-anchor=\"start\" x=\"179\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\">A</text>\n</g>\n<!-- 4 -->\n<g id=\"node5\" class=\"node\">\n<title>4</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"371\" cy=\"-83\" rx=\"18\" ry=\"18\"/>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"371\" cy=\"-83\" rx=\"22\" ry=\"22\"/>\n<text text-anchor=\"middle\" x=\"371\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">4</text>\n</g>\n<!-- 1->4 -->\n<g id=\"edge5\" class=\"edge\">\n<title>1->4</title>\n<path fill=\"none\" stroke=\"red\" stroke-width=\"3\" d=\"M256.07,-146.94C275.44,-145.08 307.4,-139.97 331,-126 338.44,-121.6 345.27,-115.32 351.07,-108.91\"/>\n<polygon fill=\"red\" stroke=\"red\" stroke-width=\"3\" points=\"354.08,-110.77 357.83,-100.86 348.72,-106.27 354.08,-110.77\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"274.5,-165 274.5,-186 294.5,-186 294.5,-165 274.5,-165\"/>\n<polygon fill=\"none\" stroke=\"red\" points=\"274.5,-165 274.5,-186 294.5,-186 294.5,-165 274.5,-165\"/>\n<text text-anchor=\"start\" x=\"279\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"294.5,-165 294.5,-186 331.5,-186 331.5,-165 294.5,-165\"/>\n<polygon fill=\"none\" stroke=\"red\" points=\"294.5,-165 294.5,-186 331.5,-186 331.5,-165 294.5,-165\"/>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"red\" points=\"274.5,-144 274.5,-165 294.5,-165 294.5,-144 274.5,-144\"/>\n<text text-anchor=\"start\" x=\"277.5\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">13</text>\n<polygon fill=\"none\" stroke=\"red\" points=\"294.5,-144 294.5,-165 331.5,-165 331.5,-144 294.5,-144\"/>\n<text text-anchor=\"start\" x=\"311\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\">.</text>\n</g>\n<!-- 2->4 -->\n<g id=\"edge6\" class=\"edge\">\n<title>2->4</title>\n<path fill=\"none\" stroke=\"black\" d=\"M256.13,-83C277.09,-83 313.01,-83 338.9,-83\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"338.97,-86.5 348.97,-83 338.97,-79.5 338.97,-86.5\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"274.5,-104 274.5,-125 294.5,-125 294.5,-104 274.5,-104\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-104 274.5,-125 294.5,-125 294.5,-104 274.5,-104\"/>\n<text text-anchor=\"start\" x=\"279\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"294.5,-104 294.5,-125 331.5,-125 331.5,-104 294.5,-104\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-104 294.5,-125 331.5,-125 331.5,-104 294.5,-104\"/>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-83 274.5,-104 294.5,-104 294.5,-83 274.5,-83\"/>\n<text text-anchor=\"start\" x=\"277.5\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">13</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-83 294.5,-104 331.5,-104 331.5,-83 294.5,-83\"/>\n<text text-anchor=\"start\" x=\"311\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\">.</text>\n</g>\n<!-- 3->4 -->\n<g id=\"edge7\" class=\"edge\">\n<title>3->4</title>\n<path fill=\"none\" stroke=\"black\" d=\"M256.13,-18.25C275.56,-19.25 307.58,-23.1 331,-37 339.15,-41.84 346.42,-49.01 352.4,-56.26\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"349.97,-58.84 358.82,-64.67 355.54,-54.6 349.97,-58.84\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"274.5,-58 274.5,-79 294.5,-79 294.5,-58 274.5,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-58 274.5,-79 294.5,-79 294.5,-58 274.5,-58\"/>\n<text text-anchor=\"start\" x=\"279\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"294.5,-58 294.5,-79 331.5,-79 331.5,-58 294.5,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-58 294.5,-79 331.5,-79 331.5,-58 294.5,-58\"/>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-37 274.5,-58 294.5,-58 294.5,-37 274.5,-37\"/>\n<text text-anchor=\"start\" x=\"277.5\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">13</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-37 294.5,-58 331.5,-58 331.5,-37 294.5,-37\"/>\n<text text-anchor=\"start\" x=\"311\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\">.</text>\n</g>\n<g id=\"node6\" class=\"node\">\n<title/>\n</g>\n<!-- ->0 -->\n<g id=\"edge1\" class=\"edge\">\n<title>->0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M54.19,-83C62.65,-83 72.05,-83 80.6,-83\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"80.83,-86.5 90.83,-83 80.83,-79.5 80.83,-86.5\"/>\n</g>\n</g>\n</svg>"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [
"processor.show_graph(batch_number=2)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 331
},
"id": "DDyE3bb2AT6V",
"outputId": "5b7243ec-a902-4cc8-c45e-e840a27094f0"
},
"execution_count": 9,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"<IPython.core.display.SVG object>"
],
"image/svg+xml": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"401pt\" height=\"232pt\" viewBox=\"0.00 0.00 401.00 232.00\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 228)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-228 397,-228 397,4 -4,4\"/>\n<text text-anchor=\"middle\" x=\"92\" y=\"-208.8\" font-family=\"Times,serif\" font-size=\"14.00\">Allowed Paths</text>\n<text text-anchor=\"middle\" x=\"92\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">Regular expression: A\\.|B\\.|C\\.</text>\n<!-- 0 -->\n<g id=\"node1\" class=\"node\">\n<title>0</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"109\" cy=\"-83\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"109\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n</g>\n<!-- 1 -->\n<g id=\"node2\" class=\"node\">\n<title>1</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"238\" cy=\"-148\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"238\" y=\"-144.3\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n</g>\n<!-- 0->1 -->\n<g id=\"edge2\" class=\"edge\">\n<title>0->1</title>\n<path fill=\"none\" stroke=\"black\" d=\"M118.83,-98.31C125,-107.68 134.08,-119.14 145,-126 164.59,-138.31 190.49,-143.74 209.81,-146.13\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"209.48,-149.61 219.79,-147.16 210.21,-142.65 209.48,-149.61\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"145.5,-165 145.5,-186 165.5,-186 165.5,-165 145.5,-165\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-165 145.5,-186 165.5,-186 165.5,-165 145.5,-165\"/>\n<text text-anchor=\"start\" x=\"150\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"165.5,-165 165.5,-186 202.5,-186 202.5,-165 165.5,-165\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-165 165.5,-186 202.5,-186 202.5,-165 165.5,-165\"/>\n<text text-anchor=\"start\" x=\"168.5\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-144 145.5,-165 165.5,-165 165.5,-144 145.5,-144\"/>\n<text text-anchor=\"start\" x=\"148.5\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">34</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-144 165.5,-165 202.5,-165 202.5,-144 165.5,-144\"/>\n<text text-anchor=\"start\" x=\"179\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\">C</text>\n</g>\n<!-- 2 -->\n<g id=\"node3\" class=\"node\">\n<title>2</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"238\" cy=\"-83\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"238\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n</g>\n<!-- 0->2 -->\n<g id=\"edge3\" class=\"edge\">\n<title>0->2</title>\n<path fill=\"none\" stroke=\"black\" d=\"M127.13,-83C148.24,-83 184.4,-83 209.44,-83\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"209.74,-86.5 219.74,-83 209.74,-79.5 209.74,-86.5\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"145.5,-104 145.5,-125 165.5,-125 165.5,-104 145.5,-104\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-104 145.5,-125 165.5,-125 165.5,-104 145.5,-104\"/>\n<text text-anchor=\"start\" x=\"150\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"165.5,-104 165.5,-125 202.5,-125 202.5,-104 165.5,-104\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-104 165.5,-125 202.5,-125 202.5,-104 165.5,-104\"/>\n<text text-anchor=\"start\" x=\"168.5\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"145.5,-83 145.5,-104 165.5,-104 165.5,-83 145.5,-83\"/>\n<text text-anchor=\"start\" x=\"148.5\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">33</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"165.5,-83 165.5,-104 202.5,-104 202.5,-83 165.5,-83\"/>\n<text text-anchor=\"start\" x=\"179\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\">B</text>\n</g>\n<!-- 3 -->\n<g id=\"node4\" class=\"node\">\n<title>3</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"238\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"238\" y=\"-14.3\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n</g>\n<!-- 0->3 -->\n<g id=\"edge4\" class=\"edge\">\n<title>0->3</title>\n<path fill=\"none\" stroke=\"red\" stroke-width=\"3\" d=\"M117.98,-67.39C124.03,-57.17 133.28,-44.38 145,-37 164.45,-24.75 190.36,-20.23 209.73,-18.64\"/>\n<polygon fill=\"red\" stroke=\"red\" stroke-width=\"3\" points=\"209.96,-22.13 219.73,-18.03 209.53,-15.15 209.96,-22.13\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"145.5,-58 145.5,-79 165.5,-79 165.5,-58 145.5,-58\"/>\n<polygon fill=\"none\" stroke=\"red\" points=\"145.5,-58 145.5,-79 165.5,-79 165.5,-58 145.5,-58\"/>\n<text text-anchor=\"start\" x=\"150\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"165.5,-58 165.5,-79 202.5,-79 202.5,-58 165.5,-58\"/>\n<polygon fill=\"none\" stroke=\"red\" points=\"165.5,-58 165.5,-79 202.5,-79 202.5,-58 165.5,-58\"/>\n<text text-anchor=\"start\" x=\"168.5\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"red\" points=\"145.5,-37 145.5,-58 165.5,-58 165.5,-37 145.5,-37\"/>\n<text text-anchor=\"start\" x=\"148.5\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">32</text>\n<polygon fill=\"none\" stroke=\"red\" points=\"165.5,-37 165.5,-58 202.5,-58 202.5,-37 165.5,-37\"/>\n<text text-anchor=\"start\" x=\"179\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\">A</text>\n</g>\n<!-- 4 -->\n<g id=\"node5\" class=\"node\">\n<title>4</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"371\" cy=\"-83\" rx=\"18\" ry=\"18\"/>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"371\" cy=\"-83\" rx=\"22\" ry=\"22\"/>\n<text text-anchor=\"middle\" x=\"371\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">4</text>\n</g>\n<!-- 1->4 -->\n<g id=\"edge5\" class=\"edge\">\n<title>1->4</title>\n<path fill=\"none\" stroke=\"black\" d=\"M256.07,-146.94C275.44,-145.08 307.4,-139.97 331,-126 338.44,-121.6 345.27,-115.32 351.07,-108.91\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"354.08,-110.77 357.83,-100.86 348.72,-106.27 354.08,-110.77\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"274.5,-165 274.5,-186 294.5,-186 294.5,-165 274.5,-165\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-165 274.5,-186 294.5,-186 294.5,-165 274.5,-165\"/>\n<text text-anchor=\"start\" x=\"279\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"294.5,-165 294.5,-186 331.5,-186 331.5,-165 294.5,-165\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-165 294.5,-186 331.5,-186 331.5,-165 294.5,-165\"/>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-171.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-144 274.5,-165 294.5,-165 294.5,-144 274.5,-144\"/>\n<text text-anchor=\"start\" x=\"277.5\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">13</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-144 294.5,-165 331.5,-165 331.5,-144 294.5,-144\"/>\n<text text-anchor=\"start\" x=\"311\" y=\"-150.8\" font-family=\"Times,serif\" font-size=\"14.00\">.</text>\n</g>\n<!-- 2->4 -->\n<g id=\"edge6\" class=\"edge\">\n<title>2->4</title>\n<path fill=\"none\" stroke=\"black\" d=\"M256.13,-83C277.09,-83 313.01,-83 338.9,-83\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"338.97,-86.5 348.97,-83 338.97,-79.5 338.97,-86.5\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"274.5,-104 274.5,-125 294.5,-125 294.5,-104 274.5,-104\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-104 274.5,-125 294.5,-125 294.5,-104 274.5,-104\"/>\n<text text-anchor=\"start\" x=\"279\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"294.5,-104 294.5,-125 331.5,-125 331.5,-104 294.5,-104\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-104 294.5,-125 331.5,-125 331.5,-104 294.5,-104\"/>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-110.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"274.5,-83 274.5,-104 294.5,-104 294.5,-83 274.5,-83\"/>\n<text text-anchor=\"start\" x=\"277.5\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">13</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"294.5,-83 294.5,-104 331.5,-104 331.5,-83 294.5,-83\"/>\n<text text-anchor=\"start\" x=\"311\" y=\"-89.8\" font-family=\"Times,serif\" font-size=\"14.00\">.</text>\n</g>\n<!-- 3->4 -->\n<g id=\"edge7\" class=\"edge\">\n<title>3->4</title>\n<path fill=\"none\" stroke=\"red\" stroke-width=\"3\" d=\"M256.13,-18.25C275.56,-19.25 307.58,-23.1 331,-37 339.15,-41.84 346.42,-49.01 352.4,-56.26\"/>\n<polygon fill=\"red\" stroke=\"red\" stroke-width=\"3\" points=\"349.97,-58.84 358.82,-64.67 355.54,-54.6 349.97,-58.84\"/>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"274.5,-58 274.5,-79 294.5,-79 294.5,-58 274.5,-58\"/>\n<polygon fill=\"none\" stroke=\"red\" points=\"274.5,-58 274.5,-79 294.5,-79 294.5,-58 274.5,-58\"/>\n<text text-anchor=\"start\" x=\"279\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">id</text>\n<polygon fill=\"#ffebcd\" stroke=\"transparent\" points=\"294.5,-58 294.5,-79 331.5,-79 331.5,-58 294.5,-58\"/>\n<polygon fill=\"none\" stroke=\"red\" points=\"294.5,-58 294.5,-79 331.5,-79 331.5,-58 294.5,-58\"/>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-64.8\" font-family=\"Times,serif\" font-size=\"14.00\">token</text>\n<polygon fill=\"none\" stroke=\"red\" points=\"274.5,-37 274.5,-58 294.5,-58 294.5,-37 274.5,-37\"/>\n<text text-anchor=\"start\" x=\"277.5\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#00b4d8\">13</text>\n<polygon fill=\"none\" stroke=\"red\" points=\"294.5,-37 294.5,-58 331.5,-58 331.5,-37 294.5,-37\"/>\n<text text-anchor=\"start\" x=\"311\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\">.</text>\n</g>\n<g id=\"node6\" class=\"node\">\n<title/>\n</g>\n<!-- ->0 -->\n<g id=\"edge1\" class=\"edge\">\n<title>->0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M54.19,-83C62.65,-83 72.05,-83 80.6,-83\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"80.83,-86.5 90.83,-83 80.83,-79.5 80.83,-86.5\"/>\n</g>\n</g>\n</svg>"
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "xNEEh_naAY_w"
},
"execution_count": 9,
"outputs": []
}
]
} |