llmcomp 1.2.1__py3-none-any.whl → 1.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- llmcomp/question/question.py +26 -1
- llmcomp/runner/runner.py +14 -2
- {llmcomp-1.2.1.dist-info → llmcomp-1.2.3.dist-info}/METADATA +1 -1
- {llmcomp-1.2.1.dist-info → llmcomp-1.2.3.dist-info}/RECORD +7 -7
- {llmcomp-1.2.1.dist-info → llmcomp-1.2.3.dist-info}/WHEEL +0 -0
- {llmcomp-1.2.1.dist-info → llmcomp-1.2.3.dist-info}/entry_points.txt +0 -0
- {llmcomp-1.2.1.dist-info → llmcomp-1.2.3.dist-info}/licenses/LICENSE +0 -0
llmcomp/question/question.py
CHANGED
|
@@ -8,7 +8,7 @@ from collections import defaultdict
|
|
|
8
8
|
from concurrent.futures import ThreadPoolExecutor
|
|
9
9
|
from copy import deepcopy
|
|
10
10
|
from queue import Queue
|
|
11
|
-
from typing import TYPE_CHECKING
|
|
11
|
+
from typing import TYPE_CHECKING, Literal, overload
|
|
12
12
|
|
|
13
13
|
import pandas as pd
|
|
14
14
|
import yaml
|
|
@@ -25,6 +25,7 @@ from llmcomp.question.result import JudgeCache, Result
|
|
|
25
25
|
from llmcomp.runner.runner import Runner
|
|
26
26
|
|
|
27
27
|
if TYPE_CHECKING:
|
|
28
|
+
from llmcomp.question.judge import FreeFormJudge, RatingJudge
|
|
28
29
|
from llmcomp.question.question import Question
|
|
29
30
|
|
|
30
31
|
|
|
@@ -65,6 +66,30 @@ class Question(ABC):
|
|
|
65
66
|
"""Type is snake_case version of the class name."""
|
|
66
67
|
return "".join("_" + c.lower() if c.isupper() else c.lower() for c in cls.__name__).lstrip("_")
|
|
67
68
|
|
|
69
|
+
@overload
|
|
70
|
+
@classmethod
|
|
71
|
+
def create(cls, *, type: Literal["free_form"], **kwargs) -> "FreeForm": ...
|
|
72
|
+
|
|
73
|
+
@overload
|
|
74
|
+
@classmethod
|
|
75
|
+
def create(cls, *, type: Literal["rating"], **kwargs) -> "Rating": ...
|
|
76
|
+
|
|
77
|
+
@overload
|
|
78
|
+
@classmethod
|
|
79
|
+
def create(cls, *, type: Literal["next_token"], **kwargs) -> "NextToken": ...
|
|
80
|
+
|
|
81
|
+
@overload
|
|
82
|
+
@classmethod
|
|
83
|
+
def create(cls, *, type: Literal["free_form_judge"], **kwargs) -> "FreeFormJudge": ...
|
|
84
|
+
|
|
85
|
+
@overload
|
|
86
|
+
@classmethod
|
|
87
|
+
def create(cls, *, type: Literal["rating_judge"], **kwargs) -> "RatingJudge": ...
|
|
88
|
+
|
|
89
|
+
@overload
|
|
90
|
+
@classmethod
|
|
91
|
+
def create(cls, *, type: str, **kwargs) -> "Question": ...
|
|
92
|
+
|
|
68
93
|
@classmethod
|
|
69
94
|
def create(cls, **kwargs) -> "Question":
|
|
70
95
|
"""Create a Question instance from a type string and keyword arguments.
|
llmcomp/runner/runner.py
CHANGED
|
@@ -61,9 +61,21 @@ class Runner:
|
|
|
61
61
|
prepared = self._prepare_for_model(params)
|
|
62
62
|
completion = openai_chat_completion(client=self.client, **prepared)
|
|
63
63
|
try:
|
|
64
|
-
|
|
64
|
+
content = completion.choices[0].message.content
|
|
65
|
+
if content is None:
|
|
66
|
+
# So far all cases here were OpenAI refusals, e.g.
|
|
67
|
+
# ChatCompletion(
|
|
68
|
+
# id='chatcmpl-...',
|
|
69
|
+
# choices=[Choice(
|
|
70
|
+
# finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(
|
|
71
|
+
# content=None,
|
|
72
|
+
# refusal="I'm sorry, I'm unable to fulfill that request.",
|
|
73
|
+
# ...))])
|
|
74
|
+
warnings.warn(f"API sent None as content. Returning empty string.\n{completion}", stacklevel=2)
|
|
75
|
+
return ""
|
|
76
|
+
return content
|
|
65
77
|
except Exception:
|
|
66
|
-
|
|
78
|
+
warnings.warn(f"Unexpected error.\n{completion}")
|
|
67
79
|
raise
|
|
68
80
|
|
|
69
81
|
def single_token_probs(
|
|
@@ -7,13 +7,13 @@ llmcomp/finetuning/manager.py,sha256=JaILoQYkNA9jIM_WR9eZactFHHcNFVeQeObXjQS8KcI
|
|
|
7
7
|
llmcomp/finetuning/update_jobs.py,sha256=blsHzg_ViTa2hBJtWCqR5onttehTtmXn3vmCTNd_hJw,980
|
|
8
8
|
llmcomp/question/judge.py,sha256=ovlEVp4XfgMc_qxYc4M7eq5qS-7C_WLjJklsO9wfU34,6105
|
|
9
9
|
llmcomp/question/plots.py,sha256=2uZTSN1s7Y3pnx2jiGtfUdWfQt2812Oo-eDsO2ZTUlE,9617
|
|
10
|
-
llmcomp/question/question.py,sha256=
|
|
10
|
+
llmcomp/question/question.py,sha256=2CvE0xePLnD5SUJsE_ZyvAIE_36rjjW37fUqG3NHTV0,39171
|
|
11
11
|
llmcomp/question/result.py,sha256=EcgXV-CbLNAQ1Bu0p-0QcjtrwBDt1WxSINwYuMmWoGs,8216
|
|
12
12
|
llmcomp/runner/chat_completion.py,sha256=iDiWE0N0_MYfggD-ouyfUPyaADt7602K5Wo16a7JJo4,967
|
|
13
13
|
llmcomp/runner/model_adapter.py,sha256=xBf6_WZbwKKTctecATujX9ZKQLDetDh-7UeCGaXJ9Zc,3244
|
|
14
|
-
llmcomp/runner/runner.py,sha256=
|
|
15
|
-
llmcomp-1.2.
|
|
16
|
-
llmcomp-1.2.
|
|
17
|
-
llmcomp-1.2.
|
|
18
|
-
llmcomp-1.2.
|
|
19
|
-
llmcomp-1.2.
|
|
14
|
+
llmcomp/runner/runner.py,sha256=C_SQ8pVGaGO57_4B85PMYWyntznsJnIwUOwnH3zP7IA,11494
|
|
15
|
+
llmcomp-1.2.3.dist-info/METADATA,sha256=NJ4ZqfAZo0SC5n1gfSKmPxAFjujTzRWlvkaeBrfUdg8,12518
|
|
16
|
+
llmcomp-1.2.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
17
|
+
llmcomp-1.2.3.dist-info/entry_points.txt,sha256=1aoN8_W9LDUnX7OIOX7ACmzNkbBMJ6GqNn_A1KUKjQc,76
|
|
18
|
+
llmcomp-1.2.3.dist-info/licenses/LICENSE,sha256=z7WR2X27WF_wZNuzfNFNlkt9cU7eFwP_3-qx7RyrGK4,1064
|
|
19
|
+
llmcomp-1.2.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|