Release Notes
โฌ๏ธ Upgrade Notes
gpt-3.5-turbowas replaced bygpt-4o-minias the default model for all components relying on OpenAI API- Support for the legacy filter syntax and operators (e.g., “$and”, “$or”, “$eq”, “$lt”, etc.), which originated in Haystack v1, has been fully removed. Users must now use only the new filter syntax. See the docs for more details.
๐ New Features
-
Added a new component
DocumentNDCGEvaluator, which is similar toDocumentMRREvaluatorand useful for retrieval evaluation. It calculates the normalized discounted cumulative gain, an evaluation metric useful when there are multiple ground truth relevant documents and the order in which they are retrieved is important. -
Add new
CSVToDocumentcomponent. Loads the file as bytes object. Adds the loaded string as a new document that can be used for further processing by the Document Splitter. -
Adds support for zero shot document classification via new
TransformersZeroShotDocumentClassifiercomponent. This allows you to classify documents into user-defined classes (binary and multi-label classification) using pre-trained models from Hugging Face. -
Added the option to use a custom splitting function in
DocumentSplitter. The function must accept a string as input and return a list of strings, representing the split units. To use the feature initialiseDocumentSplitterwithsplit_by="function"providing the custom splitting function assplitting_function=custom_function. -
Add new
JSONConverterComponent to convert JSON files to Document. Optionally it can use jq to filter the source JSON files and extract only specific parts.
import json
from haystack.components.converters import JSONConverter
from haystack.dataclasses import ByteStream
data = {
"laureates": [
{
"firstname": "Enrico",
"surname": "Fermi",
"motivation": "for his demonstrations of the existence of new radioactive elements produced "
"by neutron irradiation, and for his related discovery of nuclear reactions brought about by slow neutrons",
},
{
"firstname": "Rita",
"surname": "Levi-Montalcini",
"motivation": "for their discoveries of growth factors",
},
],
}
source = ByteStream.from_string(json.dumps(data))
converter = JSONConverter(jq_schema=".laureates[]", content_key="motivation", extra_meta_fields=["firstname", "surname"])
results = converter.run(sources=[source])
documents = results["documents"] print(documents[0].content)
# 'for his demonstrations of the existence of new radioactive elements produced by
# neutron irradiation, and for his related discovery of nuclear reactions brought
# about by slow neutrons'
print(documents[0].meta)
# {'firstname': 'Enrico', 'surname': 'Fermi'}
print(documents[1].content)
# 'for their discoveries of growth factors' print(documents[1].meta) # {'firstname': 'Rita', 'surname': 'Levi-Montalcini'}
-
Added a new
NLTKDocumentSplitter, a component enhancing document preprocessing capabilities with NLTK. This feature allows for fine-grained control over the splitting of documents into smaller parts based on configurable criteria such as word count, sentence boundaries, and page breaks. It supports multiple languages and offers options for handling sentence boundaries and abbreviations, facilitating better handling of various document types for further processing tasks. -
Updates
SentenceTransformersDocumentEmbedderandSentenceTransformersTextEmbeddersomodel_max_lengthpassed throughtokenizer_kwargsalso updates themax_seq_lengthof the underlying SentenceTransformer model.
โก๏ธ Enhancement Notes
-
Adapts how
ChatPromptBuildercreates ChatMessages. Messages are deep copied to ensure all meta fields are copied correctly. -
Expose
default_headersto pass custom headers to Azure API including APIM subscription key. -
Add optional
azure_kwargsdictionary parameter to pass in parameters undefined in Haystack but supported by AzureOpenAI. -
Allow the ability to add the current date inside a template in
PromptBuilderusing the following syntax:{% now 'UTC' %}: Get the current date for the UTC timezone.{% now 'America/Chicago' + 'hours=2' %}: Add two hours to the current date in the Chicago timezone.{% now 'Europe/Berlin' - 'weeks=2' %}: Subtract two weeks from the current date in the Berlin timezone.{% now 'Pacific/Fiji' + 'hours=2', '%H' %}: Display only the number of hours after adding two hours to the Fiji timezone.{% now 'Etc/GMT-4', '%I:%M %p' %}: Change the date format to AM/PM for the GMT-4 timezone.
Note that if no date format is provided, the default will be
%Y-%m-%d %H:%M:%S. Please refer to list of tz database for a list of timezones. -
Adds
usagemeta field withprompt_tokensandcompletion_tokenskeys toHuggingFaceAPIChatGenerator. -
Add new
GreedyVariadicinput type. This has a similar behaviour toVariadicinput type as it can be connected to multiple output sockets, though the Pipeline will run it as soon as it receives an input without waiting for others. This replaces theis_greedyargument in the@componentdecorator. If you had a Component with aVariadicinput type and@component(is_greedy=True)you need to change the type toGreedyVariadicand removeis_greedy=truefrom@component. -
Add new Pipeline init argument
max_runs_per_component, this has the same identical behaviour as the existingmax_loops_allowedargument but is more descriptive of its actual effects. -
Add new
PipelineMaxLoopsto reflect newmax_runs_per_componentinit argument -
We added batching during inference time to the
TransformerSimilarityRankerto help prevent OOMs when ranking large amounts of Documents.
โ ๏ธ Deprecation Notes
- The
DefaultConverterclass used by thePyPDFToDocumentcomponent has been deprecated. Its functionality will be merged into the component in 2.7.0. - Pipeline init argument
debug_pathis deprecated and will be removed in version 2.7.0. @componentdecoratoris_greedyargument is deprecated and will be removed in version 2.7.0. UseGreedyVariadictype instead.- Deprecate connecting a Component to itself when calling
Pipeline.connect(), it will raise an error from version 2.7.0 onwards - Pipeline init argument
max_loops_allowedis deprecated and will be removed in version 2.7.0. Usemax_runs_per_componentinstead. PipelineMaxLoopsexception is deprecated and will be removed in version 2.7.0. UsePipelineMaxComponentRunsinstead.
๐ Bug Fixes
- Fix the serialization of
PyPDFToDocumentcomponent to prevent the default converter from being serialized unnecessarily. - Add constraints to
component.set_input_typeandcomponent.set_input_typesto prevent undefined behaviour when therunmethod does not contain a variadic keyword argument. - Prevent
set_output_typesfrom being called when theoutput_typesdecorator is used. - Update the
CHAT_WITH_WEBSITEPipeline template to reflect the changes in theHTMLToDocumentconverter component. - Fix a Pipeline visualization issue due to changes in the new release of Mermaid.
- Fixing the filters in the
SentenceWindowRetrieverallowing now support for 3 more DocumentStores: Astra, PGVector, Qdrant - Fix Pipeline not running Components with Variadic input even if it received inputs only from a subset of its senders
- The
from_dictmethod ofConditionalRouternow correctly handles the case where thedictpassed to it contains the keycustom_filtersexplicitly set toNone. Previously this was causing anAttributeError - Make the
from_dictmethod of thePyPDFToDocumentmore robust to cases when the converter is not provided in the dictionary.
