Skip to content

Commit

Permalink
Merge branch 'main' into wk4
Browse files Browse the repository at this point in the history
  • Loading branch information
vazirim committed Oct 4, 2024
2 parents c9a7fe4 + 842994d commit d40d5ba
Show file tree
Hide file tree
Showing 59 changed files with 175 additions and 138 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ text:
EVALUATION:
The similarity (Levenshtein) between this answer and the ground truth is:
- def: EVAL
lan: python
lang: python
code: |
import textdistance
expl = """
Expand Down Expand Up @@ -348,7 +348,7 @@ text:
${ CODE.source_code }```
- def: EVAL
contribute: []
lan: python
lang: python
code:
|
import textdistance
Expand Down
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ text:
EVALUATION:
The similarity (Levenshtein) between this answer and the ground truth is:
- def: EVAL
lan: python
lang: python
code: |
import textdistance
expl = """
Expand Down Expand Up @@ -353,7 +353,7 @@ text:
${ CODE.source_code }```
- def: EVAL
contribute: []
lan: python
lang: python
code:
|
import textdistance
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ See for example: ([file](https://github.com/IBM/prompt-declaration-language//blo
description: Hello world showing call to python code
text:
- "Hello, "
- lan: python
- lang: python
code:
|
import random
Expand Down Expand Up @@ -390,7 +390,7 @@ text:
include_stop_sequence: false
def: LOCATION
contribute: []
- lan: python
- lang: python
code: |
import requests
response = requests.get('https://api.weatherapi.com/v1/current.json?key=cf601276764642cb96224947230712&q=${ LOCATION }')
Expand Down Expand Up @@ -438,7 +438,7 @@ text:
${ CODE.source_code }```
- def: EVAL
contribute: []
lan: python
lang: python
code:
|
import textdistance
Expand Down Expand Up @@ -552,7 +552,7 @@ text:
include_stop_sequence: false
- '= '
- def: RESULT
lan: python
lang: python
code: result = ${ EXPR }
- ' >>'
until: ${ "The answer is" in REASON_OR_CALC }
Expand Down
6 changes: 3 additions & 3 deletions docs/viewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ hide:
"input": {
"kind": "text",
"defs": {},
"text": ["Question: Write the following prompts in PDL:\nHello world!\nThis is your first prompt descriptor!\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"Hello, world!\\n\"\n- \"This is your first prompt descriptor!\\n\" \n```\n\nQuestion: Turn the code into PDL:\ncontents = []\nwhile True:\ntry:\n line = input()\nexcept EOFError:\n break\ncontents.append(line + \"\\n\")\nresult = ''.join(contents)\n\nAnswer:\n```\ndescription: Example of PDL code block\ntext:\n- lan: python\n code:\n - |\n contents = []\n while True:\n try:\n line = input()\n except EOFError:\n break\n contents.append(line + \"\\n\")\n result = ''.join(contents)\n```\n\nQuestion: Write the following in PDL where the parts in << >> are done in Python.\nHello world!\nThis is your << expr >> prompt descriptor!\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"Hello, world!\\n\"\n- \"This is your \"\n- lan: python\n code:\n - |\n result = expr\n- \" prompt descriptor!\"\n```\nQuestion: Write the following in PDL where the parts in << >> are done in Python.\nWhat is << 67+ 67 - 78 + 2 >>\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"What is \"\n- lan: python\n code:\n - |\n result = 67+ 67 - 78 + 2\n```\n\n\nQuestion: Write the following in PDL with parts << >> written in Python", {
"text": ["Question: Write the following prompts in PDL:\nHello world!\nThis is your first prompt descriptor!\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"Hello, world!\\n\"\n- \"This is your first prompt descriptor!\\n\" \n```\n\nQuestion: Turn the code into PDL:\ncontents = []\nwhile True:\ntry:\n line = input()\nexcept EOFError:\n break\ncontents.append(line + \"\\n\")\nresult = ''.join(contents)\n\nAnswer:\n```\ndescription: Example of PDL code block\ntext:\n- lang: python\n code:\n - |\n contents = []\n while True:\n try:\n line = input()\n except EOFError:\n break\n contents.append(line + \"\\n\")\n result = ''.join(contents)\n```\n\nQuestion: Write the following in PDL where the parts in << >> are done in Python.\nHello world!\nThis is your << expr >> prompt descriptor!\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"Hello, world!\\n\"\n- \"This is your \"\n- lang: python\n code:\n - |\n result = expr\n- \" prompt descriptor!\"\n```\nQuestion: Write the following in PDL where the parts in << >> are done in Python.\nWhat is << 67+ 67 - 78 + 2 >>\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"What is \"\n- lang: python\n code:\n - |\n result = 67+ 67 - 78 + 2\n```\n\n\nQuestion: Write the following in PDL with parts << >> written in Python", {
"kind": "get",
"defs": {},
"get": "QUERY1",
"result": "\nAnswer:\nBobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?",
}, "\n\n"],
"result": "Question: Write the following prompts in PDL:\nHello world!\nThis is your first prompt descriptor!\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"Hello, world!\\n\"\n- \"This is your first prompt descriptor!\\n\" \n```\n\nQuestion: Turn the code into PDL:\ncontents = []\nwhile True:\ntry:\n line = input()\nexcept EOFError:\n break\ncontents.append(line + \"\\n\")\nresult = ''.join(contents)\n\nAnswer:\n```\ndescription: Example of PDL code block\ntext:\n- lan: python\n code:\n - |\n contents = []\n while True:\n try:\n line = input()\n except EOFError:\n break\n contents.append(line + \"\\n\")\n result = ''.join(contents)\n```\n\nQuestion: Write the following in PDL where the parts in << >> are done in Python.\nHello world!\nThis is your << expr >> prompt descriptor!\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"Hello, world!\\n\"\n- \"This is your \"\n- lan: python\n code:\n - |\n result = expr\n- \" prompt descriptor!\"\n```\nQuestion: Write the following in PDL where the parts in << >> are done in Python.\nWhat is << 67+ 67 - 78 + 2 >>\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"What is \"\n- lan: python\n code:\n - |\n result = 67+ 67 - 78 + 2\n```\n\n\nQuestion: Write the following in PDL with parts << >> written in Python\nAnswer:\nBobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?\n\n",
"result": "Question: Write the following prompts in PDL:\nHello world!\nThis is your first prompt descriptor!\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"Hello, world!\\n\"\n- \"This is your first prompt descriptor!\\n\" \n```\n\nQuestion: Turn the code into PDL:\ncontents = []\nwhile True:\ntry:\n line = input()\nexcept EOFError:\n break\ncontents.append(line + \"\\n\")\nresult = ''.join(contents)\n\nAnswer:\n```\ndescription: Example of PDL code block\ntext:\n- lang: python\n code:\n - |\n contents = []\n while True:\n try:\n line = input()\n except EOFError:\n break\n contents.append(line + \"\\n\")\n result = ''.join(contents)\n```\n\nQuestion: Write the following in PDL where the parts in << >> are done in Python.\nHello world!\nThis is your << expr >> prompt descriptor!\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"Hello, world!\\n\"\n- \"This is your \"\n- lang: python\n code:\n - |\n result = expr\n- \" prompt descriptor!\"\n```\nQuestion: Write the following in PDL where the parts in << >> are done in Python.\nWhat is << 67+ 67 - 78 + 2 >>\n\nAnswer:\n```\ndescription: Hello world!\ntext:\n- \"What is \"\n- lang: python\n code:\n - |\n result = 67+ 67 - 78 + 2\n```\n\n\nQuestion: Write the following in PDL with parts << >> written in Python\nAnswer:\nBobby had 3 apples. He then added 2. Hence 3 + 2 = 5 How many apple did Bobby have?\n\n",
},
"parameters": {
"decoding_method": "greedy",
Expand All @@ -167,7 +167,7 @@ hide:
}, {
"kind": "code",
"defs": {},
"lan": "python",
"lang": "python",
"code": ["from pdl import pdl_ast, pdl_interpreter\nfrom pdl.pdl_ast import Program\nfrom pdl.pdl_interpreter import process_prog\nfrom pdl.pdl_interpreter import InterpreterState\nfrom pdl.pdl_interpreter import empty_scope\nimport re\nimport yaml\ns = \"\"\"'\n", {
"kind": "get",
"defs": {},
Expand Down
2 changes: 1 addition & 1 deletion examples/arith/Arith-simple.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ text:
post_message: ""
- '= '
- def: RESULT
lan: python
lang: python
code: result = ${ EXPR }
- ' >>'
until: ${ "The answer is" in REASON_OR_CALC }
Expand Down
2 changes: 1 addition & 1 deletion examples/arith/arith.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ text:
include_stop_sequence: false
- '= '
- def: RESULT
lan: python
lang: python
code: result = ${ EXPR }
- ' >>'
until: ${ "The answer is" in REASON_OR_CALC }
Expand Down
20 changes: 10 additions & 10 deletions examples/cldk/cldk-assistant.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ text:
message: "Please enter the path to your Java project:\n"
contribute: []
- "***Analyzing...\n"
- lan: python
- lang: python
def: analysis
contribute: []
code: |
Expand Down Expand Up @@ -42,7 +42,7 @@ text:
Answer:
```
text:
- lan: python
- lang: python
code:
- |
classes = PDL_SESSION.cldk_state.get_classes().keys()
Expand All @@ -53,7 +53,7 @@ text:
Answer:
```
text:
- lan: python
- lang: python
code:
- |
constructors = PDL_SESSION.cldk_state.get_constructors("org.ibm.App")
Expand All @@ -64,7 +64,7 @@ text:
Answer:
```
text:
- lan: python
- lang: python
code:
- |
fields = PDL_SESSION.cldk_state.get_fields("org.ibm.App")
Expand All @@ -76,7 +76,7 @@ text:
Answer:
```
text:
- lan: python
- lang: python
code:
- |
methods = PDL_SESSION.cldk_state.get_methods_in_class("org.ibm.App")
Expand All @@ -87,7 +87,7 @@ text:
Answer:
```
text:
- lan: python
- lang: python
code:
- |
graph = PDL_SESSION.cldk_state.get_class_call_graph("org.ibm.App", method_name=None)
Expand All @@ -98,7 +98,7 @@ text:
Answer:
```
text:
- lan: python
- lang: python
code:
- |
method = PDL_SESSION.cldk_state.get_method("org.ibm.App", "Foo(string)")
Expand All @@ -109,7 +109,7 @@ text:
Answer:
```
text:
- lan: python
- lang: python
code:
- |
method = PDL_SESSION.cldk_state.get_method("org.ibm.App", "Foo(string)")
Expand All @@ -122,7 +122,7 @@ text:
Answer:
```
text:
- lan: python
- lang: python
code:
- |
method = PDL_SESSION.cldk_state.get_method("org.ibm.App", "Foo(string)")
Expand All @@ -140,7 +140,7 @@ text:
stop_sequence: ["Question"]
include_stop_sequence: false
- "\n\n***Executing the above PDL code:\n\n"
- lan: python
- lang: python
contribute: []
code: |
from pdl import pdl_ast, pdl_interpreter
Expand Down
2 changes: 1 addition & 1 deletion examples/code/code-eval.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ text:
EVALUATION:
The similarity (Levenshtein) between this answer and the ground truth is:
- def: EVAL
lan: python
lang: python
code: |
import textdistance
expl = """
Expand Down
2 changes: 1 addition & 1 deletion examples/code/code-json.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ text:
${ CODE.source_code }```
- def: EVAL
contribute: []
lan: python
lang: python
code:
|
import textdistance
Expand Down
10 changes: 5 additions & 5 deletions examples/demo/2-teacher.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ defs:
icl_answer: ${example.answer}
join:
as: array
- lan: python
- lang: python
code: | # flatten list_of_lists into simple list
result = [q for qs in ${list_of_lists} for q in qs]

Expand Down Expand Up @@ -188,7 +188,7 @@ defs:
join:
as: array
filtered:
lan: python
lang: python
code: | # keep only if "keep" column is non-zero
result = [p["question"] for p in ${ list_of_pairs } if p["keep"]]
- ${filtered}
Expand Down Expand Up @@ -255,7 +255,7 @@ defs:
include_stop_sequence: false
max_new_tokens: ${prompt_data.max_new_tokens}
parsed_answer:
lan: python
lang: python
code: | # parse model output
result = """ ${teacher_output} """.strip()
if "[Response]" in result:
Expand All @@ -282,7 +282,7 @@ defs:
question: ${question}
join:
as: array
- lan: python
- lang: python
spec: [{question: str, answer: str}]
code: | # keep only if answer non-empty
result = [r for r in ${all_results} if len(r["answer"]) > 0]
Expand Down Expand Up @@ -369,7 +369,7 @@ defs:
join:
as: array
filtered:
lan: python
lang: python
spec: [{question: str, answer: str}]
code: | # keep only if rating is at least two
result = [p["qa_pair"] for p in ${ratings} if p["rating"] >= 2]
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/3-weather.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ text:
include_stop_sequence: false
def: LOCATION
contribute: []
- lan: python
- lang: python
code: |
import requests
response = requests.get('https://api.weatherapi.com/v1/current.json?key=cf601276764642cb96224947230712&q=${ LOCATION }')
Expand Down
6 changes: 3 additions & 3 deletions examples/fibonacci/fib.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ text:

- "\nFind a random number between 1 and 20\n"
- def: N
lan: python
lang: python
code: |
import random
result = random.randint(1, 20)
- "\nNow computing fib("
- get: N
- ")\n"
- def: EXTRACTED
lan: python
lang: python
code: |
s = """'${ CODE } '"""
result = s.split("```")[1].replace("python", "")
- def: RESULT
lan: python
lang: python
code: |
${ EXTRACTED }
result = fib(${ N })
Expand Down
10 changes: 5 additions & 5 deletions examples/gsm8k/math-jinja.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ text:
description: my answer
text:
- Let's call the number of people on the first ship x.
- lan: python
- lang: python
def: equation
code:
- |
Expand All @@ -25,15 +25,15 @@ text:
result = x + 2*x + 4*x
- "The equation is ${ equation } = 847.\n"
- "Solving for x, we get "
- lan: python
- lang: python
def: RESULT
code:
- |
from sympy import *
x = symbols('x')
result = solve(${ equation } - 847, x)[0]
- "\nThe answer is ${RESULT}."
- lan: python
- lang: python
def: FINAL
code:
- |
Expand All @@ -57,7 +57,7 @@ text:
- "\ntennis balls. The answer is\n"
- def: RESULT
data: ${ tennis_balls + bought_balls }
- lan: python
- lang: python
def: FINAL
code:
- |
Expand All @@ -72,7 +72,7 @@ text:
parameters:
stop_sequences: ["Question"]
include_stop_sequence: false
- lan: python
- lang: python
code: |
from pdl import pdl_ast, pdl_interpreter
from pdl.pdl_ast import Program
Expand Down
Loading

0 comments on commit d40d5ba

Please sign in to comment.