When general-purpose large language models handle domain-specific professional tasks, they may struggle to generate precise or format-compliant responses. By adopting a few-shot learning approach, the system retrieves relevant high-quality question-answer pairs from a predefined example library to guide the model toward more accurate and stylistically consistent outputs. This feature is especially valuable in scenarios requiring strict adherence to existing knowledge or fixed stylistic conventions—such as intelligent customer service, domain-specific Q&A, and structured content generation.
Effect Demonstration
The table below shows sample entries included in the example library.
| User Input | Model Output |
|---|---|
| Explain the term: API (Application Programming Interface) | Explanation: An API is an interface specification that defines how software components interact. It enables different applications to exchange data and invoke functionality through predefined rules and protocols. Analogy: Think of a restaurant menu—the menu (API) lists available dishes (functions) and how to order them (request format); the kitchen (backend service) prepares the food (response) according to the menu, without you needing to understand its internal operations. |
| Explain the term: Blockchain | Explanation: Blockchain is a distributed, decentralized digital ledger technology that records transaction data in a continuously growing chain of cryptographically linked "blocks," making data tamper-resistant and enhancing transparency and security. Analogy: Imagine a shared bank ledger maintained collectively by many people—everyone can view it, each new transaction appears as a new entry, and every entry is secured with cryptography. Once written, the ledger cannot be altered secretly by any single participant. |
| Explain the term: Quantum Entanglement | Explanation: Quantum entanglement is a peculiar quantum mechanical phenomenon where two or more particles become correlated such that their quantum states are interdependent—even across vast distances. Measuring one particle's state instantly determines the state of the other(s). Analogy: Picture a pair of magical gloves—you put on the left glove, and instantly the other glove (wherever it is) becomes the right glove. Their states are instantaneously correlated. |
Creating and Using a Prompt Example Library
1. Create a Prompt Example Library
Navigate to the Example Library page and click Create Library (displayed only for first-time users) or click the + icon to create a new library.
Enter a name for your library and select an import method: Manual Entry or Bulk Import.
Manual Entry
Directly input example pairs (User Input and Model Output) on the page. Click + to add multiple entries.
Bulk Import
Download the template file, fill it out following the required format, then upload it. Excel files under 20 MB are supported; up to 100 examples can be imported per batch.
During bulk import, the system validates character length per row. Any example where either User Input or Model Output exceeds 500 characters will be automatically filtered out and excluded from import. For examples exceeding 500 characters, use manual entry instead.
2. Use the Example Library in an Agent Application
Associate the Prompt Example Library with an agent application located in the same business space to activate it.
- Ensure you already have an agent application set up.
- Go to the Application Management page, locate your target agent application, and click the Settings icon on its application card.
- Find Enable Prompt Example Library and toggle it on. Then click Add Library, and select the library created earlier (a single application can associate up to 5 example libraries, using a multi-path retrieval strategy).
Multi-path retrieval strategy: The system retrieves relevant examples from all associated libraries in parallel and uses a ranking model to select the top-K most relevant ones (configurable "retrieved snippet count") to inject into the LLM's input tokens for reference during response generation. Manual control over retrieval priority order is not currently supported.
- Optional: Click Edit, adjust the retrieved snippet count (default: 5, max: 10).
- Click Save to apply the configuration.
3. Test and Validate
Console Debugging
In the application debugging interface, enter a query related to your examples. For example, Explain the term: Neural Network.
Click Prompt Example Retrieval to inspect the retrieved input-output pairs used in inference.
API Call
When calling the application API, set the request parameter has_thoughts to true. The response's thoughts field will contain detailed retrieval process information, facilitating debugging and validation. Refer to the API call example.
Managing Example Libraries and Examples
On the Prompt Example Library page, you can maintain both existing libraries and individual examples within them.
Managing Example Libraries
- Add: Click the + icon on the right to create a new library.
- Delete: Hover over the target library and click the Delete icon to delete it.
Libraries currently referenced by applications cannot be deleted directly. First go to the Application Management page and remove the library reference from the relevant application's configuration before deletion.
- Rename: Hover over the library name and click the Edit icon to rename it.
Managing Examples
Within a selected example library, perform the following actions:
- Add: Click + or Add Similar Example.
- Delete: In the Actions column of the target example, click Delete.
- Edit: In the Actions column of the example to modify, click Edit, modify the content, then click Save.
Usage Limits
| Limit | Description |
|---|---|
| Library Capacity | Each example library supports up to 300 examples. This limit balances retrieval performance and recall accuracy. Larger libraries may increase latency. If you exceed 300 examples, consider splitting them into multiple topic-specific libraries (e.g., "Product Features Library", "After-sales Policy Library"). |
| Application Association Limit | Each agent application can associate up to 5 example libraries, with parallel multi-path retrieval enabled. |
| Retrieved Snippet Count | Up to 10 examples can be injected into context per request. This value is configurable in the application settings and helps balance output quality against token cost. |
| File Import Limits | Bulk imports accept Excel files up to 20 MB; maximum 100 examples per batch. Examples with over 500 characters in either User Input or Model Output are automatically filtered out during import. |
Billing Information
The Prompt Example Library feature itself incurs no storage or management fees.
However, enabling this feature increases LLM token consumption—specifically due to the inclusion of retrieved examples in the model's context—which impacts your overall usage cost.
Cost estimation formula: Total Input Tokens ≈ User Query Tokens + Sum of All Retrieved Example Tokens + System Instruction Tokens
Frequently Asked Questions
What is the relationship between an example library and individual examples?
An example library contains examples. Each library holds up to 300 semantically similar examples. Each example consists of a User Input and corresponding Model Output.
Libraries organize and manage examples; you can create multiple uniquely named libraries for flexible application configuration.
How does the Prompt Example Library differ from a Knowledge Base?
These are two distinct features serving different purposes:
- Prompt Example Library: Uses Few-shot Learning to teach the model how to speak—i.e., controlling response style, formatting, and factual phrasing via high-quality demonstration examples. Ideal for precise stylistic replication and controlled output generation.
- Knowledge Base: Uses RAG (Retrieval-Augmented Generation) to tell the model what to say—i.e., supplying external factual context by retrieving relevant passages from large document collections. Best suited for open-ended Q&A grounded in extensive documentation.