Closed7

Haystackチュートリアルをやってみる: Build a Scalable Question Answering System

kun432kun432

Colaboratoryで進める。

GPUを有効にする必要があるので、「ノートブックの設定」で"T4 GPU"を使用する。

インストール。このチュートリアルではDocumentStoreにElasticSearchを使うので有効化しておく。

%%bash

pip install --upgrade pip
pip install farm-haystack[colab,preprocessing,elasticsearch,inference]

テレメトリー有効化。

from haystack.telemetry import tutorial_running

tutorial_running(3)

ロギング設定。

import logging

logging.basicConfig(format="%(levelname)s - %(name)s -  %(message)s", level=logging.WARNING)
logging.getLogger("haystack").setLevel(logging.INFO)
kun432kun432

DocumentStoreは、ElasticSearch DocumentStoreを使う。

ElasticSearchのアーカイブを取得して展開。

%%bash

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.2-linux-x86_64.tar.gz -q
tar -xzf elasticsearch-7.9.2-linux-x86_64.tar.gz
chown -R daemon:daemon elasticsearch-7.9.2

ElasticSearchをデーモンとして起動。

%%bash --bg

sudo -u daemon -- elasticsearch-7.9.2/bin/elasticsearch

起動が完了するまで30秒ほど待つ。

import time

time.sleep(30)

一応確認してみる

