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

Milestone 1 #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ e==1.4.5
einops==0.7.0
filelock==3.13.1
fire==0.5.0
flash-attn==2.5.1.post1
fonttools==4.47.0
fsspec==2023.12.2
huggingface-hub==0.20.2
Expand Down
7 changes: 6 additions & 1 deletion src/phi/phi_utils/model_setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# TODO - import relevant model and tokenizer modules from transformers
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

# helper function provided to get model info
def get_model_info(model):
Expand Down Expand Up @@ -33,7 +34,11 @@ def model_and_tokenizer_setup(model_id_or_path):

# End of TODO.
##################################################

# Adapted from sample code: https://huggingface.co/microsoft/phi-2
model = AutoModelForCausalLM.from_pretrained(model_id_or_path, torch_dtype=torch.float16, attn_implementation="flash_attention_2", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(model_id_or_path, padding="max_length", padding_side="left", pad_token="<|endoftext|>", trust_remote_code=True)

# get_model_info(model)
print(get_model_info(model))

return model, tokenizer
8 changes: 8 additions & 0 deletions src/utils/eval_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# TODO - import relevant sklearn score modules
from sklearn import metrics

from sklearn.metrics import accuracy_score, f1_score
import argparse
from utils.file_utils import load_jsonl
Expand All @@ -20,7 +22,13 @@ def evaluate_standard(gt_labels, pred_labels):

# End of TODO.
##################################################

accuracy = metrics.accuracy_score(gt_labels, pred_labels)

# Need to tell sklearn which label is the positive one
f1score = metrics.f1_score(gt_labels, pred_labels, pos_label='SUPPORTS')

print(accuracy, f1score)
return accuracy, f1score

def model_eval_report(gt_filepath, pred_filepath):
Expand Down