Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
9397436e
"examples/single_model_scripts/run_swag.py" did not exist on "c490f5ce8703ebdf49f8dc62f280045df92c1049"
Unverified
Commit
9397436e
authored
Sep 18, 2020
by
Patrick von Platen
Committed by
GitHub
Sep 18, 2020
Browse files
Create README.md
parent
7eeca4d3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
model_cards/facebook/rag-sequence-base/README.md
model_cards/facebook/rag-sequence-base/README.md
+22
-0
No files found.
model_cards/facebook/rag-sequence-base/README.md
0 → 100644
View file @
9397436e
## RAG
This is a "base" version of the RAG-Sequence Model of the the paper
[
Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks
](
https://arxiv.org/pdf/2005.11401.pdf
)
by Patrick Lewis, Ethan Perez, Aleksandara Piktus et al.
## Usage:
```
python
from
transformers
import
RagTokenizer
,
RagRetriever
,
RagSequenceForGeneration
tokenizer
=
RagTokenizer
.
from_pretrained
(
"facebook/rag-sequence-base"
)
retriever
=
RagRetriever
.
from_pretrained
(
"facebook/rag-sequence-base"
,
index_name
=
"exact"
,
use_dummy_dataset
=
True
)
model
=
RagSequenceForGeneration
.
from_pretrained
(
"facebook/rag-sequence-base"
,
retriever
=
retriever
)
input_ids
=
tokenizer
(
"What is the largest country in the world?"
,
return_tensors
=
"pt"
).
input_ids
generated
=
model
.
generate
(
input_ids
=
input_ids
)
generated_string
=
tokenizer
.
batch_decode
(
generated
,
skip_special_tokens
=
True
)
# => should give ["Asia ended in 2010 when China overtook Japan to become the world's second largest economy."]
# Interesting answer. Definitely on topic, but might factual probably not fully correct.
```
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment