Skip to main content

GenerateAnswersFromContext

Description

Generates synthetic answers for each question present in the incoming records using a Large Language Model (LLM). For every record, the processor extracts the question and its associated context based on the specified RecordPaths, constructs a prompt, and sends it to an LLM provider to obtain a synthetic answer. The generated answer is then inserted into the record at the designated RecordPath.

Tags

NLP, ai, answers, contextual, generation, llm, openai, rag, synthetic

Properties

In the list below required Properties are shown with an asterisk (*). Other properties are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

Display NameAPI NameDefault ValueAllowable ValuesDescription
Record Reader *Record ReaderController Service:
RecordReaderFactory

Implementations:
AvroReader
CEFReader
CSVReader
ExcelReader
GrokReader
JsonPathReader
JsonTreeReader
ReaderLookup
ScriptedReader
Syslog5424Reader
SyslogReader
WindowsEventLogReader
XMLReader
YamlTreeReader
The Record Reader to use for reading the FlowFile.
Record Writer *Record WriterController Service:
RecordSetWriterFactory

Implementations:
AvroRecordSetWriter
CSVRecordSetWriter
FreeFormTextRecordSetWriter
JsonRecordSetWriter
RecordSetWriterLookup
ScriptedRecordSetWriter
XMLRecordSetWriter
The Record Writer to use for writing the results.
Question Record Path *Question Record PathThe RecordPath to the question field in the record.

Supports Expression Language, using FlowFile attributes and Environment variables.
Context Record Path *Context Record PathThe RecordPath to the array of contexts in the record.

Supports Expression Language, using FlowFile attributes and Environment variables.
Answer Record Path *Answer Record PathThe RecordPath to the synthetically generated answers

Supports Expression Language, using FlowFile attributes and Environment variables.
LLM Provider Service *LLM Provider ServiceController Service:
LLMService

Implementations:
StandardAnthropicLLMService
StandardOpenAILLMService
The provider service for sending evaluation prompts to LLM
Max Character Context LengthMax Character Context LengthMaximum character length of context window.

Dynamic Properties

This component does not support dynamic properties.

Relationships

NameDescription
failureFlowFiles that cannot be processed are routed to this relationship
successFlowFiles that are successfully processed are routed to this relationship

Reads Attributes

This processor does not read attributes.

Writes Attributes

NameDescription
answers.failed.generatedThe total number of synthetic answer generation attempts that failed for the FlowFile.
answers.successfully.generatedThe total number of successfully generated synthetic answers for the FlowFile.
json.parse.failuresNumber of JSON parse failures encountered.

State Management

This component does not store state.

Restricted

This component is not restricted.

Input Requirement

This component requires an incoming relationship.

System Resource Considerations

This component does not specify system resource considerations.

See Also