julien-c HF staff commited on
Commit
b3dfee1
1 Parent(s): 2cadda9

Migrate model card from transformers-repo

Browse files

Read announcement at https://discuss.huggingface.co/t/announcement-all-model-cards-will-be-migrated-to-hf-co-model-repos/2755
Original file history: https://github.com/huggingface/transformers/commits/master/model_cards/facebook/rag-sequence-nq/README.md

Files changed (1) hide show
  1. README.md +37 -0
README.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: apache-2.0
4
+ datasets:
5
+ - wiki_dpr
6
+ thumbnail: https://huggingface.co/front/thumbnails/facebook.png
7
+ ---
8
+ ## RAG
9
+
10
+ This is the RAG-Sequence Model of the the paper [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://arxiv.org/pdf/2005.11401.pdf)
11
+ by Patrick Lewis, Ethan Perez, Aleksandara Piktus et al.
12
+
13
+ The model is a *uncased* model, which means that capital letters are simply converted to lower-case letters.
14
+
15
+ The model consits of a *question_encoder*, *retriever* and a *generator*. The retriever extracts relevant passages from the *wiki_dpr* `train` datasets, which is linked above.
16
+ The question_encoder and retriever are based on `facebook/dpr-question_encoder-single-nq-base` and `facebook/bart-large`, which were jointly finetuned on
17
+ on the *wiki_dpr* QA dataset in an end-to-end fashion.
18
+
19
+ ## Usage:
20
+
21
+ **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.
22
+ The model can generate answers to any factoid question as follows:
23
+
24
+ ```python
25
+ from transformers import RagTokenizer, RagRetriever, RagSequenceForGeneration
26
+
27
+ tokenizer = RagTokenizer.from_pretrained("facebook/rag-sequence-nq")
28
+ retriever = RagRetriever.from_pretrained("facebook/rag-sequence-nq", index_name="exact", use_dummy_dataset=True)
29
+ model = RagSequenceForGeneration.from_pretrained("facebook/rag-sequence-nq", retriever=retriever)
30
+
31
+ input_dict = tokenizer.prepare_seq2seq_batch("how many countries are in europe", return_tensors="pt")
32
+
33
+ generated = model.generate(input_ids=input_dict["input_ids"])
34
+ print(tokenizer.batch_decode(generated, skip_special_tokens=True)[0])
35
+
36
+ # should give 54 => google says either 44 or 51
37
+ ```