forked from EleutherAI/elk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d304ab3
commit 761c82d
Showing
7 changed files
with
65 additions
and
84 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,10 @@ | ||
balance: true | ||
datasets: | ||
- "dbpedia_14" | ||
label_column: null | ||
max_examples: | ||
- 5 | ||
- 5 | ||
num_shots: 0 | ||
num_variants: -1 | ||
seed: 42 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,11 @@ | ||
balance: true | ||
datasets: | ||
- "super_glue boolq" | ||
- "super_glue copa" | ||
label_column: null | ||
max_examples: | ||
- 5 | ||
- 5 | ||
num_shots: 0 | ||
num_variants: -1 | ||
seed: 42 |
This file contains 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,39 @@ | ||
from elk.extraction import load_prompts, PromptConfig | ||
from elk.promptsource.templates import DatasetTemplates | ||
from itertools import cycle | ||
from typing import Literal | ||
import pytest | ||
|
||
|
||
@pytest.mark.filterwarnings("ignore:Unable to find a decoding function") | ||
def test_load_prompts(): | ||
def test_single_split(cfg: PromptConfig, split_type: Literal["train", "val"]): | ||
prompt_ds = load_prompts( | ||
*cfg.datasets, max_examples=cfg.max_examples[0], split_type=split_type | ||
) | ||
prompters = [] | ||
|
||
for ds in cfg.datasets: | ||
ds_name, _, config_name = ds.partition(" ") | ||
prompter = DatasetTemplates(ds_name, config_name or None) | ||
prompters.append(prompter) | ||
|
||
for prompter, record in zip(cycle(prompters), prompt_ds): | ||
true_template_names = prompter.all_template_names | ||
returned_template_names = record["template_names"] | ||
|
||
# check for using the same templates | ||
assert set(true_template_names) == set(returned_template_names) | ||
# check for them being in the same order | ||
assert true_template_names == true_template_names | ||
|
||
# the case where the dataset has 2 classes | ||
# this dataset is small | ||
cfg = PromptConfig.load_yaml("tests/super_glue_prompts.yaml") | ||
test_single_split(cfg, "train") | ||
test_single_split(cfg, "val") | ||
|
||
# the case where the dataset has more than 2 classes | ||
cfg = PromptConfig.load_yaml("tests/dbpedia_prompts.yaml") | ||
test_single_split(cfg, "train") | ||
test_single_split(cfg, "val") |
This file was deleted.
Oops, something went wrong.