Question
Put your question here
Additional context
Add any other context or screenshots about the question (optional).
Hey,
Can you please describe in more detail what you mean with "spread the context"?
I mean, when I use print_answer function in the tutorials, it returns the answers and also include the context that the answer is in. However, I notice that the context is limited in 26 tokens approximately. How can I get the context longer (more tokens)? By the way, Can I get a full paragraph in the context? I also notice that it misses some sentence in the beginning and ending.
Ok got it.
The context length around the answer is configured in the Reader class (i.e. it's completely independent of DensePassageRetriever).
You can set the number of characters like this:
reader = FARMReader(model_name_or_path="deepset/roberta-base-squad2", context_window_size=500)
Can I get a full paragraph in the context?
You can get the document to see the "full context" like this:
>>> print_answers(prediction, details="all")
'answers': [ { 'answer': 'Lord Eddard Stark',
'context': 'ircumstances 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'
'During 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',
'document_id': '40e26398-9a50-428d-aa97-101dca6f489b',
...
>>> docs = document_store.get_documents_by_id("40e26398-9a50-428d-aa97-101dca6f489b")
>>> print(doc[0].text)
===In the Riverlands===
The Stark army reaches the Twins, a bridge stronghold controlled by Walder Frey, who agrees to allow the army to cross the river and to commit his troops in return for Robb and Arya Stark marrying two of his children.
Tyrion Lannister suspects his father Tywin, who decides Tyrion and his barbarians will fight in the vanguard, wants him killed. As Tyrion, Bronn, and the prostitute Shae swap stories, Tyrion reveals he was married to a woman his father revealed was a prostitute, and made Tyrion watch as his guardsmen raped her.
As a Stark force approaches, Tyrion is trampled in the rush and regains consciousness to find the battle over. Tywin discovers the Stark host was only 2,000 men, not the 20,000 he was led to expect.
Robb, having divided his forces, defeats Jaime Lannister's army with his remaining 18,000 men and captures Jaime.
Hope this helps!
Seems resolved. Feel free to re-open if not :)
Most helpful comment
Ok got it.
The context length around the answer is configured in the
Readerclass (i.e. it's completely independent of DensePassageRetriever).You can set the number of characters like this:
You can get the document to see the "full context" like this:
Hope this helps!