Feat: add alternative choices selection methods (#835)

This commit is contained in:
Aidan Cooper
2024-08-05 11:27:49 +01:00
committed by GitHub
parent b216a545b3
commit 94e0115186
10 changed files with 426 additions and 48 deletions

View File

@@ -538,24 +538,17 @@ class StreamExecutor:
self.stream_var_event[name].set()
def _execute_select(self, expr: SglSelect):
(
decision,
normalized_prompt_logprobs,
input_token_logprobs,
output_token_logprobs,
) = self.backend.select(self, expr.choices, expr.temperature)
choices_decision = self.backend.select(
self, expr.choices, expr.temperature, expr.choices_method
)
if expr.name is not None:
name = expr.name
self.variables[name] = decision
self.meta_info[name] = {
"normalized_prompt_logprobs": normalized_prompt_logprobs,
"input_token_logprobs": input_token_logprobs,
"output_token_logprobs": output_token_logprobs,
}
self.variables[name] = choices_decision.decision
self.meta_info[name] = choices_decision.meta_info
self.variable_event[name].set()
if self.stream_var_event:
self.stream_var_event[name].set()
self.text_ += decision
self.text_ += choices_decision.decision
def _execute_variable(self, expr: SglVariable):
src_executor = expr.source_stream_executor