|
7 | 7 | }, |
8 | 8 | "source": [ |
9 | 9 | "\n", |
10 | | - "\u003ca href=\"https://colab.research.google.com/github/google-research/text-to-text-transfer-transformer/blob/main/notebooks/t5-trivia.ipynb\" target=\"_parent\"\u003e\u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/\u003e\u003c/a\u003e" |
| 10 | + "<a href=\"https://colab.research.google.com/github/google-research/text-to-text-transfer-transformer/blob/main/notebooks/t5-trivia.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" |
11 | 11 | ] |
12 | 12 | }, |
13 | 13 | { |
|
55 | 55 | "## _Or: What does T5 know?_\n", |
56 | 56 | "\n", |
57 | 57 | "*The following tutorial guides you through the process of fine-tuning a pre-trained T5 model, evaluating its accuracy, and using it for prediction,\n", |
58 | | - "all on a free Google Cloud TPU \u003ca href=\"https://colab.research.google.com/github/google-research/text-to-text-transfer-transformer/blob/main/notebooks/t5-trivia.ipynb\" target=\"_parent\"\u003e\u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/\u003e\u003c/a\u003e.*\n", |
| 58 | + "all on a free Google Cloud TPU <a href=\"https://colab.research.google.com/github/google-research/text-to-text-transfer-transformer/blob/main/notebooks/t5-trivia.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>.*\n", |
59 | 59 | "\n", |
60 | 60 | "### Background\n", |
61 | 61 | "\n", |
|
102 | 102 | "id": "eDeE_yVuHMYg" |
103 | 103 | }, |
104 | 104 | "source": [ |
105 | | - "\u003ch3\u003e\u003ca href=\"https://cloud.google.com/tpu/\"\u003e\u003cimg valign=\"middle\" src=\"https://raw.githubusercontent.com/GoogleCloudPlatform/tensorflow-without-a-phd/master/tensorflow-rl-pong/images/tpu-hexagon.png\" width=\"50\"\u003e\u003c/a\u003e \u0026nbsp;\u0026nbsp;Train on TPU\u003c/h3\u003e\n", |
| 105 | + "<h3><a href=\"https://cloud.google.com/tpu/\"><img valign=\"middle\" src=\"https://raw.githubusercontent.com/GoogleCloudPlatform/tensorflow-without-a-phd/master/tensorflow-rl-pong/images/tpu-hexagon.png\" width=\"50\"></a> Train on TPU</h3>\n", |
106 | 106 | "\n", |
107 | 107 | "\n", |
108 | 108 | "\n", |
|
253 | 253 | "name": "stdout", |
254 | 254 | "output_type": "stream", |
255 | 255 | "text": [ |
256 | | - "I1206 00:11:00.169766 248738 \u003cipython-input-3-45e03d923fbf\u003e:51] Loading NQ from cache.\n" |
| 256 | + "I1206 00:11:00.169766 248738 <ipython-input-3-45e03d923fbf>:51] Loading NQ from cache.\n" |
257 | 257 | ] |
258 | 258 | } |
259 | 259 | ], |
|
304 | 304 | " elif \"document_text\" in ex:\n", |
305 | 305 | " tokens = ex[\"document_text\"].split(\" \")\n", |
306 | 306 | " answer = extract_answer(tokens, answer_span)\n", |
307 | | - " # Write this line as \u003cquestion\u003e\\t\u003canswer\u003e\n", |
| 307 | + " # Write this line as <question>\\t<answer>\n", |
308 | 308 | " outfile.write(\"%s\\t%s\\n\" % (question, answer))\n", |
309 | 309 | " count += 1\n", |
310 | 310 | " tf.logging.log_every_n(\n", |
|
378 | 378 | "\n", |
379 | 379 | " # Load lines from the text file as examples.\n", |
380 | 380 | " ds = tf.data.TextLineDataset(nq_tsv_path[split])\n", |
381 | | - " # Split each \"\u003cquestion\u003e\\t\u003canswer\u003e\" example into (question, answer) tuple.\n", |
| 381 | + " # Split each \"<question>\\t<answer>\" example into (question, answer) tuple.\n", |
382 | 382 | " ds = ds.map(\n", |
383 | 383 | " functools.partial(tf.io.decode_csv, record_defaults=[\"\", \"\"],\n", |
384 | 384 | " field_delim=\"\\t\", use_quote_delim=False),\n", |
|
417 | 417 | " return text\n", |
418 | 418 | "\n", |
419 | 419 | " def to_inputs_and_targets(ex):\n", |
420 | | - " \"\"\"Map {\"question\": ..., \"answer\": ...}-\u003e{\"inputs\": ..., \"targets\": ...}.\"\"\"\n", |
| 420 | + " \"\"\"Map {\"question\": ..., \"answer\": ...}->{\"inputs\": ..., \"targets\": ...}.\"\"\"\n", |
421 | 421 | " return {\n", |
422 | 422 | " \"inputs\":\n", |
423 | 423 | " tf.strings.join(\n", |
|
889 | 889 | "\n", |
890 | 890 | "Please see our [paper on closed-book QA](https://arxiv.org/abs/2002.08910) where achieved even better results.\n", |
891 | 891 | "\n", |
892 | | - "\u003cimg src=\"https://storage.googleapis.com/t5-data/assets/t5_trivia_expected.png\"\u003e" |
| 892 | + "<img src=\"https://storage.googleapis.com/t5-data/assets/t5_trivia_expected.png\">" |
893 | 893 | ] |
894 | 894 | }, |
895 | 895 | { |
|
954 | 954 | "name": "stdout", |
955 | 955 | "output_type": "stream", |
956 | 956 | "text": [ |
957 | | - "\u003c== Random predictions for triviaqa_context_free using checkpoint 1100000 ==\u003e\n", |
| 957 | + "<== Random predictions for triviaqa_context_free using checkpoint 1100000 ==>\n", |
958 | 958 | "\n", |
959 | 959 | "Input: trivia question: jackpot counter, ghost drop and drop zone are all terms used in which uk television game show?\n", |
960 | 960 | "Target: tipping point\n", |
|
1006 | 1006 | "Prediction: scooby-doo\n", |
1007 | 1007 | "Counted as Correct? False\n", |
1008 | 1008 | "\n", |
1009 | | - "\u003c== Random predictions for nq_context_free using checkpoint 1100000 ==\u003e\n", |
| 1009 | + "<== Random predictions for nq_context_free using checkpoint 1100000 ==>\n", |
1010 | 1010 | "\n", |
1011 | 1011 | "Input: trivia question: who is known as the super fast boy in the series the icredible?\n", |
1012 | 1012 | "Target: dashiell robert parr/dash\n", |
|
1093 | 1093 | " tf.compat.as_text(ex[\"targets_pretokenized\"]),\n", |
1094 | 1094 | " pred.strip()))\n", |
1095 | 1095 | "\n", |
1096 | | - " print(\"\u003c== Random predictions for %s using checkpoint %s ==\u003e\\n\" %\n", |
| 1096 | + " print(\"<== Random predictions for %s using checkpoint %s ==>\\n\" %\n", |
1097 | 1097 | " (task_name, \n", |
1098 | 1098 | " _prediction_file_to_ckpt(latest_prediction_file)))\n", |
1099 | 1099 | "\n", |
|
0 commit comments