Skip to content

Commit

Permalink
rename and improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
teetone committed Jan 2, 2023
1 parent a85c6ab commit 59f9902
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/helm/benchmark/adaptation/adapters/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ def generate_requests(self, eval_instance: Instance) -> List[RequestState]:
"""
pass

def sample_instances(self, instances: List[Instance]) -> List[Instance]:
def get_run_instances(self, instances: List[Instance]) -> List[Instance]:
"""
Leave the train instances alone. For the eval instances, keep at most `max_eval_instances`.
Get the instances necessary for this run:
Train instances (split=train): keep all (if any) for in-context learning
Eval instances (split=valid or test): keep at most `max_eval_instances` specified in `AdapterSpec` by sampling
Return the resulting train and eval instances.
"""
all_train_instances: List[Instance] = [instance for instance in instances if instance.split == TRAIN_SPLIT]
Expand Down
6 changes: 3 additions & 3 deletions src/helm/benchmark/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def run_one(self, run_spec: RunSpec):
run_path: str = os.path.join(self.runs_path, run_spec.name)
ensure_directory_exists(run_path)

# Initialize the adapter
# Fetch and initialize the Adapter based on the `AdapterSpec`.
adapter: Adapter = AdapterFactory.get_adapter(run_spec.adapter_spec, self.tokenizer_service)

instances: List[Instance]
Expand All @@ -118,8 +118,8 @@ def run_one(self, run_spec: RunSpec):
# Give each instance a unique ID
instances = with_instance_ids(instances)

# Sample only as many as we need
instances = adapter.sample_instances(instances)
# Get the instances necessary for this run.
instances = adapter.get_run_instances(instances)

# Data preprocessing
instances = DataPreprocessor(run_spec.data_augmenter_spec).preprocess(
Expand Down

0 comments on commit 59f9902

Please sign in to comment.