Categories

Versions

Generate Prompts (Generative Models)

Synopsis

Generate prompts based on a template and the input data

Description

This operator generates a new column and adds it to the input data set. The values of this column are generated based on the provided prompt template text. Regular text is kept as is. You can refer to the values of a column in your input data with [[column_name]]. There are also some special commands. The command adds all values of the row in a key-value-pair format and uses one row for each of the data columns. The command is doing the same but separates the key value pairs by a pipe symbol while keeping them in a single row. The next two special commands will only work if you provide a second data set as input. The command adds all rows of the second data set as key value pairs in the same format as . The command is doing the same with the pipe symbol format. This can be useful if you want to provide additional data for few shot learning approaches. The optional target parameter is only relevant for these special commands. If set, it will move the specified column to the end of the list of key value pairs (if the target column exists in the data at all, otherwise the setting has no impact).

Input

  • data (Data table)

    The input data to which the new prompt column will be added.

  • input 2 (IOObject)

    An input port

Output

  • data (Data table)

    The resulting data set including the new prompt column.

Parameters

  • name The name of the new column containing the resulting prompts.
  • prompt The prompt template. Normal text is used as is. You can refer to the values of the columns of the input data with [[column_name]].
  • target The name of an optional target column. The target column will be placed in the last position if you use the , , , or special commands.
  • use target in all In many cases you do not want to include a specified target column in the special "all" command. You can specify here if you want to include it or not. This only has an impact on the "all" commands", not the variants for the "shots".
  • conda environment The conda environment used for this task. Please refer to the extension documentation for additional details on this and on version requirements for Python and all used packages in this environment.

Tutorial Processes

Generate a Metaprompt for Retrieval Augmented Generation (RAG)

This tutorial generates a simple data set with just a few rows and columns. It then generates a multi-line prompt based on the Question column as well as two Context columns. This approach is often used for Retrieval Augmented Generation (RAG) and can help to make answers from a Gen AI model more relevant and less prone to hallucination - without the need for finetuning the model.