Skip to content

Releases: deepset-ai/haystack

v2.2.0-rc2

30 May 17:14
16e2ad7
Compare
Choose a tag to compare
v2.2.0-rc2 Pre-release
Pre-release

Release Notes

v2.2.0-rc1

Highlights

The Multiplexer component proved to be hard to explain and to understand. After reviewing its use cases, the documentation was rewritten and the component was renamed to BranchJoiner to better explain its functionalities.

Add the 'OPENAI_TIMEOUT' and 'OPENAI_MAX_RETRIES' to the OpenAI components.

⬆️ Upgrade Notes

  • BranchJoiner has the very same interface as Multiplexer. To upgrade your code, just rename any occurrence of Multiplexer to BranchJoiner and ajdust the imports accordingly.

🚀 New Features

  • Add BranchJoiner to eventually replace Multiplexer
  • AzureOpenAIGenerator and AzureOpenAIChatGenerator can now be configured passing a timeout for the underlying AzureOpenAI client.

⚡️ Enhancement Notes

  • ChatPromptBuilder now supports changing its template at runtime. This allows you to define a default template and then change it based on your needs at runtime.
  • If an LLM-based evaluator (e.g., Faithfulness or ContextRelevance) is initialised with raise_on_failure=False, and if a call to an LLM fails or an LLM outputs an invalid JSON, the score of the sample is set to NaN instead of raising an exception. The user is notified with a warning indicating the number of requests that failed.
  • Adds inference mode to model call of the ExtractiveReader. This prevents gradients from being calculated during inference time in pytorch.
  • The DocumentCleaner class has the optional attribute keep_id that if set to True it keeps the document ids unchanged after cleanup.
  • DocumentSplitter now has an optional split_threshold parameter. Use this parameter if you want to rather not split inputs that are only slightly longer than the allowed split_length. If when chunking one of the chunks is smaller than the split_threshold, the chunk will be concatenated with the previous one. This avoids having too small chunks that are not meaningful.
  • Re-implement InMemoryDocumentStore BM25 search with incremental indexing by avoiding re-creating the entire inverse index for every new query. This change also removes the dependency on haystack_bm25. Please refer to [PR #7549](#7549) for the full context.
  • Improved MIME type management by directly setting MIME types on ByteStreams, enhancing the overall handling and routing of different file types. This update makes MIME type data more consistently accessible and simplifies the process of working with various document formats.
  • PromptBuilder now supports changing its template at runtime (e.g. for Prompt Engineering). This allows you to define a default template and then change it based on your needs at runtime.
  • Now you can set the timeout and max_retries parameters on OpenAI components by setting the 'OPENAI_TIMEOUT' and 'OPENAI_MAX_RETRIES' environment vars or passing them at __init__.
  • The DocumentJoiner component's run method now accepts a top_k parameter, allowing users to specify the maximum number of documents to return at query time. This fixes issue #7702.
  • Enforce JSON mode on OpenAI LLM-based evaluators so that the they always return valid JSON output. This is to ensure that the output is always in a consistent format, regardless of the input.
  • Make warm_up() usage consistent across the codebase.
  • Create a class hierarchy for pipeline classes, and move the run logic into the child class. Preparation work for introducing multiple run stratgegies.
  • Make the SerperDevWebSearch more robust when snippet is not present in the request response.
  • Make SparseEmbedding a dataclass, this makes it easier to use the class with Pydantic
  • `HTMLToDocument`: change the HTML conversion backend from boilerpy3 to trafilatura, which is more robust and better maintained.

⚠️ Deprecation Notes

  • Mulitplexer is now deprecated.
  • DynamicChatPromptBuilder has been deprecated as ChatPromptBuilder fully covers its functionality. Use ChatPromptBuilder instead.
  • DynamicPromptBuilder has been deprecated as PromptBuilder fully covers its functionality. Use PromptBuilder instead.
  • The following parameters of HTMLToDocument are ignored and will be removed in Haystack 2.4.0: extractor_type and try_others.

🐛 Bug Fixes

  • FaithfullnessEvaluator and ContextRelevanceEvaluator now return 0 instead of NaN when applied to an empty context or empty statements.
  • Azure generators components fixed, they were missing the @component decorator.
  • Updates the from_dict method of SentenceTransformersTextEmbedder, SentenceTransformersDocumentEmbedder, NamedEntityExtractor, SentenceTransformersDiversityRanker and LocalWhisperTranscriber to allow None as a valid value for device when deserializing from a YAML file. This allows a deserialized pipeline to auto-determine what device to use using the ComponentDevice.resolve_device logic.
  • Fix the broken serialization of HuggingFaceAPITextEmbedder, HuggingFaceAPIDocumentEmbedder, HuggingFaceAPIGenerator, and HuggingFaceAPIChatGenerator.
  • Fix NamedEntityExtractor crashing in Python 3.12 if constructed using a string backend argument.
  • Fixed the PdfMinerToDocument converter's outputs to be properly wired up to 'documents'.
  • Add to_dict method to DocumentRecallEvaluator to allow proper serialization of the component.
  • Improves/fixes type serialization of PEP 585 types (e.g. list[Document], and their nested version). This improvement enables better serialization of generics and nested types and improves/fixes matching of list[X] and List[X] types in component connections after serialization.
  • Fixed (de)serialization of NamedEntityExtractor. Includes updated tests verifying these fixes when NamedEntityExtractor is used in pipelines.
  • The include_outputs_from parameter in Pipeline.run correctly returns outputs of components with multiple outputs.
  • Return an empty list of answers when ExtractiveReader receives an empty list of documents instead of raising an exception.

v2.2.0-rc1

30 May 16:51
3814e75
Compare
Choose a tag to compare
v2.2.0-rc1 Pre-release
Pre-release
v2.2.0-rc1

v2.1.2

16 May 13:40
Compare
Choose a tag to compare

Release Notes

v2.1.2

⚡️ Enhancement Notes

  • Enforce JSON mode on OpenAI LLM-based evaluators so that the they always return valid JSON output. This is to ensure that the output is always in a consistent format, regardless of the input.

🐛 Bug Fixes

  • FaithfullnessEvaluator and ContextRelevanceEvaluator now return 0 instead of NaN when applied to an empty context or empty statements.
  • Azure generators components fixed, they were missing the @component decorator.
  • Updates the from_dict method of SentenceTransformersTextEmbedder, SentenceTransformersDocumentEmbedder, NamedEntityExtractor, SentenceTransformersDiversityRanker and LocalWhisperTranscriber to allow None as a valid value for device when deserializing from a YAML file. This allows a deserialized pipeline to auto-determine what device to use using the ComponentDevice.resolve_device logic.
  • Improves/fixes type serialization of PEP 585 types (e.g. list[Document], and their nested version). This improvement enables better serialization of generics and nested types and improves/fixes matching of list[X] and List[X]` types in component connections after serialization.
  • Fixed (de)serialization of NamedEntityExtractor. Includes updated tests verifying these fixes when NamedEntityExtractor is used in pipelines.
  • The include_outputs_from parameter in Pipeline.run correctly returns outputs of components with multiple outputs.

v2.1.1-rc1

09 May 15:19
Compare
Choose a tag to compare

Release Notes

v2.1.1-rc1

⚡️ Enhancement Notes

  • Make SparseEmbedding a dataclass, this makes it easier to use the class with Pydantic

🐛 Bug Fixes

  • Fix the broken serialization of HuggingFaceAPITextEmbedder, HuggingFaceAPIDocumentEmbedder, HuggingFaceAPIGenerator, and HuggingFaceAPIChatGenerator.
  • Add to_dict method to DocumentRecallEvaluator to allow proper serialization of the component.

v2.1.1

09 May 16:03
Compare
Choose a tag to compare

Release Notes

v2.1.1

⚡️ Enhancement Notes

  • Make SparseEmbedding a dataclass, this makes it easier to use the class with Pydantic

🐛 Bug Fixes

  • Fix the broken serialization of HuggingFaceAPITextEmbedder, HuggingFaceAPIDocumentEmbedder, HuggingFaceAPIGenerator, and HuggingFaceAPIChatGenerator.
  • Add to_dict method to DocumentRecallEvaluator to allow proper serialization of the component.

v2.1.0-rc2

06 May 08:45
Compare
Choose a tag to compare

Release Notes

Highlights

📊 New Evaluator Components

Haystack introduces new components for both with model-based, and statistical evaluation: AnswerExactMatchEvaluator, ContextRelevanceEvaluator, DocumentMAPEvaluator, DocumentMRREvaluator, DocumentRecallEvaluator, FaithfulnessEvaluator, LLMEvaluator, SASEvaluator

Here's an example of how to use DocumentMAPEvaluator to evaluate retrieved documents and calculate mean average precision score:

from haystack import Document
from haystack.components.evaluators import DocumentMAPEvaluator

evaluator = DocumentMAPEvaluator()
result = evaluator.run(
    ground_truth_documents=[
        [Document(content="France")],
        [Document(content="9th century"), Document(content="9th")],
    ],
    retrieved_documents=[
        [Document(content="France")],
        [Document(content="9th century"), Document(content="10th century"), Document(content="9th")],
    ],
)

result["individual_scores"]
>> [1.0, 0.8333333333333333]
result["score"]
>> 0 .9166666666666666

To learn more about evaluating RAG pipelines both with model-based, and statistical metrics available in the Haystack, check out Tutorial: Evaluating RAG Pipelines.

🕸️ Support For Sparse Embeddings

Haystack offers robust support for Sparse Embedding Retrieval techniques, including SPLADE. Here's how to create a simple retrieval Pipeline with sparse embeddings:

from haystack import Pipeline
from haystack_integrations.components.retrievers.qdrant import QdrantSparseEmbeddingRetriever
from haystack_integrations.components.embedders.fastembed import FastembedSparseTextEmbedder

sparse_text_embedder = FastembedSparseTextEmbedder(model="prithvida/Splade_PP_en_v1")
sparse_retriever = QdrantSparseEmbeddingRetriever(document_store=document_store)

query_pipeline = Pipeline()
query_pipeline.add_component("sparse_text_embedder", sparse_text_embedder)
query_pipeline.add_component("sparse_retriever", sparse_retriever)

query_pipeline.connect("sparse_text_embedder.sparse_embedding", "sparse_retriever.query_sparse_embedding")

Learn more about this topic in our documentation on Sparse Embedding-based Retrievers
Start building with our new cookbook: 🧑‍🍳 Sparse Embedding Retrieval using Qdrant and FastEmbed.

🧐 Inspect Component Outputs

As of 2.1.0, you can now inspect each component output after running a pipeline. Provide component names with include_outputs_from key to pipeline.run:

pipe.run(data, include_outputs_from=["prompt_builder", "llm", "retriever"])

And the pipeline output should look like this:

{'llm': {'replies': ['The Rhodes Statue was described as being built with iron tie bars to which brass plates were fixed to form the skin. It stood on a 15-meter-high white marble pedestal near the Rhodes harbor entrance. The statue itself was about 70 cubits, or 32 meters, tall.'],
  'meta': [{'model': 'gpt-3.5-turbo-0125',
    ...
    'usage': {'completion_tokens': 57,
     'prompt_tokens': 446,
     'total_tokens': 503}}]},
 'retriever': {'documents': [Document(id=a3ee3a9a55b47ff651ae11dc56d84d2b6f8d931b795bd866c14eacfa56000965, content: 'Within it, too, are to be seen large masses of rock, by the weight of which the artist steadied it w...', meta: {'url': 'https://en.wikipedia.org/wiki/Colossus_of_Rhodes', '_split_id': 9}, score: 0.648961685430463),...]},
 'prompt_builder': {'prompt': "\nGiven the following information, answer the question.\n\nContext:\n\n    Within it, too, are to be seen large masses of rock, by the weight of which the artist steadied it while...
 ... levels during construction.\n\n\n\nQuestion: What does Rhodes Statue look like?\nAnswer:"}}

🚀 New Features

  • Add several new Evaluation components, i.e:

    • AnswerExactMatchEvaluator
    • ContextRelevanceEvaluator
    • DocumentMAPEvaluator
    • DocumentMRREvaluator
    • DocumentRecallEvaluator
    • FaithfulnessEvaluator
    • LLMEvaluator
    • SASEvaluator
  • Introduce a new SparseEmbedding class that can store a sparse vector representation of a document. It will be instrumental in supporting sparse embedding retrieval with the subsequent introduction of sparse embedders and sparse embedding retrievers.

  • Added a SentenceTransformersDiversityRanker. The diversity ranker orders documents to maximize their overall diversity. The ranker leverages sentence-transformer models to calculate semantic embeddings for each document and the query.

  • Introduced new HuggingFace API components, namely:

    • HuggingFaceAPIChatGenerator, which will replace the HuggingFaceTGIChatGenerator in the future.
    • HuggingFaceAPIDocumentEmbedder, which will replace the HuggingFaceTEIDocumentEmbedder in the future.
    • HuggingFaceAPIGenerator, which will replace the HuggingFaceTGIGenerator in the future.
    • HuggingFaceAPITextEmbedder, which will replace the HuggingFaceTEITextEmbedder in the future.
    • These components support different Hugging Face APIs:
      • free Serverless Inference API
      • paid Inference Endpoints
      • self-hosted Text Generation Inference

⚡️ Enhancement Notes

  • Compatibility with huggingface_hub>=0.22.0 for HuggingFaceTGIGenerator and HuggingFaceTGIChatGenerator components.

  • Adds truncate and normalize parameters to HuggingFaceTEITextEmbedder and HuggingFaceTEITextEmbedder to allow truncation and normalization of embeddings.

  • Adds trust_remote_code parameter to SentenceTransformersDocumentEmbedder and SentenceTransformersTextEmbedder for allowing custom models and scripts.

  • Adds streaming_callback parameter to HuggingFaceLocalGenerator, allowing users to handle streaming responses.

  • Adds a ZeroShotTextRouter that uses an NLI model from HuggingFace to classify texts based on a set of provided labels and routes them based on the label they were classified with.

  • Adds dimensions parameter to Azure OpenAI Embedders (AzureOpenAITextEmbedder and AzureOpenAIDocumentEmbedder) to fully support new embedding models like text-embedding-3-small, text-embedding-3-large and upcoming ones

  • Now the DocumentSplitter adds the page_number field to the metadata of all output documents to keep track of the page of the original document it belongs to.

  • Allows users to customise text extraction from PDF files. This is particularly useful for PDFs with unusual layouts, such as multiple text columns. For instance, users can configure the object to retain the reading order.

  • Enhanced PromptBuilder to specify and enforce required variables in prompt templates.

  • Set max_new_tokens default to 512 in HuggingFace generators.

  • Enhanced the AzureOCRDocumentConverter to include advanced handling of tables and text. Features such as extracting preceding and following context for tables, merging multiple column headers, and enabling single-column page layout for text have been introduced. This update furthers the flexibility and accuracy of document conversion within complex layouts.

  • Enhanced DynamicChatPromptBuilder's capabilities by allowing all user and system messages to be templated with provided variables. This update ensures a more versatile and dynamic templating process, making chat prompt generation more efficient and customised to user needs.

  • Improved HTML content extraction by attempting to use multiple extractors in order of priority until successful. An additional try_others parameter in HTMLToDocument, True by default, determines whether subsequent extractors are used after a failure. This enhancement decreases extraction failures, ensuring more dependable content retrieval.

  • Enhanced FileTypeRouter with regex pattern support for MIME types. This powerful addition allows for more granular control and flexibility in routing files based on their MIME types, enabling the handling of broad categories or specific MIME type patterns with ease. This feature particularly benefits applications requiring sophisticated file classification and routing logic.

  • In Jupyter notebooks, the image of the Pipeline will no longer be displayed automatically. Instead, the textual representation of the Pipeline will be displayed. To display the Pipeline image, use the show method of the Pipeline object.

  • Add support for callbacks during pipeline deserialization. Currently supports a pre-init hook for components that can be used to inspect and modify the initialization parameters before the invocation of the component's __init__ method.

  • pipeline.run() accepts a set of component names whose intermediate outputs are returned in the final pipeline output dictionary.

  • Refactor PyPDFToDocument to simplify support for custom PDF converters. PDF converters are classes that implement the PyPDFConverter protocol and have 3 methods: convert, to_dict and from_dict.

⚠️ Deprecation Notes

  • Deprecate HuggingFaceTGIChatGenerator, will be removed in Haystack 2.3.0. Use HuggingFaceAPIChatGenerator instead.
  • Deprecate `HuggingFaceTEIDocumentEmbedder...
Read more

v2.1.0

07 May 09:03
Compare
Choose a tag to compare

Release Notes

Highlights

📊 New Evaluator Components

Haystack introduces new components for both with model-based, and statistical evaluation: AnswerExactMatchEvaluator, ContextRelevanceEvaluator, DocumentMAPEvaluator, DocumentMRREvaluator, DocumentRecallEvaluator, FaithfulnessEvaluator, LLMEvaluator, SASEvaluator

Here's an example of how to use DocumentMAPEvaluator to evaluate retrieved documents and calculate mean average precision score:

from haystack import Document
from haystack.components.evaluators import DocumentMAPEvaluator

evaluator = DocumentMAPEvaluator()
result = evaluator.run(
    ground_truth_documents=[
        [Document(content="France")],
        [Document(content="9th century"), Document(content="9th")],
    ],
    retrieved_documents=[
        [Document(content="France")],
        [Document(content="9th century"), Document(content="10th century"), Document(content="9th")],
    ],
)

result["individual_scores"]
>> [1.0, 0.8333333333333333]
result["score"]
>> 0 .9166666666666666

To learn more about evaluating RAG pipelines both with model-based, and statistical metrics available in the Haystack, check out Tutorial: Evaluating RAG Pipelines.

🕸️ Support For Sparse Embeddings

Haystack offers robust support for Sparse Embedding Retrieval techniques, including SPLADE. Here's how to create a simple retrieval Pipeline with sparse embeddings:

from haystack import Pipeline
from haystack_integrations.components.retrievers.qdrant import QdrantSparseEmbeddingRetriever
from haystack_integrations.components.embedders.fastembed import FastembedSparseTextEmbedder

sparse_text_embedder = FastembedSparseTextEmbedder(model="prithvida/Splade_PP_en_v1")
sparse_retriever = QdrantSparseEmbeddingRetriever(document_store=document_store)

query_pipeline = Pipeline()
query_pipeline.add_component("sparse_text_embedder", sparse_text_embedder)
query_pipeline.add_component("sparse_retriever", sparse_retriever)

query_pipeline.connect("sparse_text_embedder.sparse_embedding", "sparse_retriever.query_sparse_embedding")

Learn more about this topic in our documentation on Sparse Embedding-based Retrievers
Start building with our new cookbook: 🧑‍🍳 Sparse Embedding Retrieval using Qdrant and FastEmbed.

🧐 Inspect Component Outputs

As of 2.1.0, you can now inspect each component output after running a pipeline. Provide component names with include_outputs_from key to pipeline.run:

pipe.run(data, include_outputs_from={"prompt_builder", "llm", "retriever"})

And the pipeline output should look like this:

{'llm': {'replies': ['The Rhodes Statue was described as being built with iron tie bars to which brass plates were fixed to form the skin. It stood on a 15-meter-high white marble pedestal near the Rhodes harbor entrance. The statue itself was about 70 cubits, or 32 meters, tall.'],
  'meta': [{'model': 'gpt-3.5-turbo-0125',
    ...
    'usage': {'completion_tokens': 57,
     'prompt_tokens': 446,
     'total_tokens': 503}}]},
 'retriever': {'documents': [Document(id=a3ee3a9a55b47ff651ae11dc56d84d2b6f8d931b795bd866c14eacfa56000965, content: 'Within it, too, are to be seen large masses of rock, by the weight of which the artist steadied it w...', meta: {'url': 'https://en.wikipedia.org/wiki/Colossus_of_Rhodes', '_split_id': 9}, score: 0.648961685430463),...]},
 'prompt_builder': {'prompt': "\nGiven the following information, answer the question.\n\nContext:\n\n    Within it, too, are to be seen large masses of rock, by the weight of which the artist steadied it while...
 ... levels during construction.\n\n\n\nQuestion: What does Rhodes Statue look like?\nAnswer:"}}

🚀 New Features

  • Add several new Evaluation components, i.e:

    • AnswerExactMatchEvaluator
    • ContextRelevanceEvaluator
    • DocumentMAPEvaluator
    • DocumentMRREvaluator
    • DocumentRecallEvaluator
    • FaithfulnessEvaluator
    • LLMEvaluator
    • SASEvaluator
  • Introduce a new SparseEmbedding class that can store a sparse vector representation of a document. It will be instrumental in supporting sparse embedding retrieval with the subsequent introduction of sparse embedders and sparse embedding retrievers.

  • Added a SentenceTransformersDiversityRanker. The diversity ranker orders documents to maximize their overall diversity. The ranker leverages sentence-transformer models to calculate semantic embeddings for each document and the query.

  • Introduced new HuggingFace API components, namely:

    • HuggingFaceAPIChatGenerator, which will replace the HuggingFaceTGIChatGenerator in the future.
    • HuggingFaceAPIDocumentEmbedder, which will replace the HuggingFaceTEIDocumentEmbedder in the future.
    • HuggingFaceAPIGenerator, which will replace the HuggingFaceTGIGenerator in the future.
    • HuggingFaceAPITextEmbedder, which will replace the HuggingFaceTEITextEmbedder in the future.
    • These components support different Hugging Face APIs:
      • free Serverless Inference API
      • paid Inference Endpoints
      • self-hosted Text Generation Inference

⚡️ Enhancement Notes

  • Compatibility with huggingface_hub>=0.22.0 for HuggingFaceTGIGenerator and HuggingFaceTGIChatGenerator components.

  • Adds truncate and normalize parameters to HuggingFaceTEITextEmbedder and HuggingFaceTEITextEmbedder to allow truncation and normalization of embeddings.

  • Adds trust_remote_code parameter to SentenceTransformersDocumentEmbedder and SentenceTransformersTextEmbedder for allowing custom models and scripts.

  • Adds streaming_callback parameter to HuggingFaceLocalGenerator, allowing users to handle streaming responses.

  • Adds a ZeroShotTextRouter that uses an NLI model from HuggingFace to classify texts based on a set of provided labels and routes them based on the label they were classified with.

  • Adds dimensions parameter to Azure OpenAI Embedders (AzureOpenAITextEmbedder and AzureOpenAIDocumentEmbedder) to fully support new embedding models like text-embedding-3-small, text-embedding-3-large and upcoming ones

  • Now the DocumentSplitter adds the page_number field to the metadata of all output documents to keep track of the page of the original document it belongs to.

  • Allows users to customise text extraction from PDF files. This is particularly useful for PDFs with unusual layouts, such as multiple text columns. For instance, users can configure the object to retain the reading order.

  • Enhanced PromptBuilder to specify and enforce required variables in prompt templates.

  • Set max_new_tokens default to 512 in HuggingFace generators.

  • Enhanced the AzureOCRDocumentConverter to include advanced handling of tables and text. Features such as extracting preceding and following context for tables, merging multiple column headers, and enabling single-column page layout for text have been introduced. This update furthers the flexibility and accuracy of document conversion within complex layouts.

  • Enhanced DynamicChatPromptBuilder's capabilities by allowing all user and system messages to be templated with provided variables. This update ensures a more versatile and dynamic templating process, making chat prompt generation more efficient and customised to user needs.

  • Improved HTML content extraction by attempting to use multiple extractors in order of priority until successful. An additional try_others parameter in HTMLToDocument, True by default, determines whether subsequent extractors are used after a failure. This enhancement decreases extraction failures, ensuring more dependable content retrieval.

  • Enhanced FileTypeRouter with regex pattern support for MIME types. This powerful addition allows for more granular control and flexibility in routing files based on their MIME types, enabling the handling of broad categories or specific MIME type patterns with ease. This feature particularly benefits applications requiring sophisticated file classification and routing logic.

  • In Jupyter notebooks, the image of the Pipeline will no longer be displayed automatically. Instead, the textual representation of the Pipeline will be displayed. To display the Pipeline image, use the show method of the Pipeline object.

  • Add support for callbacks during pipeline deserialization. Currently supports a pre-init hook for components that can be used to inspect and modify the initialization parameters before the invocation of the component's __init__ method.

  • pipeline.run() accepts a set of component names whose intermediate outputs are returned in the final pipeline output dictionary.

  • Refactor PyPDFToDocument to simplify support for custom PDF converters. PDF converters are classes that implement the PyPDFConverter protocol and have 3 methods: convert, to_dict and from_dict.

⚠️ Deprecation Notes

  • Deprecate HuggingFaceTGIChatGenerator, will be removed in Haystack 2.3.0. Use HuggingFaceAPIChatGenerator instead.
  • Deprecate HuggingFaceTEIDocumentEmbedder, will be removed in...
Read more

v2.1.0-rc1

02 May 10:54
Compare
Choose a tag to compare

Release Notes

v2.1.0-rc1

Highlights

Add the "page_number" field to the metadata of all output documents.

⬆️ Upgrade Notes

  • The HuggingFaceTGIGenerator and HuggingFaceTGIChatGenerator components have been modified to be compatible with huggingface_hub>=0.22.0.

    If you use these components, you may need to upgrade the huggingface_hub library. To do this, run the following command in your environment: `bash pip install "huggingface_hub>=0.22.0"`

🚀 New Features

  • Add SentenceTransformersDiversityRanker. The Diversity Ranker orders documents in such a way as to maximize the overall diversity of the given documents. The ranker leverages sentence-transformer models to calculate semantic embeddings for each document and the query.

  • Adds truncate and normalize parameters to HuggingFaceTEITextEmbedder and HuggingFaceTEITextEmbedder for allowing truncation and normalization of embeddings.

  • Add trust_remote_code parameter to SentenceTransformersDocumentEmbedder and SentenceTransformersTextEmbedder for allowing custom models and scripts.

  • Add a new ContextRelevanceEvaluator component that can be used to evaluate whether retrieved documents are relevant to answer a question with a RAG pipeline. Given a question and a list of retrieved document contents (contexts), an LLM is used to score to what extent the provided context is relevant. The score ranges from 0 to 1.

  • Add DocumentMAPEvaluator, it can be used to calculate mean average precision of retrieved documents.

  • Add DocumentMRREvaluator, it can be used to calculate mean reciprocal rank of retrieved documents.

  • Add a new FaithfulnessEvaluator component that can be used to evaluate faithfulness / groundedness / hallucinations of LLMs in a RAG pipeline. Given a question, a list of retrieved document contents (contexts), and a predicted answer, FaithfulnessEvaluator returns a score ranging from 0 (poor faithfulness) to 1 (perfect faithfulness). The score is the proportion of statements in the predicted answer that could by inferred from the documents.

  • Introduce HuggingFaceAPIChatGenerator. This text-generation component uses the ChatMessage format and supports different Hugging Face APIs: - free Serverless Inference API - paid Inference Endpoints - self-hosted Text Generation Inference.

    This generator will replace the HuggingFaceTGIChatGenerator in the future.

  • Introduce HuggingFaceAPIDocumentEmbedder. This component can be used to compute Document embeddings using different Hugging Face APIs: - free Serverless Inference API - paid Inference Endpoints - self-hosted Text Embeddings Inference. This embedder will replace the HuggingFaceTEIDocumentEmbedder in the future.

  • Introduce HuggingFaceAPIGenerator. This text-generation component supports different Hugging Face APIs:

    • free Serverless Inference API
    • paid Inference Endpoints
    • self-hosted Text Generation Inference.

    This generator will replace the HuggingFaceTGIGenerator in the future.

  • Introduce HuggingFaceAPITextEmbedder. This component can be used to embed strings using different Hugging Face APIs: - free Serverless Inference API - paid Inference Endpoints - self-hosted Text Embeddings Inference. This embedder will replace the HuggingFaceTEITextEmbedder in the future.

  • Adds 'streaming_callback' parameter to 'HuggingFaceLocalGenerator', allowing users to handle streaming responses.

  • Added a new EvaluationRunResult dataclass that wraps the results of an evaluation pipeline, allowing for its transformation and visualization.

  • Add a new LLMEvaluator component that leverages LLMs through the OpenAI api to evaluate pipelines.

  • Add DocumentRecallEvaluator, a Component that can be used to calculate the Recall single-hit or multi-hit metric given a list of questions, a list of expected documents for each question and the list of predicted documents for each question.

  • Add SASEvaluator, it can be used to calculate Semantic Answer Similarity of generated answers from an LLM

  • Introduce a new SparseEmbedding class which can be used to store a sparse vector representation of a Document. It will be instrumental to support Sparse Embedding Retrieval with the subsequent introduction of Sparse Embedders and Sparse Embedding Retrievers.

  • Add a Zero Shot Text Router that uses an NLI model from HF to classify texts based on a set of provided labels and routes them based on the label they were classified with.

⚡️ Enhancement Notes

  • add dimensions parameter to Azure OpenAI Embedders (AzureOpenAITextEmbedder and AzureOpenAIDocumentEmbedder) to fully support new embedding models like text-embedding-3-small, text-embedding-3-large and upcoming ones

  • Now the DocumentSplitter adds the "page_number" field to the metadata of all output documents to keep track of the page of the original document it belongs to.

  • Provides users the ability to customize text extraction from PDF files. It is particularly useful for PDFs with unusual layouts, such as those containing multiple text columns. For instance, users can configure the object to retain the reading order.

  • Enhanced PromptBuilder to specify and enforce required variables in prompt templates.

  • Set max_new_tokens default to 512 in Hugging Face generators.

  • Enhanced the AzureOCRDocumentConverter to include advanced handling of tables and text. Features such as extracting preceding and following context for tables, merging multiple column headers, and enabling single column page layout for text have been introduced. This update furthers the flexibility and accuracy of document conversion within complex layouts.

  • Enhanced DynamicChatPromptBuilder's capabilities by allowing all user and system messages to be templated with provided variables. This update ensures a more versatile and dynamic templating process, making chat prompt generation more efficient and customized to user needs.

  • Improved HTML content extraction by attempting to use multiple extractors in order of priority until successful. An additional try_others parameter in HTMLToDocument, which is true by default, determines whether subsequent extractors are used after a failure. This enhancement decreases extraction failures, ensuring more dependable content retrieval.

  • Enhanced FileTypeRouter with Regex Pattern Support for MIME Types: This introduces a significant enhancement to the FileTypeRouter, now featuring support for regex pattern matching for MIME types. This powerful addition allows for more granular control and flexibility in routing files based on their MIME types, enabling the handling of broad categories or specific MIME type patterns with ease. This feature is particularly beneficial for applications requiring sophisticated file classification and routing logic.

    Usage example: `python from haystack.components.routers import FileTypeRouter router = FileTypeRouter(mime_types=[r"text/.*", r"application/(pdf|json)"]) # Example files to classify file_paths = [ Path("document.pdf"), Path("report.json"), Path("notes.txt"), Path("image.png"), ] result = router.run(sources=file_paths) for mime_type, files in result.items(): print(f"MIME Type: {mime_type}, Files: {[str(file) for file in files]}")`

  • Improved pipeline run tracing to include pipeline input/output data.

  • In Jupyter notebooks, the image of the Pipeline will no longer be displayed automatically. The textual representation of the Pipeline will be displayed.

    To display the Pipeline image, use the show method of the Pipeline object.

  • Add support for callbacks during pipeline deserialization. Currently supports a pre-init hook for components that can be used to inspect and modify the initialization parameters before the invocation of the component's __init__ method.

  • pipeline.run accepts a set of component names whose intermediate outputs are returned in the final pipeline output dictionary.

  • Pipeline.inputs and Pipeline.outputs can optionally include components input/output sockets that are connected.

  • Refactor PyPDFToDocument to simplify support for custom PDF converters. PDF converters are classes that implement the PyPDFConverter protocol and have 3 methods: convert, to_dict and from_dict. The DefaultConverter class is provided as a default implementation.

  • Add an __eq__ method to SparseEmbedding class to compare two SparseEmbedding objects.

⚠️ Deprecation Notes

  • Deprecate HuggingFaceTGIChatGenerator. This component will be removed in Haystack 2.3.0. Use HuggingFaceAPIChatGenerator instead.
  • Deprecate HuggingFaceTEIDocumentEmbedder. This component will be removed in Haystack 2.3.0. Use HuggingFaceAPIDocumentEmbedder instead.
  • Deprecate <span class="t...
Read more

v1.25.5

24 Apr 13:24
Compare
Choose a tag to compare

Release Notes

v1.25.5

🐛 Bug Fixes

  • Pipeline run error when using the FileTypeClassifier with the raise_on_error: True option. Instead of returning an unexpected NoneType, we route the file to a dead-end edge.

v1.25.4

23 Apr 17:38
Compare
Choose a tag to compare

Release Notes

v1.25.4

🐛 Bug Fixes

  • Fixes OutputParser usage in PromptTemplate after making invocation context immutable in #7510.