Created
September 29, 2025 11:35
-
-
Save alonsosilvaallende/df5959452e81b7a34dcdf163cd7204ac to your computer and use it in GitHub Desktop.
Litelines-Multiple-Choice.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "nbformat": 4, | |
| "nbformat_minor": 0, | |
| "metadata": { | |
| "colab": { | |
| "provenance": [], | |
| "gpuType": "T4", | |
| "authorship_tag": "ABX9TyOCnRvylQezx7p52LEa+9R0", | |
| "include_colab_link": true | |
| }, | |
| "kernelspec": { | |
| "name": "python3", | |
| "display_name": "Python 3" | |
| }, | |
| "language_info": { | |
| "name": "python" | |
| }, | |
| "accelerator": "GPU" | |
| }, | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": { | |
| "id": "view-in-github", | |
| "colab_type": "text" | |
| }, | |
| "source": [ | |
| "<a href=\"https://colab.research.google.com/gist/alonsosilvaallende/df5959452e81b7a34dcdf163cd7204ac/litelines-multiple-choice.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "# Multiple choice question" | |
| ], | |
| "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_input = \"\"\"Which key combination exits Vim?\n", | |
| "\n", | |
| "A) Ctrl+X\n", | |
| "B) Esc then :q!\n", | |
| "C) Alt+F4\n", | |
| "\"\"\"\n", | |
| "messages = [{\"role\": \"user\", \"content\": user_input}]\n", | |
| "inputs = tokenizer.apply_chat_template(\n", | |
| " messages,\n", | |
| " add_generation_prompt=True,\n", | |
| " return_tensors=\"pt\",\n", | |
| " return_dict=True\n", | |
| ").to(model.device)" | |
| ], | |
| "metadata": { | |
| "id": "Y8RtiZ7UefUx" | |
| }, | |
| "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": "6b6a373e-91cd-48ce-ed31-e198d2584dce" | |
| }, | |
| "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": [ | |
| "generated = model.generate(**inputs, logits_processor=[processor], temperature=0.1)\n", | |
| "print(f\"Response: {tokenizer.decode(generated[0][inputs['input_ids'].shape[-1]:-1])}\")" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "4oIHOm-rMdG0", | |
| "outputId": "d64d1505-aa01-4498-85fe-acc0112126c5" | |
| }, | |
| "execution_count": 6, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "Response: B.\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "## 6. Visualize the selected path" | |
| ], | |
| "metadata": { | |
| "id": "7ANqIJQ_M9fH" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "processor.show_graph()" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 331 | |
| }, | |
| "id": "Pqo5AVexMnJ6", | |
| "outputId": "471d79a3-b43a-4f12-c756-32eecfb596e4" | |
| }, | |
| "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": [], | |
| "metadata": { | |
| "id": "El18jdbOM66M" | |
| }, | |
| "execution_count": 7, | |
| "outputs": [] | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment