Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Suppose we want to define a translation function that takes a string and calls a

In this program, the first block defines a function `translate` that takes as parameters `sentence` and `language`, both of which are of type string. The body of the function is defined by its `return` field. In this case, we formulate a translation prompt using the parameters and send it to a Granite multilingual model.

The last two blocks are calls to this function, as indicated by `call: translate`. This block specifies the arguments to be passed. When we execute this program, we obtain:
The last two blocks are calls to this function, as indicated by `call: ${ translate }`. This block specifies the arguments to be passed. When we execute this program, we obtain:

```
The translation of 'I love Paris!' to French is 'J'aime Paris!'.
Expand Down
32 changes: 16 additions & 16 deletions examples/demo/2-teacher.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ defs:
return:
defs:
prompt_data:
call: question_template_freeform
call: ${question_template_freeform}
spec: { introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int }
args:
num_samples: ${num_samples}
task_description: ${task_description}
icl_question: ${icl_question}
teacher_input:
call: teacher_template
call: ${teacher_template}
args:
sys_prompt: ${teacher_sys_prompt}
prompt: |-
Expand Down Expand Up @@ -94,7 +94,7 @@ defs:
for:
example: ${seed_examples}
repeat:
call: gen_questions_freeform_inner
call: ${gen_questions_freeform_inner}
args:
num_samples: 2
task_description: ${task_description}
Expand Down Expand Up @@ -139,13 +139,13 @@ defs:
return:
defs:
prompt_data:
call: filter_questions_template
call: ${filter_questions_template}
spec: {introduction: str, principles: str, generation: str, max_new_tokens: int}
args:
task_description: ${task_description}
question: ${question}
teacher_input:
call: teacher_template
call: ${teacher_template}
args:
sys_prompt: ${teacher_sys_prompt}
prompt: |-
Expand Down Expand Up @@ -179,7 +179,7 @@ defs:
repeat:
defs:
filter_output:
call: filter_questions_inner
call: ${filter_questions_inner}
args:
task_description: ${task_description}
question: ${question.question}
Expand Down Expand Up @@ -233,14 +233,14 @@ defs:
return:
defs:
prompt_data:
call: answer_template
call: ${answer_template}
spec: {introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int, additional_stop_tokens: [str]}
args:
icl_question: ${question.icl_question}
icl_response: ${question.icl_answer}
question: ${question.question}
teacher_input:
call: teacher_template
call: ${teacher_template}
args:
sys_prompt: ${teacher_sys_prompt}
prompt: |-
Expand Down Expand Up @@ -278,7 +278,7 @@ defs:
for:
question: ${ questions }
repeat:
call: gen_answers_inner
call: ${gen_answers_inner}
args:
question: ${question}
join:
Expand Down Expand Up @@ -322,13 +322,13 @@ defs:
return:
defs:
prompt_data:
call: filter_qa_template
call: ${filter_qa_template}
spec: {introduction: str, principles: str, generation: str, max_new_tokens: int}
args:
question: ${question}
answer: ${answer}
teacher_input:
call: teacher_template
call: ${teacher_template}
args:
sys_prompt: ${teacher_sys_prompt}
prompt: |-
Expand Down Expand Up @@ -360,7 +360,7 @@ defs:
repeat:
defs:
filter_output:
call: filter_question_answer_pair_inner
call: ${filter_question_answer_pair_inner}
spec: float
args:
question: ${qa_pair.question}
Expand All @@ -385,25 +385,25 @@ text:
parser: yaml
- "\n\n----- Generating questions -----\n\n"
- def: generated_questions
call: gen_questions_freeform
call: ${gen_questions_freeform}
spec: [{icl_question: str, icl_answer: str, question: str}]
args:
task_description: ${seed_examples.task_description}
seed_examples: ${seed_examples.seed_examples}
- "\n\n----- Filtering questions -----\n\n"
- def: filtered_questions
call: filter_questions
call: ${filter_questions}
spec: [{icl_question: str, icl_answer: str, question: str}]
args:
task_description: ${seed_examples.task_description}
questions: ${generated_questions}
- "\n\n----- Generating answers -----\n\n"
- def: qa_pairs
call: gen_answers
call: ${gen_answers}
args:
questions: ${filtered_questions}
- "\n\n----- Filtering QA pairs -----\n\n"
- call: filter_question_answer_pair
- call: ${filter_question_answer_pair}
args:
qa_pairs: ${qa_pairs}

2 changes: 1 addition & 1 deletion examples/hello/hello-data.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ text:
return:
${ something }
- "Hello World!\n"
- call: stutter
- call: ${ stutter }
- "\n"


2 changes: 1 addition & 1 deletion examples/hello/hello-defs.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defs:
bye:
"Good bye"
text:
- call: hello
- call: ${ hello }
args:
name: World
- "\n"
Expand Down
2 changes: 1 addition & 1 deletion examples/hello/hello-function-alias.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defs:
function:
name: str
return: Hello ${ name }!
alias: hello
alias: ${ hello }
text:
- call: ${ alias }
args:
Expand Down
2 changes: 1 addition & 1 deletion examples/hello/hello-function.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ text:
function:
name: str
return: Hello ${ name }!
- call: hello
- call: ${ hello }
args:
name: World
4 changes: 2 additions & 2 deletions examples/hello/hello-type.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ text:
- model: replicate/ibm-granite/granite-3.0-8b-instruct
parameters:
stop_sequences: "\n"
- call: translate
- call: ${ translate }
spec: str
args:
sentence: ${ GEN }
language: French
- call: translate
- call: ${ translate }
args:
sentence: ${ GEN }
language: Spanish
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/notebook_debug.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "pdl-3.12",
"language": "python",
"name": "python3"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/react/react_call.pdl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
description: Wikipedia example using the react_fun function definition
text:
- include: ./react_fun.pdl
- call: react
- call: ${ react }
args:
question: How many years ago was the discoverer of the Hudson River born? Keep in mind we are in 2024.
model: replicate/ibm-granite/granite-3.0-8b-instruct
Expand Down
2 changes: 1 addition & 1 deletion examples/react/react_fun.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ defs:
Act:
[{"name": "Finish", "arguments": {"topic": "director, screenwriter, actor"}}]

call: react_inner
call: ${ react_inner }
args:
pdl_context: []
examples: ${ examples }
Expand Down
32 changes: 16 additions & 16 deletions examples/talk/10-sdg.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ defs:
return:
defs:
prompt_data:
call: question_template_freeform
call: ${question_template_freeform}
spec: { introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int }
args:
num_samples: ${num_samples}
task_description: ${task_description}
icl_question: ${icl_question}
teacher_input:
call: teacher_template
call: ${teacher_template}
args:
sys_prompt: ${teacher_sys_prompt}
prompt: |-
Expand Down Expand Up @@ -94,7 +94,7 @@ defs:
for:
example: ${seed_examples}
repeat:
call: gen_questions_freeform_inner
call: ${gen_questions_freeform_inner}
args:
num_samples: 2
task_description: ${task_description}
Expand Down Expand Up @@ -139,13 +139,13 @@ defs:
return:
defs:
prompt_data:
call: filter_questions_template
call: ${filter_questions_template}
spec: {introduction: str, principles: str, generation: str, max_new_tokens: int}
args:
task_description: ${task_description}
question: ${question}
teacher_input:
call: teacher_template
call: ${teacher_template}
args:
sys_prompt: ${teacher_sys_prompt}
prompt: |-
Expand Down Expand Up @@ -179,7 +179,7 @@ defs:
repeat:
defs:
filter_output:
call: filter_questions_inner
call: ${filter_questions_inner}
args:
task_description: ${task_description}
question: ${question.question}
Expand Down Expand Up @@ -233,14 +233,14 @@ defs:
return:
defs:
prompt_data:
call: answer_template
call: ${answer_template}
spec: {introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int, additional_stop_tokens: [str]}
args:
icl_question: ${question.icl_question}
icl_response: ${question.icl_answer}
question: ${question.question}
teacher_input:
call: teacher_template
call: ${teacher_template}
args:
sys_prompt: ${teacher_sys_prompt}
prompt: |-
Expand Down Expand Up @@ -278,7 +278,7 @@ defs:
for:
question: ${ questions }
repeat:
call: gen_answers_inner
call: ${gen_answers_inner}
args:
question: ${question}
join:
Expand Down Expand Up @@ -322,13 +322,13 @@ defs:
return:
defs:
prompt_data:
call: filter_qa_template
call: ${filter_qa_template}
spec: {introduction: str, principles: str, generation: str, max_new_tokens: int}
args:
question: ${question}
answer: ${answer}
teacher_input:
call: teacher_template
call: ${teacher_template}
args:
sys_prompt: ${teacher_sys_prompt}
prompt: |-
Expand Down Expand Up @@ -360,7 +360,7 @@ defs:
repeat:
defs:
filter_output:
call: filter_question_answer_pair_inner
call: ${filter_question_answer_pair_inner}
spec: float
args:
question: ${qa_pair.question}
Expand All @@ -385,25 +385,25 @@ text:
parser: yaml
- "\n\n----- Generating questions -----\n\n"
- def: generated_questions
call: gen_questions_freeform
call: ${gen_questions_freeform}
spec: [{icl_question: str, icl_answer: str, question: str}]
args:
task_description: ${seed_examples.task_description}
seed_examples: ${seed_examples.seed_examples}
- "\n\n----- Filtering questions -----\n\n"
- def: filtered_questions
call: filter_questions
call: ${filter_questions}
spec: [{icl_question: str, icl_answer: str, question: str}]
args:
task_description: ${seed_examples.task_description}
questions: ${generated_questions}
- "\n\n----- Generating answers -----\n\n"
- def: qa_pairs
call: gen_answers
call: ${gen_answers}
args:
questions: ${filtered_questions}
- "\n\n----- Filtering QA pairs -----\n\n"
- call: filter_question_answer_pair
- call: ${filter_question_answer_pair}
args:
qa_pairs: ${qa_pairs}

4 changes: 2 additions & 2 deletions examples/talk/4-function.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ text:
parameters:
stop_sequences: "\n"
temperature: 0
- call: translate
- call: ${ translate }
args:
sentence: I love Paris!
language: French
- "\n"
- call: translate
- call: ${ translate }
args:
sentence: I love Madrid!
language: Spanish
Loading
Loading