⭐️ Highlights
🗄️ Using LLMs Hosted on AWS SageMaker
We are thrilled to share that Haystack now supports the use of open source LLMs deployed to AWS SageMaker! This means you can easily host your models with AWS SageMaker and use them with PromptNode by simply providing the inference endpoint name and your aws_profile_name
👇
from haystack.nodes import PromptNode
prompt_node = PromptNode(
model_name_or_path="sagemaker-model-endpoint-name",
model_kwargs={"aws_profile_name": "my_aws_profile_name",
"aws_region_name": "your-region-k"}
)
For more details on model deployment, check out the documentation.
🗂️ PromptHub
Exciting news! We’re introducing PromptHub: A place for ready-made prompts for the most common NLP tasks. The best part about it is that you can easily import prompts from the hub into Haystack. For example, if you want to use deepset/topic-classification prompt with Haystack, all you need is the prompt name, and that's it! 👇
import os
from haystack.nodes import PromptNode, PromptTemplate
topic_classifier_template = PromptTemplate("deepset/topic-classification")
prompt_node = PromptNode(model_name_or_path="text-davinci-003", api_key=os.environ.get("OPENAI_API_KEY"))
prompt_node.prompt(prompt_template=topic_classifier_template, documents="YOUR_DOCUMENTS", options=["A LIST OF TOPICS"])
Check out the PromptHub and discover other prompt options for various NLP tasks.
🛠️ Adding Tools to ConversationalAgent
The wait is over – you can now greatly enhance your chat application by adding various tools using the tools
parameter of ConversationalAgent.
from haystack.agents import Tool
from haystack.agents.conversational import ConversationalAgent
search_tool = Tool(
name="USA_Presidents_QA",
pipeline_or_node=presidents_qa,
description="useful for when you need to answer questions related to the presidents of the USA.",
)
conversational_agent = ConversationalAgent(prompt_node=prompt_node, tools=[search_tool])
conversational_agent.run("YOUR QUERY")
Go to our docs to learn more about various tools you can use.
⚠️ Breaking Changes
🔦 A new optional dependency: inference
To simplify the installation of Haystack, we removed some redundant dependencies (like PyTorch) for users who rely on LLMs through APIs. This means you will get a smaller package and faster Haystack installation if you want to use Haystack with OpenAI models or Transformers models via Hugging Face Inference API. If you prefer to run models locally, for example on your GPU, pip install farm-haystack[inference]
will install all required dependencies as before.
🔁 PromptTemplate parameter changes
As of v1.18, PromptTemplate accepts only prompt
and output_parser
and doesn’t support name
and prompt_text
parameters anymore. See an example of how you can migrate to the new PromptTemplate 👇🏼
qa_template = PromptTemplate(
name="question-answering",
promp_text="""
Given the context please answer the question. Context: {join(documents)};
Question: {query};
Answer:
""",
output_parser=AnswerParser()
)
qa_template = PromptTemplate(
prompt="""
Given the context please answer the question. Context: {join(documents)};
Question: {query};
Answer:
""",
output_parser=AnswerParser()
)
🚫 Seq2SeqGenerator and RAGenerator deprecation
With Haystack 1.18, we removed the Seq2SeqGenerator and RAGenerator from Haystack. We recommend using the more powerful PromptNode
instead. See the announcement for more details.
What's Changed
Breaking Changes
- PromptHub integration in
PromptNode
by @ZanSara in #4879 - chore: remove deprecated node PDFToTextOCRConverter by @masci in #4982
- refactor: Use globally defined request timeout in
ElasticsearchDocumentStore
andOpenSearchDocumentStore
by @bogdankostic in #5064 - feat!: simplify weaviate auth by @hsm207 in #5115
- feat!: Add extra for inference dependencies such as torch by @julian-risch in #5147
- Remove deprecated param
return_table_cell
by @masci in #5218
Pipeline
- build: Remove tiktoken alternative by @julian-risch in #4991
- fix:
fitz
import switcher by @ZanSara in #5012 - refactor: Generate eval result in separate method by @bogdankostic in #5001
- chore: Unpin typing_extensions and remove all its uses by @silvanocerza in #5040
- docs: Fix doc for
FARMReader.predict
by @pcreux in #5049 - feat: Allow setting custom api_base for OpenAI nodes by @michaelfeil in #5033
- fix: Ensure eval mode for farm and transformer models for predictions by @sjrl in #3791
- chore: remove audio node import by @ZanSara in #5097
- feat: introduce
lazy_import
by @ZanSara in #5084 - fix: WebRetriever top_k is ignored in a pipeline by @vblagoje in #5106
- build: Move Azure's Form Recognizer dependency to extras by @julian-risch in #5096
- chore: mark some unit tests under
test/pipeline
by @ZanSara in #5124 - feat: optional
transformers
by @ZanSara in #5101 - feat:
current_datetime
shaper function by @ZanSara in #5195 - feat: hard document length limit at
max_chars_check
by @ZanSara in #5191 - chore: remove
safe_import
and all usages by @ZanSara in #5139 - fix: Send batches of query-doc pairs to inference_from_objects by @bogdankostic in #5125
- fix: Use add_isolated_node_eval of eval_batch in run_batch by @bogdankostic in #5223
DocumentStores
- docs: updating docstrings to say OpenSearch and backlink to correct docs by @dtaivpp in #5000
- feat: Add batching for querying in
ElasticsearchDocumentStore
andOpenSearchDocumentStore
by @bogdankostic in #5063 - feat: Add batch_size parameter and cast timeout_config value to tuple for
WeaviateDocumentStore
by @bogdankostic in #5079 - fix: changing document scores by @benheckmann in #5090
Documentation
- fix: Fix CohereInvocationLayer _ensure_token_limit not returning resized prompt by @silvanocerza in #4978
- feat: Add prompt_template to conversational agent init params by @julian-risch in #4994
- feat: Allow setting java options when launching Elasticsearch / OpenSearch by @bogdankostic in #5002
- refactor: Adapt retriever benchmarks script by @bogdankostic in #5004
- refactor: Add reader-retriever benchmark script by @bogdankostic in #5006
- refactor: Adapt running benchmarks by @bogdankostic in #5007
- fix: Move check for default
PromptTemplate
s inPromptTemplate
itself by @ZanSara in #5018 - chore: Simplify DefaultPromptHandler logic and add tests by @silvanocerza in #4979
- feat: prompts caching from PromptHub by @ZanSara in #5048
- fix: Fix handling of streaming response in AnthropicClaudeInvocationLayer by @silvanocerza in #4993
- feat: pass model parameters to HFLocalInvocationLayer via
model_kwargs
, enabling direct model usage by @vblagoje in #4956 - feat: Consider prompt_node's default_prompt_template in agent by @julian-risch in #5095
- fix: rename
requests.py
intorequests_utils.py
by @ZanSara in #5099 - docs: update CLI readme by @dfokina in #5129
- fix: small improvement to pipeline v2 tests by @ZanSara in #5153
- feat: Optional Content Moderation for OpenAI PromptNode & OpenAIAnswerGenerator by @benheckmann in #5017
- feat: Update ConversationalAgent by @bilgeyucel in #5065
- fix: Check Agent's prompt template variables and prompt resolver parameters are aligned by @vblagoje in #5163
- feat: add ensure token limit for direct prompting of ChatGPT by @sjrl in #5166
- chore: remove deprecated
Seq2SeqGenerator
andRAGenerator
by @anakin87 in #5180 - fix: model_tokenizer in openai text completion tokenization details by @michaelfeil in #5104
- chore: Remove
add_tool
fromToolsManager
by @bogdankostic in #5192 - feat: enable LLMs hosted via AWS SageMaker in PromptNode by @tholor in #5155
- feat: Add CohereRanker node using Cohere reranking endpoint by @sjrl in #5152
- Fix:
FARMReader
- Consider the max number of labels/answers during training by @anakin87 in #5197 - fix: Support all SageMaker HF text generation models (other than Falcon) by @vblagoje in #5205
Other Changes
- build(deps): bump requests from 2.28.2 to 2.31.0 in /docs/pydoc by @dependabot in #4984
- fix: Pin typing_extensions to fix Pydantic issue by @silvanocerza in #4987
- build: Remove SPARQLWrapper and rdflib from generalimport by @julian-risch in #4986
- fix: remove old dependency from file-converters.yml by @masci in #4999
- test: Mock request from prompt hub in unit test by @bogdankostic in #5011
- feat: Add back hardcoded default templates by @silvanocerza in #4998
- refactor: Adapt benchmarking utils by @bogdankostic in #5003
- ci: track license compliance failures with Datadog by @masci in #5020
- ci: migrate to Datadog all the License Compliance jobs by @masci in #5022
- build: Install protobuf via transformers extra sentencepiece by @julian-risch in #4989
- refactor: Adapt reader benchmarks by @bogdankostic in #5005
- build: Remove dill dependency by @julian-risch in #4985
- ci: fix Datadog event body by @masci in #5024
- fix: prompt_template_resolved.output_variable is NoneType issue by @faaany in #4976
- chore: Change checklist to simple list in PR template by @silvanocerza in #4872
- fix: remove
prompt_text
in examples by @ZanSara in #5041 - chore: pin
prompthub-py
by @ZanSara in #5045 - feat: Add CLI prompt cache command by @silvanocerza in #5050
- feat: move
cli
out frompreview
by @ZanSara in #5055 - fix: Use queries from aggregated labels in benchmarks by @bogdankostic in #5054
- ci:
cli
tests not running in CI by @ZanSara in #5060 - refactor: Delete outdated benchmark files by @bogdankostic in #5008
- fix: Docker workflow runner by @ZanSara in #5077
- fix: Update prompthub-py by @silvanocerza in #5061
- revert fix: change the Docker workflow runner by @ZanSara in #5078
- build: Pin mlflow by @bogdankostic in #5094
- build: Upgrade transformers to v4.30.1 by @julian-risch in #5120
- fix: Don't log info message in DataSilo with SquadProcessor about clipping by @bogdankostic in #5127
- chore: block all HTTP requests in CI by @ZanSara in #5088
- test: Skip flaky PromptNode test by @silvanocerza in #5039
- fix: PromptNode falls back to empty list of documents if none are provided but expected by @julian-risch in #5132
- fix: Relax ChatGPT model name check to support gpt-3.5-turbo-0613 by @julian-risch in #5142
- fix: increase max token length for openai 16k models by @darionreyes in #5145
- test: Add benchmark config files by @bogdankostic in #5093
- feat: Add AgentToolLogger by @vblagoje in #5087
- fix: azure openai authentication error by @erwanlc in #5105
- docs: Remove transformers module from AnswerGenerator API docs by @bogdankostic in #5185
- test: Adding unit tests to Ranker by @sjrl in #5167
- fix:Rename SageMakerInvocationLayer -> SageMakerHFTextGenerationInvocationLayer by @vblagoje in #5204
- Change 'history' to 'memory' in the ConversationalAgent prompts by @bilgeyucel in #5203
- build: add inference dependency group to docker images by @anakin87 in #5215
New Contributors
- @dtaivpp made their first contribution in #5000
- @pcreux made their first contribution in #5049
- @michaelfeil made their first contribution in #5033
- @darionreyes made their first contribution in #5145
- @erwanlc made their first contribution in #5105
Full Changelog: v1.17.2...v1.18.0