Optimizing Knowledge Segment References in HyperFlow RAG Applications

Example Instruction Templates for Knowledge Segment References

HyperFlow’s RAG capabilities enable powerful knowledge-based AI applications that properly cite sources. Below are proven instruction templates for reliable knowledge attribution in production HyperFlow applications.

Core Segment Reference Instructions

The following instruction block can be included in your HyperFlow Instructions node for reliable segment references:

- **Use Knowledge Segments:** Use as much helpful detail as possible from the knowledge segments provided below.

- **Segment IDs:** For each knowledge segment you reference in your answer, output their `segment_ids` at the **end** of your answer in JSON format: `{"segment_ids": ["id1", "id2"]}`.
  - Do **not** mention segment IDs or JSON labels in the main answer.
  - Do **not** insert any labels like "json" before the JSON output.
  - You must reference **at least one** knowledge segment in order to provide a positive answer.
  
- **Written Answer Required:** Do not answer with JSON references alone; always provide a written answer as well.

Handling Special Formatting Requirements

When your knowledge segments contain special formatting (such as math equations or code), include instructions like:

- **Knowledge segment format:** The knowledge segments are formatted in markdown in most cases. Please preserve as much of the markdown formatting as possible, particularly embedded latex math equations.

- **Math equations:** You **must** preserve markdown/latex math formulas from the knowledge segments, ensuring the $ math markers are inserted around an equation on its own, but repair any equation markup for inline math segments, with $ immediately surrounding the inline equation form in output markdown.

Multilingual Support Instructions

For applications serving multiple languages:

- **Language:** Provide helpful answers in **English**.

- **Unable to Answer:** If the user's query cannot be answered from the provided information, respond with: "**Sorry, I do not have sufficient information to help with that.**" (or appropriate message in other languages)

Formatting Control Instructions

To ensure consistently formatted outputs:

- **Numbered Lists:** If you output a numbered list, ensure the numbers are **sequential**, starting from 1.

- **Avoid Unnecessary Labels:** Do **not** include any unnecessary labels or headings in your answer.

- **Detailed Instructions:** Provide detailed instructions and **always** provide the segment_IDs list for the knowledge segments used to form your answer. **Do not include** explanations about the referenced knowledge-segments, just the answer followed by the segment_id list.

How HyperFlow Identifies Knowledge Sources in LLM Responses

HyperFlow’s knowledge injection system connects AI responses with source knowledge through its segment ID reference system. This section explains how this works behind the scenes and how you can optimize your prompts.

Knowledge Segment Metadata

Knowledge segments in HyperFlow can include rich metadata that’s surfaced to users when properly referenced: