-
Notifications
You must be signed in to change notification settings - Fork 2
rui/ds1000 #44
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
Open
rays1024
wants to merge
34
commits into
main
Choose a base branch
from
rui/ds-1000
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
rui/ds1000 #44
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
c2a2116
added length_calculator
529edce
re-upload the implementation for llama, alpaca, santacoder
yilunzhao 7caf0ea
Merge branch 'main' into yilunzhao/llm_implementation
yilunzhao 9dbc8cd
try to pass CI check
yilunzhao 06c7858
Merge branch 'main' into yilunzhao/llm_implementation
niansong1996 ce36f13
modify process_output function in exectutor.py to handle the case tha…
yilunzhao 60fd89b
fix error related to llama eos_token
yilunzhao 83546d9
add starcoder, gpt-neox-20b; test gpt-j-6b
yilunzhao 86d3bd5
archieve code for NeurIPS exps; add gpt-4, pythia, replit, dolly, sta…
yilunzhao d10a59a
added dataset and executor for DS1000
a9df68b
Merge branch 'main' into rui/ds-1000
40c02b5
removed all .DS_Store
af3ffa2
added ds1000 prompt file
2bfee22
fixed missing file and added ds1000 prompt file
9e8b571
zipped ds1000_data and removed irrelevant files
fb089c0
class variable ds_data now initialize in init
rays1024 cfb10c7
Merge remote-tracking branch 'origin/yilunzhao/llm_implementation' in…
rays1024 adb4c79
fixed ds1000 gpt-neo-125M evaluation bugs
rays1024 39a4fd4
some code clean up
rays1024 0ecdb5f
included reference code in prompt
rays1024 5666a22
updated ds1000.yaml
rays1024 27e0e70
fixed evaluation error at 158/159th problem
rays1024 4ba669d
fixed evaluation bug
rays1024 dc4fc0c
fixed torch tensor bug
rays1024 62250c5
undo changes caused by wrong jsonargparse version
rays1024 f7e930b
fixed ds1000 saving issue
rays1024 1ed0607
Revert "fixed ds1000 saving issue"
rays1024 90cba4f
fixed result saving issue
rays1024 4229001
evaluating raw output without cutting off at keywords
rays1024 b787508
No custom instruction and using only DS1000 prompt
rays1024 73b9676
reverted raw output and uses keyword cutoff in execution
rays1024 d41eb3b
no cutoff at execution to check raw output
rays1024 5fad2f3
updated gitignore
rays1024 b3aa6ba
execution now preprocess model output
rays1024 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably put this file in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import json | ||
| import argparse | ||
| import numpy as np | ||
| from transformers import GPT2Tokenizer | ||
| # from execution.executors import sql_program_len, python_program_len | ||
| from ds1000.ds1000 import DS1000Dataset | ||
|
|
||
| def sql_program_len(code: str) -> int: | ||
| """ return the length of the sql query """ | ||
| return len(list(filter(lambda x: not len(x.strip()) == 0, code.split()))) | ||
|
|
||
| def python_program_len(code: str) -> int: | ||
| """ return the length of the python program """ | ||
| return len(list(filter(lambda x: not x.startswith("#") and not len(x.strip()) == 0, code.split("\n")))) | ||
|
|
||
|
|
||
| TOKENIZER = GPT2Tokenizer.from_pretrained('gpt2') | ||
|
|
||
| def load_ds1000(): | ||
| ds_data = DS1000Dataset("ds1000/ds1000_data") # loads all questions into RAM | ||
| return ds_data | ||
|
|
||
|
|
||
| def parse_arg() -> tuple[str, str]: | ||
| parser = argparse.ArgumentParser(description='Process a file at the specified path') | ||
|
|
||
| parser.add_argument('path', type=str, help='the path of the file to process') | ||
|
|
||
| choices = ['mbpp', 'gsmath', 'spider', 'ds1000'] | ||
| parser.add_argument('--dataset', type=str, default='mbpp', choices=choices, help='the name of the dataset to use') | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| path = args.path | ||
| dataset = args.dataset | ||
|
|
||
| return path, dataset | ||
|
|
||
| def generate_length(lines, dataset): | ||
| NL_lengths = [] | ||
|
|
||
| program_lengths = [] | ||
|
|
||
| extra_info_lengths = [] | ||
|
|
||
| if dataset == "ds1000": | ||
| ds_data = load_ds1000() | ||
| for key in ds_data.data.keys(): | ||
| for data in ds_data[key]: | ||
| program_lengths.append(python_program_len(data['reference_code'])) | ||
| extra_info_lengths.append(python_program_len(data['prompt'])) | ||
| print(data['ans']) | ||
|
|
||
| for line in lines: | ||
| data = json.loads(line) | ||
|
|
||
| if dataset == "mbpp": | ||
| NL_lengths.append(len(TOKENIZER.encode(data['text']))) | ||
| program_lengths.append(python_program_len(data['code'])) | ||
|
|
||
| elif dataset == "gsmath": | ||
| question_length = len(TOKENIZER.encode(data['question'])) | ||
| NL_lengths.append(question_length) | ||
|
|
||
| elif dataset == "spider": | ||
| NL_lengths.append(len(TOKENIZER.encode(data['question']))) | ||
| program_lengths.append(sql_program_len(data['query'])) | ||
| extra_info_lengths.append(len(TOKENIZER.encode(str(data['db_table_headers'])))) | ||
|
|
||
|
|
||
| if NL_lengths: | ||
| print("Average length of natural language input: {:.2f}".format(np.mean(NL_lengths))) | ||
| print("90% percentile of length of natural language input: {:.2f}".format(np.percentile(NL_lengths, 90))) | ||
| print("99% percentile of length of natural language input: {:.2f}".format(np.percentile(NL_lengths, 99))) | ||
| if program_lengths: | ||
| print("Average length of reference program: {:.2f}".format(np.mean(program_lengths))) | ||
| if extra_info_lengths: | ||
| print("Average length of extra information: {:.2f}".format(np.mean(extra_info_lengths))) | ||
|
|
||
| def main(): | ||
| path, dataset = parse_arg() | ||
|
|
||
| with open(path, 'r') as f: | ||
| lines = f.readlines() | ||
|
|
||
| generate_length(lines, dataset) | ||
|
|
||
| main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.