From d0ff3fa7c271780791319dd881a05ad49ac2c500 Mon Sep 17 00:00:00 2001 From: Daria Fokina Date: Mon, 9 Oct 2023 15:24:47 +0200 Subject: [PATCH] docs: readme-get-started (#5993) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * readme-get-started * lg update * lg update Co-authored-by: Bilge Yücel --------- Co-authored-by: Bilge Yücel --- README.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 61a97068962..b39c3cc70a6 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,57 @@ | Meta | ![Discord](https://img.shields.io/discord/993534733298450452?logo=discord) ![Twitter Follow](https://img.shields.io/twitter/follow/deepset_ai) | -[Haystack](https://haystack.deepset.ai/) is an end-to-end NLP framework that enables you to build applications powered by LLMs, Transformer models, vector search and more. Whether you want to perform question answering, answer generation, semantic document search, or build tools that are capable of complex decision making and query resolution, you can use the state-of-the-art NLP models with Haystack to build end-to-end NLP applications solving your use case. +[Haystack](https://haystack.deepset.ai/) is an end-to-end NLP framework that enables you to build applications powered by LLMs, Transformer models, vector search and more. Whether you want to perform question answering, answer generation, semantic document search, or build tools that are capable of complex decision-making and query resolution, you can use the state-of-the-art NLP models with Haystack to build end-to-end NLP applications solving your use case. + +## Quickstart + +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. + +Try out how Haystack answers questions about Game of Thrones using the Retrieval Augmented Generation (RAG) approach 👇 + +First, run the minimal Haystack installation: + +```sh +pip install farm-haystack +``` + +Then, index your data to the DocumentStore, build a RAG pipeline, and ask a question on your data: + +```python +from haystack.document_stores import InMemoryDocumentStore +from haystack.utils import build_pipeline, add_example_data, print_answers + +# We are model agnostic :) Here, you can choose from: "anthropic", "cohere", "huggingface", and "openai". +provider = "openai" +API_KEY = "sk-..." # ADD YOUR KEY HERE + +# We support many different databases. Here, we load a simple and lightweight in-memory database. +document_store = InMemoryDocumentStore(use_bm25=True) + +# Download and add Game of Thrones TXT articles to Haystack DocumentStore. +# You can also provide a folder with your local documents. +add_example_data(document_store, "data/GoT_getting_started") + +# Build a pipeline with a Retriever to get relevant documents to the query and a PromptNode interacting with LLMs using a custom prompt. +pipeline = build_pipeline(provider, API_KEY, document_store) + +# Ask a question on the data you just added. +result = pipeline.run(query="Who is the father of Arya Stark?") + +# For details, like which documents were used to generate the answer, look into the object +print_answers(result, details="medium") +``` + +The output of the pipeline will reference the documents used to generate the answer: + +``` +'Query: Who is the father of Arya Stark?' +'Answers:' +[{'answer': 'The father of Arya Stark is Lord Eddard Stark of ' + 'Winterfell. [Document 1, Document 4, Document 5]'}] +``` + +Congratulations, you have just built your first Haystack app! ## Core Concepts