Skip to content

Commit

Permalink
✨ Add least-to-most SCAN example
Browse files Browse the repository at this point in the history
  • Loading branch information
wesen committed Feb 15, 2023
1 parent 361454b commit 39a3de4
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 8 deletions.
8 changes: 3 additions & 5 deletions cmd/pinocchio/prompts/examples/simple/example-driven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ factories:
completion:
engine: text-davinci-003
temperature: 0.2
max_response_tokens: 256
max_response_tokens: 512
# stream: true
flags:
- name: question
Expand All @@ -32,11 +32,9 @@ prompt: |
{{ range $i, $example := .examples }}
Q: {{ $example.question }}
A: {{ $example.answer }}
{{ end }}
{{ if .instructions -}}
{{ end -}}
{{ if .instructions }}
Instructions: {{ .instructions }}
{{- end }}
Q: {{ .question }}
A:
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: letter-concatenate-chain-of-thought
aliasFor: example-driven
flags:
examples: ./examples/letter-concatenation/chain-of-thought.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: letter-concatenate-least-to-most
aliasFor: example-driven
flags:
examples: ./examples/letter-concatenation/least-to-most.yaml
42 changes: 42 additions & 0 deletions examples/scan/least-to-most-mapping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
- question: "turn left"
answer: >
"turn left" outputs "TURN LEFT".
- question: "turn right"
answer: >
"turn right" outputs "TURN RIGHT".
- question: "jump left"
answer: >
The output of "jump left" concatenates: the output of "turn left", the output of "jump". "turn left" outputs "TURN LEFT". "jump" outputs "JUMP". So concatenating the output of "turn left" and the out- put of "jump" leads to "TURN LEFT" + "JUMP". So the output of "jump left" is "TURN LEFT" + "JUMP".
- question: "run right"
answer: >
The output of "run right" concatenates: the output of "turn right", the output of "run". "turn right" outputs "TURN RIGHT". "run" outputs "RUN". So concatenating the output of "turn right" and the output of "run" leads to "TURN RIGHT" + "RUN". So the output of "run right" is "TURN RIGHT" + "RUN".
- question: "look twice"
answer: >
The output of "look twice" concatenates: the output of "look", the output of "look". "look" outputs "LOOK". So repeating the output of "look" two times leads to "LOOK" * 2. So the output of "look twice" is "LOOK" * 2.
- question: "run and look twice"
answer: >
The output of "run and look twice" concatenates: the output of "run", the output of "look twice". "run" outputs "RUN". "look twice" outputs "LOOK" * 2. So concatenating the output of "run" and the output of "look twice" leads to "RUN" + "LOOK" * 2. So the output of "run and look twice" is "RUN" + "LOOK" * 2.
- question: "jump right thrice"
answer: >
The output of "jump right thrice" concatenates: the output of "jump right", the output of "jump right", the output of "jump right". "jump right" outputs "TURN RIGHT" + "JUMP". So repeating the output of "jump right" three times leads to ("TURN RIGHT" + "JUMP") * 3. So the output of "jump right thrice" is ("TURN RIGHT" + "JUMP") * 3.
- question: "walk after run"
answer: >
The output of "walk after run" concatenates: the output of "run", the output of "walk". "run" outputs "RUN". "walk" outputs "WALK". So concatenating the output of "run" and the output of "walk" leads to "RUN" + "WALK". So the output of "walk after run" is "RUN" + "WALK".
- question: "turn opposite left"
answer: >
The output of "turn opposite left" concatenates: the output of "turn left", the output of "turn left". "turn left" outputs "TURN LEFT". So repeating the output of "turn left" twice leads to "TURN LEFT" * 2. So the output of "turn opposite left" is "TURN LEFT" * 2.
- question: "turn around left"
answer: >
The output of "turn around left" concatenates: the output of "turn left", the output of "turn left", the output of "turn left", the output of "turn left". "turn left" outputs "TURN LEFT". So repeating the output of "turn left" four times leads to "TURN LEFT" * 4. So the output of "turn around left" is "TURN LEFT" * 4.
- question: "turn opposite right"
answer: >
The output of "turn opposite right" concatenates: the output of "turn right", the output of "turn right". "turn right" outputs "TURN RIGHT". So repeating the output of "turn right" twice leads to "TURN RIGHT" * 2. So the output of "turn opposite right" is "TURN RIGHT" * 2.
- question: "turn around right"
answer: >
The output of "turn around right" concatenates: the output of "turn right", the output of "turn right", the output of "turn right", the output of "turn right". "turn right" outputs "TURN RIGHT". So repeating the output of "turn right" four times leads to "TURN RIGHT" * 4. So the output of "turn around right" is "TURN RIGHT" * 4.
- question: "walk opposite left"
answer: >
The output of "walk opposite left" concatenates: the output of "turn opposite left", the output of "walk". "turn opposite left" outputs "TURN LEFT" * 2. "walk" outputs "WALK". So concatenating the output of "turn opposite left" and the output of "walk" leads to "TURN LEFT" * 2 + "WALK". So the output of "walk opposite left" is "TURN LEFT" * 2 + "WALK".
- question: "walk around left"
answer: >
The output of "walk around left" concatenates: the output of "walk left", the output of "walk left", the output of "walk left", the output of "walk left". "walk left" outputs "TURN LEFT" + "WALK". So repeating the output of "walk around left" four times leads to ("TURN LEFT" + "WALK") * 4. So the output of "walk around left" is ("TURN LEFT" + "WALK") * 4.
24 changes: 24 additions & 0 deletions examples/scan/least-to-most-reduction.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- question: "look right after look twice"
answer: >
"look right after look twice" can be solved by: "look right", "look twice".
- question: "jump opposite right thrice and walk"
answer: >
"jump opposite right thrice" can be solved by: "jump opposite right", "jump opposite right thrice". "walk" can be solved by: "walk". So, "jump opposite right thrice and walk" can be solved by: "jump opposite right", "jump opposite right thrice", "walk".
- question: "run left twice and run right"
answer: >
"run left twice" can be solved by: "run left", "run left twice". "run right" can be solved by "run right". So, "run left twice and run right" can.be solved by: "run left", "run left twice", "run right".
- question: "run opposite right"
answer: >
"run opposite right" can be solved by "run opposite right".
- question: "look opposite right thrice after walk"
answer: >
"look opposite right thrice" can be solved by: "look opposite right", "look opposite right thrice". "walk" can be solved by "walk". So, "look opposite right thrice after walk" can be solved by: "look opposite right", "look opposite right thrice", "walk".
- question: "jump around right"
answer: >
"jump around right" can be solved by: "jump right", "jump around right". So, "jump around right" can be solved by: "jump right", "jump around right".
- question: "look around right thrice and walk"
answer: >
"look around right thrice" can be solved by: "look right", "look around right", "look around right thrice". "walk" can be solved by "walk". So, "look around right thrice and walk" can be solved by: "look right", "look around right", "look around right thrice", "walk".
- question: "turn right after run right thrice"
answer: >
"turn right" can be solved by: "turn right". "run right thrice" can be solved by: "run right", "run right thrice". So, "turn right after run right thrice" can be solved by: "turn right", "run right", "run right thrice".
28 changes: 28 additions & 0 deletions examples/scan/standard-prompting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
- question: turn left
answer: TURN LEFT
- question: turn right
answer: TURN RIGHT
- question: jump left
answer: TURN LEFT + JUMP
- question: run right
answer: TURN RIGHT + RUN
- question: look twice
answer: LOOK * 2
- question: run and look twice
answer: RUN + LOOK * 2
- question: jump right thrice
answer: (TURN RIGHT + JUMP) * 3
- question: walk after run
answer: RUN + WALK
- question: turn opposite left
answer: TURN LEFT * 2
- question: turn around left
answer: TURN LEFT * 4
- question: turn opposite right
answer: TURN RIGHT * 2
- question: turn around right
answer: TURN RIGHT * 4
- question: walk opposite left
answer: TURN LEFT * 2 + WALK
- question: walk around left
answer: (TURN LEFT + WALK) * 4
6 changes: 3 additions & 3 deletions pkg/cmds/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (g *GeppettoCommand) Run(parameters map[string]interface{}, _ *glazedcmds.G
}
settings := openaiCompletionStepFactory__.StepSettings

dyno, err := helpers.RenderTemplateString(dynoTemplate, map[string]interface{}{
dyno, err := helpers.RenderHtmlTemplateString(dynoTemplate, map[string]interface{}{
"initialPrompt": promptBuffer.String(),
"initialResponse": "",
"maxTokens": settings.MaxResponseTokens,
Expand Down Expand Up @@ -160,8 +160,8 @@ func (g *GeppettoCommand) BuildCobraCommand() (*cobra.Command, error) {
if err != nil {
return nil, err
}
cmd.Flags().Bool("print-prompt", false, "Print the prompt that will be executed.")
cmd.Flags().Bool("print-dyno", false, "Print a dyno HTML embed with the given prompt. Useful to create documentation examples.")
cmd.PersistentFlags().Bool("print-prompt", false, "Print the prompt that will be executed.")
cmd.PersistentFlags().Bool("print-dyno", false, "Print a dyno HTML embed with the given prompt. Useful to create documentation examples.")

cmd.PersistentFlags().Int("timeout", 60, "timeout in seconds")
cmd.PersistentFlags().String("organization", "", "organization to use")
Expand Down

0 comments on commit 39a3de4

Please sign in to comment.