Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

ReferencePredictor

Use this component in retrieval augmented generation (RAG) pipelines to predict references for the generated answer.

Deprecation Notice

This component is deprecated. It will continue to work in your existing pipelines. You can use LLM-generated references instead. For more information, see Enable References for Generated Answers.

Key Features

  • Predicts which parts of source documents correspond to each sentence in the generated answer.
  • Adds a _references metadata field to each answer with detailed span-level reference information.
  • Configurable verifiability model to filter out unsupported or hallucinated answer sentences.
  • Supports custom sentence-splitting rules and abbreviation handling for better accuracy.
  • Works best with English data using the default cross-encoder model.

Configuration

  1. Drag the ReferencePredictor component onto the canvas from the Component Library.
  2. Click the component to open the configuration panel.
  3. Configure the parameters as needed.

Connections

ReferencePredictor receives an answers list of GeneratedAnswer objects from a Generator. It outputs the same answers list with added reference metadata. Connect its answers output to AnswerBuilder.

Usage Example

This is an example of a query pipeline in which ReferencePredictor sends answers with references to AnswerBuilder.

components:
# ...
reference_predictor:
type: deepset_cloud_custom_nodes.augmenters.reference_predictor.ReferencePredictor
init_parameters:
use_split_rules: True
extend_abbreviations: True

answer_builder:
type: haystack.components.builders.answer_builder.AnswerBuilder
init_parameters: {} # In this example, we're using AnswerBuilder with default parameters

connections:
# ...
- sender: reference_predictor.answers
receiver: answer_builder.answers

Parameters

Inputs

ParameterTypeDefaultDescription
answersList[GeneratedAnswer]The generated answers to which you want to add references.

Outputs

ParameterTypeDefaultDescription
answersList[GeneratedAnswer]Generated answers with a metadata field _references added to each answer and containing a list of references this answer was based on. Each reference contains: document_start_idx, document_end_idx, answer_start_idx, answer_end_idx, score, document_id, document_position, and label.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
modelstrcross-encoder/ms-marco-MiniLM-L-6-v2The name identifier of the model to use on Hugging Face Hub or the path to a local model folder.
revisionOptional[str]NoneThe revision of the model to use.
max_seq_lenint512The maximum number of tokens that a sequence should be truncated to before inference.
languageLanguageenThe language of the data that you want to generate references for. The language is needed to apply the right sentence splitting rules.
deviceOptional[ComponentDevice]NoneThe device on which the model is loaded. If None, the default device is automatically selected.
batch_sizeint16The batch size that should be used for inference.
answer_window_sizeint1How many sentences of an answer should be packed into one span for inference.
document_window_sizeint3How many sentences of a document should be packed into one span for inference.
tokenOptional[Secret]Secret.from_env_var('HF_API_TOKEN', strict=False)The token to use as HTTP bearer authorization for remote files.
function_to_applystrsigmoidWhat activation function to use on top of the logits. Available: sigmoid, softmax, none.
min_score_2_label_thresholdsOptional[Dict]NoneThe minimum prediction score threshold for each corresponding label.
label_2_score_mapOptional[Dict]NoneIf using a model with a multi label prediction head, pass in a dict mapping label names to a float value that will be used as score.
reference_thresholdOptional[int]NoneIf using this component to generate references for answer spans, you can pass in a minimum score threshold that determines if a prediction should be included as reference or not. If no threshold is passed, the reference is chosen by picking the maximum score.
default_classstrnot_groundedA fallback class that should be used if the predicted score doesn't match any threshold.
verifiability_modelOptional[str]tstadel/answer-classification-setfit-v2-binaryThe name identifier of the verifiability model to use on Hugging Face Hub or the path to a local model folder.
verifiability_revisionOptional[str]NoneThe revision of the verifiability model to use.
verifiability_batch_sizeint32The batch size that should be used for verifiability inference.
needs_verification_classesList[str] | NoneNoneThe class names to be used to determine if a sentence needs verification. Defaults to ["needs_verification"].
use_split_rulesboolFalseIf True, additional rules for better splitting answers are applied to the sentence splitting tokenizer.
extend_abbreviationsboolFalseIf True, the abbreviations used by NLTK's PunktTokenizer are extended by a list of curated abbreviations if available.
answer_strideint1The stride size for answer window.
document_strideint3The stride size for document window.
model_kwargsOptional[Dict]NoneAdditional keyword arguments for the model.
verifiability_model_kwargsOptional[Dict]NoneAdditional keyword arguments for the verifiability model.

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
answersList[GeneratedAnswer]Replies returned by the Generator.