Multigen
multigen #
Functions for comparing output across models.
- thread_multigen(), query_multigen() and multigen(): Compare outputs across models.
- cycle_gen_print(): For a list of models, sequentially grow a Thread with model responses to given IN messages.
thread_multigen #
thread_multigen(
threads,
model_names,
text=None,
csv=None,
gencall=None,
genconf=None,
out_keys=["text", "dic", "value"],
thread_titles=None,
)
Generate a single thread on a list of models, returning/saving results in text/CSV.
Actual generation for each model is implemented by an optional Callable with this signature
def gencall(model: Model, thread: Thread, genconf: GenConf) -> GenOut
Parameters:
Name | Type | Description | Default |
---|---|---|---|
threads |
list[Thread]
|
List of threads to input into each model. |
required |
model_names |
list[str]
|
A list of Models names. |
required |
text |
Union[str, list[str], None]
|
An str list with "print"=print results, path=a path to output a text file with results. Defaults to None. |
None
|
csv |
Union[str, list[str], None]
|
An str list with "print"=print CSV results, path=a path to output a CSV file with results. Defaults to None. |
None
|
gencall |
Optional[Callable]
|
Callable function that does the actual generation. Defaults to None, which will use a text generation default function. |
None
|
genconf |
Optional[GenConf]
|
Model generation configuration to use in models. Defaults to None, meaning default values. |
None
|
out_keys |
list[str]
|
A list with GenOut members to output. Defaults to ["text","dic", "value"]. |
['text', 'dic', 'value']
|
thread_titles |
Optional[list[str]]
|
A human-friendly title for each Thread. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
list[list[GenOut]]
|
A list of lists in the format [thread,model] of shape (len(threads), len(models)). For example: out[0] holds threads[0] results on all models, out[1]: threads[1] on all models, ... |
Source code in sibila/multigen.py
query_multigen #
query_multigen(
in_list,
inst_text,
model_names,
text=None,
csv=None,
gencall=None,
genconf=None,
out_keys=["text", "dic", "value"],
in_titles=None,
)
Generate an INST+IN thread on a list of models, returning/saving results in text/CSV.
Actual generation for each model is implemented by an optional Callable with this signature
def gencall(model: Model, thread: Thread, genconf: GenConf) -> GenOut
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_list |
list[str]
|
List of IN messages to initialize Threads. |
required |
inst_text |
str
|
The common INST to use in all models. |
required |
model_names |
list[str]
|
A list of Models names. |
required |
text |
Union[str, list[str], None]
|
An str list with "print"=print results, path=a path to output a text file with results. Defaults to None. |
None
|
csv |
Union[str, list[str], None]
|
An str list with "print"=print CSV results, path=a path to output a CSV file with results. Defaults to None. |
None
|
gencall |
Optional[Callable]
|
Callable function that does the actual generation. Defaults to None, which will use a text generation default function. |
None
|
genconf |
Optional[GenConf]
|
Model generation configuration to use in models. Defaults to None, meaning default values. |
None
|
out_keys |
list[str]
|
A list with GenOut members to output. Defaults to ["text","dic", "value"]. |
['text', 'dic', 'value']
|
in_titles |
Optional[list[str]]
|
A human-friendly title for each Thread. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
list[list[GenOut]]
|
A list of lists in the format [thread,model] of shape (len(threads), len(models)). |
list[list[GenOut]]
|
For example: out[0] holds threads[0] results on all models, out[1]: threads[1] on all models, ... |
Source code in sibila/multigen.py
multigen #
multigen(
threads,
*,
models=None,
model_names=None,
model_names_del_after=True,
gencall=None,
genconf=None
)
Generate a list of Threads in multiple models, returning the GenOut for each [thread,model] combination.
Actual generation for each model is implemented by the gencall arg Callable with this signature
def gencall(model: Model, thread: Thread, genconf: GenConf) -> GenOut
Parameters:
Name | Type | Description | Default |
---|---|---|---|
threads |
list[Thread]
|
List of threads to input into each model. |
required |
models |
Optional[list[Model]]
|
A list of initialized models. Defaults to None. |
None
|
model_names |
Optional[list[str]]
|
--Or-- A list of Models names. Defaults to None. |
None
|
model_names_del_after |
bool
|
Delete model_names models after using them: important or an out-of-memory error will eventually happen. Defaults to True. |
True
|
gencall |
Optional[Callable]
|
Callable function that does the actual generation. Defaults to None, which will use a text generation default function. |
None
|
genconf |
Optional[GenConf]
|
Model generation configuration to use in models. Defaults to None, meaning default values. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
Only one of models or model_names can be given. |
Returns:
Type | Description |
---|---|
list[list[GenOut]]
|
A list of lists in the format [thread,model] of shape (len(threads), len(models)). For example: out[0] holds threads[0] results on all models, out[1]: threads[1] on all models, ... |
Source code in sibila/multigen.py
cycle_gen_print #
cycle_gen_print(
in_list,
inst_text,
model_names,
gencall=None,
genconf=None,
out_keys=["text", "dic", "value"],
json_kwargs={
"indent": 2,
"sort_keys": False,
"ensure_ascii": False,
},
)
For a list of models, sequentially grow a Thread with model responses to given IN messages and print the results.
Works by doing:
- Generate an INST+IN prompt for a list of models. (Same INST for all).
- Append the output of each model to its own Thread.
- Append the next IN prompt and generate again. Back to 2.
Actual generation for each model is implemented by an optional Callable with this signature
def gencall(model: Model, thread: Thread, genconf: GenConf) -> GenOut
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_list |
list[str]
|
List of IN messages to initialize Threads. |
required |
inst_text |
str
|
The common INST to use in all models. |
required |
model_names |
list[str]
|
A list of Models names. |
required |
gencall |
Optional[Callable]
|
Callable function that does the actual generation. Defaults to None, which will use a text generation default function. |
None
|
genconf |
Optional[GenConf]
|
Model generation configuration to use in models. Defaults to None, meaning default values. |
None
|
out_keys |
list[str]
|
A list with GenOut members to output. Defaults to ["text","dic", "value"]. |
['text', 'dic', 'value']
|
json_kwargs |
dict
|
JSON dumps() configuration. Defaults to {"indent": 2, "sort_keys": False, "ensure_ascii": False }. |
{'indent': 2, 'sort_keys': False, 'ensure_ascii': False}
|
Source code in sibila/multigen.py
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 |
|