Skip to content

Commit

Permalink
add logprob method to Model
Browse files Browse the repository at this point in the history
  • Loading branch information
Valery Chernov committed Dec 1, 2023
1 parent 7123ceb commit a54943c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions serve/mlc_serve/model/paged_cache_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,27 @@ def generate(

return outputs

def logprob(
self,
context: str,
continuation: str,
):
r"""Generate log probs for given context and continuation.
Return logprobs and is_greedy boolean
Parameters
----------
context : str
The user input context string.
continuation : str
The user input continuation string.
Returns
-------
{"logprobs": float, "is_greedy": bool} : dict
"""

return self.mod["loglikelihood"](context, continuation)


def get_gpu_memory(gpu: int = 0) -> int:
return torch.cuda.get_device_properties(gpu).total_memory
Expand Down

0 comments on commit a54943c

Please sign in to comment.