-
Hello, Please refer following link that describes answer generation - [https://haystack.deepset.ai/pipeline_nodes/answer-generator] It suggests following code to implement stand alone answering system -
Here, the 'generator' object is initialized using a 'retriever' object and I guess retriever object requires some kind of data store (elastic search). I wish to understand how I can simply pass a paragraph and a question to generate an answer. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The available generators are:
If you want to quickly manually try a Generator node, I'll report a straightforward example for you using from haystack import Document
from haystack.nodes import Seq2SeqGenerator
# some texts about Queen Elizabeth
texts=[
"Elizabeth II (Elizabeth Alexandra Mary; 21 April 1926 – 8 September 2022) was Queen of the United Kingdom and the other Commonwealth realms from 6 February 1952 until her death in 2022.",
"She was queen regnant of 32 sovereign states during her life and served as monarch of 15 of them at the time of her death.",
"Elizabeth met her future husband, Prince Philip of Greece and Denmark, in 1934 and again in 1937.",
"Her reign of 70 years and 214 days is the longest of any British monarch and the longest recorded of any female head of state in history.",
"Elizabeth's four children, along with her daughters-in-law and grandsons Prince William and Prince Harry, travelled to Balmoral. Her death was confirmed that evening at 18:30 BST",
"From Elizabeth's birth onwards, the British Empire continued its transformation into the Commonwealth of Nations."
]
docs = [Document(text) for text in texts]
generator = Seq2SeqGenerator(model_name_or_path="vblagoje/bart_lfqa")
generator.predict(
query="When did Queen Elizabeth die?",
documents=docs,
top_k=1
) You get this output:
|
Beta Was this translation helpful? Give feedback.
The available generators are:
RAGenerator
(Retrieval-Augmented Generator): it relies on a retriever or, anyway, it needs vector embeddings for the documentsSeq2SeqGenerator
: generic sequence-to-sequence generator based on Hugging Face's transformersOpenAIAnswerGenerator
: you need an OpenAI accountIf you want to quickly manually try a Generator node, I'll report a straightforward example for you using
Seq2SeqGenerator
.Note: In any case, for better results, I suggest to read the available tutorials (RAG, LFQA) that use the generators in combination with a retriever.