Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: update annotations #169

Merged
merged 7 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
69 changes: 59 additions & 10 deletions dbgpt_hub/baseline/show_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,31 @@
import json
from typing import Optional, Dict, Any
from prettytable.colortable import ColorTable, Theme
from prettytable.colortable import ColorTable, Theme

ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(ROOT_PATH)


MYTHEME = Theme(
default_color="96", # blue
vertical_color="31", # red
horizontal_color="33", # yellow
junction_color="97", # white
)
HEADER = [
"dataset",
"model",
"method",
"prompt",
"etype",
"easy",
"medium",
"hard",
"extra",
"all",
]

MYTHEME = Theme(
default_color="96", # blue
vertical_color="31", # red
Expand All @@ -28,6 +48,7 @@
]
baseline_file = "./dbgpt_hub/baseline/baseline.json"


with open(baseline_file, "r") as file:
baseline_json = json.load(file)

Expand Down Expand Up @@ -74,6 +95,24 @@ def add_scores_to_table(


def show_score(dataset=None, model=None, method=None, prompt=None):
"""
Displays the model baseline score information for a given dataset, model, method and prompt.

Args:
dataset (str, optional): The dataset to be used for scoring.
model (str, optional): The model to be scored on the dataset.
method (str, optional): The training method to us.
prompt (str, optional): Additional information or context prompt.

Returns:
model baseline score.


Examples
>>> from dbgpt_hub.baseline import show_score
>>> show_score(dataset="spider", model="llama2-7b-hf", method="base", prompt="alpaca")

"""
if dataset is None:
raise ValueError("dataset cannot be None!")
elif model is None:
Expand Down Expand Up @@ -101,9 +140,26 @@ def get_model_score(acc_data, etype, model_data):


def show_scores():
"""
Displays baseline score information for all models.

Args:
None

Returns:
model baseline score.


Examples
>>> from dbgpt_hub.baseline import show_scores
>>> show_scores()

"""
datasets = baseline_json.keys()
table_scores = ColorTable(theme=MYTHEME)
table_scores.field_names = HEADER
table_scores = ColorTable(theme=MYTHEME)
table_scores.field_names = HEADER
for dataset in datasets:
models = baseline_json[dataset].keys()
for model in models:
Expand All @@ -112,25 +168,18 @@ def show_scores():
prompts = baseline_json[dataset][model][method].keys()
for prompt in prompts:
acc_data = baseline_json[dataset][model][method][prompt]["acc"]
table_scores = table_add_row(
table_scores, acc_data, dataset, model, method, prompt
table_scores = table_add_row(
table_scores, acc_data, dataset, model, method, prompt
)
print(table_scores, "\n")
print(table_scores, "\n")


def show_scores_api():
show_scores()


# def update():
# # todo : update baseline.json
# #


if __name__ == "__main__":
# show_scores()
# show_score() # ValueError: dataset cannot be None!
# show_score(dataset="spider")
# show_score(dataset="spider", model="llama2-7b-hf")
# show_score(dataset="spider", model="llama2-7b-hf", method="base")
show_score(dataset="spider", model="llama2-7b-hf", method="base", prompt="alpaca")
9 changes: 4 additions & 5 deletions dbgpt_hub/baseline/show_result_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
from dbgpt_hub.baseline import show_result


def show_scores():
show_result.show_scores_api()
def show_scores():
show_result.show_scores_api()


def show_score(dataset=None, model=None, method=None, prompt=None):
show_result.show_score_api(dataset, model, method, prompt)
def show_score(dataset=None, model=None, method=None, prompt=None):
show_result.show_score_api(dataset, model, method, prompt)


if __name__ == "__main__":
# show_scores()
# show_score() # ValueError: dataset cannot be None!
# show_score(dataset="spider")
# show_score(dataset="spider", model="llama2-7b-hf")
# show_score(dataset="spider", model="llama2-7b-hf", method="base")
show_score(dataset="spider", model="llama2-7b-hf", method="base", prompt="alpaca")
Loading