PairedPromptedGenerator
About 326 wordsAbout 1 min
2025-10-09
📘 Overview
PairedPromptedGenerator is a paired-input prompt generator. It is designed to take two columns from a dataset, combine them with a system prompt to create a complete prompt, and then use a Large Language Model (LLM) to generate a response. The operator processes data in batches and writes the generated content back to a new column.
__init__
def __init__(self, llm_serving: LLMServingABC, system_prompt: str = "You are a helpful agent.")| Parameter | Type | Default Value | Description |
|---|---|---|---|
| llm_serving | LLMServingABC | Required | The Large Language Model serving instance used for inference and generation. |
| system_prompt | str | "You are a helpful agent." | A system-level instruction that prefixes each sample to guide the model's role and output style. |
Prompt Template Descriptions
| Prompt Template Name | Primary Use | Applicable Scenarios | Feature Description |
|---|---|---|---|
run
def run(self, storage: DataFlowStorage, input_key_1: str = "input_key_1", input_key_2: str = 'input_key_2', output_key: str = "generated_content")Executes the main logic of the operator. It reads an input DataFrame from storage, generates LLM-based responses from paired input columns, and writes the results back to storage.
Parameters
| Name | Type | Default Value | Description |
|---|---|---|---|
| storage | DataFlowStorage | Required | The data flow storage instance for reading and writing data. |
| input_key_1 | str | "input_key_1" | The name of the column for the first part of the paired input. |
| input_key_2 | str | "input_key_2" | The name of the column for the second part of the paired input. |
| output_key | str | "generated_content" | The name of the column where the generated output will be stored. |
🧠 Example Usage
🧾 Default Output Format
| Field | Type | Description |
|---|---|---|
| (original fields) | - | The original fields from the input data are preserved. |
| generated_content | str | The response generated by the model based on the paired inputs. |
Example Input:
{
"input_key_1": "Translate the following English text to French:",
"input_key_2": "Data science is an interdisciplinary field."
}Example Output:
{
"input_key_1": "Translate the following English text to French:",
"input_key_2": "Data science is an interdisciplinary field.",
"generated_content": "La science des données est un domaine interdisciplinaire."
}
