Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Docs V0.10 #164

Merged
merged 7 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add generator page
  • Loading branch information
brandenchan committed Sep 21, 2021
commit ebbbe1860a36ed183657225490812570015e7dc5
44 changes: 39 additions & 5 deletions docs/latest/components/generator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,61 @@

While extractive QA highlights the span of text that answers a query,
generative QA can return a novel text answer that it has composed.

The best current approaches, such as [Retriever-Augmented Generation](https://arxiv.org/abs/2005.11401) and [LFQA](https://yjernite.github.io/lfqa.html),
can draw upon both the knowledge it gained during language model pretraining (parametric memory)
as well as passages provided to it with a retriever (non-parametric memory).

With the advent of Transformer based retrieval methods such as [Dense Passage Retrieval](https://arxiv.org/abs/2004.04906),
retriever and generator can be trained concurrently from the one loss signal.

<div className="max-w-xl bg-yellow-light-theme border-l-8 border-yellow-dark-theme px-6 pt-6 pb-4 my-4 rounded-md dark:bg-yellow-900">

**Tutorial**

Checkout our tutorial notebooks for a guide on how to build your own generative QA system with RAG ([here](/tutorials/retrieval-augmented-generation))
**Tutorial:** Checkout our tutorial notebooks for a guide on how to build your own generative QA system with RAG ([here](/tutorials/retrieval-augmented-generation))
or with LFQA ([here](/tutorials/pipelines)).

</div>

Pros
**Pros**

- More appropriately phrased answers
- Able to synthesize information from different texts
- Can draw on latent knowledge stored in language model

Cons
**Cons**

- Not easy to track what piece of information the generator is basing its response off of

## Usage

Initialize a Generator as follows:

``` python
from haystack.generator.transformers import RAGenerator

generator = RAGenerator(
model_name_or_path="facebook/rag-sequence-nq",
retriever=dpr_retriever,
top_k=1,
min_length=2
)
```

Running a Generator in a pipeline:

``` python
from haystack.pipeline import GenerativeQAPipeline

pipeline = GenerativeQAPipeline(generator=generator, retriever=dpr_retriever)
result = pipelines.run(query='What are the best party games for adults?', top_k_retriever=20)
```

Running a stand-alone Generator:

``` python
result = generator.predict(
query='What are the best party games for adults?',
documents=[doc1, doc2, doc3...],
top_k=top_k
)
```
1 change: 1 addition & 0 deletions docs/latest/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
{"slug": "reader", "title": "Reader"},
{"slug": "generator", "title": "Generator" },
{"slug": "summarizer", "title": "Summarizer"},
{"slug": "classifier", "title": "Classifier"},
{"slug": "translator", "title": "Translator"},
{"slug": "knowledge-graph", "title": "Knowledge Graph"},
{"slug": "ranker", "title": "Ranker"},
Expand Down