!ps auxw | grep elastic
root        2465  0.0  0.0  10776  4948 ?        S    09:10   0:00 sudo -u daemon -- elasticsearch-7.9.2/bin/elasticsearch
daemon      2466 78.2  9.9 3748536 1323596 ?     Sl   09:10   0:31 /content/elasticsearch-7.9.2/jdk/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -XX:+ShowCodeDetailsInExceptionMessages -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.locale.providers=SPI,COMPAT -Xms1g -Xmx1g -XX:+UseG1GC -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -Djava.io.tmpdir=/tmp/elasticsearch-17325493177708278979 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m -XX:MaxDirectMemorySize=536870912 -Des.path.home=/content/elasticsearch-7.9.2 -Des.path.conf=/content/elasticsearch-7.9.2/config -Des.distribution.flavor=default -Des.distribution.type=tar -Des.bundled_jdk=true -cp /content/elasticsearch-7.9.2/lib/* org.elasticsearch.bootstrap.Elasticsearch
daemon      2680  0.0  0.0  99596  6964 ?        Sl   09:10   0:00 /content/elasticsearch-7.9.2/modules/x-pack-ml/platform/linux-x86_64/bin/controller
root        2876  0.0  0.0   7372  3464 ?        S    09:10   0:00 /bin/bash -c ps auxw | grep elastic
root        2878  0.0  0.0   6480  2244 ?        S    09:10   0:00 grep elastic

ElasticSearch DocumentStoreの初期化

import os
from haystack.document_stores import ElasticsearchDocumentStore

# Get the host where Elasticsearch is running, default to localhost
host = os.environ.get("ELASTICSEARCH_HOST", "localhost")

document_store = ElasticsearchDocumentStore(host=host, username="", password="", index="document")
kun432kun432

パイプラインを使ってドキュメントのインデックスを作成する。

サンプルはBuild Your First Question Answering Systemと同じもの。

from haystack.utils import fetch_archive_from_http

doc_dir = "data/build_a_scalable_question_answering_system"

fetch_archive_from_http(
    url="https://s3.eu-central-1.amazonaws.com/deepset.ai-farm-qa/datasets/documents/wiki_gameofthrones_txt3.zip",
    output_dir=doc_dir,
)

今回はノードからパイプラインを作成する。使用するノードは以下。

  • TextConverter: テキストファイルをHaystackのDocumentオブジェクトに変換するノード。
  • PreProcessor: Document内のテキストを整形してチャンクに分割するノード。
from haystack import Pipeline
from haystack.nodes import TextConverter, PreProcessor

# パイプライン初期化
indexing_pipeline = Pipeline()

# TextConverter初期化
text_converter = TextConverter()

# PreProcessor初期化
preprocessor = PreProcessor(
    clean_whitespace=True,
    clean_header_footer=True,
    clean_empty_lines=True,
    split_by="word",
    split_length=200,
    split_overlap=20,
    split_respect_sentence_boundary=True,
)

LangChainでいうところのTextLoaderとTextSplitterみたいなものかな。

パイプラインに、TextConverter/PreProcessor/DocumentStoreノードを追加。

import os

indexing_pipeline.add_node(component=text_converter, name="TextConverter", inputs=["File"])
indexing_pipeline.add_node(component=preprocessor, name="PreProcessor", inputs=["TextConverter"])
indexing_pipeline.add_node(component=document_store, name="DocumentStore", inputs=["PreProcessor"])

パイプライン実行

files_to_index = [doc_dir + "/" + f for f in os.listdir(doc_dir)]
indexing_pipeline.run_batch(file_paths=files_to_index)

ちなみにパイプラインを使わずに、Documentオブジェクトを自分で作って、DocumentStoreのメソッドでドキュメントを読み込むこともできるらしい。

As an alternative, you can cast you text data into Document objects and write them into the DocumentStore using DocumentStore.write_documents().

実際にドキュメントが読み込まれているか、ElasticSearchを直接見てみる。

!curl -XGET 'localhost:9200/_cat/indices?v'
health status index    uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   document TZm381JvRtWGMDopFFnDrw   1   1       2801            3      3.8mb          3.8mb
yellow open   label    rea1-Lc_RZuefvotER0vjA   1   1          0            0       208b           208b
!curl -XGET 'localhost:9200/document/_search?pretty'
{
  "took" : 46,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2801,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "document",
        "_type" : "_doc",
        "_id" : "89eee1cbee4aceaae32cba0f2b44a06f",
        "_score" : 1.0,
        "_source" : {
          "content" : "\n\n'''Jorah Mormont''' is a fictional character in the ''A Song of Ice and Fire'' series of fantasy novels by American author George R. R. Martin and its television adaptation ''Game of Thrones''.\n\nIntroduced in ''A Game of Thrones'' (1996), Jorah is a knight in exile, the disgraced former lord of Bear Island and the only son of Jeor Mormont, the honorable lord commander of the Night's Watch. Jorah subsequently appeared in Martin's ''A Clash of Kings'' (1998), ''A Storm of Swords'' (2000) and ''A Dance with Dragons'' (2011). After fleeing Westeros, Jorah pledges fealty to Daenerys Targaryen and over the course of both the novels and the television show becomes her closest and most loyal companion; Jorah's passionate yet unrequited love of Daenerys is central to the character's arc in both the novels and television show. He is portrayed as a skilled warrior whose knowledge of the peoples and customs of Essos proves invaluable to Daenerys' journeys.\n\nJorah is portrayed by the Scottish actor Iain Glen in the HBO television adaptation.\n\n",
          "content_type" : "text",
          "id_hash_keys" : [
            "content"
          ],
          "_split_id" : 0,
          "_split_overlap" : [
            {
              "doc_id" : "d9c513ac3ea589e189f0035b8a7c3d44",
              "range" : [
                831,
                1047
              ]
            }
          ]
        }
      },
      {
        "_index" : "document",
        "_type" : "_doc",
        "_id" : "d9c513ac3ea589e189f0035b8a7c3d44",
        "_score" : 1.0,
        "_source" : {
          "content" : "He is portrayed as a skilled warrior whose knowledge of the peoples and customs of Essos proves invaluable to Daenerys' journeys.\n\nJorah is portrayed by the Scottish actor Iain Glen in the HBO television adaptation.\n\n==Character==\n===Background===\nSer Jorah Mormont is the only child of the Night's Watch's Lord Commander Jeor Mormont, who abdicated shortly before Robert's Rebellion to join the Night's Watch and let Jorah assume the lordship of Bear Island. At some point Jorah married a lady of House Glover, who died from miscarriage after ten years of marriage. Jorah fought in Greyjoy's Rebellion, distinguishing himself by being one of the first to enter the fray during the siege of Pyke and was knighted by King Robert Baratheon. At a tourney at Lannisport celebrating the Baratheon victory, Jorah fell in love with the beautiful Lynesse Hightower (aunt of Margaery Tyrell). He named her Queen of Love and Beauty after winning the tourney and asked her father for her hand in marriage, which he accepted. However, Lynesse found herself ill-suited to the rough life on Bear Island, having grown up as a member of the wealthy House Hightower. ",
          "content_type" : "text",
          "id_hash_keys" : [
            "content"
          ],
          "_split_id" : 1,
          "_split_overlap" : [
            {
              "doc_id" : "89eee1cbee4aceaae32cba0f2b44a06f",
              "range" : [
                0,
                216
              ]
            },
            {
              "doc_id" : "f920976ec731533d578e5bb7a28ee9d5",
              "range" : [
                1014,
                1149
              ]
            }
          ]
        }
      },
kun432kun432

RetrieverとReaderを初期化

from haystack.nodes import BM25Retriever
from haystack.nodes import FARMReader

retriever = BM25Retriever(document_store=document_store)
reader = FARMReader(model_name_or_path="deepset/roberta-base-squad2", use_gpu=True)

RetrieverとReaderをつなぐパイプラインを初期化。前回はビルトインのExtractiveQAPipeline を作成したけど今回は普通にパイプラインを作成してノードを追加する。

from haystack import Pipeline

querying_pipeline = Pipeline()
querying_pipeline.add_node(component=retriever, name="Retriever", inputs=["Query"])
querying_pipeline.add_node(component=reader, name="Reader", inputs=["Retriever"])
kun432kun432

パイプラインを実行して検索。

from pprint import pprint

prediction = querying_pipeline.run(
    query="Who is the father of Arya Stark?", params={"Retriever": {"top_k": 10}, "Reader": {"top_k": 5}}
)

pprint(prediction)
Inferencing Samples: 100%|██████████| 1/1 [00:03<00:00,  3.71s/ Batches]
{'answers': [
             <Answer {'answer': 'Eddard', 'type': 'extractive', 'score': 0.993372917175293, 'context': "s Nymeria after a legendary warrior queen. She travels with her father, Eddard, to King's Landing when he is made Hand of the King. Before she leaves,", 'offsets_in_document': [{'start': 207, 'end': 213}], 'offsets_in_context': [{'start': 72, 'end': 78}], 'document_ids': ['9e3c863097d66aeed9992e0b6bf1f2f4'], 'meta': {'_split_id': 4, '_split_overlap': [{'range': [0, 266], 'doc_id': '241c8775e39c6c937c67bbd10ccc471c'}, {'range': [960, 1200], 'doc_id': '87e8469dcf7354fd2a25fbd2ba07c543'}]}}>,
             <Answer {'answer': 'Ned', 'type': 'extractive', 'score': 0.9753613471984863, 'context': "k in the television series.\n\n====Season 1====\nArya accompanies her father Ned and her sister Sansa to King's Landing. Before their departure, Arya's h", 'offsets_in_document': [{'start': 630, 'end': 633}], 'offsets_in_context': [{'start': 74, 'end': 77}], 'document_ids': ['7d3360fa29130e69ea6b2ba5c5a8f9c8'], 'meta': {'_split_id': 13, '_split_overlap': [{'range': [0, 235], 'doc_id': 'e49395627d81a9d3a1c889db7f701b4'}, {'range': [949, 1168], 'doc_id': '653abd42ad47a1f7cbb188875a8d9e25'}]}}>,
             <Answer {'answer': 'Lord Eddard Stark', 'type': 'extractive', 'score': 0.9566047191619873, 'context': 'rk daughters.\n\nDuring the Tourney of the Hand to honour her father Lord Eddard Stark, Sansa Stark is enchanted by the knights performing in the event.', 'offsets_in_document': [{'start': 804, 'end': 821}], 'offsets_in_context': [{'start': 67, 'end': 84}], 'document_ids': ['a80ae4f1d1187bde6a34a29aeeb0837d'], 'meta': {'_split_id': 3, '_split_overlap': [{'range': [0, 99], 'doc_id': '244e2a5926e7f89b5f267a9d99493c97'}, {'range': [889, 1110], 'doc_id': 'c4ea66d17668dd910673351c384d29d5'}]}}>,
             <Answer {'answer': 'Joffrey', 'type': 'extractive', 'score': 0.6413301825523376, 'context': "Mycah, sparring in the woods with broomsticks.  Arya defends Mycah from Joffrey's torments and her direwolf Nymeria helps Arya fight off Joffrey, woun", 'offsets_in_document': [{'start': 634, 'end': 641}], 'offsets_in_context': [{'start': 72, 'end': 79}], 'document_ids': ['9e3c863097d66aeed9992e0b6bf1f2f4'], 'meta': {'_split_id': 4, '_split_overlap': [{'range': [0, 266], 'doc_id': '241c8775e39c6c937c67bbd10ccc471c'}, {'range': [960, 1200], 'doc_id': '87e8469dcf7354fd2a25fbd2ba07c543'}]}}>,
             <Answer {'answer': 'King Robert', 'type': 'extractive', 'score': 0.5891164541244507, 'context': "en refuses to yield Gendry, who is actually a bastard son of the late King Robert, to the Lannisters.  The Night's Watch convoy is overrun and massacr", 'offsets_in_document': [{'start': 820, 'end': 831}], 'offsets_in_context': [{'start': 70, 'end': 81}], 'document_ids': ['87e8469dcf7354fd2a25fbd2ba07c543'], 'meta': {'_split_id': 5, '_split_overlap': [{'range': [0, 240], 'doc_id': '9e3c863097d66aeed9992e0b6bf1f2f4'}, {'range': [962, 1184], 'doc_id': 'c056004103e1e9eeb382381b3c776f5d'}]}}>],
 'documents': [<Document: {'content': '== Storylines ==\n=== Novels ===\n==== \'\'A Game of Thrones\'\' ====\nCoat of arms of House Stark\n\nArya adopts a direwolf cub, which she names Nymeria after a legendary warrior queen. She travels with her father, Eddard, to King\'s Landing when he is made Hand of the King. Before she leaves, her half-brother Jon Snow has a smallsword made for her as a parting gift, which she names "Needle" after her least favorite ladylike activity.\n\nWhile taking a walk together, Prince Joffrey and her sister Sansa happen upon Arya and her friend, the low-born butcher apprentice Mycah, sparring in the woods with broomsticks.  Arya defends Mycah from Joffrey\'s torments and her direwolf Nymeria helps Arya fight off Joffrey, wounding his arm in the process.  Knowing that Nymeria will likely be killed in retribution, Arya chases her wolf away; but Sansa\'s direwolf Lady is killed in Nymeria\'s stead and Mycah is hunted down and killed by Sandor Clegane, Joffrey\'s bodyguard.\n\nIn King\'s Landing, her father discovers Arya\'s possession of Needle, but instead of confiscating it he arranges for fencing lessons under the Braavosi swordmaster Syrio Forel, who teaches her the style of fighting known as "water dancing".  ', 'content_type': 'text', 'score': 0.7666465067367613, 'meta': {'_split_id': 4, '_split_overlap': [{'range': [0, 266], 'doc_id': '241c8775e39c6c937c67bbd10ccc471c'}, {'range': [960, 1200], 'doc_id': '87e8469dcf7354fd2a25fbd2ba07c543'}]}, 'id_hash_keys': ['content'], 'embedding': None, 'id': '9e3c863097d66aeed9992e0b6bf1f2f4'}>,
               <Document: {'content': "She was also the future bride of Prince Joffrey, and thus the future Queen of the Seven Kingdoms as well. She names her direwolf Lady; she is the smallest of the pack and the first to die, sentenced to death by Cersei after Arya's direwolf, Nymeria, bit a violent Joffrey.\n\n===Arya Stark===\nMaisie Williams\n\n'''Arya Stark''' portrayed by Maisie Williams. Arya Stark of House Stark is the younger daughter and third child of Lord Eddard and Catelyn Stark of Winterfell. Ever the tomboy, Arya would rather be training to use weapons than sewing with a needle. She names her direwolf Nymeria, after a legendary warrior queen.\n\n===Robb Stark===\nRichard Madden\n\n'''Robb Stark''' (seasons 1–3) portrayed by Richard Madden. Robb Stark of House Stark is the eldest son of Eddard and Catelyn Stark and the heir to Winterfell. His dire wolf is called Grey Wind. Robb becomes involved in the war against the Lannisters after his father, Ned Stark, is arrested for treason. Robb summons his bannermen for war against House Lannister and marches to the Riverlands. Eventually, crossing the river at the Twins becomes strategically necessary. ", 'content_type': 'text', 'score': 0.7524122846680525, 'meta': {'_split_id': 17, '_split_overlap': [{'range': [0, 105], 'doc_id': 'eb88ae1b1c38780164f39d99aab5b59e'}, {'range': [962, 1128], 'doc_id': '697049b2034dc9a8e9d5ec59027af7a2'}]}, 'id_hash_keys': ['content'], 'embedding': None, 'id': '726b0655306246943c29202b25bd4733'}>,
               <Document: {'content': 'When Rafford begs for a healer, Arya cuts his throat in the same fashion as he had killed Lommy and throws his corpse into a canal.  She heads back to perform the play, knowing this murder will most likely ruin her Mercedene identity.\n\n=== Family tree of House Stark ===\n\n=== Television series ===\n\nArya Stark is portrayed by English actress Maisie Williams in the television adaption of the book series, this being Williams\' first role as an actress. Williams was chosen from among 300 actresses across England.\nMaisie Williams plays the role of Arya Stark in the television series.\n\n====Season 1====\nArya accompanies her father Ned and her sister Sansa to King\'s Landing. Before their departure, Arya\'s half-brother Jon Snow gifts Arya a sword which she dubs "Needle". On the Kingsroad, Arya is sparring with a butcher\'s boy, Mycah, when Sansa\'s betrothed Prince Joffrey Baratheon attacks Mycah, prompting Arya\'s direwolf Nymeria to bite Joffrey. Arya shoos Nymeria away so she is not killed, but is furious when Sansa later refuses to support her version of events. Mycah is later killed by Joffrey\'s bodyguard Sandor "The Hound" Clegane, earning him Arya\'s hatred. ', 'content_type': 'text', 'score': 0.7474909767058237, 'meta': {'_split_id': 13, '_split_overlap': [{'range': [0, 235], 'doc_id': 'e49395627d81a9d3a1c889db7f701b4'}, {'range': [949, 1168], 'doc_id': '653abd42ad47a1f7cbb188875a8d9e25'}]}, 'id_hash_keys': ['content'], 'embedding': None, 'id': '7d3360fa29130e69ea6b2ba5c5a8f9c8'}>,
               <Document: {'content': 'She is the most beautiful woman in Westeros at the time of the events of "A Song of Ice and Fire".\n\n==Storylines==\nCoat of arms of House Stark\n\n===\'\'A Game of Thrones\'\'===\n\nSansa Stark begins the novel by being betrothed to Crown Prince Joffrey Baratheon, believing Joffrey to be a gallant prince. While Joffrey and Sansa are walking through the woods, Joffrey notices Arya sparring with the butcher\'s boy, Mycah. A fight breaks out and Joffrey is attacked by Nymeria (Arya\'s direwolf) after Joffrey threatens to hurt Arya. Sansa lies to King Robert about the circumstances of the fight in order to protect both Joffrey and her sister Arya.  Since Arya ran off with her wolf to save it, Sansa\'s wolf is killed instead, estranging the Stark daughters.\n\nDuring the Tourney of the Hand to honour her father Lord Eddard Stark, Sansa Stark is enchanted by the knights performing in the event.  At the request of his mother, Queen Cersei Lannister, Joffrey spends a portion of the tourney with Sansa, but near the end he commands his guard Sandor Clegane, better known as The Hound, to take her back to her quarters. ', 'content_type': 'text', 'score': 0.7452338269957905, 'meta': {'_split_id': 3, '_split_overlap': [{'range': [0, 99], 'doc_id': '244e2a5926e7f89b5f267a9d99493c97'}, {'range': [889, 1110], 'doc_id': 'c4ea66d17668dd910673351c384d29d5'}]}, 'id_hash_keys': ['content'], 'embedding': None, 'id': 'a80ae4f1d1187bde6a34a29aeeb0837d'}>,
               <Document: {'content': '* \'\'\'Lothar Frey\'\'\' (seasons 3, 6) portrayed by Tom Brooke in season 3, and by Daniel Tuite in season 6. One of Lord Walder Frey\'s many sons, nicknamed “Lame Lothar” because of his twisted leg. He and his half-brother Black Walder are sent by their father to Riverrun to propose a marriage between Lord Edmure Tully and Roslin Frey as terms for House Frey rejoining Robb Stark\'s campaign against the Lannisters. He is one of the first to commence the "Red Wedding", stabbing Talisa Stark in the womb several times and killing her and her unborn child. In the sixth season, he is ordered by Walder to retake Riverrun from Brynden Tully. Though they succeed with Lannister help, he is killed by Arya Stark, who subsequently bakes him into a pie.\n* \'\'\'Black Walder Rivers\'\'\' (seasons 3, 6) portrayed by Tim Plester. One of Lord Walder Frey\'s many bastard sons, nicknamed “Black Walder” for his dark demeanor. He and his half-brother Lame Lothar are sent by their father to Riverrun to propose a marriage between Lord Edmure Tully and Roslin Frey as terms for House Frey rejoining Robb Stark\'s campaign against the Lannister. ', 'content_type': 'text', 'score': 0.7447136878768036, 'meta': {'_split_id': 71, '_split_overlap': [{'range': [0, 104], 'doc_id': '5be30637fd1d2937cfad37edf31a8781'}, {'range': [906, 1121], 'doc_id': '99f108411616a2bc6724f10ce4536645'}]}, 'id_hash_keys': ['content'], 'embedding': None, 'id': 'ef7ad089df4cc85d00e671a3f32153a4'}>,
               <Document: {'content': 'In King\'s Landing, her father discovers Arya\'s possession of Needle, but instead of confiscating it he arranges for fencing lessons under the Braavosi swordmaster Syrio Forel, who teaches her the style of fighting known as "water dancing".  After her father\'s arrest, Syrio is killed protecting her and Arya narrowly escapes capture.  She later witnesses the public execution of her father before falling under the protection of the Night\'s Watch recruiter Yoren.\n\n==== \'\'A Clash of Kings\'\' ====\nArya escapes King\'s Landing with Yoren and his party of recruits; and on the road, she clashes with the other Night\'s Watch child recruits Lommy, Gendry, and Hot Pie but eventually befriends them. On the way, the party is attacked by Amory Lorch when Yoren refuses to yield Gendry, who is actually a bastard son of the late King Robert, to the Lannisters.  The Night\'s Watch convoy is overrun and massacred, but Arya and the other children escape through a tunnel.  Before escaping, she rescues three prisoners locked in a wagon cage, among them a mysterious man named Jaqen H\'ghar.\n\nArya and her friends are later captured by Ser Gregor Clegane and taken to Harrenhal as slave laborers.  ', 'content_type': 'text', 'score': 0.740692558914948, 'meta': {'_split_id': 5, '_split_overlap': [{'range': [0, 240], 'doc_id': '9e3c863097d66aeed9992e0b6bf1f2f4'}, {'range': [962, 1184], 'doc_id': 'c056004103e1e9eeb382381b3c776f5d'}]}, 'id_hash_keys': ['content'], 'embedding': None, 'id': '87e8469dcf7354fd2a25fbd2ba07c543'}>,
               <Document: {'content': "===On the Iron Islands===\nReturning to his homeland, Theon Greyjoy tries to seduce a young woman, Yara. At Pyke, Theon presents his father Balon with Robb's offer that will make Balon King of the Iron Islands. Balon refuses, wishing to take his crown with Yara, revealed to be Theon's sister, at the helm of his fleet. Theon realises Balon's intention is to take the North for himself.\n\n===In the Red Waste===\nRakharo's horse returns to Daenerys Targaryen's camp carrying his severed head, which Ser Jorah Mormont explains is a message from another khal, and Daenerys vows revenge.\n\n===On the Kingsroad===\nCity Watchmen search the caravan for Gendry but are turned away by Yoren. Gendry tells Arya Stark that he knows she is a girl, and she reveals she is actually Arya Stark after learning that her father met Gendry before he was executed.\n\n===At Craster's Keep===\nSamwell Tarly asks Jon Snow about taking Gilly, one of Craster's daughter-wives, with them but Jon refuses. Gilly is pregnant, and Jon wonders what happens to Craster's sons. That night, Jon follows Craster taking a newborn child into the woods, and sees a White Walker retrieve the baby, but Craster knocks Jon unconscious.\n\n", 'content_type': 'text', 'score': 0.7354745312879696, 'meta': {'_split_id': 2, '_split_overlap': [{'range': [0, 209], 'doc_id': '6b872bd2585cd63b097ec40a38d4933f'}, {'range': [1042, 1192], 'doc_id': 'b89b1728d37d3eb4af9dc978160c12f8'}]}, 'id_hash_keys': ['content'], 'embedding': None, 'id': '8a495456ded3ab7e15cd66c6d3ca82ad'}>,
               <Document: {'content': 'Tyrion is consigned to the Eyrie\'s "sky cells" while Lysa prepares to pass judgment on him as an accomplice in her husband\'s murder.\n\n===In the North===\nAt Winterfell, Theon Greyjoy grows jealous of Tyrion after his favorite prostitute Ros taunts him. To take Bran\'s mind off his paralysis and his mother\'s departure, Maester Luwin teaches him the Dothraki art of horseback archery.\n\n===In King\'s Landing===\nAfter Ned Stark convinces King Robert not to join the tourney, the crowd watches the fearsome Ser Gregor "The Mountain" Clegane joust with Ser Loras Tyrell, the "Knight of Flowers", who wins by riding a mare in heat, distracting Clegane\'s stallion. Clegane beheads his horse and attempts to kill Loras, but Sandor "The Hound" Clegane intervenes.\n\nVarys reveals to Ned that Jon Arryn was killed by a poison called the "Tears of Lys", and suggests that Arryn\'s slain squire Ser Hugh of the Vale was the poisoner.\n\nIn training, Arya chases a cat through the Red Keep and overhears a conversation between Varys and Illyrio, who appear to be plotting against the throne. Arya tries to warn her father but is unable to identify the plotters. ', 'content_type': 'text', 'score': 0.7350875083806473, 'meta': {'_split_id': 2, '_split_overlap': [{'range': [0, 133], 'doc_id': '252cf0165e96af9e18d23e3796c36857'}, {'range': [920, 1143], 'doc_id': 'cf9e6741ebdb92e03e9d4d15634b8592'}]}, 'id_hash_keys': ['content'], 'embedding': None, 'id': '1d850d17893da5959cd677e4d82c144'}>,
               <Document: {'content': '"Asha" is portrayed as a fairly provocative and independent woman, a captain of thirty ships, as opposed to her television counterpart Yara, who did not retain "Asha\'s" traits, although her rivalry with Theon remained intact. Their father Balon Greyjoy was played by Patrick Malahide. Many of the characters involved in the Greyjoys\' storyline weren\'t introduced, most notably Balon\'s brother Aeron Greyjoy. Nonetheless, the storyline received enormous praise, with the alteration of Yara\'s name and persona being the only criticism.\n\nTom Wlaschiha is cast as Jaqen H\'ghar, a mysterious prisoner who develops a murderous relationship with young Arya Stark (Maisie Williams). Wlaschiha\'s pronunciation of his character\'s name, \'\'Jack-in\'\', was adopted for use in the show. Natalie Dormer, best known for her portrayal as seductive Anne Boleyn in Showtime\'s \'\'The Tudors\'\', was cast in a similar role as Margaery Tyrell, a noblewoman and the wife of the third claimant to the throne, Renly Baratheon. Gwendoline Christie played, to much praise, Brienne of Tarth, a female warrior who joins Renly Baratheon\'s guard, but later becomes a follower of Catelyn Stark. To prepare for the role, Christie took up an intense training regimen, adding over a stone (6.4\xa0kg) of muscle mass. ', 'content_type': 'text', 'score': 0.7348211242262005, 'meta': {'_split_id': 8, '_split_overlap': [{'range': [0, 284], 'doc_id': 'fb9fcfcfc15f4cc93dd8fc9718cf6d26'}, {'range': [1160, 1275], 'doc_id': 'b222d5c242e652f9e916e806aa358e42'}]}, 'id_hash_keys': ['content'], 'embedding': None, 'id': '937a3c260025a30112a7a29da8d1d242'}>,
               <Document: {'content': "Decades before the events of ''A Game of Thrones'', he was sent to the Citadel in Oldtown on the orders of his grandfather Daeron II, who felt there were too many Targaryens, and became a Maester (one of an order of scholars and healers). He was later offered the throne of the Seven Kingdoms after the death of his father Maekar, but ceded the rule to Aegon and joined the Night's Watch. By ''A Game of Thrones'', he is elderly and blind, but provides guidance to the men of the Watch. In ''A Feast for Crows'', Jon Snow sends him to the Citadel by sea, but Maester Aemon dies on the voyage between Braavos and Oldtown.\n\nIn the HBO television adaptation, he is portrayed by Peter Vaughan.\n\n=== Yoren ===\nYoren is a recruiter of the Night's Watch. In ''A Game of Thrones'' Yoren travels with Tyrion Lannister from the Wall to King's Landing, and is present when Tyrion is arrested by Catelyn Stark. He then races to King's Landing to inform Eddard Stark. During Lord Eddard's execution, he finds Arya Stark and shields her from seeing her father's death. ", 'content_type': 'text', 'score': 0.7310199917885002, 'meta': {'_split_id': 91, '_split_overlap': [{'range': [0, 238], 'doc_id': 'f916c6de28e6deff0553506c9028ab28'}, {'range': [899, 1054], 'doc_id': '89ca63d9986390e978146fc69f289170'}]}, 'id_hash_keys': ['content'], 'embedding': None, 'id': '1a134f1ce82ea118cb873dfd9ba090e2'}>],
 'no_ans_gap': 11.405388832092285,
 'node_id': 'Reader',
 'params': {'Reader': {'top_k': 5}, 'Retriever': {'top_k': 10}},
 'query': 'Who is the father of Arya Stark?',
 'root_node': 'Query'}
このスクラップは2023/10/03にクローズされました