-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding adapter to use message on model inferencing
- Loading branch information
Showing
6 changed files
with
60 additions
and
4 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
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,49 @@ | ||
from typing import List | ||
|
||
from helm.benchmark.adaptation.prompt import Prompt | ||
from helm.benchmark.adaptation.request_state import RequestState | ||
from helm.benchmark.scenarios.scenario import Instance | ||
from helm.common.request import Request | ||
from helm.benchmark.adaptation.adapters.in_context_learning_adapter import InContextLearningAdapter | ||
|
||
|
||
class ChatAdapter(InContextLearningAdapter): | ||
""" | ||
Each `Instance` in a `Scenario` has a history of the format: | ||
[ | ||
{"role": "user", "content": <user-content>}, | ||
{"role": "assistant", "content": <assistant-content>}, | ||
{"role": "user", "content": <user-content>}, | ||
... | ||
] | ||
""" | ||
|
||
def generate_requests( | ||
self, eval_instance: Instance, train_trial_index: int, training_instances: List[Instance] | ||
) -> List[RequestState]: | ||
assert eval_instance.extra_data | ||
request = Request( | ||
model=self.adapter_spec.model, | ||
model_deployment=self.adapter_spec.model_deployment, | ||
messages=eval_instance.extra_data['conversation'], | ||
num_completions=self.adapter_spec.num_outputs, | ||
temperature=self.adapter_spec.temperature, | ||
max_tokens=self.adapter_spec.max_tokens, | ||
stop_sequences=self.adapter_spec.stop_sequences, | ||
random=self.adapter_spec.random, | ||
image_generation_parameters=self.adapter_spec.image_generation_parameters, | ||
) | ||
request_state = RequestState( | ||
instance=eval_instance, | ||
reference_index=None, | ||
request_mode=None, | ||
train_trial_index=train_trial_index, | ||
output_mapping=None, | ||
request=request, | ||
result=None, | ||
num_train_instances=0, | ||
prompt_truncated=False, | ||
) | ||
return [request_state] |
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
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