Skip to content

Commit

Permalink
Merge branch 'main' of github.com:deepset-ai/haystack-home
Browse files Browse the repository at this point in the history
  • Loading branch information
TuanaCelik committed Jan 3, 2024
2 parents 8f96d77 + e30c7de commit 349713a
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 12 deletions.
8 changes: 1 addition & 7 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ paginatePath = "/"
weight = 1

[[menu.main]]
name = 'Quick Start'
name = 'Get Started'
url = '/overview/quick-start'
parent = 'overview'
weight = 2
Expand All @@ -129,12 +129,6 @@ paginatePath = "/"
parent = 'overview'
weight = 5

[[menu.main]]
name = 'Use Cases'
url = '/overview/use-cases'
parent = 'overview'
weight = 3

# Resources children
[[menu.main]]
name = 'PromptHub'
Expand Down
96 changes: 93 additions & 3 deletions content/overview/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: overview
header: dark
footer: dark
title: Quick Start
title: Get Started
description: Guide to setting up and installing Haystack.
weight: 2
toc: true
Expand All @@ -17,7 +17,97 @@ You can find the source code for Haystack on GitHub. This is also the main chann
{{< button url="https://github.com/deepset-ai/haystack" text="View Source Code" color="green">}} -->

## Installation
Haystack is an open source Python framework that helps developers build LLM powered custom applications. In December 2023, a significant update, version 2.0-Beta, was released. This page provides information for both Haystack 1.x and the latest version, 2.0-Beta. For more information on Haystack 2.0-Beta, you can also read the [announcement post](https://haystack.deepset.ai/blog/introducing-haystack-2-beta-and-advent).

## Installation (2.0-Beta)

Use [pip](https://github.com/pypa/pip) to install Haystack 2.0-Beta release:

```python
pip install haystack-ai
```

For more details, refer to our 2.0-Beta documentation.

{{< button url="https://docs.haystack.deepset.ai/v2.0/docs/installation" text="Docs: Installation (2.0-Beta)" color="green">}}

## Build Your First RAG Pipeline

To build modern search pipelines with LLMs, you need two things: powerful components and an easy way to put them together. The Haystack pipeline is built for this purpose and enables you to design and scale your interactions with LLMs. Learn how to create pipelines [here](https://docs.haystack.deepset.ai/v2.0/docs/creating-pipelines).

By connecting three components, a [Retriever](https://docs.haystack.deepset.ai/v2.0/docs/retrievers), a [PromptBuilder](https://docs.haystack.deepset.ai/v2.0/docs/promptbuilder) and a [Generator](https://docs.haystack.deepset.ai/v2.0/docs/generators), you can build your first Retrieval Augmented Generation (RAG) pipeline with Haystack.

Try out how Haystack answers questions about the given documents using the **RAG** approach 👇

First, install Haystack 2.0-Beta:
```bash
pip install haystack-ai
```

Then, index your data to the DocumentStore, build a RAG pipeline, and ask a question on your data:
```python
import os

from haystack import Pipeline, Document
from haystack.document_stores import InMemoryDocumentStore
from haystack.components.retrievers import InMemoryBM25Retriever
from haystack.components.generators import GPTGenerator
from haystack.components.builders.prompt_builder import PromptBuilder

# Write documents to InMemoryDocumentStore
document_store = InMemoryDocumentStore()
document_store.write_documents([
Document(text="My name is Jean and I live in Paris."),
Document(text="My name is Mark and I live in Berlin."),
Document(text="My name is Giorgio and I live in Rome.")
])

# Build a RAG pipeline
prompt_template = """
Given these documents, answer the question.
Documents:
{% for doc in documents %}
{{ doc.content }}
{% endfor %}
Question: {{question}}
Answer:
"""

document_store = InMemoryDocumentStore()
retriever = InMemoryBM25Retriever(document_store=document_store)
prompt_builder = PromptBuilder(template=prompt_template)
llm = GPTGenerator(api_key=api_key)

rag_pipeline = Pipeline()
rag_pipeline.add_component("retriever", retriever)
rag_pipeline.add_component("prompt_builder", prompt_builder)
rag_pipeline.add_component("llm", llm)
rag_pipeline.connect("retriever", "prompt_builder.documents")
rag_pipeline.connect("prompt_builder", "llm")

# Ask a question
question = "Who lives in Paris?"
results = rag_pipeline.run(
{
"retriever": {"query": question},
"prompt_builder": {"question": question},
}
)

print(results["llm"]["replies"])
```
The pipeline uses the given documents to generate the answer:

```text
['Jean lives in Paris.']
```

For a hands-on guide on how to build your first RAG Pipeline with Haystack 2.0-Beta, see our tutorial.

{{< button url="https://haystack.deepset.ai/tutorials/27_first_rag_pipeline" text="Tutorial: Creating a RAG Pipeline" color="green">}}


## Installation (1.x)

Use [pip](https://github.com/pypa/pip) to install the latest Haystack release:

Expand Down Expand Up @@ -70,7 +160,7 @@ For a more comprehensive installation guide, including methods for various opera

{{< button url="https://docs.haystack.deepset.ai/docs/installation" text="Docs: Installation" color="green">}}

## Build Your First Retrieval Augmented Generation (RAG) Pipeline
## Build Your First RAG Pipeline with Haystack 1.x

Haystack is built around the concept of pipelines. A pipeline is a powerful structure that performs an NLP task. It's made up of components connected together.
For example, you can connect a Retriever and a PromptNode to build a Generative Question Answering pipeline that uses your own data.
Expand Down
1 change: 1 addition & 0 deletions content/overview/use-cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ title: Use Cases
description: Discover how you can use Haystack.
weight: 5
toc: true
hidden: true
---

## Semantic Search System
Expand Down
2 changes: 1 addition & 1 deletion themes/haystack/layouts/_default/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{/* Sidebar */}}
<aside class="toc-sidebar">
<ul class="content" role="list">
{{ range where .Site.Pages "Section" "overview" }}
{{ range where (where .Site.Pages "Section" "overview") "Params.hidden" "!=" true }}
<li>
{{ if (eq $currentPage.RelPermalink .RelPermalink) }}
<details class="accordion-js accordion-child" open>
Expand Down
2 changes: 1 addition & 1 deletion themes/haystack/layouts/partials/announcement.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<a href="/advent-of-haystack" class="announcement-bar">
<div class="container">
<span>Join us for Advent of Haystack this December 🌲</span>
<span>Complete Advent of Haystack 2023 Challenges 🌲</span>
<span>
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down

1 comment on commit 349713a

@vercel
Copy link

@vercel vercel bot commented on 349713a Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.