-
Notifications
You must be signed in to change notification settings - Fork 250
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
Input
, Output
and Adapter
refactor
#1280
Conversation
Wow, this is great! Since this is such a big PR, would you mind going through and putting a few comments to help understand what the changes are (e.g., this piece of code is new or simply moved from another file)? |
I did a big run with the changes in this PR for the offline eval models, and the cache seems to be safe. I will work on adding comments on this PR next. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM fwiw - did you test, since I noticed there are some minor changes to the scenario files beyond the main Input/Output change (e.g. renaming variables in wikfact), so curious just to make sure it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@percyliang I added comments in most files
@@ -0,0 +1,86 @@ | |||
from dataclasses import dataclass, field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved out Substitution
and AdapterSpec
out from the old adapter.py to their own file.
@@ -0,0 +1,65 @@ | |||
import re |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved out Prompt
out from the old adapter.py to its own file.
@@ -0,0 +1,75 @@ | |||
from dataclasses import dataclass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved out RequestState
out of the old adapter.py to its own file.
@@ -0,0 +1,40 @@ | |||
from collections import defaultdict, OrderedDict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved out ScenarioState
out from the old adapter.py to its own file.
@@ -66,18 +66,18 @@ def apply(self, instance: Instance, seed: Optional[int] = None) -> Instance: | |||
""" | |||
rng: Random = self.get_rng(instance, seed) | |||
|
|||
perturbed_instance: str = instance.input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input
of Instance
is now an object instead of a string. Also, the variable nameperturbed_instance
was a bit confusing.
from helm.common.request import Request | ||
from .in_context_learning_adapter import InContextLearningAdapter | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic in this file was from the old Adapter.
from helm.benchmark.adaptation.adapter_spec import AdapterSpec | ||
from .adapter_factory import AdapterFactory, ADAPT_GENERATION | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was part of the old test_adapter.py file.
from helm.benchmark.adaptation.adapter_spec import AdapterSpec | ||
from .adapter_factory import AdapterFactory, ADAPT_LANGUAGE_MODELING | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was part of the old test_adapter.py file.
from helm.benchmark.adaptation.adapter_spec import AdapterSpec | ||
from .adapter_factory import AdapterFactory, ADAPT_MULTIPLE_CHOICE_JOINT | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was part of the old test_adapter.py file.
from helm.benchmark.adaptation.adapter_spec import AdapterSpec | ||
from helm.benchmark.window_services.tokenizer_service import TokenizerService | ||
from .adapter import Adapter | ||
from .generation_adapter import GenerationAdapter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All Adapters live in src/helm/benchmark/adaptation/adapters
.
Yes, I tested extensively. I did a full run with the Together and TNLGv2 models to ensure the cache is safe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for the big refactor! Everything looks good - only thing is making TextInput
separate from Input
.
I will do another big rerun before I merge this PR. |
Changes
input
ofInstance
is now an object.output
ofReference
is now an object.Adapter
by creating a class for each adaptation method.Adapter
is now an abstract class withGenerationAdapter
,LanguageModelingAdapter
,MultipleChoiceJointAdapter
,MultipleChoiceSeparateAdapter
,MultipleChoiceCalibratedAdapter
, andBinaryRankingAdapter
child classes.AdapterSpec
,Prompt
,RequestState
, andScenarioState
from adapter.py to separate files.text_code
toModelRunExpander
for reasoning scenarios. We can't assumeall
models are text-only.The changes in this PR should not invalidate our cache. I did a full run with the offline models to ensure the changes in this PR are safe.