Instructions to use NAACL2022/spider-trivia-question-encoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NAACL2022/spider-trivia-question-encoder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="NAACL2022/spider-trivia-question-encoder")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("NAACL2022/spider-trivia-question-encoder") model = AutoModel.from_pretrained("NAACL2022/spider-trivia-question-encoder", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from NAACL2022/spider-trivia-question-encoder: direct link, hf CLI and curl.
- Browser
- Download file 950 Bytes
-
https://huggingface.co/NAACL2022/spider-trivia-question-encoder/resolve/main/README.md
- Command line
-
hf download hf://NAACL2022/spider-trivia-question-encoder/README.md
-
curl -L -o README.md https://huggingface.co/NAACL2022/spider-trivia-question-encoder/resolve/main/README.md
950 Bytes
Spider-TriviaQA: Question Encoder
This is the question encoder of the model fine-tuned on TriviaQA (and initialized from Spider) discussed in our paper Learning to Retrieve Passages without Supervision.
Usage
We used weight sharing for the query encoder and passage encoder, so the same model should be applied for both.
Note! We format the passages similar to DPR, i.e. the title and the text are separated by a [SEP] token, but token
type ids are all 0-s.
An example usage:
from transformers import AutoTokenizer, DPRQuestionEncoder
tokenizer = AutoTokenizer.from_pretrained("NAACL2022/spider-trivia-question-encoder")
model = DPRQuestionEncoder.from_pretrained("NAACL2022/spider-trivia-question-encoder")
question = "Who is the villain in lord of the rings"
input_dict = tokenizer(question, return_tensors="pt")
del input_dict["token_type_ids"]
outputs = model(**input_dict)