Skip to content

Commit

Permalink
fix(evaluation): chat template in batch logprobs inference
Browse files Browse the repository at this point in the history
  • Loading branch information
TianyiQ committed Dec 20, 2024
1 parent ae490dc commit 4de1544
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/abstractions/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,18 +481,25 @@ def get_response(
s, conversation: List, temperature: float = 0.2, max_tokens: int = None, options: list = []
) -> str:
nonlocal purpose
last_role = None

for turn in conversation:
if turn["role"] == "assistant":
s += sgl.assistant(turn["content"])
last_role = "assistant"

elif turn["role"] == "user":
s += sgl.user(turn["content"])
last_role = "user"

elif turn["role"] == "system":
s += sgl.system(turn["content"])

else:
raise ValueError(f"Unknown role: {turn['role']}")

if purpose == "responses":
if purpose == "responses" or options:
assert last_role == "user"
s += sgl.assistant_begin()

if options:
Expand Down

0 comments on commit 4de1544

Please sign in to comment.