Return logprob for choices (#87)

This commit is contained in:
Lianmin Zheng
2024-01-23 05:07:30 -08:00
committed by GitHub
parent 9e037c822c
commit 9a16fea012
15 changed files with 161 additions and 112 deletions

View File

@@ -1,6 +1,6 @@
from dataclasses import dataclass, field
from enum import Enum, auto
from typing import Callable, Dict, List, Tuple, Optional
from typing import Callable, Dict, List, Optional, Tuple
class ChatTemplateStyle(Enum):
@@ -111,7 +111,7 @@ register_chat_template(
"assistant": ("<|im_start|>assistant\n", "\n<|im_end|>\n"),
},
style=ChatTemplateStyle.PLAIN,
stop_str=('<|im_end|>',)
stop_str=("<|im_end|>",),
)
)

View File

@@ -80,7 +80,7 @@ def run_program_batch(
# Run all programs
if num_threads == "auto":
num_threads = max(64, multiprocessing.cpu_count() * 8)
num_threads = max(96, multiprocessing.cpu_count() * 16)
num_threads = min(num_threads, len(batch_arguments))
if num_threads == 1:
@@ -364,10 +364,16 @@ class StreamExecutor:
self.stream_var_event[name].set()
def _execute_select(self, expr: SglSelect):
decision, scores = self.backend.select(self, expr.choices, expr.temperature)
decision, normalized_prompt_logprob, prompt_logprob = self.backend.select(
self, expr.choices, expr.temperature
)
if expr.name is not None:
name = expr.name
self.variables[name] = decision
self.meta_info[name] = {
"normalized_prompt_logprob": normalized_prompt_logprob,
"prompt_logprob": prompt_logprob,
}
self.variable_event[name].set()
self.text_ += decision