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

Remove blobfile dep, load directly from URL #4

Open
wants to merge 2 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
6 changes: 3 additions & 3 deletions drop_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import re
import string
from typing import Any, Dict, List, Optional, Set, Tuple, Union
import urllib

import blobfile as bf
import numpy as np
from scipy.optimize import linear_sum_assignment

Expand Down Expand Up @@ -247,9 +247,9 @@ def __init__(self, num_examples: int | None = None, train_samples_per_prompt: in
self.test_jsonl = (
"https://openaipublic.blob.core.windows.net/simple-evals/drop_v0_dev.jsonl.gz"
)
with gzip.GzipFile(fileobj=bf.BlobFile(self.train_jsonl, "rb"), mode="rb") as f:
with gzip.GzipFile(fileobj=urllib.request.urlopen(self.train_jsonl), mode="rb") as f:
self.train_samples = list(map(json.loads, f.readlines()))
with gzip.GzipFile(fileobj=bf.BlobFile(self.test_jsonl, "rb"), mode="rb") as f:
with gzip.GzipFile(fileobj=urllib.request.urlopen(self.test_jsonl), mode="rb") as f:
self.test_samples = list(map(json.loads, f.readlines()))
if self._num_examples:
self.test_samples = random.Random(self.seed).sample(
Expand Down
5 changes: 1 addition & 4 deletions gpqa_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import random
import re

import blobfile as bf
import pandas

from . import common
Expand All @@ -27,9 +26,7 @@ def __init__(
num_examples: int | None = None, # restrict to a subset of the data for debugging
):
df = pandas.read_csv(
bf.BlobFile(
f"https://openaipublic.blob.core.windows.net/simple-evals/gpqa_{variant}.csv"
)
f"https://openaipublic.blob.core.windows.net/simple-evals/gpqa_{variant}.csv"
)
examples = [row.to_dict() for _, row in df.iterrows()]
rng = random.Random(0)
Expand Down
1 change: 0 additions & 1 deletion humaneval_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from io import BytesIO
from typing import Any, Tuple

import blobfile as bf
import tqdm
from human_eval.data import HUMAN_EVAL, read_problems
from human_eval.evaluation import estimate_pass_at_k
Expand Down
3 changes: 1 addition & 2 deletions math_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import random
import re

import blobfile as bf
import pandas

from . import common
Expand Down Expand Up @@ -92,7 +91,7 @@ def check_equality(sampler: SamplerBase, expr1: str, expr2: str):

class MathEval(Eval):
def __init__(self, equality_checker: SamplerBase, num_examples: int | None = None):
df = pandas.read_csv(bf.BlobFile("https://openaipublic.blob.core.windows.net/simple-evals/math_test.csv"))
df = pandas.read_csv("https://openaipublic.blob.core.windows.net/simple-evals/math_test.csv")
examples = [row.to_dict() for _, row in df.iterrows()]
if num_examples:
examples = random.Random(0).sample(examples, num_examples)
Expand Down
7 changes: 3 additions & 4 deletions mgsm_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

import re
from typing import Optional

import blobfile as bf
import urllib

from . import common
from .mmlu_eval import HTML_JINJA
Expand Down Expand Up @@ -109,8 +108,8 @@ def score_mgsm(target: str, prediction: str) -> bool:
def get_lang_examples(lang: str) -> list[dict[str, str]]:
fpath = LANG_TO_FPATH[lang]
examples = []
with bf.BlobFile(fpath, "r") as f:
for line in f:
with urllib.request.urlopen(fpath) as f:
for line in f.read().decode("utf-8").splitlines():
inputs, targets = line.strip().split("\t")
if "." in targets:
raise ValueError(f"targets {targets} contains a decimal point.")
Expand Down
3 changes: 1 addition & 2 deletions mmlu_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import random
import re

import blobfile as bf
import pandas

from . import common
Expand Down Expand Up @@ -95,7 +94,7 @@ def format_question(row):
class MMLUEval(Eval):
def __init__(self, num_examples: int | None = None):
df = pandas.read_csv(
bf.BlobFile("https://openaipublic.blob.core.windows.net/simple-evals/mmlu.csv")
"https://openaipublic.blob.core.windows.net/simple-evals/mmlu.csv"
)
examples = [row.to_dict() for _, row in df.iterrows()]
if num_examples:
Expand Down