Skip to content

Commit dae1890

Browse files
wangchao1230D-W-
andauthored
update recommended sdk version to: 101370926 (#65)
Co-authored-by: Han Wang <[email protected]>
1 parent 7ef4c6f commit dae1890

File tree

10 files changed

+17
-43
lines changed

10 files changed

+17
-43
lines changed

examples/flows/evaluation/basic-eval/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ Testing flow/node:
1919
pf flow test --flow .
2020

2121
# test with flow inputs
22-
pf flow test --flow . --inputs groundtruth=groundtruth prediction=prediction
22+
pf flow test --flow . --inputs groundtruth=ABC prediction=ABC
2323

2424
# test node with inputs
25-
pf flow test --flow . --node line_process --inputs groundtruth=groundtruth prediction=prediction
25+
pf flow test --flow . --node line_process --inputs groundtruth=ABC prediction=ABC
2626
```
2727

2828
### 2. create flow run with multi line data

examples/flows/evaluation/basic-eval/aggregate.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44

55

66
@tool
7-
def aggregate(processed_results: List[str], variant_ids: List[str], line_numbers: List[int]):
7+
def aggregate(processed_results: List[str]):
88
"""
99
This tool aggregates the processed result of all lines to the variant level and log metric for each variant.
1010
1111
:param processed_results: List of the output of line_process node.
12-
:param variant_ids: List of variant ids that can be used to group the results by variant.
13-
:param line_numbers: List of line numbers of the variants. If provided, this can be used to
14-
group the results by line number.
1512
"""
1613

1714
# Add your aggregation logic here
@@ -28,6 +25,7 @@ def aggregate(processed_results: List[str], variant_ids: List[str], line_numbers
2825
# },
2926
# ...
3027
# }
28+
print(len(processed_results))
3129
aggregated_results = {}
3230

3331
# Log metric for each variant
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"groundtruth": "Tomorrow's weather will be sunny.","prediction": "The weather will be sunny tomorrow.","variant_id": "variant_0","line_number": 0}
1+
{"groundtruth": "Tomorrow's weather will be sunny.","prediction": "The weather will be sunny tomorrow."}

examples/flows/evaluation/basic-eval/flow.dag.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ inputs:
55
prediction:
66
type: string
77
default: prediction
8-
variant_id:
9-
type: string
10-
default: variant_0
11-
line_number:
12-
type: int
13-
default: 0
148
outputs:
159
results:
1610
type: string
@@ -31,8 +25,4 @@ nodes:
3125
path: aggregate.py
3226
inputs:
3327
processed_results: ${line_process.output}
34-
variant_ids: ${inputs.variant_id}
35-
line_numbers: ${inputs.line_number}
3628
aggregation: true
37-
id: template_eval_flow
38-
name: Template Evaluation Flow

examples/flows/evaluation/basic-eval/line_process.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,5 @@ def line_process(groundtruth: str, prediction: str):
1010
:param prediction: the prediction of a single line.
1111
"""
1212

13-
processed_result = ""
14-
1513
# Add your line processing logic here
16-
17-
return processed_result
14+
return "Correct" if groundtruth.lower() == prediction.lower() else "Incorrect"

examples/flows/evaluation/classification-accuracy-eval/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ In this flow, you will learn
1919
pf flow test --flow .
2020

2121
# test with flow inputs
22-
pf flow test --flow . --inputs line_number=0 variant_id=variant_0
22+
pf flow test --flow . --inputs groundtruth=APP prediction=APP
2323

2424
# test node with inputs
2525
pf flow test --flow . --node grade --inputs groundtruth=groundtruth prediction=prediction

examples/flows/evaluation/classification-accuracy-eval/calculate_accuracy.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@
44

55

66
@tool
7-
def calculate_accuracy(grades: List[str], variant_ids: List[str]):
8-
aggregate_grades = {}
7+
def calculate_accuracy(grades: List[str]):
8+
result = []
99
for index in range(len(grades)):
1010
grade = grades[index]
11-
variant_id = variant_ids[index]
12-
if variant_id not in aggregate_grades.keys():
13-
aggregate_grades[variant_id] = []
14-
aggregate_grades[variant_id].append(grade)
11+
result.append(grade)
1512

1613
# calculate accuracy for each variant
17-
for name, values in aggregate_grades.items():
18-
accuracy = round((values.count("Correct") / len(values)), 2)
19-
log_metric("accuracy", accuracy, variant_id=name)
14+
accuracy = round((result.count("Correct") / len(result)), 2)
15+
log_metric("accuracy", accuracy)
2016

21-
return aggregate_grades
17+
return result
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
{"line_number": 0, "variant_id": "variant_0", "groundtruth": "App","prediction": "App"}
2-
{"line_number": 1, "variant_id": "variant_0", "groundtruth": "Channel","prediction": "Channel"}
3-
{"line_number": 2, "variant_id": "variant_0", "groundtruth": "Academic","prediction": "Academic"}
1+
{"groundtruth": "App","prediction": "App"}
2+
{"groundtruth": "Channel","prediction": "Channel"}
3+
{"groundtruth": "Academic","prediction": "Academic"}

examples/flows/evaluation/classification-accuracy-eval/flow.dag.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
inputs:
2-
line_number:
3-
type: int
4-
default: 0
5-
variant_id:
6-
type: string
7-
default: variant_0
82
groundtruth:
93
type: string
104
description: Please specify the groundtruth column, which contains the true label
@@ -35,5 +29,4 @@ nodes:
3529
path: calculate_accuracy.py
3630
inputs:
3731
grades: ${grade.output}
38-
variant_ids: ${inputs.variant_id}
3932
aggregation: true

examples/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# remove when we publish to pypi
22
--extra-index-url https://azuremlsdktestpypi.azureedge.net/promptflow/
3-
promptflow[azure]==0.0.101192967
3+
promptflow[azure]==0.0.101370926
44
promptflow-tools==0.0.1.dev0
55
python-dotenv
66
langchain

0 commit comments

Comments
 (0)