Package: farm-haystack
CI/CDDocsPackageMetaHaystackis 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  state-of-the-art NLP models with Haystack to build end-to-end NLP applications to solve your use case.QuickstartHaystack 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 aRetrieverand aPromptNodeto 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:pipinstallfarm-haystackThen, index your data to the DocumentStore, build a RAG pipeline, and ask a question on your data:fromhaystack.document_storesimportInMemoryDocumentStorefromhaystack.utilsimportbuild_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 <result> objectprint_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🏃‍♀️Pipelines:This is the standard Haystack structure that builds on top of your data to perform various NLP tasks such as retrieval augmented generation, question answering and more. The data in a Pipeline flows from one Node to the next. You define how Nodes interact with each other and how one Node pushes data to the next.An example pipeline would consist of oneRetrieverNode and onePromptNode. When the pipeline runs with a query, the Retriever first retrieves the relevant context to the query from your data, and then the PromptNode uses an LLM to generate the final answer.⚛️Nodes:Each Node achieves one thing. Such as preprocessing documents, retrieving documents, using language models to answer questions, and so on.🕵️Agent:(since 1.15) An Agent is a component that is powered by an LLM, such as GPT-3. It can decide on the next best course of action so as to get to the result of a query. It uses the Tools available to it to achieve this. While a pipeline has a clear start and end, an Agent is able to decide whether the query has been resolved or not. It may also make use of a Pipeline as a Tool.🛠️Tools:You can think of a Tool as an expert, that is able to do something really well. Such as a calculator, good at mathematics. Or aWebRetriever, good at retrieving pages from the internet. A Node or pipeline in Haystack can also be used as a Tool. A Tool is a component that is used by an Agent, to resolve complex queries.🗂️DocumentStores:A DocumentStore is database where you store your text data for Haystack to access. Haystack DocumentStores are available with ElasticSearch, Opensearch, Weaviate, Pinecone, FAISS and more. For a full list of available DocumentStores, check out ourdocumentation.What to Build with HaystackBuildretrieval augmented generation (RAG)by making use of one of the available vector databases and customizing your LLM interaction, the sky is the limit 🚀Perform Question Answeringin natural languageto find granular answers in your documents.Performsemantic searchand retrieve documents according to meaning.Build applications that can make complex decisions making to answer complex queries: such as systems that can resolve complex customer queries, do knowledge search on many disconnected resources and so on.Useoff-the-shelf modelsorfine-tunethem to your data.Useuser feedbackto evaluate, benchmark, and continuously improve your models.FeaturesLatest models: Haystack allows you to use and compare models available from OpenAI, Cohere and Hugging Face, as well as your own local models or models hosted on SageMaker. Use the latest LLMs or Transformer-based models (for example: BERT, RoBERTa, MiniLM).Modular: Multiple choices to fit your tech stack and use case. A wide choice of DocumentStores to store your data, file conversion tools and moreOpen: Integrated with Hugging Face's model hub, OpenAI, Cohere and various Azure services.Scalable: Scale to millions of docs using retrievers and production-scale components like Elasticsearch and a fastAPI REST API.End-to-End: All tooling in one place: file conversion, cleaning, splitting, training, eval, inference, labeling, and more.Customizable: Fine-tune models to your domain or implement your custom Nodes.Continuous Learning: Collect new training data from user feedback in production & improve your models continuously.Resources📒DocsComponents, Pipeline Nodes, Guides, API Reference💾InstallationHow to install Haystack🎓TutorialsSee what Haystack can do with our Notebooks & Scripts🎉Haystack ExtrasA repository that lists extra Haystack packages and components that can be installed separately.🔰DemosA repository containing Haystack demo applications with Docker Compose and a REST API🖖CommunityDiscord,𝕏 (Twitter),Stack Overflow,GitHub Discussions💙ContributingWe welcome all contributions!📊BenchmarksSpeed & Accuracy of Retriever, Readers and DocumentStores🔭RoadmapPublic roadmap of Haystack📰BlogLearn about the latest with Haystack and NLP☎️JobsWe're hiring! Have a look at our open positions💾 InstallationFor a detailed installation guide seethe official documentation. There you’ll find instructions for custom installations handling Windows and Apple Silicon.Basic InstallationUsepipto install a basic version of Haystack's latest release:pipinstallfarm-haystackThis command installs everything needed for basic Pipelines that use an in-memory DocumentStore and external LLM provider (e.g. OpenAI).Full InstallationTo use more advanced features, like certain DocumentStores, inference with local transformer models, FileConverters, OCR, or Ray,
you need to install further dependencies. The following command installs thelatest releaseof Haystack and all its dependencies:pipinstall'farm-haystack[all]'## or 'all-gpu' for the GPU-enabled dependenciesIf you want to install only the dependencies needed for model inference on your local hardware (not remote API endpoints), such as torch and sentence-transformers, you can use the following command:pipinstall'farm-haystack[inference]'## installs torch, sentence-transformers, sentencepiece, and huggingface-hubIf you want to try out the newest features that are not in an official release yet, you can install the unstable version from the main branch with the following command:pipinstallgit+https://github.com/deepset-ai/haystack.git@main#egg=farm-haystackTo be able to make changes to Haystack code, first of all clone this repo:gitclonehttps://github.com/deepset-ai/haystack.gitThen move into the cloned folder and install the project withpip, including the development dependencies:cd haystack && pip install -e '.[dev]'If you want to contribute to the Haystack repo, check ourContributor Guidelinesfirst.See the list ofdependenciesto check which ones you want to install (for example,[all],[dev], or other).Installing the REST APIHaystack comes packaged with a REST API so that you can deploy it as a service. Run the following command from the root directory of the Haystack repo to install REST_API:pip install rest_api/You can find out more about our PyPi package on ourPyPi page.🔰DemosYou can find some of our hosted demos with instructions to run them locally too on ourhaystack-demosrepository:dizzy:Reduce Hallucinations with Retrieval Augmentation- Generative QA with LLMs🐥Should I follow?- Summarizing tweets with LLMs🌎Explore The World- Extractive Question Answering🖖 CommunityIf you have a feature request or a bug report, feel free to open anissue in Github. We regularly check these and you can expect a quick response. If you'd like to discuss a topic, or get more general advice on how to make Haystack work for your project, you can start a thread inGithub Discussionsor ourDiscord channel. We also check𝕏 (Twitter)andStack Overflow.💙 ContributingWe are very open to the community's contributions - be it a quick fix of a typo, or a completely new feature! You don't need to be a Haystack expert to provide meaningful improvements. To learn how to get started, check out ourContributor Guidelinesfirst.Who Uses HaystackHere's a list of projects and companies using Haystack. Want to add yours? Open a PR, add it to the list and let the
world know that you use Haystack!AirbusAlcatel-LucentAppleBetterUpDatabricksDeepsetEtalabInfineonIntelIntelijusIntel LabsLEGONetflixNvidiaPostHogRakutenSooth.ai