You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
StringTemplate should not be the only prompt template mechanism used in Spring AI. Nor should it be the default.
StringTemplate is presently deeply baked into Spring AI. Consider AdvisedRequest.toPrompt and PromptTemplate. ChatClient.defaultSystem will automatically use ST.
The template engine should be pluggable, and a more familiar default such as Mustache should be used, ideally aligning as far as possible with existing Spring support. Jinjava provides solid JVM support for Jinja and it should also be an option because of its pervasive use in the Gen AI space.
Reasons:
StringTemplate is not particularly popular and is not a common choice in the broader Spring ecosystem. Forcing its use creates unnecessary friction for new adopters, and frustration for existing advanced users.
Most existing IP around Gen AI comes out of the Python ecosystem. StringTemplate does not have a Python implementation. Thus supporting only StringTemplate makes it impossible to benefit from the many valuable prompts produced by this ecosystem. Not only is reuse impossible; porting even simple templates from Jinja to StringTemplate is harder than to, say, Mustache.
Pluggability has always been a core Spring value. Spring MVC supported different template engines from its inception. Hardcoding one template engine is not Spring-like.
StringTemplate syntax is quirky and likely to be off-putting to developers, even if they're familiar with other templating technologies.
While variable interpolation is fine, more complex things are quirky with StringTemplate. For example, looping is a common requirement in prompt templates. Consider how it looks in various popular template languages:
Mustache (familiar to many developers on all stacks):
{{#items}}
{{.}}
{{/items}}
Jinja (the norm in Python and probably the most widely used in Gen AI):
{%foriteminitems%}
{{ item }}
{%endfor%}
Both of these are easy for any developer to grasp, even if they haven't seen that particular syntax.
This looks more like a BNF grammar than a typical template.
The text was updated successfully, but these errors were encountered:
johnsonr
changed the title
StringTemplate should not be only prompt template mechanism
StringTemplate should not be the only prompt template mechanism
Nov 6, 2024
StringTemplate should not be the only prompt template mechanism used in Spring AI. Nor should it be the default.
StringTemplate is presently deeply baked into Spring AI. Consider
AdvisedRequest.toPrompt
andPromptTemplate
.ChatClient.defaultSystem
will automatically use ST.The template engine should be pluggable, and a more familiar default such as Mustache should be used, ideally aligning as far as possible with existing Spring support. Jinjava provides solid JVM support for Jinja and it should also be an option because of its pervasive use in the Gen AI space.
Reasons:
While variable interpolation is fine, more complex things are quirky with StringTemplate. For example, looping is a common requirement in prompt templates. Consider how it looks in various popular template languages:
Mustache (familiar to many developers on all stacks):
Jinja (the norm in Python and probably the most widely used in Gen AI):
Both of these are easy for any developer to grasp, even if they haven't seen that particular syntax.
Now take StringTemplate:
This looks more like a BNF grammar than a typical template.
The text was updated successfully, but these errors were encountered: