oriram commited on
Commit
421284f
1 Parent(s): 6ce91d0

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +27 -0
README.md ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Spider-NQ: Context Encoder
2
+
3
+ This is the context encoder of the model fine-tuned on Natural Questions (and initialized from Spider) discussed in our paper [Learning to Retrieve Passages without Supervision](https://arxiv.org/abs/2112.07708).
4
+
5
+ ## Usage
6
+
7
+ We used weight sharing for the query encoder and passage encoder, so the same model should be applied for both.
8
+
9
+ **Note**! We format the passages similar to DPR, i.e. the title and the text are separated by a `[SEP]` token, but token
10
+ type ids are all 0-s.
11
+
12
+ An example usage:
13
+
14
+ ```python
15
+ from transformers import AutoTokenizer, DPRContextEncoder
16
+
17
+ tokenizer = AutoTokenizer.from_pretrained("NAACL2022/spider-nq-ctx-encoder")
18
+ model = DPRContextEncoder.from_pretrained("NAACL2022/spider-nq-ctx-encoder")
19
+
20
+ title = "Sauron"
21
+ context = "Sauron is the title character and main antagonist of J. R. R. Tolkien's \"The Lord of the Rings\"."
22
+
23
+ input_dict = tokenizer(title, context, return_tensors="pt")
24
+ del input_dict["token_type_ids"]
25
+
26
+ outputs = model(**input_dict)
27
+ ```