Skip to content
KNIME Documentation
Main Navigation Get startedBuildWork with KnimeAccount and adminRelease notesDeveloper tools
Community Hub
DevelopersKnime 2.0
Sidebar Navigation

Getting Started

Installation

User Guide

Release Notes

Install Extensions

Building Workflows

Components

Flow Control

Expressions

File Handling

Deployment

Integrated Deployment

Workflow Invocation

Best Practices

Advanced Features

AI Extension

Get Started

Build an Agent

Inject context with RAG

LLM Providers

Tutorials

Summarize product reviews

Product FAQ assistant

Restaurant agent

Your first local agent

Task extractor

Reporting

Kerberos

Extensions

Database

Overview

Tutorials

Read and filter data from a database

Write a transformed dataset to a database

Concepts

Ports and Sessions

Query Generation

Type Mapping

Deprecated Framework

Connecting

Connect: Dedicated Node

Connect: File-Based Database

Connect: Generic DB Connector

Register a JDBC Driver

Install Third-Party Driver Plug-in

Drivers on Hub and Server

Kerberos Constrained Delegation

Reading and Transforming

Read Data

Transform Data Visually

Run a Custom SQL Query

Parameterize a Query

Writing and Modifying

Insert, Update, or Merge

Delete Rows

Bulk Load Data

Create and Remove Tables

Use Transactions

Reference

Connector Node Settings

JDBC Driver Reference

Deprecated Node Mapping

Migrate Deprecated Workflows

Python

Overview

Tutorials

Python Scripting Quickstart

Data App Development Using Plotly

Data Processing

K-AI Scripting Assistant

Data Type Conversion

Batch Processing

Jupyter Integration

Environment Management

Pixi Configuration

Dependency Management

Environment Persistence

Channel Mirrors & Air-Gapped Setups

Conda Migration

Alternative Configurations

Conda and Miniforge Setup

Conda Environment Propagation

Manual Python Configuration

Legacy Node Migration

Concepts

Pixi Backend Architecture

Storage Logic

Python Environments on Executors

Reference

Python Scripting API

Bundled Packages

Executor and Hub Configuration

Troubleshooting Guide

API Reference

Inputs and outputs

Classes

Views

Utility functions

R

Deep Learning

Snowflake

Google Cloud

Azure

AWS

Big Data

Big Data Admin

Big Data Secured Cluster

Databricks

Microsoft Fabric

Power BI

Tableau

Report Designer

H2O

Changelogs

Version 5.12

Version 5.11

Version 5.10

Version 5.9

Version 5.8

Version 5.7

Version 5.6

Version 5.5

Version 5.3

Extensions

Inject retrieved context into a prompt ​

Provide retrieved documents as additional context to a language model so it can generate responses grounded in your own data.

This is the final step in a retrieval-augmented generation (RAG) workflow: the model receives both the user instruction and the retrieved context in the same prompt.

When this is useful ​

Inject retrieved context when you want to:

  • Answer questions based on your own documents
  • Ground model responses in specific source material
  • Reduce hallucinations by providing explicit context
  • Build RAG workflows for question answering or summarization

If you only need generic model responses without external context, see Prompt a model instead.

How context injection works in KNIME ​

In KNIME, retrieved documents are passed to the model as plain text.

There is no special “context channel”: you explicitly insert the retrieved content into the prompt text alongside the user instruction.

Typically, this involves:

  • retrieving the most relevant documents from a vector store
  • formatting them into a single text block
  • combining that text with the user’s question or instruction

The model then uses both the instruction and the provided context to generate its response.

Context is just text

Retrieved documents are not interpreted differently by the model. How you format and delimit the context in the prompt directly affects response quality.

Inject context into a prompt ​

Prerequisites
  • A vector store containing embeddings
  • A workflow that retrieves relevant documents as text
  • An LLM selected via an LLM Selector
  • A prompt that combines context and instruction

Retrieve relevant documents ​

Use a vector store retriever node to fetch the most relevant documents for a given query.

The result is typically a table containing:

  • document text
  • optional metadata
  • similarity scores

Only the text content is required for prompt injection.

Prepare the context text ​

Combine the retrieved documents into a single text block.

Common approaches include:

  • concatenating documents with clear separators
  • limiting the number of retrieved documents
  • truncating long passages to fit model limits

This step ensures the context can be safely injected into the prompt.

Combine context and instruction ​

Create a prompt that clearly separates context from the user instruction.

Example structure:


Use the following context to answer the question.

Context:
{{retrieved_documents}}

Question:
{{user_question}}

Being explicit about what is context and what is the instruction helps the model reason more reliably over the provided information.

Delimit your context

Use labels, separators, or headings to clearly mark the context section in the prompt. This improves grounding and reduces ambiguity.

Send the prompt to the model ​

Use the LLM Prompter or LLM Chat Prompter node to send the combined prompt to the selected model.

Each execution injects the retrieved context dynamically, based on the current query.

Result ​

The model generates a response that is informed by the retrieved documents.

The output reflects both:

  • the user’s instruction
  • the context retrieved from the vector store

This allows responses to be grounded in your own data rather than general model knowledge.

Next steps ​

  • Build a complete RAG workflow: Product FAQ Assistant tutorial
Pager
Next pageInstallation