π Constrainers#
- class text_machina.src.constrainers.base.Constrainer[source]#
Bases:
ABC
Base class for constrainers.
A constrainer is any kind of class that infers something from a dataset and constrains the generation parameters according to that. For instance, length constrainers, that automatically infer the length and return maximum or minimum number of tokens accordingly.
- class text_machina.src.constrainers.length.LengthConstrainer(lengths, provider, min_tokens=10, max_tokens=512)[source]#
Bases:
Constrainer
,ABC
Base class for length constrainers to compute automatically the number of tokens to generate.
- class text_machina.src.constrainers.length.MeanLengthConstrainer(lengths, provider, min_tokens=10, max_tokens=512)[source]#
Bases:
LengthConstrainer
Constrainer within one std radius of the mean of a list of numbers
- class text_machina.src.constrainers.length.MedianLengthConstrainer(lengths, provider, min_tokens=10, max_tokens=512)[source]#
Bases:
LengthConstrainer
Constrainer within one std radius of the median of a list of numbers