{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:08.638655Z", "iopub.status.busy": "2025-11-05T13:43:08.638430Z", "iopub.status.idle": "2025-11-05T13:43:24.407440Z", "shell.execute_reply": "2025-11-05T13:43:24.406858Z", "shell.execute_reply.started": "2025-11-05T13:43:08.638638Z" }, "trusted": true }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2025-11-05 13:43:10.451350: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:477] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n", "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n", "E0000 00:00:1762350190.702179 37 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n", "E0000 00:00:1762350190.776498 37 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n" ] } ], "source": [ "import os\n", "import json\n", "import random\n", "import re\n", "import tensorflow as tf\n", "import tensorflow_text as tf_text\n", "import sentencepiece as spm\n", "import matplotlib.pyplot as plt\n", "from tqdm import tqdm\n", "from tensorflow import keras\n", "from tensorflow.keras import layers" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:24.408695Z", "iopub.status.busy": "2025-11-05T13:43:24.408142Z", "iopub.status.idle": "2025-11-05T13:43:24.413411Z", "shell.execute_reply": "2025-11-05T13:43:24.412824Z", "shell.execute_reply.started": "2025-11-05T13:43:24.408669Z" }, "trusted": true }, "outputs": [], "source": [ "# ================================\n", "# 1. CONFIG\n", "# ================================\n", "DATA_DIR = \"/kaggle/input/got-q-and-a/output4\" # UPDATE THIS\n", "SPM_MODEL = \"/kaggle/input/ice-and-fire-tokenizer/keras/default/1/icefire_spm.model\"\n", "CHECKPOINT_PATH = \"/kaggle/input/got-qa-model/tensorflow2/default/1/got_qa_transformer.keras\"\n", "BATCH_SIZE = 150\n", "EPOCHS = 20\n", "VAL_SPLIT = 0.05\n", "MAX_QUESTION_WORDS = 25\n", "MAX_ANSWER_WORDS = 60\n", "SEQ_LEN_EN = 30\n", "SEQ_LEN_TE = 64\n", "VOCAB_SIZE = 30_000\n", "EMBED_DIM = 256\n", "DENSE_DIM = 512\n", "NUM_HEADS = 8\n", "NUM_LAYERS_ENC = 1\n", "NUM_LAYERS_DEC = 1" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:24.415672Z", "iopub.status.busy": "2025-11-05T13:43:24.415488Z", "iopub.status.idle": "2025-11-05T13:43:25.379642Z", "shell.execute_reply": "2025-11-05T13:43:25.378765Z", "shell.execute_reply.started": "2025-11-05T13:43:24.415658Z" }, "trusted": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using =2, =3\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "I0000 00:00:1762350205.339625 37 gpu_device.cc:2022] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 15513 MB memory: -> device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0\n" ] } ], "source": [ "sp = spm.SentencePieceProcessor(model_file=SPM_MODEL)\n", "tokenizer = tf_text.SentencepieceTokenizer(model=open(SPM_MODEL, \"rb\").read())\n", "\n", "START_ID = sp.bos_id() # \n", "END_ID = sp.eos_id() # \n", "print(f\"Using ={START_ID}, ={END_ID}\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:25.380580Z", "iopub.status.busy": "2025-11-05T13:43:25.380369Z", "iopub.status.idle": "2025-11-05T13:43:25.384455Z", "shell.execute_reply": "2025-11-05T13:43:25.383709Z", "shell.execute_reply.started": "2025-11-05T13:43:25.380563Z" }, "trusted": true }, "outputs": [], "source": [ "# ================================\n", "# 3. Safe Word Count\n", "# ================================\n", "def count_words(text):\n", " if not text:\n", " return 0\n", " return len(re.findall(r'\\b\\w+\\b', str(text)))" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:25.385587Z", "iopub.status.busy": "2025-11-05T13:43:25.385294Z", "iopub.status.idle": "2025-11-05T13:43:25.399506Z", "shell.execute_reply": "2025-11-05T13:43:25.398820Z", "shell.execute_reply.started": "2025-11-05T13:43:25.385565Z" }, "trusted": true }, "outputs": [], "source": [ "# ================================\n", "# 5. Load JSON Files (array format)\n", "# ================================\n", "def load_all_json_files(data_dir):\n", " json_paths = [\n", " os.path.join(data_dir, f) for f in os.listdir(data_dir)\n", " if f.lower().endswith('.json')\n", " ]\n", " if not json_paths:\n", " raise FileNotFoundError(f\"No .json files in {data_dir}\")\n", "\n", " pairs = []\n", " skipped = 0\n", "\n", " for path in tqdm(json_paths, desc=\"Loading JSON\"):\n", " with open(path, \"r\", encoding=\"utf-8\") as f:\n", " try:\n", " data = json.load(f)\n", " except:\n", " continue\n", " if not isinstance(data, list):\n", " continue\n", " for item in data:\n", " q = str(item.get(\"question\", \"\")).strip()\n", " a_raw = item.get(\"answer\", \"\")\n", " if a_raw is None:\n", " a = \"\"\n", " elif isinstance(a_raw, (int, float, bool)):\n", " a = str(a_raw)\n", " else:\n", " a = str(a_raw).strip()\n", "\n", " if not q or not a:\n", " skipped += 1\n", " continue\n", " if count_words(q) > MAX_QUESTION_WORDS or count_words(a) > MAX_ANSWER_WORDS:\n", " skipped += 1\n", " continue\n", " pairs.append((q, a))\n", "\n", " print(f\"Loaded {len(pairs):,} | Skipped {skipped:,}\")\n", " return pairs" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:25.400399Z", "iopub.status.busy": "2025-11-05T13:43:25.400216Z", "iopub.status.idle": "2025-11-05T13:43:25.416666Z", "shell.execute_reply": "2025-11-05T13:43:25.416030Z", "shell.execute_reply.started": "2025-11-05T13:43:25.400385Z" }, "trusted": true }, "outputs": [], "source": [ "# ================================\n", "# 6. Tokenization (graph-safe)\n", "# ================================\n", "def _pad_ragged(ragged, seq_len):\n", " \"\"\"Pad a RaggedTensor to a dense tensor of shape (B, seq_len).\"\"\"\n", " # ragged.to_tensor() works on RaggedTensor\n", " # ragged.values gives the flat values → reshape not needed\n", " return tf.cast(\n", " ragged.to_tensor(default_value=0, shape=[None, seq_len]),\n", " tf.int32\n", " )\n", "\n", "def tokenize_batch(texts, is_target=False):\n", " \"\"\"\n", " texts : tf.Tensor of dtype=string, shape=(batch,)\n", " is_target : bool – add / for decoder\n", " Returns : tf.Tensor int32, shape=(batch, SEQ_LEN_*)\n", " \"\"\"\n", " # tokenizer.tokenize returns a RaggedTensor\n", " tok = tokenizer.tokenize(texts) # RaggedTensor\n", "\n", " if is_target:\n", " batch_size = tf.shape(tok)[0]\n", " start = tf.fill([batch_size, 1], START_ID) # \n", " end = tf.fill([batch_size, 1], END_ID) # \n", " tok = tf.concat([start, tok, end], axis=1) # still Ragged\n", " return _pad_ragged(tok, SEQ_LEN_TE)\n", " else:\n", " return _pad_ragged(tok, SEQ_LEN_EN)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:25.417552Z", "iopub.status.busy": "2025-11-05T13:43:25.417272Z", "iopub.status.idle": "2025-11-05T13:43:25.433813Z", "shell.execute_reply": "2025-11-05T13:43:25.433270Z", "shell.execute_reply.started": "2025-11-05T13:43:25.417533Z" }, "trusted": true }, "outputs": [], "source": [ "def make_dataset(pairs, shuffle=True):\n", " if len(pairs) == 0:\n", " raise ValueError(\"Empty pairs!\")\n", "\n", " # 1. Convert Python lists → tf.data.Dataset of (question, answer) strings\n", " en = [p[0] for p in pairs]\n", " te = [p[1] for p in pairs]\n", " ds = tf.data.Dataset.from_tensor_slices((en, te))\n", "\n", " if shuffle:\n", " ds = ds.shuffle(len(pairs), reshuffle_each_iteration=True)\n", "\n", " # 2. Batch the dataset\n", " ds = ds.batch(BATCH_SIZE, drop_remainder=True)\n", "\n", " # 3. Tokenize and structure the data for Keras: ( (X_enc, X_dec), Y_target )\n", " ds = ds.map(\n", " lambda q, a: (\n", " # X_model_inputs (Tuple of 2 inputs for the model)\n", " (tokenize_batch(q, False),\n", " tokenize_batch(a, True)[:, :-1]), # X_decoder: , w1, w2, ... (removes final padding/eos)\n", " # Y_target (Ground truth)\n", " tokenize_batch(a, True)[:, 1:] # Y_target: w1, w2, w3, , ... (removes )\n", " ),\n", " num_parallel_calls=tf.data.AUTOTUNE,\n", " deterministic=False\n", " )\n", "\n", " ds = ds.prefetch(tf.data.AUTOTUNE)\n", " return ds" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:25.434631Z", "iopub.status.busy": "2025-11-05T13:43:25.434424Z", "iopub.status.idle": "2025-11-05T13:43:39.493515Z", "shell.execute_reply": "2025-11-05T13:43:39.492780Z", "shell.execute_reply.started": "2025-11-05T13:43:25.434617Z" }, "trusted": true }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Loading JSON: 100%|██████████| 800/800 [00:13<00:00, 57.90it/s]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Loaded 523,762 | Skipped 24,617\n" ] } ], "source": [ "# ================================\n", "all_pairs = load_all_json_files(DATA_DIR)\n", "random.shuffle(all_pairs)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:39.496077Z", "iopub.status.busy": "2025-11-05T13:43:39.495861Z", "iopub.status.idle": "2025-11-05T13:43:39.518929Z", "shell.execute_reply": "2025-11-05T13:43:39.518101Z", "shell.execute_reply.started": "2025-11-05T13:43:39.496061Z" }, "trusted": true }, "outputs": [], "source": [ "split_idx = int(len(all_pairs) * (1 - VAL_SPLIT))\n", "train_pairs = all_pairs[:split_idx]\n", "val_pairs = all_pairs[split_idx:]" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:39.520502Z", "iopub.status.busy": "2025-11-05T13:43:39.519821Z", "iopub.status.idle": "2025-11-05T13:43:43.975005Z", "shell.execute_reply": "2025-11-05T13:43:43.974154Z", "shell.execute_reply.started": "2025-11-05T13:43:39.520480Z" }, "trusted": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Train: 497,573 | Val: 26,189\n" ] } ], "source": [ "print(f\"Train: {len(train_pairs):,} | Val: {len(val_pairs):,}\")\n", "\n", "train_ds = make_dataset(train_pairs, shuffle=True)\n", "val_ds = make_dataset(val_pairs, shuffle=False)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:43.976105Z", "iopub.status.busy": "2025-11-05T13:43:43.975862Z", "iopub.status.idle": "2025-11-05T13:43:48.138156Z", "shell.execute_reply": "2025-11-05T13:43:48.137297Z", "shell.execute_reply.started": "2025-11-05T13:43:43.976077Z" }, "trusted": true }, "outputs": [], "source": [ "train_ds = make_dataset(train_pairs, shuffle=True)\n", "val_ds = make_dataset(val_pairs, shuffle=False)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:48.139995Z", "iopub.status.busy": "2025-11-05T13:43:48.139167Z", "iopub.status.idle": "2025-11-05T13:43:49.026113Z", "shell.execute_reply": "2025-11-05T13:43:49.025387Z", "shell.execute_reply.started": "2025-11-05T13:43:48.139975Z" }, "trusted": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "✅ Successfully retrieved one batch from the dataset.\n", "\n", "--- Encoder Inputs (Questions) ---\n", "Shape: (150, 30)\n", "DType: \n", "\n", "First Encoder Sequence (Example 1/Batch)\n", "[ 6779 496 121 213 2021 350 25 4596 995 40 2830 29951\n", " 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0 0 0 0]\n", "\n", "--- Decoder Inputs (Partial Answers) ---\n", "Shape: (150, 63)\n", "DType: \n", "\n", "First Decoder Sequence (Example 1/Batch)\n", "[ 2 213 2021 350 25 4596 570 12 74 29962 1088 318\n", " 29940 12619 4989 947 311 29936 945 13206 2636 259 40 23487\n", " 3 0 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0]\n", "\n", "--- Target Outputs (Ground Truth) ---\n", "Shape: (150, 63)\n", "DType: \n", "\n", "First Target Sequence (Example 1/Batch)\n", "[ 213 2021 350 25 4596 570 12 74 29962 1088 318 29940\n", " 12619 4989 947 311 29936 945 13206 2636 259 40 23487 3\n", " 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0]\n" ] } ], "source": [ "# Corrected Unpacking\n", "for element in train_ds.take(1):\n", " # Unpack element: ((X_encoder, X_decoder), Y_target)\n", " (encoder_inputs, decoder_inputs), target_outputs = element \n", "\n", " print(f\"✅ Successfully retrieved one batch from the dataset.\")\n", "\n", " # ... The rest of your printing code will now work ...\n", " \n", " # Print the shape and data type of the encoder input batch\n", " print(\"\\n--- Encoder Inputs (Questions) ---\")\n", " print(f\"Shape: {encoder_inputs.shape}\") # This will now be a Tensor\n", " print(f\"DType: {encoder_inputs.dtype}\")\n", "\n", " # Print the first sequence (one example) from the encoder batch\n", " print(\"\\nFirst Encoder Sequence (Example 1/Batch)\")\n", " print(encoder_inputs[0].numpy())\n", "\n", " # Print the shape and data type of the decoder input batch\n", " print(\"\\n--- Decoder Inputs (Partial Answers) ---\")\n", " print(f\"Shape: {decoder_inputs.shape}\") # This will now be a Tensor\n", " print(f\"DType: {decoder_inputs.dtype}\")\n", "\n", " # Print the first sequence (one example) from the decoder batch\n", " print(\"\\nFirst Decoder Sequence (Example 1/Batch)\")\n", " print(decoder_inputs[0].numpy())\n", "\n", " # Print the target outputs (optional, but useful for verification)\n", " print(\"\\n--- Target Outputs (Ground Truth) ---\")\n", " print(f\"Shape: {target_outputs.shape}\")\n", " print(f\"DType: {target_outputs.dtype}\")\n", " print(\"\\nFirst Target Sequence (Example 1/Batch)\")\n", " print(target_outputs[0].numpy())\n", " \n", " break" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:49.027233Z", "iopub.status.busy": "2025-11-05T13:43:49.026989Z", "iopub.status.idle": "2025-11-05T13:43:49.032774Z", "shell.execute_reply": "2025-11-05T13:43:49.032126Z", "shell.execute_reply.started": "2025-11-05T13:43:49.027197Z" }, "trusted": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "<_TakeDataset element_spec=((TensorSpec(shape=(150, 30), dtype=tf.int32, name=None), TensorSpec(shape=(150, 63), dtype=tf.int32, name=None)), TensorSpec(shape=(150, 63), dtype=tf.int32, name=None))>\n" ] } ], "source": [ "print(train_ds.take(1))" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:49.033558Z", "iopub.status.busy": "2025-11-05T13:43:49.033361Z", "iopub.status.idle": "2025-11-05T13:43:49.051704Z", "shell.execute_reply": "2025-11-05T13:43:49.051068Z", "shell.execute_reply.started": "2025-11-05T13:43:49.033544Z" }, "trusted": true }, "outputs": [], "source": [ "# ================================\n", "# 8. Model Layers\n", "# ================================\n", "class PositionalEmbedding(layers.Layer):\n", " def __init__(self, seq_len, vocab_size, embed_dim, **kwargs):\n", " super().__init__(**kwargs)\n", " self.token_emb = layers.Embedding(vocab_size, embed_dim)\n", " # Initializes a positional embedding matrix of size (seq_len, embed_dim)\n", " self.pos_emb = layers.Embedding(seq_len, embed_dim)\n", " self.seq_len = seq_len # Stored for get_config\n", "\n", " def call(self, x):\n", " length = tf.shape(x)[-1]\n", " # Creates positions [0, 1, 2, ..., length-1] dynamically\n", " positions = tf.range(start=0, limit=length, delta=1) \n", " return self.token_emb(x) + self.pos_emb(positions)\n", "\n", " # get_config remains correct for serialization\n", " def get_config(self):\n", " cfg = super().get_config()\n", " cfg.update({\"seq_len\": self.seq_len, \"vocab_size\": VOCAB_SIZE, \"embed_dim\": EMBED_DIM})\n", " return cfg\n", "\n", "class TransformerEncoder(layers.Layer):\n", " def __init__(self, embed_dim, dense_dim, num_heads, **kwargs):\n", " super().__init__(**kwargs)\n", " self.attn = layers.MultiHeadAttention(num_heads, embed_dim)\n", " self.ffn = keras.Sequential([layers.Dense(dense_dim, activation=\"relu\"), layers.Dense(embed_dim)])\n", " self.ln1 = layers.LayerNormalization()\n", " self.ln2 = layers.LayerNormalization()\n", "\n", " def call(self, x, mask=None):\n", " if mask is not None: mask = mask[:, tf.newaxis, :]\n", " attn = self.attn(x, x, attention_mask=mask)\n", " x = self.ln1(x + attn)\n", " ffn = self.ffn(x)\n", " return self.ln2(x + ffn)\n", "\n", " def get_config(self):\n", " cfg = super().get_config()\n", " cfg.update({\"embed_dim\": EMBED_DIM, \"dense_dim\": DENSE_DIM, \"num_heads\": NUM_HEADS})\n", " return cfg\n", "\n", "class TransformerDecoder(layers.Layer):\n", " def __init__(self, embed_dim, dense_dim, num_heads, **kwargs):\n", " super().__init__(**kwargs)\n", " self.self_attn = layers.MultiHeadAttention(num_heads, embed_dim)\n", " self.cross_attn = layers.MultiHeadAttention(num_heads, embed_dim)\n", " self.ffn = keras.Sequential([layers.Dense(dense_dim, activation=\"relu\"), layers.Dense(embed_dim)])\n", " self.ln1 = layers.LayerNormalization()\n", " self.ln2 = layers.LayerNormalization()\n", " self.ln3 = layers.LayerNormalization()\n", "\n", " def get_causal_mask(self, x):\n", " seq_len = tf.shape(x)[1]\n", " mask = tf.linalg.band_part(tf.ones((seq_len, seq_len)), -1, 0)\n", " return tf.cast(mask, tf.int32)[tf.newaxis, ...]\n", "\n", " def call(self, x, enc_out, mask=None):\n", " causal_mask = self.get_causal_mask(x)\n", " attn1 = self.self_attn(x, x, attention_mask=causal_mask)\n", " x = self.ln1(x + attn1)\n", " padding_mask = mask[:, tf.newaxis, :] if mask is not None else None\n", " attn2 = self.cross_attn(x, enc_out, enc_out, attention_mask=padding_mask)\n", " x = self.ln2(x + attn2)\n", " ffn = self.ffn(x)\n", " return self.ln3(x + ffn)\n", "\n", " def get_config(self):\n", " cfg = super().get_config()\n", " cfg.update({\"embed_dim\": EMBED_DIM, \"dense_dim\": DENSE_DIM, \"num_heads\": NUM_HEADS})\n", " return cfg\n", "\n", "# ================================\n", "# 9. Build Model (2 inputs!)\n", "# Assuming SEQ_LEN_TE is 64 (based on the error: expected 64, found 63)\n", "# Set this variable based on the constant defined in your global scope\n", "DEC_INPUT_LEN = SEQ_LEN_TE - 1 \n", "\n", "def build_model():\n", " # Encoder Input: The question sequence length (SEQ_LEN_EN) is unchanged.\n", " enc_in = keras.Input(shape=(SEQ_LEN_EN,), dtype=\"int64\", name=\"encoder_inputs\")\n", " \n", " # Decoder Input: MUST be SEQ_LEN_TE - 1 (e.g., 63) to match the sliced data.\n", " dec_in = keras.Input(shape=(DEC_INPUT_LEN,), dtype=\"int64\", name=\"decoder_inputs\")\n", "\n", " # --- Encoder Stack ---\n", " # PositionalEmbedding for the Encoder (uses original length)\n", " enc_emb = PositionalEmbedding(SEQ_LEN_EN, VOCAB_SIZE, EMBED_DIM)(enc_in)\n", " x = enc_emb\n", " for _ in range(NUM_LAYERS_ENC):\n", " x = TransformerEncoder(EMBED_DIM, DENSE_DIM, NUM_HEADS)(x)\n", " enc_out = x\n", "\n", " # --- Decoder Stack ---\n", " # PositionalEmbedding for the Decoder (uses the new, shorter length)\n", " dec_emb = PositionalEmbedding(DEC_INPUT_LEN, VOCAB_SIZE, EMBED_DIM)(dec_in)\n", " x = dec_emb\n", " for _ in range(NUM_LAYERS_DEC):\n", " # Pass the encoder output (enc_out) to the decoder cross-attention\n", " x = TransformerDecoder(EMBED_DIM, DENSE_DIM, NUM_HEADS)(x, enc_out)\n", " \n", " # Final dense layer to predict vocabulary token logits\n", " logits = layers.Dense(VOCAB_SIZE)(x)\n", "\n", " model = keras.Model([enc_in, dec_in], logits)\n", " return model\n", "# ================================\n", "# 10. Loss & Metrics\n", "# ================================\n", "def masked_loss(y_true, y_pred):\n", " loss_fn = keras.losses.SparseCategoricalCrossentropy(from_logits=True, reduction='none')\n", " loss = loss_fn(y_true, y_pred)\n", " mask = tf.cast(tf.not_equal(y_true, 0), loss.dtype)\n", " return tf.reduce_sum(loss * mask) / tf.reduce_sum(mask)\n", "\n", "def masked_accuracy(y_true, y_pred):\n", " y_pred = tf.argmax(y_pred, axis=-1, output_type=y_true.dtype)\n", " matches = tf.cast(tf.equal(y_true, y_pred), tf.float32)\n", " mask = tf.cast(tf.not_equal(y_true, 0), tf.float32)\n", " return tf.reduce_sum(matches * mask) / tf.reduce_sum(mask)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:49.052942Z", "iopub.status.busy": "2025-11-05T13:43:49.052761Z", "iopub.status.idle": "2025-11-05T13:43:56.741222Z", "shell.execute_reply": "2025-11-05T13:43:56.740406Z", "shell.execute_reply.started": "2025-11-05T13:43:49.052930Z" }, "trusted": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Loading checkpoint...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/usr/local/lib/python3.11/dist-packages/keras/src/layers/layer.py:393: UserWarning: `build()` was called on layer 'positional_embedding', however the layer does not have a `build()` method implemented and it looks like it has unbuilt state. This will cause the layer to be marked as built, despite not being actually built, which may cause failures down the line. Make sure to implement a proper `build()` method.\n", " warnings.warn(\n", "/usr/local/lib/python3.11/dist-packages/keras/src/layers/layer.py:393: UserWarning: `build()` was called on layer 'transformer_encoder', however the layer does not have a `build()` method implemented and it looks like it has unbuilt state. This will cause the layer to be marked as built, despite not being actually built, which may cause failures down the line. Make sure to implement a proper `build()` method.\n", " warnings.warn(\n", "/usr/local/lib/python3.11/dist-packages/keras/src/layers/layer.py:393: UserWarning: `build()` was called on layer 'positional_embedding_1', however the layer does not have a `build()` method implemented and it looks like it has unbuilt state. This will cause the layer to be marked as built, despite not being actually built, which may cause failures down the line. Make sure to implement a proper `build()` method.\n", " warnings.warn(\n", "/usr/local/lib/python3.11/dist-packages/keras/src/layers/layer.py:393: UserWarning: `build()` was called on layer 'transformer_encoder_1', however the layer does not have a `build()` method implemented and it looks like it has unbuilt state. This will cause the layer to be marked as built, despite not being actually built, which may cause failures down the line. Make sure to implement a proper `build()` method.\n", " warnings.warn(\n", "/usr/local/lib/python3.11/dist-packages/keras/src/layers/layer.py:393: UserWarning: `build()` was called on layer 'transformer_decoder', however the layer does not have a `build()` method implemented and it looks like it has unbuilt state. This will cause the layer to be marked as built, despite not being actually built, which may cause failures down the line. Make sure to implement a proper `build()` method.\n", " warnings.warn(\n", "/usr/local/lib/python3.11/dist-packages/keras/src/layers/layer.py:393: UserWarning: `build()` was called on layer 'transformer_decoder_1', however the layer does not have a `build()` method implemented and it looks like it has unbuilt state. This will cause the layer to be marked as built, despite not being actually built, which may cause failures down the line. Make sure to implement a proper `build()` method.\n", " warnings.warn(\n" ] } ], "source": [ "# ================================\n", "# 13. Train or Load\n", "# ================================\n", "if os.path.exists(CHECKPOINT_PATH):\n", " print(\"Loading checkpoint...\")\n", " model = keras.models.load_model(CHECKPOINT_PATH, custom_objects={\n", " \"PositionalEmbedding\": PositionalEmbedding,\n", " \"TransformerEncoder\": TransformerEncoder,\n", " \"TransformerDecoder\": TransformerDecoder,\n", " \"masked_loss\": masked_loss,\n", " \"masked_accuracy\": masked_accuracy\n", " })\n", "else:\n", " model = build_model()\n", " model.compile(\n", " optimizer=keras.optimizers.Adam(1e-4),\n", " loss=masked_loss,\n", " metrics=[masked_accuracy]\n", " )\n", "\n", " print(\"Training...\")\n", " history = model.fit(\n", " train_ds,\n", " validation_data=val_ds,\n", " epochs=EPOCHS,\n", " verbose=2,\n", " callbacks=[\n", " tf.keras.callbacks.ModelCheckpoint(\n", " CHECKPOINT_PATH,\n", " save_best_only=True,\n", " monitor='val_loss',\n", " verbose=1\n", " ),\n", " tf.keras.callbacks.EarlyStopping(\n", " monitor='val_loss',\n", " patience=3,\n", " restore_best_weights=True\n", " )\n", " ]\n", " )\n", "\n", " model.save(CHECKPOINT_PATH)\n", " print(f\"Model saved: {CHECKPOINT_PATH}\")" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:56.742581Z", "iopub.status.busy": "2025-11-05T13:43:56.742309Z", "iopub.status.idle": "2025-11-05T13:43:56.747282Z", "shell.execute_reply": "2025-11-05T13:43:56.746382Z", "shell.execute_reply.started": "2025-11-05T13:43:56.742563Z" }, "trusted": true }, "outputs": [], "source": [ "# ================================\n", "# 12. Save Tokenizer Info\n", "# ================================\n", "with open(\"tokenizer_info.json\", \"w\") as f:\n", " json.dump({\n", " \"spm_model\": SPM_MODEL,\n", " \"start_id\": int(START_ID),\n", " \"end_id\": int(END_ID),\n", " \"seq_len_en\": SEQ_LEN_EN,\n", " \"seq_len_te\": SEQ_LEN_TE\n", " }, f)" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T13:43:56.748345Z", "iopub.status.busy": "2025-11-05T13:43:56.748157Z", "iopub.status.idle": "2025-11-05T13:43:56.815708Z", "shell.execute_reply": "2025-11-05T13:43:56.814995Z", "shell.execute_reply.started": "2025-11-05T13:43:56.748330Z" }, "trusted": true }, "outputs": [], "source": [ "# ================================\n", "# 13. Plot History\n", "# ================================\n", "def plot_history(history, prefix=\"got_qa\"):\n", " # Loss\n", " plt.figure(figsize=(10, 6))\n", " plt.plot(history.history['loss'], label='Train Loss')\n", " plt.plot(history.history['val_loss'], label='Val Loss')\n", " plt.title('Training & Validation Loss')\n", " plt.xlabel('Epoch')\n", " plt.ylabel('Loss')\n", " plt.legend()\n", " plt.grid(True, alpha=0.3)\n", " plt.tight_layout()\n", " loss_path = f\"{prefix}_loss.png\"\n", " plt.savefig(loss_path, dpi=300)\n", " plt.show()\n", " print(f\"Saved: {loss_path}\")\n", "\n", " # Accuracy\n", " plt.figure(figsize=(10, 6))\n", " plt.plot(history.history['masked_accuracy'], label='Train Acc')\n", " plt.plot(history.history['val_masked_accuracy'], label='Val Acc')\n", " plt.title('Training & Validation Accuracy')\n", " plt.xlabel('Epoch')\n", " plt.ylabel('Accuracy')\n", " plt.legend()\n", " plt.grid(True, alpha=0.3)\n", " plt.tight_layout()\n", " acc_path = f\"{prefix}_acc.png\"\n", " plt.savefig(acc_path, dpi=300)\n", " plt.show()\n", " print(f\"Saved: {acc_path}\")\n", "\n", "if 'history' in locals():\n", " plot_history(history)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": { "iopub.execute_input": "2025-11-05T14:12:26.123895Z", "iopub.status.busy": "2025-11-05T14:12:26.123017Z", "iopub.status.idle": "2025-11-05T14:13:11.057855Z", "shell.execute_reply": "2025-11-05T14:13:11.057156Z", "shell.execute_reply.started": "2025-11-05T14:12:26.123869Z" }, "trusted": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Running inference on Game of Thrones QA model\n", "\n", "Q: \n", "A: This is the captain of the guard.\n", "\n", "Q: What does Robb's army do at the Green Fork of the Trident?\n", "A: Robb's army gathers at the Green Fork.\n", "\n", "Q: Who plays Maester Aemon in season 5?\n", "A: Peter Vaughan plays Maester Aemon.\n", "\n", "Q: What is 'General Electric' related to in this text?\n", "A: 'General Electric' related to 'What' is listed among other terms and entities, suggesting it is a television program that has been recognized or nominated.\n", "\n", "Q: Where did the line 'I brought us' appear?\n", "A: The line 'I brought us' appeared in Season 02, Episode 08 (The Prince of Winterfell).\n", "\n", "Q: What is House Bracken? (Part 19)\n", "A: The Brackens are part of the war that is of the Dance of the Dragons , and the Blackwoods are among the lords of the riverlands who oppose House Tully . The Brackens and the Blackwoods are among the lords of the riverlands who are\n", "\n", "Q: Who is Tyana Wylde?\n", "A: Tyana Wylde is the wife of SER AENYS, belonging to Wylde.\n", "\n", "Q: What was the political outcome of the \"Battle of the Kingsroad\"?\n", "A: The Battle of the Kingsroad led by Lord Borros Baratheon, Lord of Storm's End, and the army of the Riverlands were annihilated by the forces of House Lannister.\n", "\n", "Q: What is \"Log in\"?\n", "A: \"Log in\" is the process for existing users to access their Wikipedia accounts.\n", "\n", "Q: What is the Dothraki language?\n", "A: The Dothraki language is a fictional language spoken by the Dothraki people, a nomadic people.\n", "\n", "Q: Which house holds Tyshara Lannister?\n", "A: House Lannister\n", "\n", "Q: What is the relationship between NAIL and HAMMER?\n", "A: NAIL is the apprentice of HAMMER.\n", "\n", "Q: What was Charles Dance's role in the TV film 'Trial & Retribution'?\n", "A: Charles Dance played Greg Harwood Fell across 2 episodes.\n", "\n", "Q: What is \"The Bellingham Herald\"?\n", "A: The Bellingham Herald is a daily newspaper published in the United States.\n", "\n", "Q: How many major awards did The Dick Van Dyke Show win at the 18th Primetime Emmy Awards?\n", "A: The Dick Van Dyke Show won 2 major awards.\n", "\n", "Q: Where did the line 'I imagine you're right.' appear?\n", "A: The line 'I imagine you're right.' appeared in Season 03, Episode 02 (Dark Wings Dark Words).\n", "\n", "Q: What is stated in the section A Game of Thrones about Lyanna Stark? (Part 1)\n", "A: Eddard and his companions return to the Vale of Arryn , who had been fostered at the Eyrie by Lord Jon Arryn , Lord of the Eyrie , and has been fostered by Lord Petyr Baelish , who has been fostered by Lord Eddard Stark , Lord of\n", "\n", "Q: What is the relationship between CERSEI LANNISTER and King Robert I Baratheon?\n", "A: CERSEI LANNISTER is the daughter of King Robert I Baratheon. Additional details: widow of King Robert I Baratheon\n", "\n", "Q: What is the scientific name for the brittle star belonging to the family Ophiocamacidae?\n", "A: The scientific name is Ophiocamax fascism.\n", "\n", "Q: What are the fantasy subgenres that are characterized by their focus on magical girls or similar protagonists?\n", "A: The fantasy subgenres that are characterized by their focus on magical girls or similar protagonists include Sookie or Fantasycounter.\n", "\n", "Q: What is the \"40th Daytime Creative Arts Emmy Awards\"?\n", "A: The 40th Daytime Creative Arts Emmy Awards is an award ceremony.\n", "\n", "Q: What were the titles of the Polish editions of 'A Feast for Crows'?\n", "A: The Polish editions were published in the Polish editions of 'A Feast for Crows' and 'A Dance with Dragons' (2011).\n", "\n", "Q: What is stated in the section Birth about Years after Aegon's Conquest/Calculations Ages (Continued2)? (Part 473)\n", "A: No further specifications can be given. Pate was thus born in either 281 AC or 282 AC .\n", "\n", "Q: What is A Game of Thrones-Chapter 19? (Part 2)\n", "A: Jon is watching the host of the Night's Watch climb. When he arrives, he sees a small group of men wearing a helmet and a helmet that has fallen into a snow-and-earth horse. The old manpower of the Night's Watch is able to walk, but he is\n", "\n", "Q: When was House Harlaw of the Tower of Glimmering founded?\n", "A: The Harlaws of the Tower of Glimmering\n", "\n", "Q: What does 'Print/export' offer?\n", "A: 'Print/export' provides options for users to download the page as a PDF or in other printable formats.\n", "\n", "Q: What passage is cited by 'A Clash of Kings, Theon I, pp. 172û173'?\n", "A: This citation refers to the second chapter of Theon Greyjoy's perspective in 'A Clash of Kings,' covering pages 233 and 1693.\n", "\n", "Q: Who is the spouse of Hosman Norcross?\n", "A: Delena Florent\n", "\n", "Q: Where did the line 'while the rest of you played.' appear?\n", "A: The line 'while the rest of you played.' appeared in Season 10, Episode 11 (Game of Thrones 07x03 Queens Justice TBS English C orig Addic7ed com).\n", "\n", "Q: What is stated in the section Character about Myles Mooton?\n", "A: Myles was a man of sixty-three men and women. He was a good friend of Lord Jonah Mooton , the Lord of Maidenpool .\n", "\n", "Q: What is the relationship between BALON GREYJOY and GOODBROTHER?\n", "A: BALON GREYJOY has GOODBROTHER as its lord bannerman. Additional details: of Great Wyk\n", "\n", "Q: What are the words of House Uller of Hellholt?\n", "A: The words of House Uller\n", "\n", "Q: Why did George R. R. Martin not make complete world maps available early on?\n", "A: Martin said in 2003 that complete world maps were not made available so that readers could better identify with people of the real Middle Ages who were uneducated about distant places.\n", "\n", "Q: What is the meaning of \"Nonbelief\" in the context of \"Religious unbelief\"?\n", "A: In the context of \"Jews not unbelief\" refers to the belief that the existence of God or divine rule can be held.\n", "\n", "Q: What is the significance of '5th_International_Emmy_Awards'?\n", "A: The 5th International Emmy Awards refers to a specific year's ceremony for the International Emmy Awards.\n", "\n", "Q: Who played Frances in season 6?\n", "A: Frances played Frances.\n", "\n", "Q: Where did the line 'we'll get there before the dead.' appear?\n", "A: The line 'we'll get there before the dead.' appeared in Season 04, Episode 01 (Game of Thrones S04E01).\n", "\n", "Q: What is Jon Pox? (Part 1)\n", "A: Jon Pox was a knight from House Vance of Wayfarer's Rest . He died in the aftermath of the War of the Ninepenny Kings .\n", "\n", "Q: What is the relationship between House Martell and Princess Elia?\n", "A: House Martell is the principal sworn house of of Princess Elia. Additional details: their seat at Sunspear\n", "\n", "Q: What are the seats of House Stark of Winterfell?\n", "A: Winterfell (formerly)\n", "\n", "Q: What is the time usage for the 'Family_tree_of_Tytos_Lannister' template?\n", "A: The 'Family_tree_of_Tytos_Lannister' template has a time usage of 7.945 ms.\n", "\n", "Q: What is the \"House of Black and White\"?\n", "A: The House of Black and White is a noble house from the Seven Kingdoms.\n", "\n", "Q: Which actor won Outstanding Lead Actor in a Comedy Series?\n", "A: Not specified in provided text\n", "\n", "Q: What is the gender of Hallyne?\n", "A: Male\n", "\n", "Q: What items did Tyrion regain possession of thanks to Catelyn Stark's intervention?\n", "A: Tyrion escaped a penny gift to Catelyn Stark, who was promised to her.\n", "\n", "Q: What is stated in the section Birth about Years after Aegon's Conquest/Calculations Ages? (Part 349)\n", "A: No further specifications can be given. Alys was thus born in either 290 AC or 291 AC .\n", "\n", "Q: What is Harbert Paege? (Part 4)\n", "A: During the tourney at Ashford Meadow , Harbert's maester was killed by Ser Glendon Hewett in the castle's castle .\n", "\n", "Q: What is the relationship between ALESANDER and SYMOND?\n", "A: ALESANDER is the son of SYMOND. Additional details: a singer\n", "\n", "Q: What is the purpose of the flaps on a dust jacket?\n", "A: The flaps of the dust jacket are flaps that folds over the horizontal ends of the boards and is a blurb, and the author's biography.\n", "\n", "Q: What is Fantasmas (TV series)?\n", "A: Fantasmas (TV series) is a series title found in the text.\n", "\n", "Q: What is the \"Iron Throne\"?\n", "A: The Iron Throne is the seat of power in the Seven Kingdoms, forged from the swords of Aegon the Conqueror's defeated enemies.\n", "\n", "Q: Which song was performed by Flight of the Conchords from \"Unnatural Love\"?\n", "A: Flight of the Conchords performed by Flight of the Conchords from \"Unnatural Love\".\n", "\n", "Q: In which TV series seasons does Nail appear?\n", "A: Season 1, Season 2, Season 3, Season 4, Season 5, Season 6\n", "\n", "Q: I see no lord. Only a dog dressed in chickenbones, who rattles when he rides.\n", "A: This was a defiantly figure in linen robes trimmed with white stripes, a distinctive voice in a red-gold crescent field. It was made by the Night's Watch and the 'most powerful' and 'most powerful' and 'Prince' and 'Frozen Blades') were made by the men\n", "\n", "Q: What is described in the House Jast during the Books[] section in House_Jast?\n", "A: Lord Antario Jast , head of the house.\n", "\n", "Q: What is Lysa Arryn? (Part 14)\n", "A: Lysa's sister, Catelyn Stark , releases Petyr from captivity at the Eyrie , [18] but she is forced to marry Lysa to Lord Beric. [19] [20]\n", "\n", "Q: What is stated in the section References and Notes about A Storm of Swords-Chapter 73? (Part 1)\n", "A: The synopsis was copied from Aol member vbkorik27 previously at\n", "\n", "Q: Who is DELENA FLORENT?\n", "A: DELENA FLORENT is the daughter of SER HOSMAN NORCROSS.\n", "\n", "Q: How did Ned Stark's execution affect the Stark children?\n", "A: Ned Stark's execution was crucial for the execution of Eddard Stark, who was executed.\n", "\n", "Q: What was the reason for splitting A Feast for Crows and A Dance with Dragons into two volumes?\n", "A: The book was split into two volumes due to the cliffhanger ending up in the cliffhanger ending up with the last kiss of the novel.\n", "\n", "Q: What is the 'Choice Awards 2018'?\n", "A: The 'Choice Awards 2018' is a title found in the New ⁇ ealand television service for the most awards for the television series.\n", "\n", "Q: What is the \"63rd Primetime Emmy Awards\"?\n", "A: This refers to the 63rd ceremony of the Primetime Emmy Awards, honoring excellence in primetime television programming.\n", "\n", "Q: What are the titles held by Sylas?\n", "A: Old King\n", "\n", "Q: What did Jaime remind Ser Boros Blount of regarding Tommen's safety?\n", "A: Jaime reminded Ser Boros that Tommen was not a good-hearted, but he was not a gentle soul. He also mentioned that he had no harm to his sister, Cersei, and the queen would have been a good place.\n", "\n", "Q: Where did the line 'that even dragons burned in flight.' appear?\n", "A: The line 'that even dragons burned in flight.' appeared in Season 10, Episode 11 (flame game of thrones conquest and rebellion 2017 EnglishSDH).\n", "\n", "Q: What is Peach? (Part 5)\n", "A: The Peach is located in Stoney Sept . It is located in Stoney Sept .\n", "\n", "Q: What is the Conflict of First Battle of Tumbleton?\n", "A: Dance of the Dragons\n", "\n", "Q: What is stated in the section Chapter 3: Mors II about List of characters created for the Cyanide game? (Part 7)\n", "A: Ondrew, a brigand in the Gift.\n", "\n", "Q: Who is SER DAVEN?\n", "A: SER DAVEN is the son of SER STAFFORD LANNISTER.\n", "\n", "Q: When is \"The Winds of Winter\" expected to be released?\n", "A: \"The Winds of Winter\" is expected to be released in 2019.\n", "\n", "Q: What is the title of the first book in the A Song of Ice and Fire series?\n", "A: The first book in the A Song of Ice and Fire series is titled \"A Game of Thrones.\"\n", "\n", "Q: What happened to Storm's End during the War of the Usurper?\n", "A: During the War of the Usurper, Storm's End was besieged for a year by Mace Tyrell, who was besieged by Mace Tyrell's army.\n", "\n", "Q: What happened to Wyman Manderly's heir, Ser Wylis?\n", "A: Ser Wylis was captured when Roose Bolton treacherously sent a large Northern force to be wiped out by Randyll Tarly.\n", "\n", "Q: What is the purpose of the 'Navbox' template?\n", "A: The 'Navbox' template is used to link related articles and links to related articles.\n", "\n", "Q: Who is Cragorn and where is he at the beginning of the text?\n", "A: Cragorn is a servant at the House of the Iron Islands. He is described as a servant at the House of the Citadel.\n", "\n", "Q: What was the overall approval rating for Game of Thrones season 5 on Rotten Tomatoes?\n", "A: On Rotten Tomatoes, the overall approval rating from 7 critics with an average rating of 8.5 out of 10.\n", "\n", "Q: What is the Lannister sigil and words?\n", "A: The Lannister sigil is a golden lion rampant on a crimson field. Their words are 'Hear Me Roar ⁇ '.\n", "\n", "Q: Where did the line 'in Maester Aemon's library.' appear?\n", "A: The line 'in Maester Aemon's library.' appeared in Season 02, Episode 05 (The Ghost of Harrenhal).\n", "\n", "Q: What is Years after Aegon's Conquest/Calculations Ages (Continued)? (Part 169)\n", "A: No further specifications can be given. Jeyne was thus born in or between ⁇ 217 AC and 261 AC .\n", "\n", "Q: What is mentioned in the history of Rosamund Ball?\n", "A: Rosamund was a dwarf, companion of Princess Saera Targaryen , who was the daughter of a Princess Saera Targaryen , who was her sister, Queen Rhaena Targaryen . She was betrothed to her sister Rhaena Targaryen , her sister, Queen Alysanne Targaryen , and her sister, Princess\n", "\n", "Q: What is stated in the section The Queen's protectors about House Targaryen? (Part 7)\n", "A: Ser Jorah Mormont , former Lord Commander of the Queensguard, former pit fighter and former pit fighter.\n", "\n", "Q: What is Doreah? (Part 2)\n", "A: In the television adaptation Game of Thrones , Doreah is portrayed by Volek.\n", "\n", "Q: What is stated in the section Episode 6: A Golden Crown about List of characters created forGame of Thrones? (Part 1133)\n", "A: Lord Erich Blackbrow. (mentioned only)\n", "\n", "Q: What is the relationship between CASS and TANSY?\n", "A: CASS is the employee of TANSY. Additional details: some of her peaches\n", "\n", "Q: Who is MAESTER OMER?\n", "A: MAESTER OMER is the son of SER COLIN, in service at Old Oak.\n", "\n", "Q: Which actresses have 4 nominations?\n", "A: Sharon Gless, Nicollaus, Nicolelli, and Kate McKe have 4 nominations.\n", "\n", "Q: How are the Shadow Men described?\n", "A: The Shadow Men are described as 'sweepers' and described as 'the Shadow of the Shadow Tower', renowned as 'wildlings' and 'white skin', possessing vast command of ice and magic.\n", "\n", "Q: What is Oldtown associated with?\n", "A: Oldtown is associated with the location where Maester Aemon Targaryen was originally the first Lord Commander of the Night's Watch.\n", "\n", "Q: What is Slaver's Bay?\n", "A: Slaver's Bay is a marginal sea of the Summer Sea, lying to the south of the Dothraki Sea.\n", "\n", "Q: What is 'Merman'?\n", "A: 'Merman' is a body of a body of water magazine.\n", "\n", "Q: Who are some notable servants and vassals of House Targaryen?\n", "A: Servants and vassals include House Stark, House Lannister, House Stark, and House Lannister are descendants of Lords of the Wide Way, and Kings.\n", "\n", "Q: What is 'Anthrax_(American_band)'?\n", "A: 'Anthrax_(American_band)' is mentioned in the text. Its relevance to the chapter's content is not detailed.\n", "\n", "Q: What is the significance of the 'Triple Crown of Acting'?\n", "A: The 'Triple Crown of Acting' refers to winning an Emmy, an Oscar, and an Oscar.\n", "\n", "Q: Who is Jay Sandrich?\n", "A: Jay Sandrich is a character from the TV series 'The_Sand_cuts', from the American poet, pist, and pop-upist, and 'The_carged'.\n", "\n", "Q: Who captures Brienne, Podrick, and Hyle, and why are they threatened?\n", "A: They are captured by the brotherhood without banners, led by Hyle Hunt.\n", "\n", "Q: What is the gender of Palla?\n", "A: Female\n", "\n", "Q: What is the significance of the 'jhat'?\n", "A: The 'jhat' refers to the jhats leadership and command of the war.\n", "\n", "Q: What was Euron Crows Eye doing across the world?\n", "A: Euron Crows Eye had sailed to Slaver's Bay to sack the world of Westeros.\n", "\n", "Q: What is the final verse of 'The Dornishman's Wife' as sung in the tent?\n", "A: The final verse is ⁇ a 'The Dornishman’s Wife’s first. ⁇ The Dornishman’s Wife ⁇ 's son ⁇ and ⁇ The Dornishman’s Wife ⁇ 's son ⁇ and ⁇ . ⁇ The man with a horned ⁇ 's 'The\n", "\n", "Q: Where did the line 'I defended the city' appear?\n", "A: The line 'I defended the city' appeared in Season 02, Episode 08 (The Prince of Winterfell).\n", "\n", "Q: Where did the line 'They'd pass wildling villages.' appear?\n", "A: The line 'They'd pass wildling villages.' appeared in Season 02, Episode 05 (The Ghost of Harrenhal).\n", "\n", "Q: Where did the line 'I like her pretty.' appear?\n", "A: The line 'I like her pretty.' appeared in Season 03, Episode 02 (Dark Wings Dark Words).\n", "\n", "Q: What happened to the æJaqen = Syrio ForelÆ mask theory?\n", "A: The ⁇ Amory Lorch man Jaqen ⁇ Rorge, Jaqen H'ghar, and Jaqen H'ghar, Rorge, and Biter. Arya escaped, and Jaqen H'ghar escaped. Arya and Jaqen H'ghar escaped, disguised Arya, disguised as Jaqen H'ghar, Rorge, and Jaqen H\n", "\n", "Q: What is stated in the section Character about Willam Dustin? (Part 1)\n", "A: According to a semi-canon source, Willam was a seasoned warrior.\n", "\n", "Q: What is Sphinx? (Part 14)\n", "A: In the aftermath of the battle, Tyrion Lannister sees a huge black-skinned woman wearing black-skinned Opskin , who are trained in battle. [10]\n", "\n", "Q: What is the Notable places of New Castle?\n", "A: New Castle Black\n", "\n", "Q: What is Landing of the Golden Company? (Part 3)\n", "A: The Golden Company is a company of sellswords , and Free Cities , Meereen , and Meereen . The sellswords are part of the Golden Company , and Dorne , but they are intercepted by the Volantene fleet. The sellswords' swords are defeated by the Tattered Prince\n", "\n", "Q: What is stated in the section House Keath at the end of the third century about House Keath? (Part 1)\n", "A: The known Keaths during the timespan of the events described in A Song of Ice and Fire are:\n", "\n", "Q: What is stated in the section A Clash of Kings about Greywater Watch? (Part 2)\n", "A: Jojen Reed tells Bran Stark that he knows of his father, Lord Eddard Stark , would have to be fostered at Greywater Watch as a hostage.\n", "\n", "Q: What is stated in the section A Game of Thrones about Doreah? (Part 6)\n", "A: Daenerys and her khas are confined by her handmaiden, Doreah , and she bathes in the pit of the Red Mountains . [6]\n", "\n", "Q: What is Category:Images by Zach Graves? (Part 1)\n", "A: Images by ⁇ achJ ( Website )\n", "\n", "Q: What is A Game of Thrones-Chapter 21? (Part 5)\n", "A: Tyrion is in the yard, but he is not sure that he is talking to Jon. Jon comments that he is not talking about his father. Jon comments that he is not a friend of the Night's Watch, but he does not want to know about Jon.\n", "\n", "Q: What is the Location of Ashford?\n", "A: Reach , Westeros\n", "\n", "Q: What is Category:Dromonds?\n", "A: Characters from Dromonds\n", "\n", "Q: What is the Page of A Clash of Kings-Chapter 35?\n", "A: 333 UK HC ( Other versions )\n", "\n", "Q: What is mentioned in the history of Allard Royce? (Part 2)\n", "A: Jonos was eventually defeated by Lord Allard Royce of Runestone in the Vale of Arryn . He was slain by Ser Arnold Arryn , who had been sent to the Eyrie to aid House Arryn .\n", "\n", "Q: What is the relationship between MELLARIO and PRINCESS ARIANNE?\n", "A: MELLARIO has PRINCESS ARIANNE as its daughter. Additional details: eldest daughter\n", "\n", "Q: What is the relationship between MORYA and Lord Walder Frey?\n", "A: MORYA is the third daughter of Lord Walder Frey. Additional details: m. Ser Flement Brax\n", "\n", "Q: What is the relationship between HARWIN and Hullen?\n", "A: HARWIN is the son of Hullen. Additional details: a boy of eight (via uncle to Lord Eddard Stark of Winterfell).\n", "\n", "Q: What is the relationship between SER DAMION LANNISTER and TYWIN LANNISTER?\n", "A: SER DAMION LANNISTER is the cousin of TYWIN LANNISTER. Additional details: Married Lady Shiera Crakehall\n", "\n", "Q: What is the relationship between TYWIN LANNISTER and SER DAMION LANNISTER?\n", "A: TYWIN LANNISTER has SER DAMION LANNISTER as its husband.\n", "\n", "Q: What is the relationship between Steffon Seaworth and Davos Seaworth?\n", "A: Steffon Seaworth is the son of Davos Seaworth. Additional details: eldest son\n", "\n", "Q: What is the relationship between Unspecified Patriarch and SER EMMON?\n", "A: Unspecified Patriarch has SER EMMON as its Son. Additional details: their eldest son, a Son of House Frey\n", "\n", "Q: What is the relationship between JON SNOW and GHOST?\n", "A: JON SNOW is the direwolf of GHOST. Additional details: Jon’s white direwolf\n", "\n", "Q: What is the relationship between Lord and ùMaceÆs\thousehold\tat\tHighgarden?\n", "A: Lord has ⁇ Mace ⁇ Mace ⁇ Mace ⁇ Mace ⁇ Mace ⁇ Mace’s household at Highgarden. Additional details: Lord of the Arbor\n", "\n", "Q: What is the relationship between EDRIC STORM and GERALD GOWER?\n", "A: EDRIC STORM has GERALD GOWER as its guard and protector.\n", "\n", "Q: What is the relationship between King Balon Greyjoy and MAESTER WENDAMYR?\n", "A: King Balon Greyjoy has MAESTER WENDAMYR as its Maester. Additional details: healer, counselor, tutor, and healer\n", "\n", "Q: What is the relationship between LADY MARGOT and Lord Titus Peake?\n", "A: LADY MARGOT is the married of Lord Titus Peake.\n", "\n", "Q: What is the relationship between Grey King and House Greyjoy?\n", "A: Grey King is the Grey King of of House Greyjoy.\n", "\n", "Q: What is the relationship between LORD TITUS PEAKE and Lady Margot?\n", "A: LORD TITUS PEAKE is the husband of Lady Margot.\n", "\n", "Q: What is the relationship between King Balon Greyjoy and DAGMER called CLEFTJAW?\n", "A: King Balon Greyjoy has DAGMER called CLEFTJAW as its captain, supporter. Additional details: commanding the ironborn, commanding the ironborn to destroy the ironborn and the ironborn.\n", "\n", "Q: What is the relationship between Aegon the Conquerer and Lord Edmyn Tully?\n", "A: Aegon the Conquerer is the King of King Aegon I. Additional details: rewarded Lord Edmyn Tully by raising House Tully to dominion over the lands of the Trident.\n", "\n", "Q: What is the relationship between THEON GREYJOY and WEX?\n", "A: THEON GREYJOY has WE ⁇ as its squire. Additional details: a boy of twelve, a mute\n", "\n", "Q: What is stated in the section Appearance and Character about Aerea Targaryen? (Part 4)\n", "A: Aerea was born in 42 AC , the birth of King Jaehaerys I Targaryen , and Queen Alysanne Targaryen , who had been the princess's heir to the Iron Throne . She was known to be a dragonrider , who had been serving the princess and queen, and her mother\n", "\n", "Q: What is stated in the section Synopsis about A Clash of Kings-Chapter 11? (Part 2)\n", "A: Theon is taken to the castle of Winterfell , where he is still held by Theon Greyjoy , who has been the captain of the Myraham in Lordsport . Theon is not a servant or a servant, but he is still unsure of his father Balon. Balon declares\n", "\n", "Q: What is the Place of A Storm of Swords-Chapter 17?\n", "A: King's Landing\n", "\n", "Q: What is stated in the section The Princess and the Queen about Errata of history novellas? (Part 4)\n", "A: The novella says Princess Rhaenyra Targaryen was named after her father's death. However, in Fire ⁇ Blood , the Princess of Dorne , died in the cradle.\n", "\n", "Q: What is stated in the section A Dance with DragonsAppendix about Errata of main series? (Part 8)\n", "A: Cuger , mistakenly listed as Cugen. [70]\n", "\n", "Q: What is stated in the section A Dance with Dragons about Holy Refuge?\n", "A: Yorko Terys rows Arya Stark to the House of Black and White. Arya Stark spots the statue of a dead.\n", "\n", "Q: What is Hugh Hammer? (Part 6)\n", "A: When Prince Aemond Targaryen was one of the conspirators who accompanied King's Landing to Oldtown , Hugh desperately wanted to be a knight of the Kingsguard . Ulf was killed by the mob in the battle, and Hugh Hammer , who was killed by the dragon .\n", "\n", "Q: What is stated in the section Rivers in Essos about List of rivers? (Part 6)\n", "A: Rivermen\n", "\n", "Q: What is stated in the section A Clash of Kings about Marriage? (Part 2)\n", "A: The wedding of Lord Edmure Tully and Roslin Frey , a wedding between Lord Edmure Tully and Roslin Frey . [55]\n", "\n", "Q: What is stated in the section A Dance with Dragons about Nymella Toland?\n", "A: Nymella is present when Ser Balon Swann arrives at Sunspear to deliver the Mountain's skull . She drinks when Ricasso raises a toast to King Tommen I Baratheon .\n", "\n", "Q: What is stated in the section A Dance with Dragons about Tattered Prince? (Part 2)\n", "A: The Tattered Prince is willing to leave Meereen, but the Tattered Prince is willing to betray them, and to offer the Tattered Prince, to the Windblown to help defend the city. The Tattered Prince is willing to offer the Windblown, but the Tattered Prince wants to help the\n", "\n", "Q: What are references in First_Men?\n", "A: No answer\n", "\n", "Q: Where did the line 'What are our words?' appear?\n", "A: The line 'What are our words?' appeared in Season 06, Episode 05 (The Door DL DD5 1 H 264).\n", "\n", "Q: Where did the line 'but I don't want to see' appear?\n", "A: The line 'but I don't want to see' appeared in Season 02, Episode 08 (The Prince of Winterfell).\n", "\n", "Q: Where did the line 'I'm not kissing your fucking hand.' appear?\n", "A: The line 'I'm not kissing your fucking hand.' appeared in Season 04, Episode 08 (Game of Thrones S04E08).\n", "\n", "Q: Where did the line 'I killed my lover' appear?\n", "A: The line 'I killed my lover' appeared in Season 02, Episode 02 (The Night Lands).\n", "\n", "Q: Where did the line 'But you have many miles to go.' appear?\n", "A: The line 'But you have many miles to go.' appeared in Season 03, Episode 01 (bdrip).\n", "\n", "Q: Where did the line 'Who was the first?' appear?\n", "A: The line 'Who was the first?' appeared in Season 01, Episode 08 (The Pointy End).\n", "\n", "Q: How did Sansa explain her father's statement that Joffrey was not the king?\n", "A: Sansa explained that her father was a boy, who was a boy, and that he was not the king. She was a boy, and had been a king, and had been the one who had ever loved him.\n", "\n", "Q: \"You would execute your own son?\"\n", "A: Jaime asked this question, dismissing the thought of the situation.\n", "\n", "Q: What question did Xaro Xhoan Daxos ask after Daenerys freed him?\n", "A: ⁇ aro asked, \"Who are you?\"\n", "\n", "Q: What are the aliases of Dudley?\n", "A: The Knight of Dudley\n", "\n", "Q: How did Garth VII deal with the alliance between the Storm King and the King of the Rock?\n", "A: Garth VII led the Stormbreakers to Hardhome, with the Storm King, who was arranging the Storm's End to attack the Storm King.\n", "\n", "Q: What was the 'Best Variety Show' winner?\n", "A: 'Best Variety Show' was the title of a Golden Girls.\n", "\n", "Q: When did Game of Thrones Season 7 get its premiere date on HBO?\n", "A: Game of Thrones Season 7 was released on May 5, 2019.\n", "\n", "Q: What is the significance of \"Howland Sharp\"?\n", "A: Howland Sharp's identification of the white hart and its symbolic meaning for King Viserys adds a layer of prophecy and foreshadowing to the narrative, subtly emphasizing the importance of rightful claims and the presence of true royalty during a time of succession uncertainty, suggesting divine endorsement.\n", "\n", "Q: What does 'Expensive parser function count: 33/500' indicate about the page's processing?\n", "A: This indicates that 33 resource-intensive parser functions were used, with a limit of 500.\n", "\n", "Q: What jape led to the undoing of Saera and her companions?\n", "A: The Barris of Saera's mother and her three favorites were not yet unknown to the issue of Saera's marriage.\n", "\n", "Q: Who is Samwell Tarly?\n", "A: Samwell Tarly is a character from A Song of Ice and Fire.\n", "\n", "Q: What is the genre of 'The Saint of Bright Doors' by Vajra Chandrasekera?\n", "A: Not specified in provided text, but it is listed among speculative fiction awards.\n", "\n", "Q: Which market is currently the only one where the HBO Go brand is still active?\n", "A: Vietnam is the only market where the HBO Go brand is still active.\n", "\n", "Q: What is the relationship between IGON VYRWEL and MACE TYRELL?\n", "A: IGON VYRWEL is the Household member of MACE TYRELL. Additional details: Captain of the guard for Mace Tyrell's guard.\n", "\n", "Q: What is A Game of Thrones-Chapter 23? (Part 2)\n", "A: Daenerys is in the hall of the servants of the servants of the Lord Commander . She is woken by Jorah Mormont , who tells her that he is in the Free Cities . Daenerys is not interested in the training of the\n", "\n", "Q: What is Helman Tallhart? (Part 10)\n", "A: When Robb Stark is proclaimed King in the North at Riverrun , Lord Roose Bolton sends word to Helman to command the siege of Moat Cailin , and is granted the castle to House Bolton . [6]\n", "\n", "Q: What is Marselen? (Part 3)\n", "A: Daenerys Targaryen purchases Unsullied from the Good Masters of Astapor . [3] Marselen of the Mother's Son are her three-headed Unsullied , a red-gold woman with a whip. [3] Marselen is a red-gold hair, and is a symbol of the Unsullied. [4]\n", "\n", "Q: What is stated in the section The Triarchy and the Daughters' War about Tyrosh? (Part 1)\n", "A: The Triarchy of the Kingdom of the Three Daughters' War was destroyed by the Triarchy , resulting in the death of Sharako Lohar in 131 AC . The Triarchy eventually led an alliance with Lys , Myr , and Tyrosh , began to trade with Tyrosh , Myr ,\n", "\n", "Q: What is described in the References and Notes[] section in Meleys?\n", "A: The Princess and the Queen\n", "\n", "Q: Where did the line 'You look pale, child.' appear?\n", "A: The line 'You look pale, child.' appeared in Season 01, Episode 08 (The Pointy End).\n", "\n", "Q: Where did the line 'I know that I can't.' appear?\n", "A: The line 'I know that I can't.' appeared in Season 10, Episode 11 (Game of Thrones 07x04 The Spoils of War WEBDL English HI C orig Addic7ed com).\n", "\n", "Q: What was Tyrion Lannister's internal thought about Prince Oberyn Martell's wit?\n", "A: Tyrion Lannister thought, 'I am not your brother, and you are not, and you are not like you.'\n", "\n", "Q: Who is Aeron Greyjoy?\n", "A: Aeron Greyjoy is the youngest of Balon's surviving brothers. He is a high priest of the Drowned God and became a high priest of the Drowned God.\n", "\n", "Q: What is Catelyn Stark's primary motivation?\n", "A: Catelyn Stark's primary motivation is to secure the loyalty of House Tully and her family.\n", "\n", "Q: What are the allegiances of Gerion Lannister?\n", "A: House Lannister of Casterly Rock\n", "\n", "Q: What did Lysa eventually admit?\n", "A: Lysa eventually admitted that she was sending her own son, Jon Arryn, and the Lord of the Eyrie.\n", "\n", "Q: Which programs tied for Outstanding Art Direction for Variety or Nonfiction Programming?\n", "A: The New York Times, The New York Times, The New York Times, and Martin Scientele.\n", "\n", "Q: Who rules Westeros at the beginning of the story?\n", "A: At the beginning of the story, the majority of Westeros is ruled by Lord Eddard Stark.\n", "\n", "Q: Who wrote the third episode of Season 2, \"The Burning Mill\"?\n", "A: David E. Kelley.\n", "\n", "Q: What is the significance of \"Archived from the original on 21 August 2007\"?\n", "A: This indicates that the original source was archived on 21stock.\n", "\n", "Q: What is Bernie Sanders' self-description mentioned in The Guardian article from April 30, 2015?\n", "A: The Guardian article about 'the Guardian' 'the biggest thing' ⁇ 'Emmy, 'There's no one is a God'.\n", "\n", "Q: What does Jon's mission beyond the Wall signify?\n", "A: It signifies Jon's leadership and his commitment to the existential threat of the Others, even in the existential threat to Westeros.\n", "\n", "Q: What is the relationship between HALLIS MOLLEN and his uncles and aunts?\n", "A: HALLIS MOLLEN has his uncles and aunts as its his uncles and aunts. Additional details: HALLIS MOLLEN\n", "\n", "Q: What is the Issue of Armond Connington?\n", "A: Armond Connington\n", "\n", "Q: What is stated in the section Initial invasion about First Dornish War? (Part 5)\n", "A: The next day, Lord Orys Baratheon , marched south with his army, and marched south with his army. The Dornish host was attacked by Orys Baratheon , who marched south with his army. The Vulture King was defeated in the battle, and Orys was killed in battle.\n", "\n", "Q: What is Lanna?\n", "A: Lanna is a prostitute who assists Lanna in the Happy Port brothel.\n", "\n", "Q: What is stated in the section Known tattooed characters about Tattoo? (Part 14)\n", "A: A man of the Free City of Lys :\n", "\n", "Q: Where did the line 'for such a pretext?' appear?\n", "A: The line 'for such a pretext?' appeared in Season 03, Episode 08 (Second Sons).\n", "\n", "Q: Where did the line 'just to gut these three.' appear?\n", "A: The line 'just to gut these three.' appeared in Season 03, Episode 08 (Second Sons).\n", "\n", "Q: Who was the man that took it upon himself to be a hero?\n", "A: The man that took it was a hero who had been a hero who had been a hero.\n", "\n", "Q: What happened to Sandor (The Hound) Clegane's face?\n", "A: Sandor Clegane's face was scarred and killed by Sandor Clegane.\n", "\n", "Q: Myranda shares gossip with Sansa, reminding her of Jeyne.\n", "A: This statement is challenged by Myranda Royce, who was not the case, but the specific context of the provided text.\n", "\n", "Q: What is \"The Daily Show with Jon Stewart\"?\n", "A: The Daily Show with Jon Stewart is a satirical news program.\n", "\n", "Q: What was the condition of Khal Drogo after the injury that developed into sepsis?\n", "A: After the injury, Khal Drogo was left in a catatonic state, unable to move, and his khalasar was left in a catatonic state.\n", "\n", "Q: What happened between Arrax and Vhagar?\n", "A: Arrax was the dragon bonded to the dragon Vhagar.\n", "\n", "Q: What is King's Landing (A Song of Ice and Fire)?\n", "A: King's Landing is the capital city of the Seven Kingdoms and the seat of the Iron Throne. It is the capital city of the Seven Kingdoms and the seat of the Iron Throne.\n", "\n", "Q: What is the primary source material for the \"Game of Thrones\" television series?\n", "A: The primary source material for the \"Game of Thrones\" television series is \"A Dance with Dragons\".\n", "\n", "Q: Who is SER BRYNDEN TULLY?\n", "A: SER BRYNDEN TULLY is the uncle of ROBB STARK, called THE BLACKFISH.\n", "\n", "Q: What is Canker Jeyne? (Part 1)\n", "A: Canker Jeyne is a slave soldiers in Astapor .\n", "\n", "Q: What is stated in the section Historical Members about House Westerling? (Part 2)\n", "A: Lord Westerling, ruling during the reign of King Aenys I Targaryen . [10]\n", "\n", "Q: What is Rhaegar Targaryen? (Part 10)\n", "A: Rhaegar was born at Dragonstone in 280 AC , and the event was held at the Red Keep by the Great Council of 101 AC . He was named after his father Maekar , who had been named Hand of the King . Aerys had been Hand of the\n", "\n", "Q: What is described in the History[] section in Hallis_Hornwood?\n", "A: Hallis and his army were sent by the Golden Company to take refuge in the Wolf's Den . He was later captured by the army of the Starks , and was later executed by the Lannisters .\n", "\n", "Q: Where did the line 'Wearing the crown for so many years' appear?\n", "A: The line 'Wearing the crown for so many years' appeared in Season 06, Episode 08 (Game of Thrones S06E08).\n", "\n", "Q: What did Arianne ask to see instead of her father the next morning?\n", "A: If they were to see the next morning, Arianne asked to see her father, who had been the next time.\n", "\n", "Q: When did \"A Golden Crown\" first air?\n", "A: The episode \"A Golden Crown\" first aired on May 13, 2011.\n", "\n", "Q: What does 'the hundred gods of the Kingdom of Sarnor still worshipped' signify?\n", "A: This signifies the emergence of the Dothraki, a powerful, and a powerful civilization, signifying their power and influence in the Dothraki culture.\n", "\n", "Q: Which program won the award for Outstanding Limited Series?\n", "A: The Daily Show won the award for Outstanding Limited Series.\n", "\n", "Q: What is the significance of the 'golden stag' as a symbol?\n", "A: Not specified in provided text\n", "\n", "Q: What does \"Is Nobody Going to San Antone?\" by Walton Simons in 'Texas Hold 'Em' imply?\n", "A: \"Is Nobody Going to San Antone?\" by Walton Simons implies a story about the role of the upcoming role or impending.\n", "\n", "Q: What is the meter of the poem \"Fire and Ice\"?\n", "A: The meter of the poem \"Fire and Ice\" is a companion book, written by Robert Frost, and by the Ice of Fire book series.\n", "\n", "Q: What is the relationship between Aegon the Dragon and Torrhen Stark?\n", "A: Aegon the Dragon is the Overlord of Torrhen Stark. Additional details: Torrhen Stark swore fealty to him and intends to conquer Westeros.\n", "\n", "Q: What is stated in the section Goals about Great ranging? (Part 1)\n", "A: The ranging is reported to be Whitetree and a few hundred men-at-arms are found by the rangers of the Night's Watch . The brothers are not yet able to use them as their horses. The brothers are also trained to fight by the wildling leader, Qhorin\n", "\n", "Q: What is stated in the section Grasses about Plants? (Part 5)\n", "A: The Bastard of Uplands\n", "\n", "Q: What are references in Hallyne?\n", "A: No answer\n", "\n", "Q: Where did the line 'A girl has no desires.' appear?\n", "A: The line 'A girl has no desires.' appeared in Season 03, Episode 02 (Dark Wings Dark Words).\n", "\n", "Q: Where does Jeor Mormont send Jon Snow and Qhorin Halfhand?\n", "A: In the Old Bear, Jeor Mormont sends Jon Snow and his ancestral home to Winterfell, where he is sent to the Wall.\n", "\n", "Q: When was Harlan Hunter born?\n", "A: In or between 240 AC and 249 AC\n", "\n", "Q: What is \"PBS\"?\n", "A: PBS is a public broadcasting service that is mentioned.\n", "\n", "Q: What is the significance of 'the Lightning Lord'?\n", "A: 'The Lightning Lord' is a nickname for Beric Dondarrion, a legendary figure who kills Beric Dondarrion.\n", "\n", "Q: What types of decks do players control in A Game of Thrones: The Card Game?\n", "A: Players control decks and decks of cards.\n", "\n", "Q: \"The consequences are grave when you discharge a cardiac patient without further assessment.\"\n", "A: This statement was a critical response to the previous medical student, which caused a profound impact on the medical condition.\n", "\n", "Q: What is Aegon Targaryen (son of Rhaegar)/Theories? (Part 15)\n", "A: The following counter-arguments:\n", "\n", "Q: What is Horas Harroway? (Part 2)\n", "A: When King Maegor I Targaryen visited Winterfell in 41 AC , Horas and his twin were killed. [3]\n", "\n", "Q: What is stated in the section A Storm of Swords about Robin Ryger?\n", "A: Robin is part of the force that Ser Jaime Lannister sends Robin to the south to protect Robin from the lands of House Ryger .\n", "\n", "Q: Where did the line 'and put leeches on me.' appear?\n", "A: The line 'and put leeches on me.' appeared in Season 03, Episode 05 (Kissed by Fire).\n", "\n", "Q: What kind of person was Qotho, one of Khal Drogo's bloodriders?\n", "A: Qotho was a kindhearted, kindhearted, and kind man with a blood, and often wore a fiery temper. He was also a kind husband.\n", "\n", "Q: Who played Wun Wun in season 6?\n", "A: Ian Whyte played Wun Wun.\n", "\n", "Q: Where did Arianne Martell and her companions await the arrival of Myrcella Baratheon?\n", "A: They were at the Greenblood in the Reach.\n", "\n", "Q: What is \"Red Prophet by Orson Scott Card (1989)\"?\n", "A: \"Red Prophet by Orson Scott Card\" won the Locus Award for Best Fantasy Novel in 1990.\n", "\n", "Q: Who was the squire captured and brought to the Red Keep?\n", "A: The squire was Ser Addam Marbrand's squire and brought to the Red Keep.\n", "\n", "Q: What historical parallels are noted regarding Cersei's introduction and her loyalty to House Lannister over her husband, the king?\n", "A: The king drew parallels to Cersei, the king of the king, Joffrey I Baratheon, and Tommen Baratheon.\n", "\n", "Q: What resemblance do scholars note between House Stark/House of York and House Lannister/House of Lancaster?\n", "A: These individuals are based on the historical text.\n", "\n", "Q: What motif does Larrington describe regarding the presumed deaths of two young Targaryen heirs in the novel's pre-history?\n", "A: Larrington describes the presumed deaths of two young Targaryen heirs in the novel's pre-history by the reaction of the epist in the \"Dance of the Dragons\".\n", "\n", "Q: To whom is Petyr Baelish compared by scholars, and why?\n", "A: Prior to the scholars, authors can be found in the provided text. Therefore, author Robert Jordan is not mentioned.\n", "\n", "Q: To whom is Khal Drogo compared, and why?\n", "A: Khal Drogo is a powerful khal, and his army to march south to seek out his khalasar. He is a warlord of the Dothraki Sea and his khalasar.\n", "\n", "Q: How does Westeros' primary religious institution compare to the medieval Catholic Church?\n", "A: Westeros' primary deity is the primary religious institution of religious faith, with the medieval Catholic Church.\n", "\n", "Q: What similarities have critics noted between the Wall in the novel and historical structures?\n", "A: The comparison of the foundation of the Wall, the focus on the historical structures of the region, the land-bridge, and the First Men, the Night's Watch have been noted for its own defense.\n", "\n", "Q: What cultures are cited as influences for the Dothraki culture?\n", "A: The Dothraki culture is represented by the Dothraki people, and ancient peoples of the Dothraki.\n", "\n", "Q: In what ways are female characters entered into marriage in the novel?\n", "A: The novel entered into marriage to one of the two female characters in the novel's events.\n", "\n", "Q: How does Borowska-Szerszun interpret Daenerys' narrative regarding traditional fairy tales?\n", "A: Borowska-Szerszun faces of fairy tales, including the title of the Father, Mother, and fairy tales.\n", "\n", "Q: What consequence does Larrington attribute to Daenerys' growing influence over Drogo?\n", "A: Larrington says, Larrington uses her growing influence over Drogo's abusive nature.\n", "\n", "Q: What political alliances are established through the marriages of Cersei and Catelyn?\n", "A: In the political alliances, Cersei is established by the Vale of Arryn, the Vale of Arryn, and the Eyrie are established by the Lords of the Eyrie and Wardens of the East.\n", "\n", "Q: How is the betrothal of Cersei and Catelyn's children used for political purposes?\n", "A: Cersei and her children are given the same name for her son, Joffrey, and Sansa.\n", "\n", "Q: What is the described nature of the betrothal between Joffrey and Sansa?\n", "A: Joffrey is described as the only thing to be a very startling match for Joffrey. Sansa is described as 'a-m ⁇ ' and 'a-pieces' to the point that Sansa is the only betrothal to Joffrey.\n", "\n", "Q: What is a contested topic regarding the series' female characters?\n", "A: The contested topic is a contested topic of the Middle East and the Iron Throne.\n", "\n", "Q: How is the series' depiction of rape described by scholars and fans?\n", "A: The Shakespeare series is described as 'series' partly fantasy novels by scholars and fans, and fans of the same name, and the series.\n", "\n", "Q: What does Mariah Larsson state about Drogo's knowledge of Daenerys' language and its use?\n", "A: Mariah Larsson states that Drogo's knowledge of Daenerys's knowledge is about Drogo's age.\n", "\n", "Q: According to Carroll, what \"problematizes\" Daenerys' consent, and what is his description of Drogo's actions?\n", "A: According to Carroll, Daenerys' consent to Khal Drogo's consent, which she believes Daenerys's consent to combat and the consequences of self-ditional nature.\n", "\n", "Q: How does Daenerys attempt to prevent or mitigate sexual violence by her husband's warriors?\n", "A: Daenerys tries to prevent the people from mitigate by her husband, Khal Drogo, who is unaware of their threat.\n", "\n", "Q: What is the consequence of Daenerys intervening to prevent the rape of another woman?\n", "A: The consequence of Daenerys Daytime Emmy Award is that Daenerys's actions are witnessed and interpreted through the female woman who becomes a significant part of her life.\n", "\n", "Q: How is Cersei depicted as being subjected to sexual violence?\n", "A: Cersei is depicted as being subject to sexual violence and sexual violence.\n", "\n", "Q: How does Marta Eidsvσg contrast Cersei's role as a mother?\n", "A: Marta Eidsv ⁇ g contrasts Cersei's role as a mother-figure her role as a mother-figure her role as a mother-playing game.\n", "\n", "Q: How is Catelyn Stark depicted in relation to her children, including Ned's illegitimate son?\n", "A: Catelyn Stark is depicted as a child and a boy of eight, with whom she and Robb's illegitimate children are given birth.\n", "\n", "Q: Why is Catelyn's role as a viewpoint character considered unusual?\n", "A: Catelyn is considered a viewpoint character because she is the one who served as a viewpoint character.\n", "\n", "Q: What is Robert's reaction to the news of Daenerys' marriage and potential offspring?\n", "A: Robert is shocked to learn that Daenerys would not marry her. He believes that her father would not marry her.\n", "\n", "Q: What symbolism does Carroll note regarding Daenerys and the dragons?\n", "A: Carroll notes to the dragons, particularly Daenerys's dragons, symbolizes her own power and her own connection to the dragons.\n", "\n", "Q: How does Sheilagh O'Brien describe the maegi Mirri Maz Duur and her symbolism?\n", "A: Sheilagh Hunter describes the maegi as a serpent from the Fourteen Flames, a series of white and red, and a serpentine, and a serpentine castle, which was said to be from her mother.\n", "\n", "Q: What does Anne Gjelsvik suggest Mirri Maz Duur represents, and what is the consequence of her actions?\n", "A: Anne Gjelsvik's former Khal Drogo's former handmaiden, and a healer, and a former slave who uses a Valyrian phrase to control Daenerys Targaryen.\n", "\n", "Q: What symbolic action does Daenerys take against Mirri Maz Duur?\n", "A: Daenerys takes Khal Drogo into a catatonic state, burning Mirri's home and killing her unborn child.\n", "\n", "Q: What does Blaszkiewicz say about Aerys' reign and its impact?\n", "A: Blaszkiewicz states that the king is dead and is able to rule the throne, and is considered a decisive factor in the creation of the Mad King's perceived weakness.\n", "\n", "Q: How is Robert described in comparison to Aerys, and what is his perceived failing as king?\n", "A: Robert is described as a 'douver girl who lived in a strong, strong and beautiful beauty'.\n", "\n", "Q: How does Hudson describe Cersei's actions regarding Robert's authority?\n", "A: Hudson states that Cersei's authority is not to be a \"giant ruler.\" She also notes that the \"gine of the show's power has been lost.\"\n", "\n", "Q: How does Walton describe Ned Stark's role as a feudal lord?\n", "A: Walton describes Ned as a master of justice and a king, honorable lord, and the lord of honor of his lord father, Lord Eddard.\n", "\n", "Q: What does Pavlac say the \"game of thrones\" refers to?\n", "A: Pavlac stated that \"game of thrones\" refers to the ability to be a warrior, honorable and evil.\"\n", "\n", "Q: What does Cersei Lannister tell Ned about participation in the game of thrones?\n", "A: Cersei Lannister tells Ned that he has joined the Night's Watch and that he has joined the Night's Watch.\n", "\n", "Q: What event drives the disputed succession and the \"game of thrones\"?\n", "A: The Lhazareen are believed to be a kind of power and because their power, and the power of their own, are driven by their desire to unite the Seven Kingdoms.\n", "\n", "Q: What is the basis for the HBO television series Game of Thrones?\n", "A: Game of Thrones is based on the HBO television series Game of Thrones.\n", "\n", "Q: How did the television series Game of Thrones diverge from the novel A Game of Thrones?\n", "A: The series diverged from the novel A Game of Thrones by characters in the first season of the HBO series Game of Thrones, but HBO scrapped the series's first season.\n", "\n", "Q: What major change did the television series make to the novel's timeline?\n", "A: The series became the first major plot to be a major plot to place the novel's timeline in the novel.\n", "\n", "Q: Which characters' ages were increased in the television series compared to the novel?\n", "A: The ages of eight and nine-and-six years, and eight, and eight of the TV series were increased in the television series.\n", "\n", "Q: Who adapted A Game of Thrones as a graphic novel, and who provided the art?\n", "A: The artist was adapted by the first-person limited point of the comic book series and art.\n", "\n", "Q: What were some of the problems Daniel Abraham faced in adapting A Game of Thrones as a graphic novel?\n", "A: Daniel Abraham described the story of adapting to a half-s perspective in adapting to a story, and the series was 'one of the last Game of Thrones' series.\n", "\n", "Q: What is A Game of Thrones: Genesis?\n", "A: A Game of Thrones: Genesis is a real-time strategy video game based on the A Song of Ice and Fire series.\n", "\n", "Q: What classification does Martin use for writers' approaches to storytelling?\n", "A: Martin's graphic novel, Vining-tied's 'taken' story arcs: 'There't a story to a very good, and a subtle look, and subtle light.'\n", "\n", "Q: How has Martin's work impacted discussions about the series' authentic representation, according to Helen Young?\n", "A: Helen Young is the primary work of 'a' artificial intelligence, the art of the series' authenticity, and its focus on the authenticity of the series' authentic representation.\n", "\n", "Q: What is Helen Young's description of Tolkien's background versus Martin's?\n", "A: Helen Young is described as a strong-willed and a person with a focus on a pragmatic and self-confocused concept.\n", "\n", "Q: What does Young note about the dramatic effect of Eddard Stark's death?\n", "A: Young noted that 'The Bells' is a significant effect that Eddard Stark dies, and Jon Snow is portrayed as a 'vast moment' in the show' and 'Winter is Coming'.\n", "\n", "Q: What characterizes 'portal-quest fantasy'?\n", "A: 'portal-quest fantasy' is a part of a period of proportional plot to be a reader's best-selling fantasy trope.\n", "\n", "Q: How is the Three-Eyed Crow's dialogue presented in portal-quest fantasy, using Bran as an example?\n", "A: The Three-Eyed Crow's dialogue is not a reader's dialogue, with a mysterious perspective on a possibility to investigate the end of a child-bear.\n", "\n", "Q: What observation does Gary Westfahl highlight regarding Lord Eddard Stark and dire-wolf pups?\n", "A: Gary Westfahl points that Lord Eddard Stark had been the dire wolf of Lord Eddard Stark and dire wolf, and the dire wolf, thus far-fashioned dire wolf.\n", "\n", "Q: What does David Symons note about Martin's work in university classes?\n", "A: David Symons notes that Martin's work is not a series of medieval European folklore.\n", "\n", "Q: What belief do some fans hold about the series' medieval portrayal, and what is Carroll's counter-argument?\n", "A: Some fans believe that the series' fantasy is the idea of an epic fantasy series that the series has been written by William Gibson, which has been written by William Gibson.\n", "\n", "Q: What is Ned's remark to Catelyn about religion, and what difficulty does Larrington note?\n", "A: Ned remarks to Catelyn about the religion of the nobility that sees the way to the nobility of the religion of the Seven Kingdoms. She notes that the House Strong is a traditional religious, and the belief that her family is the true faith.\n", "\n", "Q: When did Martin have the idea for the Wall, and where did it originate?\n", "A: Martin had the idea for the Wall in the end of the first novel in the series, but he was in fact he was in a coma.\n", "\n", "Q: How does Carroll describe Cersei as a narrative foil to Sansa?\n", "A: Carroll describes Cersei as a story about her father, who is a recurring theme in the story of the 'Game of Thrones' world'.\n", "\n", "Q: What difficulty do commentators have with analyzing rape in A Song of Ice and Fire, according to Carroll?\n", "A: According to Carroll, the series' criticism of the series, critics appreciated the difficulty of sexual violence and women in the books.\n", "\n", "Q: \n", "A: This is the captain of the guard.\n", "\n", "Q: \n", "A: This is the captain of the guard.\n", "\n" ] } ], "source": [ "import tensorflow as tf\n", "import sentencepiece as spm\n", "import json\n", "import os\n", "import numpy as np\n", "\n", "# ================================\n", "# Load Config\n", "# ================================\n", "with open(\"/kaggle/input/got-qa-model/tensorflow2/default/1/tokenizer_info.json\") as f:\n", " info = json.load(f)\n", "\n", "SPM_MODEL = info[\"spm_model\"]\n", "START_ID = info[\"start_id\"]\n", "END_ID = info[\"end_id\"]\n", "SEQ_LEN_EN = info[\"seq_len_en\"]\n", "SEQ_LEN_TE = info[\"seq_len_te\"]\n", "def predict_step(src, tgt): \n", " return model([src, tgt], training=False)\n", "# ================================\n", "# Load Model & Tokenizer\n", "# ================================\n", "sp = spm.SentencePieceProcessor(model_file=SPM_MODEL)\n", "model = keras.models.load_model(CHECKPOINT_PATH, custom_objects={\n", " \"PositionalEmbedding\": PositionalEmbedding,\n", " \"TransformerEncoder\": TransformerEncoder,\n", " \"TransformerDecoder\": TransformerDecoder,\n", " \"masked_loss\": masked_loss,\n", " \"masked_accuracy\": masked_accuracy\n", " })\n", "DEC_INPUT_LEN = SEQ_LEN_TE - 1 \n", "def tokenize_question(question): \n", " ids = sp.encode(question, out_type=int) \n", " if len(ids) < SEQ_LEN_EN: \n", " ids = ids + [0] * (SEQ_LEN_EN - len(ids)) \n", " else: \n", " ids = ids[:SEQ_LEN_EN] \n", " return np.array([ids], dtype=np.int64)\n", "def decode_sequence(question, max_len=60):\n", " src_np = tokenize_question(question) # numpy (1, SEQ_LEN_EN)\n", " src = tf.constant(src_np, dtype=tf.int64) # tf.Tensor (1, SEQ_LEN_EN)\n", "\n", " # Start token (1,1)\n", " tgt = tf.constant([[START_ID]], dtype=tf.int64)\n", "\n", " for _ in range(max_len):\n", " # current length as Python int\n", " cur_len = int(tf.shape(tgt)[1].numpy()) # scalar Python int\n", "\n", " pad_len = DEC_INPUT_LEN - cur_len # Python int\n", " if pad_len < 0:\n", " # truncate to last DEC_INPUT_LEN tokens\n", " tgt_for_model = tgt[:, -DEC_INPUT_LEN:]\n", " effective_pos = DEC_INPUT_LEN - 1 # we will read logits at this index\n", " else:\n", " # pad on right with PAD_ID (assumed 0)\n", " paddings = [[0, 0], [0, pad_len]] # plain Python list of ints\n", " tgt_for_model = tf.pad(tgt, paddings, constant_values=0) # (1, DEC_INPUT_LEN)\n", " effective_pos = cur_len - 1 # index of latest token's logits\n", "\n", " # call the model (predict_step should accept tensors shaped (1, SEQ_LEN_EN) and (1, DEC_INPUT_LEN))\n", " logits = predict_step(src, tgt_for_model) # shape (1, DEC_INPUT_LEN, VOCAB)\n", "\n", " # Use Python int index into logits\n", " next_logits = logits[:, effective_pos, :] # shape (1, vocab)\n", " next_id = tf.argmax(next_logits, axis=-1, output_type=tf.int64) # shape (1,)\n", "\n", " # make (1,1) and append\n", " next_id = tf.expand_dims(next_id, axis=-1) # (1,1)\n", " tgt = tf.concat([tgt, next_id], axis=-1) # (1, cur_len+1)\n", "\n", " # stop if end token produced\n", " if int(next_id.numpy()[0][0]) == END_ID:\n", " break\n", "\n", " # remove start token and truncate at END_ID if present\n", " ids = tgt[0].numpy()\n", " ids = ids[1:] # drop START\n", " if END_ID in ids:\n", " ids = ids[:np.where(ids == END_ID)[0][0]]\n", " return sp.decode(ids.tolist())\n", "\n", "\n", "\n", "questions = \"\"\"\n", "What does Robb's army do at the Green Fork of the Trident?\n", "Who plays Maester Aemon in season 5?\n", "What is 'General Electric' related to in this text?\n", "Where did the line 'I brought us' appear?\n", "What is House Bracken? (Part 19)\n", "Who is Tyana Wylde?\n", "What was the political outcome of the \"Battle of the Kingsroad\"?\n", "What is \"Log in\"?\n", "What is the Dothraki language?\n", "Which house holds Tyshara Lannister?\n", "What is the relationship between NAIL and HAMMER?\n", "What was Charles Dance's role in the TV film 'Trial & Retribution'?\n", "What is \"The Bellingham Herald\"?\n", "How many major awards did The Dick Van Dyke Show win at the 18th Primetime Emmy Awards?\n", "Where did the line 'I imagine you're right.' appear?\n", "What is stated in the section A Game of Thrones about Lyanna Stark? (Part 1)\n", "What is the relationship between CERSEI LANNISTER and King Robert I Baratheon?\n", "What is the scientific name for the brittle star belonging to the family Ophiocamacidae?\n", "What are the fantasy subgenres that are characterized by their focus on magical girls or similar protagonists?\n", "What is the \"40th Daytime Creative Arts Emmy Awards\"?\n", "What were the titles of the Polish editions of 'A Feast for Crows'?\n", "What is stated in the section Birth about Years after Aegon's Conquest/Calculations Ages (Continued2)? (Part 473)\n", "What is A Game of Thrones-Chapter 19? (Part 2)\n", "When was House Harlaw of the Tower of Glimmering founded?\n", "What does 'Print/export' offer?\n", "What passage is cited by 'A Clash of Kings, Theon I, pp. 172û173'?\n", "Who is the spouse of Hosman Norcross?\n", "Where did the line 'while the rest of you played.' appear?\n", "What is stated in the section Character about Myles Mooton?\n", "What is the relationship between BALON GREYJOY and GOODBROTHER?\n", "What are the words of House Uller of Hellholt?\n", "Why did George R. R. Martin not make complete world maps available early on?\n", "What is the meaning of \"Nonbelief\" in the context of \"Religious unbelief\"?\n", "What is the significance of '5th_International_Emmy_Awards'?\n", "Who played Frances in season 6?\n", "Where did the line 'we'll get there before the dead.' appear?\n", "What is Jon Pox? (Part 1)\n", "What is the relationship between House Martell and Princess Elia?\n", "What are the seats of House Stark of Winterfell?\n", "What is the time usage for the 'Family_tree_of_Tytos_Lannister' template?\n", "What is the \"House of Black and White\"?\n", "Which actor won Outstanding Lead Actor in a Comedy Series?\n", "What is the gender of Hallyne?\n", "What items did Tyrion regain possession of thanks to Catelyn Stark's intervention?\n", "What is stated in the section Birth about Years after Aegon's Conquest/Calculations Ages? (Part 349)\n", "What is Harbert Paege? (Part 4)\n", "What is the relationship between ALESANDER and SYMOND?\n", "What is the purpose of the flaps on a dust jacket?\n", "What is Fantasmas (TV series)?\n", "What is the \"Iron Throne\"?\n", "Which song was performed by Flight of the Conchords from \"Unnatural Love\"?\n", "In which TV series seasons does Nail appear?\n", "I see no lord. Only a dog dressed in chickenbones, who rattles when he rides.\n", "What is described in the House Jast during the Books[] section in House_Jast?\n", "What is Lysa Arryn? (Part 14)\n", "What is stated in the section References and Notes about A Storm of Swords-Chapter 73? (Part 1)\n", "Who is DELENA FLORENT?\n", "How did Ned Stark's execution affect the Stark children?\n", "What was the reason for splitting A Feast for Crows and A Dance with Dragons into two volumes?\n", "What is the 'Choice Awards 2018'?\n", "What is the \"63rd Primetime Emmy Awards\"?\n", "What are the titles held by Sylas?\n", "What did Jaime remind Ser Boros Blount of regarding Tommen's safety?\n", "Where did the line 'that even dragons burned in flight.' appear?\n", "What is Peach? (Part 5)\n", "What is the Conflict of First Battle of Tumbleton?\n", "What is stated in the section Chapter 3: Mors II about List of characters created for the Cyanide game? (Part 7)\n", "Who is SER DAVEN?\n", "When is \"The Winds of Winter\" expected to be released?\n", "What is the title of the first book in the A Song of Ice and Fire series?\n", "What happened to Storm's End during the War of the Usurper?\n", "What happened to Wyman Manderly's heir, Ser Wylis?\n", "What is the purpose of the 'Navbox' template?\n", "Who is Cragorn and where is he at the beginning of the text?\n", "What was the overall approval rating for Game of Thrones season 5 on Rotten Tomatoes?\n", "What is the Lannister sigil and words?\n", "Where did the line 'in Maester Aemon's library.' appear?\n", "What is Years after Aegon's Conquest/Calculations Ages (Continued)? (Part 169)\n", "What is mentioned in the history of Rosamund Ball?\n", "What is stated in the section The Queen's protectors about House Targaryen? (Part 7)\n", "What is Doreah? (Part 2)\n", "What is stated in the section Episode 6: A Golden Crown about List of characters created forGame of Thrones? (Part 1133)\n", "What is the relationship between CASS and TANSY?\n", "Who is MAESTER OMER?\n", "Which actresses have 4 nominations?\n", "How are the Shadow Men described?\n", "What is Oldtown associated with?\n", "What is Slaver's Bay?\n", "What is 'Merman'?\n", "Who are some notable servants and vassals of House Targaryen?\n", "What is 'Anthrax_(American_band)'?\n", "What is the significance of the 'Triple Crown of Acting'?\n", "Who is Jay Sandrich?\n", "Who captures Brienne, Podrick, and Hyle, and why are they threatened?\n", "What is the gender of Palla?\n", "What is the significance of the 'jhat'?\n", "What was Euron Crows Eye doing across the world?\n", "What is the final verse of 'The Dornishman's Wife' as sung in the tent?\n", "Where did the line 'I defended the city' appear?\n", "Where did the line 'They'd pass wildling villages.' appear?\n", "Where did the line 'I like her pretty.' appear?\n", "What happened to the æJaqen = Syrio ForelÆ mask theory?\n", "What is stated in the section Character about Willam Dustin? (Part 1)\n", "What is Sphinx? (Part 14)\n", "What is the Notable places of New Castle?\n", "What is Landing of the Golden Company? (Part 3)\n", "What is stated in the section House Keath at the end of the third century about House Keath? (Part 1)\n", "What is stated in the section A Clash of Kings about Greywater Watch? (Part 2)\n", "What is stated in the section A Game of Thrones about Doreah? (Part 6)\n", "What is Category:Images by Zach Graves? (Part 1)\n", "What is A Game of Thrones-Chapter 21? (Part 5)\n", "What is the Location of Ashford?\n", "What is Category:Dromonds?\n", "What is the Page of A Clash of Kings-Chapter 35?\n", "What is mentioned in the history of Allard Royce? (Part 2)\n", "What is the relationship between MELLARIO and PRINCESS ARIANNE?\n", "What is the relationship between MORYA and Lord Walder Frey?\n", "What is the relationship between HARWIN and Hullen?\n", "What is the relationship between SER DAMION LANNISTER and TYWIN LANNISTER?\n", "What is the relationship between TYWIN LANNISTER and SER DAMION LANNISTER?\n", "What is the relationship between Steffon Seaworth and Davos Seaworth?\n", "What is the relationship between Unspecified Patriarch and SER EMMON?\n", "What is the relationship between JON SNOW and GHOST?\n", "What is the relationship between Lord and ùMaceÆs\thousehold\tat\tHighgarden?\n", "What is the relationship between EDRIC STORM and GERALD GOWER?\n", "What is the relationship between King Balon Greyjoy and MAESTER WENDAMYR?\n", "What is the relationship between LADY MARGOT and Lord Titus Peake?\n", "What is the relationship between Grey King and House Greyjoy?\n", "What is the relationship between LORD TITUS PEAKE and Lady Margot?\n", "What is the relationship between King Balon Greyjoy and DAGMER called CLEFTJAW?\n", "What is the relationship between Aegon the Conquerer and Lord Edmyn Tully?\n", "What is the relationship between THEON GREYJOY and WEX?\n", "What is stated in the section Appearance and Character about Aerea Targaryen? (Part 4)\n", "What is stated in the section Synopsis about A Clash of Kings-Chapter 11? (Part 2)\n", "What is the Place of A Storm of Swords-Chapter 17?\n", "What is stated in the section The Princess and the Queen about Errata of history novellas? (Part 4)\n", "What is stated in the section A Dance with DragonsAppendix about Errata of main series? (Part 8)\n", "What is stated in the section A Dance with Dragons about Holy Refuge?\n", "What is Hugh Hammer? (Part 6)\n", "What is stated in the section Rivers in Essos about List of rivers? (Part 6)\n", "What is stated in the section A Clash of Kings about Marriage? (Part 2)\n", "What is stated in the section A Dance with Dragons about Nymella Toland?\n", "What is stated in the section A Dance with Dragons about Tattered Prince? (Part 2)\n", "What are references in First_Men?\n", "Where did the line 'What are our words?' appear?\n", "Where did the line 'but I don't want to see' appear?\n", "Where did the line 'I'm not kissing your fucking hand.' appear?\n", "Where did the line 'I killed my lover' appear?\n", "Where did the line 'But you have many miles to go.' appear?\n", "Where did the line 'Who was the first?' appear?\n", "How did Sansa explain her father's statement that Joffrey was not the king?\n", "\"You would execute your own son?\"\n", "What question did Xaro Xhoan Daxos ask after Daenerys freed him?\n", "What are the aliases of Dudley?\n", "How did Garth VII deal with the alliance between the Storm King and the King of the Rock?\n", "What was the 'Best Variety Show' winner?\n", "When did Game of Thrones Season 7 get its premiere date on HBO?\n", "What is the significance of \"Howland Sharp\"?\n", "What does 'Expensive parser function count: 33/500' indicate about the page's processing?\n", "What jape led to the undoing of Saera and her companions?\n", "Who is Samwell Tarly?\n", "What is the genre of 'The Saint of Bright Doors' by Vajra Chandrasekera?\n", "Which market is currently the only one where the HBO Go brand is still active?\n", "What is the relationship between IGON VYRWEL and MACE TYRELL?\n", "What is A Game of Thrones-Chapter 23? (Part 2)\n", "What is Helman Tallhart? (Part 10)\n", "What is Marselen? (Part 3)\n", "What is stated in the section The Triarchy and the Daughters' War about Tyrosh? (Part 1)\n", "What is described in the References and Notes[] section in Meleys?\n", "Where did the line 'You look pale, child.' appear?\n", "Where did the line 'I know that I can't.' appear?\n", "What was Tyrion Lannister's internal thought about Prince Oberyn Martell's wit?\n", "Who is Aeron Greyjoy?\n", "What is Catelyn Stark's primary motivation?\n", "What are the allegiances of Gerion Lannister?\n", "What did Lysa eventually admit?\n", "Which programs tied for Outstanding Art Direction for Variety or Nonfiction Programming?\n", "Who rules Westeros at the beginning of the story?\n", "Who wrote the third episode of Season 2, \"The Burning Mill\"?\n", "What is the significance of \"Archived from the original on 21 August 2007\"?\n", "What is Bernie Sanders' self-description mentioned in The Guardian article from April 30, 2015?\n", "What does Jon's mission beyond the Wall signify?\n", "What is the relationship between HALLIS MOLLEN and his uncles and aunts?\n", "What is the Issue of Armond Connington?\n", "What is stated in the section Initial invasion about First Dornish War? (Part 5)\n", "What is Lanna?\n", "What is stated in the section Known tattooed characters about Tattoo? (Part 14)\n", "Where did the line 'for such a pretext?' appear?\n", "Where did the line 'just to gut these three.' appear?\n", "Who was the man that took it upon himself to be a hero?\n", "What happened to Sandor (The Hound) Clegane's face?\n", "Myranda shares gossip with Sansa, reminding her of Jeyne.\n", "What is \"The Daily Show with Jon Stewart\"?\n", "What was the condition of Khal Drogo after the injury that developed into sepsis?\n", "What happened between Arrax and Vhagar?\n", "What is King's Landing (A Song of Ice and Fire)?\n", "What is the primary source material for the \"Game of Thrones\" television series?\n", "Who is SER BRYNDEN TULLY?\n", "What is Canker Jeyne? (Part 1)\n", "What is stated in the section Historical Members about House Westerling? (Part 2)\n", "What is Rhaegar Targaryen? (Part 10)\n", "What is described in the History[] section in Hallis_Hornwood?\n", "Where did the line 'Wearing the crown for so many years' appear?\n", "What did Arianne ask to see instead of her father the next morning?\n", "When did \"A Golden Crown\" first air?\n", "What does 'the hundred gods of the Kingdom of Sarnor still worshipped' signify?\n", "Which program won the award for Outstanding Limited Series?\n", "What is the significance of the 'golden stag' as a symbol?\n", "What does \"Is Nobody Going to San Antone?\" by Walton Simons in 'Texas Hold 'Em' imply?\n", "What is the meter of the poem \"Fire and Ice\"?\n", "What is the relationship between Aegon the Dragon and Torrhen Stark?\n", "What is stated in the section Goals about Great ranging? (Part 1)\n", "What is stated in the section Grasses about Plants? (Part 5)\n", "What are references in Hallyne?\n", "Where did the line 'A girl has no desires.' appear?\n", "Where does Jeor Mormont send Jon Snow and Qhorin Halfhand?\n", "When was Harlan Hunter born?\n", "What is \"PBS\"?\n", "What is the significance of 'the Lightning Lord'?\n", "What types of decks do players control in A Game of Thrones: The Card Game?\n", "\"The consequences are grave when you discharge a cardiac patient without further assessment.\"\n", "What is Aegon Targaryen (son of Rhaegar)/Theories? (Part 15)\n", "What is Horas Harroway? (Part 2)\n", "What is stated in the section A Storm of Swords about Robin Ryger?\n", "Where did the line 'and put leeches on me.' appear?\n", "What kind of person was Qotho, one of Khal Drogo's bloodriders?\n", "Who played Wun Wun in season 6?\n", "Where did Arianne Martell and her companions await the arrival of Myrcella Baratheon?\n", "What is \"Red Prophet by Orson Scott Card (1989)\"?\n", "Who was the squire captured and brought to the Red Keep?\n", "What historical parallels are noted regarding Cersei's introduction and her loyalty to House Lannister over her husband, the king?\n", "What resemblance do scholars note between House Stark/House of York and House Lannister/House of Lancaster?\n", "What motif does Larrington describe regarding the presumed deaths of two young Targaryen heirs in the novel's pre-history?\n", "To whom is Petyr Baelish compared by scholars, and why?\n", "To whom is Khal Drogo compared, and why?\n", "How does Westeros' primary religious institution compare to the medieval Catholic Church?\n", "What similarities have critics noted between the Wall in the novel and historical structures?\n", "What cultures are cited as influences for the Dothraki culture?\n", "In what ways are female characters entered into marriage in the novel?\n", "How does Borowska-Szerszun interpret Daenerys' narrative regarding traditional fairy tales?\n", "What consequence does Larrington attribute to Daenerys' growing influence over Drogo?\n", "What political alliances are established through the marriages of Cersei and Catelyn?\n", "How is the betrothal of Cersei and Catelyn's children used for political purposes?\n", "What is the described nature of the betrothal between Joffrey and Sansa?\n", "What is a contested topic regarding the series' female characters?\n", "How is the series' depiction of rape described by scholars and fans?\n", "What does Mariah Larsson state about Drogo's knowledge of Daenerys' language and its use?\n", "According to Carroll, what \"problematizes\" Daenerys' consent, and what is his description of Drogo's actions?\n", "How does Daenerys attempt to prevent or mitigate sexual violence by her husband's warriors?\n", "What is the consequence of Daenerys intervening to prevent the rape of another woman?\n", "How is Cersei depicted as being subjected to sexual violence?\n", "How does Marta Eidsvσg contrast Cersei's role as a mother?\n", "How is Catelyn Stark depicted in relation to her children, including Ned's illegitimate son?\n", "Why is Catelyn's role as a viewpoint character considered unusual?\n", "What is Robert's reaction to the news of Daenerys' marriage and potential offspring?\n", "What symbolism does Carroll note regarding Daenerys and the dragons?\n", "How does Sheilagh O'Brien describe the maegi Mirri Maz Duur and her symbolism?\n", "What does Anne Gjelsvik suggest Mirri Maz Duur represents, and what is the consequence of her actions?\n", "What symbolic action does Daenerys take against Mirri Maz Duur?\n", "What does Blaszkiewicz say about Aerys' reign and its impact?\n", "How is Robert described in comparison to Aerys, and what is his perceived failing as king?\n", "How does Hudson describe Cersei's actions regarding Robert's authority?\n", "How does Walton describe Ned Stark's role as a feudal lord?\n", "What does Pavlac say the \"game of thrones\" refers to?\n", "What does Cersei Lannister tell Ned about participation in the game of thrones?\n", "What event drives the disputed succession and the \"game of thrones\"?\n", "What is the basis for the HBO television series Game of Thrones?\n", "How did the television series Game of Thrones diverge from the novel A Game of Thrones?\n", "What major change did the television series make to the novel's timeline?\n", "Which characters' ages were increased in the television series compared to the novel?\n", "Who adapted A Game of Thrones as a graphic novel, and who provided the art?\n", "What were some of the problems Daniel Abraham faced in adapting A Game of Thrones as a graphic novel?\n", "What is A Game of Thrones: Genesis?\n", "What classification does Martin use for writers' approaches to storytelling?\n", "How has Martin's work impacted discussions about the series' authentic representation, according to Helen Young?\n", "What is Helen Young's description of Tolkien's background versus Martin's?\n", "What does Young note about the dramatic effect of Eddard Stark's death?\n", "What characterizes 'portal-quest fantasy'?\n", "How is the Three-Eyed Crow's dialogue presented in portal-quest fantasy, using Bran as an example?\n", "What observation does Gary Westfahl highlight regarding Lord Eddard Stark and dire-wolf pups?\n", "What does David Symons note about Martin's work in university classes?\n", "What belief do some fans hold about the series' medieval portrayal, and what is Carroll's counter-argument?\n", "What is Ned's remark to Catelyn about religion, and what difficulty does Larrington note?\n", "When did Martin have the idea for the Wall, and where did it originate?\n", "How does Carroll describe Cersei as a narrative foil to Sansa?\n", "What difficulty do commentators have with analyzing rape in A Song of Ice and Fire, according to Carroll?\n", "\n", "\"\"\"\n", "\n", "print(\"\\n Running inference on Game of Thrones QA model\\n\")\n", "\n", "for q in questions.split('\\n'):\n", " try:\n", " answer = decode_sequence(q)\n", " print(f\"Q: {q}\")\n", " print(f\"A: {answer}\\n\")\n", " except Exception as e:\n", " print(f\"Error for question [{q}]: {e}\\n\")\n", "\n" ] } ], "metadata": { "kaggle": { "accelerator": "gpu", "dataSources": [ { "datasetId": 8655050, "sourceId": 13618980, "sourceType": "datasetVersion" }, { "isSourceIdPinned": true, "modelId": 490854, "modelInstanceId": 474960, "sourceId": 630334, "sourceType": "modelInstanceVersion" }, { "isSourceIdPinned": true, "modelId": 491226, "modelInstanceId": 475332, "sourceId": 630775, "sourceType": "modelInstanceVersion" } ], "dockerImageVersionId": 31153, "isGpuEnabled": true, "isInternetEnabled": true, "language": "python", "sourceType": "notebook" }, "kernelspec": { "display_name": "Python 3", "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.11.13" }, "papermill": { "default_parameters": {}, "duration": null, "end_time": null, "environment_variables": {}, "exception": null, "input_path": "__notebook__.ipynb", "output_path": "__notebook__.ipynb", "parameters": {}, "start_time": "2025-09-05T11:34:00.968853", "version": "2.6.0" } }, "nbformat": 4, "nbformat_minor": 4 }