Hello everyone,
I am interesting in studying how RAG behaves without the DPR retriever or with other contexts identified by other methods.
For example in the code below
``from transformers import RagRetriever
from transformers import RagTokenizer, RagRetriever, RagTokenForGeneration
retriever = RagRetriever.from_pretrained(’./rag-token-nq’, indexed_dataset=dataset)
tokenizer = RagTokenizer.from_pretrained("./rag-token-nq")
model = RagTokenForGeneration.from_pretrained("./rag-token-nq", retriever=retriever)
input_dict = tokenizer.prepare_seq2seq_batch(“How many people live in Paris?”, “In Paris, there are 10 million people.”, return_tensors=“pt”)
input_ids = input_dict[“input_ids”]
model = RagTokenForGeneration.from_pretrained(“facebook/rag-token-nq”, retriever=retriever)
generated_ids = model.generate(input_ids=input_ids, labels=input_dict[“labels”])
generated_string = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
print(generated_string) ``
In the line ‘’ input_dict = tokenizer.prepare_seq2seq_batch(“How many people live in Paris?”, “In Paris, there are 10 million people.”, return_tensors=“pt”) ``, I want to use “How many people live in Paris ?” as the question and “In Paris, there are 10 million people.” the passage / context which should be used to generate the answer.
Kindly let me know how to do this?
Is my understanding of the code correct and if not, how to go about it?
Thanks,
Krishanu