llmcomp 1.3.1__py3-none-any.whl → 1.3.2__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/config.py +9 -1
- llmcomp/question/plots.py +5 -2
- llmcomp/runner/chat_completion.py +19 -13
- llmcomp/runner/runner.py +5 -5
- {llmcomp-1.3.1.dist-info → llmcomp-1.3.2.dist-info}/METADATA +1 -1
- {llmcomp-1.3.1.dist-info → llmcomp-1.3.2.dist-info}/RECORD +9 -9
- {llmcomp-1.3.1.dist-info → llmcomp-1.3.2.dist-info}/WHEEL +0 -0
- {llmcomp-1.3.1.dist-info → llmcomp-1.3.2.dist-info}/entry_points.txt +0 -0
- {llmcomp-1.3.1.dist-info → llmcomp-1.3.2.dist-info}/licenses/LICENSE +0 -0
llmcomp/config.py
CHANGED
|
@@ -238,12 +238,20 @@ class Config(metaclass=_ConfigMeta):
|
|
|
238
238
|
try:
|
|
239
239
|
client = openai.OpenAI(api_key=key, base_url=url)
|
|
240
240
|
params = ModelAdapter.test_request_params(model)
|
|
241
|
-
|
|
241
|
+
|
|
242
|
+
backoff_on = [openai.RateLimitError, openai.APIConnectionError]
|
|
243
|
+
if "tinker" not in url:
|
|
244
|
+
# Because Tinker returns InternalServerError for bad model IDs now, for some reason
|
|
245
|
+
backoff_on.append(openai.InternalServerError)
|
|
246
|
+
|
|
247
|
+
openai_chat_completion(client=client, kwargs=params, backoff_on=backoff_on)
|
|
242
248
|
except (
|
|
243
249
|
openai.NotFoundError,
|
|
244
250
|
openai.BadRequestError,
|
|
245
251
|
openai.PermissionDeniedError,
|
|
246
252
|
openai.AuthenticationError,
|
|
253
|
+
openai.InternalServerError,
|
|
254
|
+
openai.APITimeoutError,
|
|
247
255
|
) as e:
|
|
248
256
|
if Config.verbose:
|
|
249
257
|
print(f"{model} doesn't work with url {url} and key {key[:16]}... ({e})")
|
llmcomp/question/plots.py
CHANGED
|
@@ -50,7 +50,7 @@ def plot(
|
|
|
50
50
|
title = selected_paraphrase + f"\nand {num_paraphrases - 1} other paraphrases"
|
|
51
51
|
|
|
52
52
|
# Dispatch based on arguments and data
|
|
53
|
-
stacked_bar_args = selected_answers is not None or min_fraction is not None
|
|
53
|
+
stacked_bar_args = selected_answers is not None or min_fraction is not None
|
|
54
54
|
|
|
55
55
|
if stacked_bar_args:
|
|
56
56
|
# Stacked bar specific args provided
|
|
@@ -103,6 +103,7 @@ def plot(
|
|
|
103
103
|
probs_column=answer_column,
|
|
104
104
|
category_column=category_column,
|
|
105
105
|
selected_categories=selected_categories,
|
|
106
|
+
colors=colors,
|
|
106
107
|
title=title,
|
|
107
108
|
filename=filename,
|
|
108
109
|
)
|
|
@@ -136,6 +137,7 @@ def rating_cumulative_plot(
|
|
|
136
137
|
probs_column: str = "probs",
|
|
137
138
|
category_column: str = "group",
|
|
138
139
|
selected_categories: list[str] = None,
|
|
140
|
+
colors: dict[str, str] = None,
|
|
139
141
|
title: str = None,
|
|
140
142
|
filename: str = None,
|
|
141
143
|
):
|
|
@@ -167,7 +169,8 @@ def rating_cumulative_plot(
|
|
|
167
169
|
y_values = [cumulative[x] / n_valid for x in x_values]
|
|
168
170
|
mean_value = mean_sum / n_valid
|
|
169
171
|
label = f"{category} (mean: {mean_value:.1f})"
|
|
170
|
-
|
|
172
|
+
color = colors.get(category) if colors else None
|
|
173
|
+
ax.plot(x_values, y_values, label=label, color=color)
|
|
171
174
|
|
|
172
175
|
ax.set_xlabel(probs_column)
|
|
173
176
|
ax.set_ylabel("Fraction with score ≤ X")
|
|
@@ -15,17 +15,23 @@ def on_backoff(details):
|
|
|
15
15
|
# But we can do that only by reading the message, and this is bad.
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
openai.APITimeoutError,
|
|
24
|
-
openai.InternalServerError,
|
|
25
|
-
),
|
|
26
|
-
max_value=60,
|
|
27
|
-
factor=1.5,
|
|
28
|
-
on_backoff=on_backoff,
|
|
18
|
+
DEFAULT_BACKOFF_EXCEPTIONS = (
|
|
19
|
+
openai.RateLimitError,
|
|
20
|
+
openai.APIConnectionError,
|
|
21
|
+
openai.APITimeoutError,
|
|
22
|
+
openai.InternalServerError,
|
|
29
23
|
)
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def openai_chat_completion(*, client, kwargs: dict, backoff_on=DEFAULT_BACKOFF_EXCEPTIONS):
|
|
27
|
+
@backoff.on_exception(
|
|
28
|
+
wait_gen=backoff.expo,
|
|
29
|
+
exception=tuple(backoff_on),
|
|
30
|
+
max_value=60,
|
|
31
|
+
factor=1.5,
|
|
32
|
+
on_backoff=on_backoff,
|
|
33
|
+
)
|
|
34
|
+
def _call():
|
|
35
|
+
return client.chat.completions.create(**kwargs)
|
|
36
|
+
|
|
37
|
+
return _call()
|
llmcomp/runner/runner.py
CHANGED
|
@@ -62,7 +62,7 @@ class Runner:
|
|
|
62
62
|
Tuple of (content, prepared_kwargs) where prepared_kwargs is what was sent to the API.
|
|
63
63
|
"""
|
|
64
64
|
prepared = self._prepare_for_model(params)
|
|
65
|
-
completion = openai_chat_completion(client=self.client,
|
|
65
|
+
completion = openai_chat_completion(client=self.client, kwargs=prepared)
|
|
66
66
|
try:
|
|
67
67
|
content = completion.choices[0].message.content
|
|
68
68
|
if content is None:
|
|
@@ -138,7 +138,7 @@ class Runner:
|
|
|
138
138
|
"logprobs": True,
|
|
139
139
|
}
|
|
140
140
|
prepared = self._prepare_for_model(complete_params)
|
|
141
|
-
completion = openai_chat_completion(client=self.client,
|
|
141
|
+
completion = openai_chat_completion(client=self.client, kwargs=prepared)
|
|
142
142
|
|
|
143
143
|
if completion.choices[0].logprobs is None:
|
|
144
144
|
raise Exception(f"No logprobs returned, it seems that your provider for {self.model} doesn't support that.")
|
|
@@ -236,11 +236,11 @@ class Runner:
|
|
|
236
236
|
else:
|
|
237
237
|
msg_info = ""
|
|
238
238
|
warnings.warn(
|
|
239
|
-
f"Unexpected error (probably API-related), runner returns
|
|
239
|
+
f"Unexpected error (probably API-related), runner returns empty string. "
|
|
240
240
|
f"Model: {self.model}, function: {func.__name__}{msg_info}. "
|
|
241
241
|
f"Error: {type(e).__name__}: {e}"
|
|
242
242
|
)
|
|
243
|
-
result = (
|
|
243
|
+
result = ("", {})
|
|
244
244
|
return kwargs, result
|
|
245
245
|
|
|
246
246
|
futures = [executor.submit(get_data, kwargs) for kwargs in kwargs_list]
|
|
@@ -290,7 +290,7 @@ class Runner:
|
|
|
290
290
|
"n": n,
|
|
291
291
|
}
|
|
292
292
|
prepared = self._prepare_for_model(complete_params)
|
|
293
|
-
completion = openai_chat_completion(client=self.client,
|
|
293
|
+
completion = openai_chat_completion(client=self.client, kwargs=prepared)
|
|
294
294
|
for choice in completion.choices:
|
|
295
295
|
cnts[choice.message.content] += 1
|
|
296
296
|
if sum(cnts.values()) != num_samples:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
llmcomp/__init__.py,sha256=y_oUvd0Q3jhF-lf8UD3eF-2ppEuZmccqpYJItXEoTns,267
|
|
2
|
-
llmcomp/config.py,sha256=
|
|
2
|
+
llmcomp/config.py,sha256=Sgk7H8-E3FdMe5fcXUAM7EPMQwmWL8YOiIP0Qj-TFOk,9342
|
|
3
3
|
llmcomp/default_adapters.py,sha256=txs6NUOwGttC8jUahaRsoPCTbE5riBE7yKdAGPvKRhM,2578
|
|
4
4
|
llmcomp/utils.py,sha256=8-jakxvwbMqfDkelE9ZY1q8Fo538Y_ryRv6PizRhHR0,2683
|
|
5
5
|
llmcomp/finetuning/__init__.py,sha256=UEdwtJNVVqWjhrxvLvRLW4W4xjkKKwOR-GRkDxCP2Qo,58
|
|
@@ -7,15 +7,15 @@ llmcomp/finetuning/manager.py,sha256=6G0CW3NWK8vdfBoAjH0HATx_g16wwq5oU0mlHs-q28o
|
|
|
7
7
|
llmcomp/finetuning/update_jobs.py,sha256=blsHzg_ViTa2hBJtWCqR5onttehTtmXn3vmCTNd_hJw,980
|
|
8
8
|
llmcomp/finetuning/validation.py,sha256=v4FoFw8woo5No9A01ktuALsMsXdgb3N2rS58ttBUmHY,14047
|
|
9
9
|
llmcomp/question/judge.py,sha256=tNY94AHqncrbl2gf-g_Y3lepJ_HrahJRH-WgQyokegk,6568
|
|
10
|
-
llmcomp/question/plots.py,sha256=
|
|
10
|
+
llmcomp/question/plots.py,sha256=oYX21wdmdsyVMMUCMWPDJd1dp_WxZP1Nw5BcBgDqN6c,12582
|
|
11
11
|
llmcomp/question/question.py,sha256=EO6MAHqz46ksKAE4NysN5gyEoU4KAcrkJkTwqKvoT_Y,41799
|
|
12
12
|
llmcomp/question/result.py,sha256=UHpXVANR0jM7sJig2BtDDGh43ysBf8RiTZrXvx-Bi7c,8845
|
|
13
13
|
llmcomp/question/viewer.py,sha256=82a5iL_lFjRs3hDS0igoFrc5zedCAzJ23zrmY8G3bZM,17843
|
|
14
|
-
llmcomp/runner/chat_completion.py,sha256=
|
|
14
|
+
llmcomp/runner/chat_completion.py,sha256=EgESpoKoIZHupXiRPjMuFNhGVP3jBWOElQKfC38-hnE,1108
|
|
15
15
|
llmcomp/runner/model_adapter.py,sha256=Dua98E7aBVrCaZ2Ep44vl164oFkpH1P78YqImQkns4U,3406
|
|
16
|
-
llmcomp/runner/runner.py,sha256=
|
|
17
|
-
llmcomp-1.3.
|
|
18
|
-
llmcomp-1.3.
|
|
19
|
-
llmcomp-1.3.
|
|
20
|
-
llmcomp-1.3.
|
|
21
|
-
llmcomp-1.3.
|
|
16
|
+
llmcomp/runner/runner.py,sha256=7GikwkVBr78ev60qEX3iZ8RxLNUpdcYNT49ZiY8bzYw,12315
|
|
17
|
+
llmcomp-1.3.2.dist-info/METADATA,sha256=xZBJL5wUN2w2szgkwJ40adbsFyXXbVltYSgvQcyUS4Y,12987
|
|
18
|
+
llmcomp-1.3.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
19
|
+
llmcomp-1.3.2.dist-info/entry_points.txt,sha256=1aoN8_W9LDUnX7OIOX7ACmzNkbBMJ6GqNn_A1KUKjQc,76
|
|
20
|
+
llmcomp-1.3.2.dist-info/licenses/LICENSE,sha256=z7WR2X27WF_wZNuzfNFNlkt9cU7eFwP_3-qx7RyrGK4,1064
|
|
21
|
+
llmcomp-1.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|