Downloads · 30 days
4.2K
0% of all-time downloads
facebook/rag-token-nq
rag-token-nq is a machine learning model from facebook. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as apache-2.0.
This is the RAG-Token Model of the the paper Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks by Patrick Lewis, Ethan Perez, Aleksandara Piktus et al.
Downloads · 30 days
4.2K
0% of all-time downloads
All-time downloads
6.2M
Public
Repo size
6.2 GB
Likes
186
Trending 1
Click a slice to open those files.
.h52.1 GB · 50%
From the Hugging Face model README
This is the RAG-Token Model of the the paper Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks by Patrick Lewis, Ethan Perez, Aleksandara Piktus et al.
The model is a uncased model, which means that capital letters are simply converted to lower-case letters.
The model consists of a question_encoder, retriever and a generator. The retriever extracts relevant passages from the wiki_dpr train datasets, which is linked above.
The question_encoder and retriever are based on facebook/dpr-question_encoder-single-nq-base and facebook/bart-large, which were jointly finetuned on
on the wiki_dpr QA dataset in an end-to-end fashion.
Note: In the usage example below only the dummy retriever of wiki_dpr is used because the complete lecagy index requires over 75 GB of RAM. The model can generate answers to any factoid question as follows:
from transformers import RagTokenizer, RagRetriever, RagTokenForGeneration
tokenizer = RagTokenizer.from_pretrained("facebook/rag-token-nq")
retriever = RagRetriever.from_pretrained("facebook/rag-token-nq", index_name="exact", use_dummy_dataset=True)
model = RagTokenForGeneration.from_pretrained("facebook/rag-token-nq", retriever=retriever)
input_dict = tokenizer.prepare_seq2seq_batch("who holds the record in 100m freestyle", return_tensors="pt")
generated = model.generate(input_ids=input_dict["input_ids"])
print(tokenizer.batch_decode(generated, skip_special_tokens=True)[0])
# should give michael phelps => sounds reasonable