New Features
The main changes in this release are:
- AutoPDL: automatic optimization of PDL programs
- Calling PDL functions from Jinja and Python
- Map/reduce block
AutoPDL: automatic optimization of PDL programs
Given a PDL program with some free variables, a search space for these free variable, a loss function, and a training set, you can optimize the PDL program using the pdl-optimize
command. This allows to optimize any part of a PDL program such as the textual prompts, the few-shots examples, or the prompting patterns. This work is based on the paper AutoPDL: Automatic Prompt Optimization for LLM Agents. A new section of the manual is describing how to use the optimizer.
Calling PDL functions from Jinja and Python
It is now possible to call a function defined in PDL inside a Jinja expression or a Python code block. Here is an example where the function translate
is called in the Jinja expression ${ translate("Hello", language="French") }
:
description: Calling a PDL function from Jinja
defs:
translate:
function:
sentence: string
language: string
return:
lastOf:
- |
Translate the sentence '${ sentence }' to ${ language }.
Only give the result of the translation.
- model: ollama_chat/granite3.2:2b
text: |
The way to say hello in French is ${ translate("Hello", language="French") }.
Map/reduce block
Similar to the repeat
loops, PDL now offers a map
block. The difference with the repeat
block is that the context is not accumulated between iterations, each iteration is executed with the same context. Here is an example of map
block:
lastOf:
- "Hello, "
- for:
name: [Alice, Bob, Charlie]
map:
lastOf:
- my name is ${ name }
- model: ollama/granite3.2:2b
join:
as: array
What's Changed
- chore: Configure Renovate by @renovate[bot] in #944
- Dataset preprocessing scripts for AutoPDL by @claudiosv in #994
- fix: avoid side effects in PdlContext by @mandel in #1054
- tests: update react example by @mandel in #1001
- tests: update calc example to use
.signature
by @mandel in #1067 - fix: output streaming in case of fallback by @mandel in #1071
- feat: make PDL functions callable as Python and jinja functions by @mandel in #1070
- feat: allow unnamed arguments when calling a PDL function in Jinja by @mandel in #1076
- feat: map/reduce by @mandel in #1010
- refactor: refactor AST to generate simpler JSON Schema by @mandel in #1079
- Fix for exception in optimizer by @vazirim in #1084
- docs: update tutorial by @mandel in #1080
- Requirements implementation by @vazirim in #1097
- fix: update AST in the UI by @mandel in #1100
- fix: ensure that
PazyApply.result
returns a non-lazy value by @mandel in #1101 - feat: parallel map reduce by @mandel in #1102
- Fix for llm message post-processing by @vazirim in #1106
- AutoPDL Simplification by @claudiosv in #1088
- tests: map-based gsm8k by @mandel in #1107
- optimizer CLI and doc by @vazirim in #1151
Full Changelog: v0.7.1...v0.8.0