Replies: 1 comment
-
Also linked to #1457 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Overview
This Discussion proposes a Jinja-like Domain Specific Language (DSL), that we call blueprints, for creating LLM output templates. The DSL aims to simplify complex template patterns, especially for function calling formats across different LLM architectures. By leveraging familiar template syntax similar to Jinja2 while adding domain-specific constructs, the DSL aims to make prompt engineering more maintainable and flexible.
Problem Statement
Current approaches to defining output structures for LLMs requires writing regular expressions or using our internal regex DSL, which becomes unwieldy when dealing with complex structures like function calling formats (see Qwen). For example, defining a Hermes function calling format using our regex DSL currently looks like:
This approach has several limitations:
Proposed Solution: Blueprints
We propose a Jinja-like DSL that compiles to the existing outlines format (regular expressions or EBNF grammar). The DSL will leverage the power of Jinja2's syntax while adding specialized constructs for LLM prompt templates.
Core Features
Syntax
Basic Template Definition
Special Constructs
Repeat Blocks:
Choice/Option Blocks:
Optional Blocks:
Variable Interpolation with Type Annotation:
Anything Constructs (match arbitrary content):
With explicit delimiter:
Implementation Details
The DSL will be implemented by:
Example Implementation Pseudocode
Templating for Different LLM Models
The DSL can be used to define templates for various LLM function calling formats:
Hermes Format
DeepSeek Format
User interface
Benefits
Conclusion
By leveraging familiar syntax and adding domain-specific constructs, blueprints make output templates more readable, maintainable, and flexible. Blueprints can be implemented on top of the existing regex DSL and thus require minimal development effort.
Example
Beta Was this translation helpful? Give feedback.
All reactions