Skip to content

Commit

Permalink
added latency of hf evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
rishsriv committed Aug 11, 2023
1 parent b7865fa commit 9045e1c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions eval/hf_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from utils.pruning import prune_metadata_str
from tqdm import tqdm
from psycopg2.extensions import QueryCanceledError
from time import time

def prepare_questions_df(questions_file, num_questions):
question_query_df = pd.read_csv(questions_file, nrows=num_questions)
Expand Down Expand Up @@ -69,6 +70,7 @@ def run_hf_eval(
with tqdm(total=len(df)) as pbar:
for row in df.to_dict("records"):
total_tried += 1
start_time = time()
generated_query = pipe(
row['prompt'],
max_new_tokens=600,
Expand All @@ -78,8 +80,10 @@ def run_hf_eval(
eos_token_id=eos_token_id,
pad_token_id=eos_token_id,
)[0]['generated_text'].split("```sql")[-1].split(";")[0].strip()
end_time = time()

row["generated_query"] = generated_query
row["latency_seconds"] = end_time - start_time
golden_query = row["query"]
db_name = row["db_name"]
question = row["question"]
Expand Down

0 comments on commit 9045e1c

Please sign in to comment.