wisent 0.5.8__py3-none-any.whl → 0.5.10__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.
Potentially problematic release.
This version of wisent might be problematic. Click here for more details.
- wisent/__init__.py +1 -1
- wisent/core/models/wisent_model.py +26 -10
- wisent/core/multi_steering.py +10 -4
- {wisent-0.5.8.dist-info → wisent-0.5.10.dist-info}/METADATA +1 -1
- {wisent-0.5.8.dist-info → wisent-0.5.10.dist-info}/RECORD +8 -8
- {wisent-0.5.8.dist-info → wisent-0.5.10.dist-info}/WHEEL +0 -0
- {wisent-0.5.8.dist-info → wisent-0.5.10.dist-info}/licenses/LICENSE +0 -0
- {wisent-0.5.8.dist-info → wisent-0.5.10.dist-info}/top_level.txt +0 -0
wisent/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.5.
|
|
1
|
+
__version__ = "0.5.10"
|
|
@@ -95,6 +95,7 @@ class WisentModel:
|
|
|
95
95
|
elif self.device == "cuda":
|
|
96
96
|
load_kwargs["dtype"] = torch.float16
|
|
97
97
|
load_kwargs["device_map"] = "auto"
|
|
98
|
+
load_kwargs["attn_implementation"] = "flash_attention_2" # Use flash attention for CUDA
|
|
98
99
|
else:
|
|
99
100
|
load_kwargs["dtype"] = torch.float32
|
|
100
101
|
load_kwargs["device_map"] = None
|
|
@@ -258,6 +259,7 @@ class WisentModel:
|
|
|
258
259
|
self,
|
|
259
260
|
message: list[ChatMessage],
|
|
260
261
|
add_generation_prompt: bool = True,
|
|
262
|
+
enable_thinking: bool = True,
|
|
261
263
|
) -> dict[str, torch.Tensor]:
|
|
262
264
|
"""
|
|
263
265
|
Encode a single input in chat format.
|
|
@@ -267,6 +269,8 @@ class WisentModel:
|
|
|
267
269
|
list of {'role': str, 'content': str} dicts (chat messages).
|
|
268
270
|
add_generation_prompt:
|
|
269
271
|
If True, append the model's generation prompt at the end.
|
|
272
|
+
enable_thinking:
|
|
273
|
+
If False, disable thinking/reasoning mode (prevents <think> tags for supported models like Qwen).
|
|
270
274
|
|
|
271
275
|
returns:
|
|
272
276
|
dict with 'input_ids' and 'attention_mask' tensors.
|
|
@@ -279,10 +283,10 @@ class WisentModel:
|
|
|
279
283
|
>>> wm._encode_one(msgs, add_generation_prompt=True)
|
|
280
284
|
{"input_ids": tensor([[...]]), "attention_mask": tensor([[...]])}
|
|
281
285
|
"""
|
|
282
|
-
|
|
286
|
+
|
|
283
287
|
ids = self.tokenizer.apply_chat_template(
|
|
284
|
-
message, tokenize=True, add_generation_prompt=add_generation_prompt, return_tensors="pt"
|
|
285
|
-
)[0]
|
|
288
|
+
message, tokenize=True, add_generation_prompt=add_generation_prompt, enable_thinking=enable_thinking, return_tensors="pt"
|
|
289
|
+
)[0]
|
|
286
290
|
return {
|
|
287
291
|
"input_ids": ids,
|
|
288
292
|
"attention_mask": torch.ones_like(ids),
|
|
@@ -292,6 +296,7 @@ class WisentModel:
|
|
|
292
296
|
self,
|
|
293
297
|
inputs: list[list[ChatMessage]],
|
|
294
298
|
add_generation_prompt: bool = True,
|
|
299
|
+
enable_thinking: bool = True,
|
|
295
300
|
) -> dict[str, torch.Tensor]:
|
|
296
301
|
"""
|
|
297
302
|
Batch-encode a list of chat messages.
|
|
@@ -301,7 +306,9 @@ class WisentModel:
|
|
|
301
306
|
list of chat messages (each a list of {'role','content'} dicts).
|
|
302
307
|
add_generation_prompt:
|
|
303
308
|
If True, append the model's generation prompt at the end of each.
|
|
304
|
-
|
|
309
|
+
enable_thinking:
|
|
310
|
+
If False, disable thinking/reasoning mode (prevents <think> tags for supported models like Qwen).
|
|
311
|
+
|
|
305
312
|
returns:
|
|
306
313
|
dict with batched 'input_ids' and 'attention_mask' tensors.
|
|
307
314
|
|
|
@@ -316,10 +323,10 @@ class WisentModel:
|
|
|
316
323
|
>>> wm._batch_encode([msgs1, msgs2], add_generation_prompt=True)
|
|
317
324
|
{"input_ids": tensor([[...],[...]]), "attention_mask": tensor([[...],[...]])}
|
|
318
325
|
"""
|
|
319
|
-
|
|
326
|
+
|
|
320
327
|
singles = []
|
|
321
328
|
for item in inputs:
|
|
322
|
-
singles.append(self._encode_one(item, add_generation_prompt=add_generation_prompt))
|
|
329
|
+
singles.append(self._encode_one(item, add_generation_prompt=add_generation_prompt, enable_thinking=enable_thinking))
|
|
323
330
|
|
|
324
331
|
batch = self.tokenizer.pad(singles, padding=True, return_tensors="pt")
|
|
325
332
|
|
|
@@ -338,6 +345,7 @@ class WisentModel:
|
|
|
338
345
|
num_return_sequences: int = 1,
|
|
339
346
|
use_steering: bool = False,
|
|
340
347
|
steering_plan: SteeringPlan | None = None,
|
|
348
|
+
enable_thinking: bool = True,
|
|
341
349
|
**gen_kwargs: Any,
|
|
342
350
|
) -> list[str]:
|
|
343
351
|
"""
|
|
@@ -361,6 +369,8 @@ class WisentModel:
|
|
|
361
369
|
steering_plan:
|
|
362
370
|
optional SteeringPlan to use for this call only (overrides internal plan).
|
|
363
371
|
If None, uses the internal plan.
|
|
372
|
+
enable_thinking:
|
|
373
|
+
If False, disable thinking/reasoning mode (prevents <think> tags for supported models like Qwen).
|
|
364
374
|
**gen_kwargs:
|
|
365
375
|
additional kwargs passed to 'model.generate()'.
|
|
366
376
|
|
|
@@ -439,7 +449,7 @@ class WisentModel:
|
|
|
439
449
|
if use_steering:
|
|
440
450
|
self.apply_steering(steering_plan)
|
|
441
451
|
|
|
442
|
-
batch = self._batch_encode(inputs, add_generation_prompt=True)
|
|
452
|
+
batch = self._batch_encode(inputs, add_generation_prompt=True, enable_thinking=enable_thinking)
|
|
443
453
|
|
|
444
454
|
gen_out = self.hf_model.generate(
|
|
445
455
|
**batch,
|
|
@@ -472,6 +482,7 @@ class WisentModel:
|
|
|
472
482
|
collect_topk: int = 5,
|
|
473
483
|
use_steering: bool = False,
|
|
474
484
|
steering_plan: SteeringPlan | None = None,
|
|
485
|
+
enable_thinking: bool = True,
|
|
475
486
|
**gen_kwargs: Any,
|
|
476
487
|
) -> tuple[list[str], list[GenerationStats]]:
|
|
477
488
|
"""
|
|
@@ -486,7 +497,7 @@ class WisentModel:
|
|
|
486
497
|
temperature:
|
|
487
498
|
sampling temperature (0 = greedy, 1 = default sampling).
|
|
488
499
|
top_p:
|
|
489
|
-
nucleus sampling probability (0 = no filtering, 1 = full filtering).
|
|
500
|
+
nucleus sampling probability (0 = no filtering, 1 = full filtering).
|
|
490
501
|
do_sample:
|
|
491
502
|
if False, uses greedy decoding (top_k=1).
|
|
492
503
|
num_return_sequences:
|
|
@@ -498,6 +509,8 @@ class WisentModel:
|
|
|
498
509
|
steering_plan:
|
|
499
510
|
optional SteeringPlan to use for this call only (overrides internal plan).
|
|
500
511
|
If None, uses the internal plan.
|
|
512
|
+
enable_thinking:
|
|
513
|
+
If False, disable thinking/reasoning mode (prevents <think> tags for supported models like Qwen).
|
|
501
514
|
**gen_kwargs:
|
|
502
515
|
additional kwargs passed to 'model.generate()'.
|
|
503
516
|
|
|
@@ -537,7 +550,7 @@ class WisentModel:
|
|
|
537
550
|
if use_steering:
|
|
538
551
|
self.apply_steering(steering_plan)
|
|
539
552
|
|
|
540
|
-
batch = self._batch_encode(inputs, add_generation_prompt=True)
|
|
553
|
+
batch = self._batch_encode(inputs, add_generation_prompt=True, enable_thinking=enable_thinking)
|
|
541
554
|
|
|
542
555
|
out = self.hf_model.generate(
|
|
543
556
|
**batch,
|
|
@@ -609,6 +622,7 @@ class WisentModel:
|
|
|
609
622
|
steering_plan: SteeringPlan | None = None,
|
|
610
623
|
skip_prompt: bool = True,
|
|
611
624
|
skip_special_tokens: bool = True,
|
|
625
|
+
enable_thinking: bool = True,
|
|
612
626
|
**gen_kwargs: Any,
|
|
613
627
|
) -> Iterable[str]:
|
|
614
628
|
"""
|
|
@@ -635,6 +649,8 @@ class WisentModel:
|
|
|
635
649
|
if True, the yielded text excludes the input prompt.
|
|
636
650
|
skip_special_tokens:
|
|
637
651
|
if True, special tokens are removed from the yielded text.
|
|
652
|
+
enable_thinking:
|
|
653
|
+
If False, disable thinking/reasoning mode (prevents <think> tags for supported models like Qwen).
|
|
638
654
|
**gen_kwargs:
|
|
639
655
|
additional kwargs passed to 'model.generate()'.
|
|
640
656
|
|
|
@@ -649,7 +665,7 @@ class WisentModel:
|
|
|
649
665
|
if use_steering:
|
|
650
666
|
self.apply_steering(steering_plan)
|
|
651
667
|
|
|
652
|
-
batch = self._batch_encode(inputs, add_generation_prompt=True)
|
|
668
|
+
batch = self._batch_encode(inputs, add_generation_prompt=True, enable_thinking=enable_thinking)
|
|
653
669
|
|
|
654
670
|
streamer = TextIteratorStreamer(
|
|
655
671
|
self.tokenizer,
|
wisent/core/multi_steering.py
CHANGED
|
@@ -165,7 +165,8 @@ class MultiSteering:
|
|
|
165
165
|
prompt: str,
|
|
166
166
|
max_new_tokens: int = 100,
|
|
167
167
|
temperature: float = 0.7,
|
|
168
|
-
top_p: float = 0.9
|
|
168
|
+
top_p: float = 0.9,
|
|
169
|
+
enable_thinking: bool = True
|
|
169
170
|
) -> Iterable[str]:
|
|
170
171
|
"""Apply the combined steering vector to generate text with streaming.
|
|
171
172
|
|
|
@@ -175,6 +176,7 @@ class MultiSteering:
|
|
|
175
176
|
max_new_tokens: Maximum tokens to generate
|
|
176
177
|
temperature: Sampling temperature
|
|
177
178
|
top_p: Top-p sampling parameter
|
|
179
|
+
enable_thinking: If False, disable thinking/reasoning mode (prevents <think> tags for supported models like Qwen)
|
|
178
180
|
|
|
179
181
|
Yields:
|
|
180
182
|
Generated text chunks
|
|
@@ -213,7 +215,8 @@ class MultiSteering:
|
|
|
213
215
|
use_steering=True,
|
|
214
216
|
steering_plan=steering_plan,
|
|
215
217
|
skip_prompt=True,
|
|
216
|
-
skip_special_tokens=True
|
|
218
|
+
skip_special_tokens=True,
|
|
219
|
+
enable_thinking=enable_thinking
|
|
217
220
|
)
|
|
218
221
|
|
|
219
222
|
except Exception as e:
|
|
@@ -227,7 +230,8 @@ class MultiSteering:
|
|
|
227
230
|
prompt: str,
|
|
228
231
|
max_new_tokens: int = 100,
|
|
229
232
|
temperature: float = 0.7,
|
|
230
|
-
top_p: float = 0.9
|
|
233
|
+
top_p: float = 0.9,
|
|
234
|
+
enable_thinking: bool = True
|
|
231
235
|
) -> str:
|
|
232
236
|
"""Apply the combined steering vector to generate text (non-streaming).
|
|
233
237
|
|
|
@@ -237,6 +241,7 @@ class MultiSteering:
|
|
|
237
241
|
max_new_tokens: Maximum tokens to generate
|
|
238
242
|
temperature: Sampling temperature
|
|
239
243
|
top_p: Top-p sampling parameter
|
|
244
|
+
enable_thinking: If False, disable thinking/reasoning mode (prevents <think> tags for supported models like Qwen)
|
|
240
245
|
|
|
241
246
|
Returns:
|
|
242
247
|
Generated text
|
|
@@ -273,7 +278,8 @@ class MultiSteering:
|
|
|
273
278
|
temperature=temperature,
|
|
274
279
|
top_p=top_p,
|
|
275
280
|
use_steering=True,
|
|
276
|
-
steering_plan=steering_plan
|
|
281
|
+
steering_plan=steering_plan,
|
|
282
|
+
enable_thinking=enable_thinking
|
|
277
283
|
)
|
|
278
284
|
|
|
279
285
|
return outputs[0] if outputs else ""
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
wisent/__init__.py,sha256=
|
|
1
|
+
wisent/__init__.py,sha256=1nlPInsRzDbcDPveZ3ghSJ6v6KveN9n6gnj-twW4DkI,23
|
|
2
2
|
wisent/benchmarks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
wisent/benchmarks/coding/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
wisent/benchmarks/coding/metrics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -64,7 +64,7 @@ wisent/core/managed_cached_benchmarks.py,sha256=JbvpZ1fgSuQQhyQVKEvqrQZRHGqfnjo9
|
|
|
64
64
|
wisent/core/mixed_benchmark_sampler.py,sha256=tKQCHUXVuYeCyx4VZt8O1hGyB-TOY_SQ_SYi8cyApII,13585
|
|
65
65
|
wisent/core/model_config_manager.py,sha256=rQAdSmk3GFlZXyHp3fSV1bORxiZWhmzIz1uo3H4JtkA,12009
|
|
66
66
|
wisent/core/model_persistence.py,sha256=6_vc1Ndujd4v0O68giINSTvYhmb7-AiacWwAbqLOrls,10636
|
|
67
|
-
wisent/core/multi_steering.py,sha256=
|
|
67
|
+
wisent/core/multi_steering.py,sha256=EMaKn4dZPlAsFupEUQZlxTZGJ0-ofpLcTCKQk8HaZL8,12295
|
|
68
68
|
wisent/core/parser.py,sha256=_YDeSuQMx0zNknz9rX3Ls1YPT1x5eohoY8rfjeoqxV8,69091
|
|
69
69
|
wisent/core/representation.py,sha256=hBl_N9qbr5Gsa7GCQ0nMWRm82RqYEfhd9cyf0PPH5LY,195
|
|
70
70
|
wisent/core/sample_size_optimizer.py,sha256=6wegGXZpdGpiR4R0YJ1D2JqLr6yinMndEx2gB5FL80s,23666
|
|
@@ -134,7 +134,7 @@ wisent/core/evaluators/oracles/interactive.py,sha256=f3v2_N17fKzGyeOxONRJbrbn8i5
|
|
|
134
134
|
wisent/core/evaluators/oracles/nlp_evaluator.py,sha256=KxbnF-I2IFbBQpoYyjQKGbYh4NErsEuhTCRYX_Tob8o,18220
|
|
135
135
|
wisent/core/evaluators/oracles/user_specified.py,sha256=V1dKrNj3Oq7UC_I7DT0WGnktP7R_DSW6UAwDdrA8SnE,2360
|
|
136
136
|
wisent/core/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
137
|
-
wisent/core/models/wisent_model.py,sha256
|
|
137
|
+
wisent/core/models/wisent_model.py,sha256=-QJRrPxQPduDyjH0l9PDZC0cdoBzyrQQ_bgeImfGwfI,29873
|
|
138
138
|
wisent/core/models/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
139
139
|
wisent/core/models/core/atoms.py,sha256=_Bpz0Sfiq6_VswThIltUwNGj_ukl5MhAg8RrgMKwEBM,15756
|
|
140
140
|
wisent/core/optuna/__init__.py,sha256=sTfwRnrRyKrCNVsF_qCjBDFEZC0ZmUZ7m6IE0iHfTVs,1914
|
|
@@ -213,8 +213,8 @@ wisent/synthetic/generators/diversities/core/__init__.py,sha256=47DEQpj8HBSa-_TI
|
|
|
213
213
|
wisent/synthetic/generators/diversities/core/core.py,sha256=TjSj5T7NE5kRH-ABcFqb1Hz_j3Z6F_TcV-95uHD5Xw8,2201
|
|
214
214
|
wisent/synthetic/generators/diversities/methods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
215
215
|
wisent/synthetic/generators/diversities/methods/fast_diversity.py,sha256=Z2UzTbzyJFM_ToxCoXM_LQQQ1Jc6BZknrbpikTG1MRw,8522
|
|
216
|
-
wisent-0.5.
|
|
217
|
-
wisent-0.5.
|
|
218
|
-
wisent-0.5.
|
|
219
|
-
wisent-0.5.
|
|
220
|
-
wisent-0.5.
|
|
216
|
+
wisent-0.5.10.dist-info/licenses/LICENSE,sha256=wy0iaw8b2tyqZAfKHib3lP3PJ9o88FDCg92oUHh3sDQ,1073
|
|
217
|
+
wisent-0.5.10.dist-info/METADATA,sha256=-CwqNc9Sz5brGHuNi1lMz34YNVqKNHRft4QVlOAjZvM,2425
|
|
218
|
+
wisent-0.5.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
219
|
+
wisent-0.5.10.dist-info/top_level.txt,sha256=2Ts9Iyldnb3auIN2HBBaHPknRy7nSRDm2f6RGzYgr8A,7
|
|
220
|
+
wisent-0.5.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|