diff --git a/v0.4.9/.nojekyll b/v0.4.9/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/v0.4.9/RWKV_8py.html b/v0.4.9/RWKV_8py.html new file mode 100644 index 0000000..3b00f26 --- /dev/null +++ b/v0.4.9/RWKV_8py.html @@ -0,0 +1,170 @@ + + + +
+ + + + +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
Go to the source code of this file.
++Classes | |
class | formatron.integrations.RWKV.PIPELINE_ARGS |
A wrapper for the arguments of the pipeline of RWKV. More... | |
class | formatron.integrations.RWKV.PIPELINE |
A wrapper for the pipeline of RWKV. More... | |
+Namespaces | |
namespace | formatron |
namespace | formatron.integrations |
This subpackage contains integrations with other frameworks and libraries. | |
namespace | formatron.integrations.RWKV |
This module integrates the RWKV library by providing convenience utilities. | |
+Functions | |
kbnf.Vocabulary | formatron.integrations.RWKV.create_engine_vocabulary (str WORD_NAME, tokenizer) |
Create a vocabulary for the KBNF engine. | |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
Go to the source code of this file.
++Namespaces | |
namespace | formatron |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
▼Nformatron | |
▼Nconfig | Configuration classes for Formatron |
CEngineGenerationConfig | Configuration for how an KBNF engine should be used in text generation |
▼Nextractor | Extractors for extracting data from generated strings |
CChoiceExtractor | An extractor that uses multiple extractors to extract data |
CExtractor | An abstract extractor that extracts data from a string and offers its KBNF rules definition |
CLiteralExtractor | An extractor that extracts a literal string |
CNonterminalExtractor | An extractor that extracts data corresponding to a nonterminal |
CSubstringExtractor | An extractor that extracts a substring of a given string from the input string |
▼Nformats | This subpackage contains modules that operate with concrete formats, like json |
▼Njson | The module defines the JsonExtractor class, which is used to extract data from a string in JSON format |
CJsonExtractor | An extractor that loads json data to an object from a string |
▼Nregex | This module contains the RegexExtractor class, which is used to extract data using a regular expression |
CRegexComplementExtractor | An extractor that extracts data by matching a regex complement |
CRegexExtractor | An extractor that extracts a string using a regular expression |
▼Nformatter | This module contains the Formatter class and its related classes |
CFormatter | |
CFormatterBase | An abstract Formatter that enforces a format on the string generated by a language model |
CFormatterBuilder | A builder for creating a Formatter |
▼Nintegrations | This subpackage contains integrations with other frameworks and libraries |
▼Nexllamav2 | This module integrates the ExLlamaV2 library by providing convenience utilities |
CFormatterFilter | ExLlamaV2Filter that uses a formatter to mask logits |
▼NRWKV | This module integrates the RWKV library by providing convenience utilities |
CPIPELINE | A wrapper for the pipeline of RWKV |
CPIPELINE_ARGS | A wrapper for the arguments of the pipeline of RWKV |
▼Ntransformers | This module integrates the transformers library by providing convenience utilities |
CFormattersLogitsProcessor | Logit processor that uses formatters to mask batch logits |
▼Nvllm | This module integrates the vllm library by providing convenience utilities |
CFormattersLogitsProcessor | Logit processor that uses formatters to mask batch logits |
▼Nschemas | This subpackage contains modules that define schemas creation from various sources |
▼Ndict_inference | This module contains utilities for inferring schemas from dictionaries |
CFieldInfo | |
▼Njson_schema | This module contains utilities for creating schemas from JSON schemas |
CFieldInfo | |
▼Npydantic | A module that implements the Schema interface using pydantic |
CClassSchema | A wrapper for pydantic BaseModel that implements the Schema interface |
CFieldInfo | A wrapper for pydantic FieldInfo |
▼Nschema | This module contains the Schema abstract class and FieldInfo abstract class |
CFieldInfo | An abstract field info that describes a data field in a schema |
CSchema | An abstract schema that describes some data |
CSubstringOf | A metadata class that indicates that the field is a substring of the given string |
CTypeWithMetadata | A type with metadata |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.config.EngineGenerationConfig, including all inherited members.
+read_prompt | formatron.config.EngineGenerationConfig | static |
reset_at_beginning | formatron.config.EngineGenerationConfig | static |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
Configuration for how an KBNF engine should be used in text generation. + More...
++Static Public Attributes | |
bool | read_prompt = False |
Whether to accept the prompt tokens when a generation begins. | |
bool | reset_at_beginning = True |
Whether to reset the engine when a new generation begins. | |
Configuration for how an KBNF engine should be used in text generation.
+ + +
+
|
+ +static | +
+
|
+ +static | +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.extractor.ChoiceExtractor, including all inherited members.
+__init__(self, typing.Iterable[Extractor] choices, str capture_name, str nonterminal) | formatron.extractor.ChoiceExtractor | |
_choices | formatron.extractor.ChoiceExtractor | protected |
extract(self, str input_str) | formatron.extractor.ChoiceExtractor | |
kbnf_definition(self) | formatron.extractor.ChoiceExtractor |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
An extractor that uses multiple extractors to extract data. + More...
++Public Member Functions | |
__init__ (self, typing.Iterable[Extractor] choices, str capture_name, str nonterminal) | |
Initialize the choice extractor. | |
typing.Optional[tuple[str, typing.Any]] | extract (self, str input_str) |
Extract data from the input string using the first succeeding extractor. | |
Public Member Functions inherited from formatron.extractor.NonterminalExtractor | |
str | nonterminal (self) |
Get the nonterminal of the extractor. | |
str | kbnf_reference (self) |
Public Member Functions inherited from formatron.extractor.Extractor | |
__str__ (self) | |
typing.Optional[str] | capture_name (self) |
Get the name of the capture, or None if the extractor does not capture. | |
+Protected Attributes | |
_choices | |
Protected Attributes inherited from formatron.extractor.NonterminalExtractor | |
_nonterminal | |
Protected Attributes inherited from formatron.extractor.Extractor | |
_capture_name | |
Properties | |
str | kbnf_definition (self) |
An extractor that uses multiple extractors to extract data.
+It stops at the first succeeding extractor.
+ +Definition at line 194 of file extractor.py.
+formatron.extractor.ChoiceExtractor.__init__ | +( | +self, | +|
+ | + | typing.Iterable[Extractor] | choices, | +
+ | + | str | capture_name, | +
+ | + | str | nonterminal ) | +
Initialize the choice extractor.
+choices | The extractors to choose from. The order determines the extractors' priority. |
capture_name | The name of the capture, or None if the extractor does not capture. |
nonterminal | The nonterminal representing the extractor. |
Reimplemented from formatron.extractor.NonterminalExtractor.
+ +Definition at line 204 of file extractor.py.
+ +typing.Optional[tuple[str, typing.Any]] formatron.extractor.ChoiceExtractor.extract | +( | +self, | +|
+ | + | str | input_str ) | +
Extract data from the input string using the first succeeding extractor.
+input_str | The input string. |
None
if all extractors failed. Reimplemented from formatron.extractor.Extractor.
+ +Definition at line 216 of file extractor.py.
+ +str formatron.extractor.ChoiceExtractor.kbnf_definition | +( | +self | ) | ++ |
Reimplemented from formatron.extractor.Extractor.
+ +Definition at line 231 of file extractor.py.
+ +
+
|
+ +protected | +
Definition at line 206 of file extractor.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.extractor.Extractor, including all inherited members.
+__init__(self, typing.Optional[str] capture_name=None) | formatron.extractor.Extractor | |
__str__(self) | formatron.extractor.Extractor | |
_capture_name | formatron.extractor.Extractor | protected |
capture_name(self) | formatron.extractor.Extractor | |
extract(self, str input_str) | formatron.extractor.Extractor | |
kbnf_definition(self) | formatron.extractor.Extractor | |
kbnf_reference(self) | formatron.extractor.Extractor |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
An abstract extractor that extracts data from a string and offers its KBNF rules definition. + More...
++Public Member Functions | |
__init__ (self, typing.Optional[str] capture_name=None) | |
Initialize an extractor. | |
typing.Optional[tuple[str, typing.Any]] | extract (self, str input_str) |
Extract data from the input string, or None if the extraction failed. | |
str | kbnf_reference (self) |
__str__ (self) | |
str | kbnf_definition (self) |
+Protected Attributes | |
_capture_name | |
Properties | |
typing.Optional[str] | capture_name (self) |
Get the name of the capture, or None if the extractor does not capture. | |
An abstract extractor that extracts data from a string and offers its KBNF rules definition.
+ +Definition at line 14 of file extractor.py.
+formatron.extractor.Extractor.__init__ | +( | +self, | +|
+ | + | typing.Optional[str] | capture_name = None ) | +
Initialize an extractor.
+capture_name | The name of the capture, or None if the extractor does not capture. |
Reimplemented in formatron.extractor.ChoiceExtractor, formatron.extractor.LiteralExtractor, formatron.extractor.NonterminalExtractor, formatron.extractor.SubstringExtractor, formatron.formats.json.JsonExtractor, formatron.formats.regex.RegexComplementExtractor, and formatron.formats.regex.RegexExtractor.
+ +Definition at line 21 of file extractor.py.
+ +formatron.extractor.Extractor.__str__ | +( | +self | ) | ++ |
Definition at line 69 of file extractor.py.
+ +typing.Optional[str] formatron.extractor.Extractor.capture_name | +( | +self | ) | ++ |
Get the name of the capture, or None
if the extractor does not capture.
Definition at line 35 of file extractor.py.
+ +typing.Optional[tuple[str, typing.Any]] formatron.extractor.Extractor.extract | +( | +self, | +|
+ | + | str | input_str ) | +
Extract data from the input string, or None
if the extraction failed.
input_str | The input string. |
None
if the extraction failed. Reimplemented in formatron.extractor.ChoiceExtractor, formatron.extractor.LiteralExtractor, formatron.extractor.SubstringExtractor, formatron.formats.json.JsonExtractor, formatron.formats.regex.RegexComplementExtractor, and formatron.formats.regex.RegexExtractor.
+ +Definition at line 48 of file extractor.py.
+ +str formatron.extractor.Extractor.kbnf_definition | +( | +self | ) | ++ |
Reimplemented in formatron.extractor.ChoiceExtractor, formatron.extractor.LiteralExtractor, formatron.extractor.SubstringExtractor, formatron.formats.json.JsonExtractor, formatron.formats.regex.RegexComplementExtractor, and formatron.formats.regex.RegexExtractor.
+ +Definition at line 92 of file extractor.py.
+ +str formatron.extractor.Extractor.kbnf_reference | +( | +self | ) | ++ |
Reimplemented in formatron.extractor.LiteralExtractor, and formatron.extractor.NonterminalExtractor.
+ +Definition at line 67 of file extractor.py.
+ +
+
|
+ +protected | +
Definition at line 22 of file extractor.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.extractor.LiteralExtractor, including all inherited members.
+__init__(self, str literal) | formatron.extractor.LiteralExtractor | |
_literal | formatron.extractor.LiteralExtractor | protected |
extract(self, str input_str) | formatron.extractor.LiteralExtractor | |
kbnf_definition(self) | formatron.extractor.LiteralExtractor | |
kbnf_reference(self) | formatron.extractor.LiteralExtractor |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
An extractor that extracts a literal string. + More...
++Public Member Functions | |
__init__ (self, str literal) | |
Initialize the literal extractor. | |
typing.Optional[tuple[str, str]] | extract (self, str input_str) |
Extract the literal from the input string, or None if the literal is not found. | |
Public Member Functions inherited from formatron.extractor.Extractor | |
__str__ (self) | |
typing.Optional[str] | capture_name (self) |
Get the name of the capture, or None if the extractor does not capture. | |
+Protected Attributes | |
_literal | |
Protected Attributes inherited from formatron.extractor.Extractor | |
_capture_name | |
Properties | |
str | kbnf_reference (self) |
str | kbnf_definition (self) |
An extractor that extracts a literal string.
+ +Definition at line 143 of file extractor.py.
+formatron.extractor.LiteralExtractor.__init__ | +( | +self, | +|
+ | + | str | literal ) | +
Initialize the literal extractor.
+It never captures since capturing a literal is redundant.
+literal | The literal string to extract. |
Reimplemented from formatron.extractor.Extractor.
+ +Definition at line 151 of file extractor.py.
+ +typing.Optional[tuple[str, str]] formatron.extractor.LiteralExtractor.extract | +( | +self, | +|
+ | + | str | input_str ) | +
Extract the literal from the input string, or None
if the literal is not found.
Reimplemented from formatron.extractor.Extractor.
+ +Definition at line 158 of file extractor.py.
+ +str formatron.extractor.LiteralExtractor.kbnf_definition | +( | +self | ) | ++ |
Reimplemented from formatron.extractor.Extractor.
+ +Definition at line 185 of file extractor.py.
+ +str formatron.extractor.LiteralExtractor.kbnf_reference | +( | +self | ) | ++ |
Reimplemented from formatron.extractor.Extractor.
+ +Definition at line 172 of file extractor.py.
+ +
+
|
+ +protected | +
Definition at line 153 of file extractor.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.extractor.NonterminalExtractor, including all inherited members.
+__init__(self, str nonterminal, typing.Optional[str] capture_name=None) | formatron.extractor.NonterminalExtractor | |
_nonterminal | formatron.extractor.NonterminalExtractor | protected |
kbnf_reference(self) | formatron.extractor.NonterminalExtractor | |
nonterminal(self) | formatron.extractor.NonterminalExtractor |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
An extractor that extracts data corresponding to a nonterminal. + More...
++Public Member Functions | |
__init__ (self, str nonterminal, typing.Optional[str] capture_name=None) | |
Initialize the nonterminal extractor. | |
Public Member Functions inherited from formatron.extractor.Extractor | |
typing.Optional[tuple[str, typing.Any]] | extract (self, str input_str) |
Extract data from the input string, or None if the extraction failed. | |
__str__ (self) | |
str | kbnf_definition (self) |
typing.Optional[str] | capture_name (self) |
Get the name of the capture, or None if the extractor does not capture. | |
+Protected Attributes | |
_nonterminal | |
Protected Attributes inherited from formatron.extractor.Extractor | |
_capture_name | |
Properties | |
str | nonterminal (self) |
Get the nonterminal of the extractor. | |
str | kbnf_reference (self) |
An extractor that extracts data corresponding to a nonterminal.
+ +Definition at line 98 of file extractor.py.
+formatron.extractor.NonterminalExtractor.__init__ | +( | +self, | +|
+ | + | str | nonterminal, | +
+ | + | typing.Optional[str] | capture_name = None ) | +
Initialize the nonterminal extractor.
+ +Reimplemented from formatron.extractor.Extractor.
+ +Reimplemented in formatron.extractor.ChoiceExtractor, formatron.extractor.SubstringExtractor, formatron.formats.json.JsonExtractor, formatron.formats.regex.RegexComplementExtractor, and formatron.formats.regex.RegexExtractor.
+ +Definition at line 103 of file extractor.py.
+ +str formatron.extractor.NonterminalExtractor.kbnf_reference | +( | +self | ) | ++ |
Reimplemented from formatron.extractor.Extractor.
+ +Definition at line 134 of file extractor.py.
+ +str formatron.extractor.NonterminalExtractor.nonterminal | +( | +self | ) | ++ |
Get the nonterminal of the extractor.
+ +Definition at line 121 of file extractor.py.
+ +
+
|
+ +protected | +
Definition at line 106 of file extractor.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.extractor.SubstringExtractor, including all inherited members.
+__init__(self, str string, str capture_name, str nonterminal, *, bool extract_empty_substring=False) | formatron.extractor.SubstringExtractor | |
_string | formatron.extractor.SubstringExtractor | protected |
_suffix_automaton | formatron.extractor.SubstringExtractor | protected |
extract(self, str input_str) | formatron.extractor.SubstringExtractor | |
extract_empty_substring | formatron.extractor.SubstringExtractor | |
kbnf_definition(self) | formatron.extractor.SubstringExtractor |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
An extractor that extracts a substring of a given string from the input string. + More...
++Public Member Functions | |
__init__ (self, str string, str capture_name, str nonterminal, *, bool extract_empty_substring=False) | |
Initialize the substring extractor. | |
typing.Optional[tuple[str, str]] | extract (self, str input_str) |
Extract the longest substring of a given string from the input string. | |
Public Member Functions inherited from formatron.extractor.NonterminalExtractor | |
str | nonterminal (self) |
Get the nonterminal of the extractor. | |
str | kbnf_reference (self) |
Public Member Functions inherited from formatron.extractor.Extractor | |
__str__ (self) | |
typing.Optional[str] | capture_name (self) |
Get the name of the capture, or None if the extractor does not capture. | |
+Public Attributes | |
extract_empty_substring | |
+Protected Attributes | |
_suffix_automaton | |
_string | |
Protected Attributes inherited from formatron.extractor.NonterminalExtractor | |
_nonterminal | |
Protected Attributes inherited from formatron.extractor.Extractor | |
_capture_name | |
Properties | |
str | kbnf_definition (self) |
An extractor that extracts a substring of a given string from the input string.
+ +Definition at line 240 of file extractor.py.
+formatron.extractor.SubstringExtractor.__init__ | +( | +self, | +|
+ | + | str | string, | +
+ | + | str | capture_name, | +
+ | + | str | nonterminal, | +
+ | + | * | , | +
+ | + | bool | extract_empty_substring = False ) | +
Initialize the substring extractor.
+string | The string to extract. |
nonterminal | The nonterminal representing the extractor. |
capture_name | The name of the capture, or None if the extractor does not capture. |
extract_empty_substring | Whether to extract empty substring as a valid substring. |
Reimplemented from formatron.extractor.NonterminalExtractor.
+ +Definition at line 250 of file extractor.py.
+ +typing.Optional[tuple[str, str]] formatron.extractor.SubstringExtractor.extract | +( | +self, | +|
+ | + | str | input_str ) | +
Extract the longest substring of a given string from the input string.
+If extract_empty_substring is True, empty string is always a valid substring, so the returned string could be empty and None
will never be returned. Otherwise, empty string is not a valid substring, so the returned string could not be empty and None
will be returned if the input string does not contain the given string.
Reimplemented from formatron.extractor.Extractor.
+ +Definition at line 262 of file extractor.py.
+ +str formatron.extractor.SubstringExtractor.kbnf_definition | +( | +self | ) | ++ |
Reimplemented from formatron.extractor.Extractor.
+ +Definition at line 285 of file extractor.py.
+ +
+
|
+ +protected | +
Definition at line 253 of file extractor.py.
+ +
+
|
+ +protected | +
Definition at line 252 of file extractor.py.
+ +formatron.extractor.SubstringExtractor.extract_empty_substring | +
Definition at line 254 of file extractor.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.formats.json.JsonExtractor, including all inherited members.
+__init__(self, str nonterminal, typing.Optional[str] capture_name, schemas.schema.Schema|collections.abc.Sequence schema, typing.Callable[[str], schemas.schema.Schema] to_object) | formatron.formats.json.JsonExtractor | |
_rule_str | formatron.formats.json.JsonExtractor | protected |
_to_object | formatron.formats.json.JsonExtractor | protected |
extract(self, str input_str) | formatron.formats.json.JsonExtractor | |
kbnf_definition(self) | formatron.formats.json.JsonExtractor |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
An extractor that loads json data to an object from a string. + More...
++Public Member Functions | |
__init__ (self, str nonterminal, typing.Optional[str] capture_name, schemas.schema.Schema|collections.abc.Sequence schema, typing.Callable[[str], schemas.schema.Schema] to_object) | |
Create a json extractor from a given schema or a list of supported types. | |
typing.Optional[tuple[str, schemas.schema.Schema]] | extract (self, str input_str) |
Extract a schema instance from a string. | |
Public Member Functions inherited from formatron.extractor.NonterminalExtractor | |
str | nonterminal (self) |
Get the nonterminal of the extractor. | |
str | kbnf_reference (self) |
Public Member Functions inherited from formatron.extractor.Extractor | |
__str__ (self) | |
typing.Optional[str] | capture_name (self) |
Get the name of the capture, or None if the extractor does not capture. | |
+Protected Attributes | |
_to_object | |
_rule_str | |
Protected Attributes inherited from formatron.extractor.NonterminalExtractor | |
_nonterminal | |
Protected Attributes inherited from formatron.extractor.Extractor | |
_capture_name | |
Properties | |
kbnf_definition (self) | |
An extractor that loads json data to an object from a string.
+ + +formatron.formats.json.JsonExtractor.__init__ | +( | +self, | +|
+ | + | str | nonterminal, | +
+ | + | typing.Optional[str] | capture_name, | +
+ | + | schemas.schema.Schema|collections.abc.Sequence | schema, | +
+ | + | typing.Callable[[str], schemas.schema.Schema] | to_object ) | +
Create a json extractor from a given schema or a list of supported types.
+Currently, the following data types are supported: +
pattern=".*"
will allow '"' to appear in the json string which is forbidden by JSON standard.substring_of="abc\""
will allow '"' to appear in the json string which is forbidden by JSON standard. Subclasses of collections.abc.Mapping[str,T] and typing.Mapping[str,T] where T is a supported type,
minItems
, maxItems
, prefixItems
constraintsnonterminal | The nonterminal representing the extractor. |
capture_name | The capture name of the extractor, or None if the extractor does not capture. |
schema | The schema. |
to_object | A callable to convert the extracted string to a schema instance. |
Reimplemented from formatron.extractor.NonterminalExtractor.
+ + + +typing.Optional[tuple[str, schemas.schema.Schema]] formatron.formats.json.JsonExtractor.extract | +( | +self, | +|
+ | + | str | input_str ) | +
Extract a schema instance from a string.
+input_str | The input string to extract from. |
None
if extraction failed. Reimplemented from formatron.extractor.Extractor.
+ + + +formatron.formats.json.JsonExtractor.kbnf_definition | +( | +self | ) | ++ |
Reimplemented from formatron.extractor.Extractor.
+ + + +
+
|
+ +protected | +
+
|
+ +protected | +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.formats.regex.RegexComplementExtractor, including all inherited members.
+__init__(self, str regex, str capture_name, str nonterminal) | formatron.formats.regex.RegexComplementExtractor | |
_regex | formatron.formats.regex.RegexComplementExtractor | protected |
extract(self, str input_str) | formatron.formats.regex.RegexComplementExtractor | |
kbnf_definition(self) | formatron.formats.regex.RegexComplementExtractor |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
An extractor that extracts data by matching a regex complement. + More...
++Public Member Functions | |
__init__ (self, str regex, str capture_name, str nonterminal) | |
Initialize the regex complement extractor. | |
typing.Optional[tuple[str, str]] | extract (self, str input_str) |
Extract the data by matching a regex complement. | |
Public Member Functions inherited from formatron.extractor.NonterminalExtractor | |
str | nonterminal (self) |
Get the nonterminal of the extractor. | |
str | kbnf_reference (self) |
Public Member Functions inherited from formatron.extractor.Extractor | |
__str__ (self) | |
typing.Optional[str] | capture_name (self) |
Get the name of the capture, or None if the extractor does not capture. | |
+Protected Attributes | |
_regex | |
Protected Attributes inherited from formatron.extractor.NonterminalExtractor | |
_nonterminal | |
Protected Attributes inherited from formatron.extractor.Extractor | |
_capture_name | |
Properties | |
str | kbnf_definition (self) |
An extractor that extracts data by matching a regex complement.
+ + +formatron.formats.regex.RegexComplementExtractor.__init__ | +( | +self, | +|
+ | + | str | regex, | +
+ | + | str | capture_name, | +
+ | + | str | nonterminal ) | +
Initialize the regex complement extractor.
+ +Reimplemented from formatron.extractor.NonterminalExtractor.
+ + + +typing.Optional[tuple[str, str]] formatron.formats.regex.RegexComplementExtractor.extract | +( | +self, | +|
+ | + | str | input_str ) | +
Extract the data by matching a regex complement.
+Specifically, the string until the first character in the first match of the regex is extracted if there is a match, + or the entire string is extracted if there is no match. ++
Reimplemented from formatron.extractor.Extractor.
+ + + +str formatron.formats.regex.RegexComplementExtractor.kbnf_definition | +( | +self | ) | ++ |
Reimplemented from formatron.extractor.Extractor.
+ + + +
+
|
+ +protected | +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.formats.regex.RegexExtractor, including all inherited members.
+__init__(self, str regex, str capture_name, str nonterminal) | formatron.formats.regex.RegexExtractor | |
_regex | formatron.formats.regex.RegexExtractor | protected |
extract(self, str input_str) | formatron.formats.regex.RegexExtractor | |
kbnf_definition(self) | formatron.formats.regex.RegexExtractor |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
An extractor that extracts a string using a regular expression. + More...
++Public Member Functions | |
__init__ (self, str regex, str capture_name, str nonterminal) | |
Initialize the regex extractor. | |
typing.Optional[tuple[str, re.Match|None]] | extract (self, str input_str) |
Extract the string using the regular expression. | |
Public Member Functions inherited from formatron.extractor.NonterminalExtractor | |
str | nonterminal (self) |
Get the nonterminal of the extractor. | |
str | kbnf_reference (self) |
Public Member Functions inherited from formatron.extractor.Extractor | |
__str__ (self) | |
typing.Optional[str] | capture_name (self) |
Get the name of the capture, or None if the extractor does not capture. | |
+Protected Attributes | |
_regex | |
Protected Attributes inherited from formatron.extractor.NonterminalExtractor | |
_nonterminal | |
Protected Attributes inherited from formatron.extractor.Extractor | |
_capture_name | |
Properties | |
str | kbnf_definition (self) |
An extractor that extracts a string using a regular expression.
+ + +formatron.formats.regex.RegexExtractor.__init__ | +( | +self, | +|
+ | + | str | regex, | +
+ | + | str | capture_name, | +
+ | + | str | nonterminal ) | +
Initialize the regex extractor.
+regex | The regular expression for extraction. |
capture_name | The name of the capture, or None if the extractor does not capture. |
nonterminal | The nonterminal representing the extractor. |
Reimplemented from formatron.extractor.NonterminalExtractor.
+ + + +typing.Optional[tuple[str, re.Match | None]] formatron.formats.regex.RegexExtractor.extract | +( | +self, | +|
+ | + | str | input_str ) | +
Extract the string using the regular expression.
+Specifically, the first match(if any) of the regex pattern in the input string is returned.
+input_str | The input string. |
re.Match
object, or None
if the extraction failed. Reimplemented from formatron.extractor.Extractor.
+ + + +str formatron.formats.regex.RegexExtractor.kbnf_definition | +( | +self | ) | ++ |
Reimplemented from formatron.extractor.Extractor.
+ + + +
+
|
+ +protected | +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.formatter.Formatter, including all inherited members.
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+Public Member Functions | |
__init__ (self, list[Extractor] extractors, kbnf.Engine engine, typing.Callable[[list[int]], str] decode_callback, str grammar_str) | |
Initialize the formatter. | |
kbnf.AcceptTokenResult | accept_token (self, int token_id) |
Accept a token from the language model. | |
kbnf.AcceptTokenResult | accept_bytes (self, bytes _bytes) |
Accept a bytes object from the language model. | |
None | compute_allowed_tokens (self) |
Compute the allowed tokens based on the current state. | |
typing.Any | mask_logits (self, logits) |
Mask the logits based on the current state. | |
typing.Sequence[int] | get_allowed_tokens_since_last_computation (self) |
Get the allowed tokens since the last computation(in other words, the last call to compute_allowed_tokens ). | |
bool | is_completed (self) |
Check if the generation is completed. | |
None | reset (self) |
Reset the formatter to the initial state. | |
__str__ (self) | |
+Protected Member Functions | |
str | _obtain_accepted_output (self) |
None | _on_completion (self, str generated_output) |
Perform actions when the generation is completed. | |
+Protected Attributes | |
_extractors | |
_engine | |
_token_id_or_bytes | |
_decode_callback | |
_grammar_str | |
_captures | |
Properties | |
grammar_str (self) | |
Get the KBNF grammar string. | |
dict[str, typing.Any]|None | captures (self) |
Get the captures from the generated string. | |
Definition at line 112 of file formatter.py.
+formatron.formatter.Formatter.__init__ | +( | +self, | +|
+ | + | list[Extractor] | extractors, | +
+ | + | kbnf.Engine | engine, | +
+ | + | typing.Callable[[list[int]], str] | decode_callback, | +
+ | + | str | grammar_str ) | +
Initialize the formatter.
+extractors | The matchers to extract data from the generated string. |
engine | The KBNF engine to enforce the format. |
decode_callback | The callback to decode the token IDs to a string. |
grammar_str | The KBNF grammar string. |
Definition at line 122 of file formatter.py.
+ +formatron.formatter.Formatter.__str__ | +( | +self | ) | ++ |
Definition at line 262 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 155 of file formatter.py.
+ +
+
|
+ +protected | +
Perform actions when the generation is completed.
+ +Reimplemented from formatron.formatter.FormatterBase.
+ +Definition at line 209 of file formatter.py.
+ +kbnf.AcceptTokenResult formatron.formatter.Formatter.accept_bytes | +( | +self, | +|
+ | + | bytes | _bytes ) | +
Accept a bytes object from the language model.
+_bytes | The bytes object. |
Reimplemented from formatron.formatter.FormatterBase.
+ +Definition at line 184 of file formatter.py.
+ +kbnf.AcceptTokenResult formatron.formatter.Formatter.accept_token | +( | +self, | +|
+ | + | int | token_id ) | +
Accept a token from the language model.
+token_id | The token ID. |
Reimplemented from formatron.formatter.FormatterBase.
+ +Definition at line 147 of file formatter.py.
+ +dict[str, typing.Any] | None formatron.formatter.Formatter.captures | +( | +self | ) | ++ |
Get the captures from the generated string.
+Note that the captures are only available for one extractor if:
Captures are obtained by calling Extractor.extract
method on the generated string in the sequence of extractors appended to the formatter. Note that the previous extractors does not 'see' the semantics of the later extractors. For example, consider the following formatter: python @code f = FormatterBuilder() f.append_line(f"{f.regex('.*?', capture_name='a')}{f.regex('.*', capture_name='b')}") f = f.build() @endcode
The b
extractor will always corresponding to None
because the a
extractor will always extract the whole string. This behavior is different from what a typical regular expression engine would do!
Reimplemented from formatron.formatter.FormatterBase.
+ +Definition at line 252 of file formatter.py.
+ +None formatron.formatter.Formatter.compute_allowed_tokens | +( | +self | ) | ++ |
Compute the allowed tokens based on the current state.
+ +Reimplemented from formatron.formatter.FormatterBase.
+ +Definition at line 192 of file formatter.py.
+ +typing.Sequence[int] formatron.formatter.Formatter.get_allowed_tokens_since_last_computation | +( | +self | ) | ++ |
Get the allowed tokens since the last computation(in other words, the last call to compute_allowed_tokens
).
Reimplemented from formatron.formatter.FormatterBase.
+ +Definition at line 198 of file formatter.py.
+ +formatron.formatter.Formatter.grammar_str | +( | +self | ) | ++ |
Get the KBNF grammar string.
+ +Definition at line 142 of file formatter.py.
+ +bool formatron.formatter.Formatter.is_completed | +( | +self | ) | ++ |
Check if the generation is completed.
+This means the generation is ended by the engine. If the generation is ended by integration-specific stop conditions like max_new_tokens
, the generation is not considered completed by this method.
Reimplemented from formatron.formatter.FormatterBase.
+ +Definition at line 206 of file formatter.py.
+ +typing.Any formatron.formatter.Formatter.mask_logits | +( | +self, | +|
+ | + | logits ) | +
Mask the logits based on the current state.
+logits | The logits to mask. |
Reimplemented from formatron.formatter.FormatterBase.
+ +Definition at line 195 of file formatter.py.
+ +None formatron.formatter.Formatter.reset | +( | +self | ) | ++ |
Reset the formatter to the initial state.
+ +Reimplemented from formatron.formatter.FormatterBase.
+ +Definition at line 257 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 129 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 127 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 125 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 124 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 128 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 126 of file formatter.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.formatter.FormatterBase, including all inherited members.
+_on_completion(self, str generated_output) | formatron.formatter.FormatterBase | protected |
accept_bytes(self, bytes _bytes) | formatron.formatter.FormatterBase | |
accept_token(self, int token_id) | formatron.formatter.FormatterBase | |
captures(self) | formatron.formatter.FormatterBase | |
compute_allowed_tokens(self) | formatron.formatter.FormatterBase | |
get_allowed_tokens_since_last_computation(self) | formatron.formatter.FormatterBase | |
is_completed(self) | formatron.formatter.FormatterBase | |
mask_logits(self, logits) | formatron.formatter.FormatterBase | |
reset(self) | formatron.formatter.FormatterBase |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
An abstract Formatter that enforces a format on the string generated by a language model. + More...
++Public Member Functions | |
accept_token (self, int token_id) | |
Accept a token from the language model. | |
None | accept_bytes (self, bytes _bytes) |
Accept a bytes object from the language model. | |
None | compute_allowed_tokens (self) |
Compute the allowed tokens based on the current state. | |
typing.Any | mask_logits (self, logits) |
Mask the logits based on the current state. | |
typing.Sequence[int] | get_allowed_tokens_since_last_computation (self) |
Get the allowed tokens since the last computation(in other words, the last call to compute_allowed_tokens ). | |
bool | is_completed (self) |
Check if the generated string satisfies the format and hence the generation is completed. | |
dict[str, typing.Any|None] | captures (self) |
None | reset (self) |
Reset the formatter to the initial state. | |
+Protected Member Functions | |
None | _on_completion (self, str generated_output) |
Perform actions when the generation is completed. | |
An abstract Formatter that enforces a format on the string generated by a language model.
+ +Definition at line 24 of file formatter.py.
+
+
|
+ +protected | +
Perform actions when the generation is completed.
+ +Reimplemented in formatron.formatter.Formatter.
+ +Definition at line 80 of file formatter.py.
+ +None formatron.formatter.FormatterBase.accept_bytes | +( | +self, | +|
+ | + | bytes | _bytes ) | +
Accept a bytes object from the language model.
+_bytes | The bytes object. |
Reimplemented in formatron.formatter.Formatter.
+ +Definition at line 42 of file formatter.py.
+ +formatron.formatter.FormatterBase.accept_token | +( | +self, | +|
+ | + | int | token_id ) | +
Accept a token from the language model.
+token_id | The token ID. |
Reimplemented in formatron.formatter.Formatter.
+ +Definition at line 34 of file formatter.py.
+ +dict[str, typing.Any|None] formatron.formatter.FormatterBase.captures | +( | +self | ) | ++ |
Reimplemented in formatron.formatter.Formatter.
+ +Definition at line 98 of file formatter.py.
+ +None formatron.formatter.FormatterBase.compute_allowed_tokens | +( | +self | ) | ++ |
Compute the allowed tokens based on the current state.
+ +Reimplemented in formatron.formatter.Formatter.
+ +Definition at line 48 of file formatter.py.
+ +typing.Sequence[int] formatron.formatter.FormatterBase.get_allowed_tokens_since_last_computation | +( | +self | ) | ++ |
Get the allowed tokens since the last computation(in other words, the last call to compute_allowed_tokens
).
Reimplemented in formatron.formatter.Formatter.
+ +Definition at line 66 of file formatter.py.
+ +bool formatron.formatter.FormatterBase.is_completed | +( | +self | ) | ++ |
Check if the generated string satisfies the format and hence the generation is completed.
+ +Reimplemented in formatron.formatter.Formatter.
+ +Definition at line 72 of file formatter.py.
+ +typing.Any formatron.formatter.FormatterBase.mask_logits | +( | +self, | +|
+ | + | logits ) | +
Mask the logits based on the current state.
+logits | The logits to mask. |
Reimplemented in formatron.formatter.Formatter.
+ +Definition at line 58 of file formatter.py.
+ +None formatron.formatter.FormatterBase.reset | +( | +self | ) | ++ |
Reset the formatter to the initial state.
+ +Reimplemented in formatron.formatter.Formatter.
+ +Definition at line 104 of file formatter.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.formatter.FormatterBuilder, including all inherited members.
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
A builder for creating a Formatter. + More...
++Public Member Functions | |
__init__ (self) | |
Initialize the formatter builder. | |
None | append_line (self, str line) |
Append a line to the format. | |
None | append_multiline_str (self, str lines) |
Appends a multiline string to the format, preserving the first line's leading whitespaces and remove any common leading whitespaces from subsequent lines. | |
None | append_str (self, str string) |
Append a string to the format without any post-processing. | |
ChoiceExtractor | choose (self, *Extractor|str extractors, str capture_name=None) |
Create a choice extractor. | |
Extractor | extractor (self, typing.Callable[[str], Extractor] create_extractor) |
Create a custom extractor. | |
JsonExtractor | json (self, typing.Type[Schema]|collections.abc.Sequence schema, *, str capture_name=None) |
Create a JSON extractor. | |
RegexExtractor | regex (self, str regex, *, str capture_name=None) |
Create a regex extractor. | |
RegexComplementExtractor | regex_complement (self, str regex, *, str capture_name=None) |
Create a regex complement extractor. | |
Extractor | str (self, *, typing.Union[str, list[str]] stop=None, typing.Optional[str] capture_name=None) |
Create a string extractor. | |
Extractor | substr (self, str string, *, str capture_name=None, bool extract_empty_substring=False) |
Create a substring extractor. | |
Formatter | build (self, kbnf.Vocabulary vocabulary, typing.Callable[[list[int]], str] decode, kbnf.Config engine_config=None) |
Build a formatter from the builder. | |
+Protected Member Functions | |
_assert_capture_name_valid (self, str capture_name) | |
str | _create_nonterminal (self, str name) |
None | _add_capture_name (self, NonterminalExtractor extractor) |
_add_extractor (self, str extractor_type, typing.Callable[[str], Extractor] create_extractor) | |
+Protected Attributes | |
_counter | |
_main_rule | |
_rules | |
_capture_names | |
_nonterminal_to_extractor | |
_extractors | |
_instance_id | |
+Static Protected Attributes | |
int | _formatter_builder_counter |
A builder for creating a Formatter.
+ +Definition at line 274 of file formatter.py.
+formatron.formatter.FormatterBuilder.__init__ | +( | +self | ) | ++ |
Initialize the formatter builder.
+ +Definition at line 283 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 369 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 395 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 294 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 364 of file formatter.py.
+ +None formatron.formatter.FormatterBuilder.append_line | +( | +self, | +|
+ | + | str | line ) | +
Append a line to the format.
+Specifically, a newline character is appended to the input.
Note that if you need a literal `$`, you need to escape it by adding a backslash: `\\$`. ++
Definition at line 305 of file formatter.py.
+ +None formatron.formatter.FormatterBuilder.append_multiline_str | +( | +self, | +|
+ | + | str | lines ) | +
Appends a multiline string to the format, preserving the first line's leading whitespaces and remove any common leading whitespaces from subsequent lines.
+Note that tabs and spaces are both treated as whitespace, but they are not equal: the lines " hello" and "\\thello" are considered to have no common leading whitespace.
+Entirely blank lines are normalized to a newline character.
+Note that if you need a literal $
, you need to escape it by adding a backslash: \\$
.
Definition at line 319 of file formatter.py.
+ +None formatron.formatter.FormatterBuilder.append_str | +( | +self, | +|
+ | + | str | string ) | +
Append a string to the format without any post-processing.
+Note that if you need a literal `$`, you need to escape it by adding a backslash: `\\$`. ++
Definition at line 328 of file formatter.py.
+ +Formatter formatron.formatter.FormatterBuilder.build | +( | +self, | +|
+ | + | kbnf.Vocabulary | vocabulary, | +
+ | + | typing.Callable[[list[int]], str] | decode, | +
+ | + | kbnf.Config | engine_config = None ) | +
Build a formatter from the builder.
+The builder will not be consumed and can be used again.
+vocabulary | The KBNF engine vocabulary for the formatter. |
decode | The callback to decode the token IDs to a string. |
engine_config | The KBNF engine configuration. |
Definition at line 519 of file formatter.py.
+ +ChoiceExtractor formatron.formatter.FormatterBuilder.choose | +( | +self, | +|
+ | + | *Extractor | str | extractors, | +
+ | + | str | capture_name = None ) | +
Create a choice extractor.
+Check out the ChoiceExtractor docs for more details. +
extractors | The extractors to choose from. |
capture_name | The capture name of the extractor, or None if the extractor does not capture. |
Definition at line 385 of file formatter.py.
+ +Extractor formatron.formatter.FormatterBuilder.extractor | +( | +self, | +|
+ | + | typing.Callable[[str], Extractor] | create_extractor ) | +
Create a custom extractor.
+create_extractor | callable with signature (extractor_nonterminal: str)->Extractor that create the extractor. extractor_nonterminal is the auto-generated nonterminal reference for the extractor. |
Definition at line 411 of file formatter.py.
+ +JsonExtractor formatron.formatter.FormatterBuilder.json | +( | +self, | +|
+ | + | typing.Type[Schema]|collections.abc.Sequence | schema, | +
+ | + | * | , | +
+ | + | str | capture_name = None ) | +
Create a JSON extractor.
+Check out the JsonExtractor docs for more details.
+schema | The schema for extraction. |
capture_name | The capture name of the extractor, or None if the extractor does not capture. |
Definition at line 423 of file formatter.py.
+ +RegexExtractor formatron.formatter.FormatterBuilder.regex | +( | +self, | +|
+ | + | str | regex, | +
+ | + | * | , | +
+ | + | str | capture_name = None ) | +
Create a regex extractor.
+Check out the RegexExtractor docs for more details. +
regex | The regular expression for extraction. |
capture_name | The capture name of the extractor, or None if the extractor does not capture. |
Definition at line 449 of file formatter.py.
+ +RegexComplementExtractor formatron.formatter.FormatterBuilder.regex_complement | +( | +self, | +|
+ | + | str | regex, | +
+ | + | * | , | +
+ | + | str | capture_name = None ) | +
Create a regex complement extractor.
+This is roughly equivalent to 'extract a string that does not match the given regex anywhere'.
Check out the RegexComplementExtractor docs for more details. +
regex | The regular expression for extraction. |
capture_name | The capture name of the extractor, or None if the extractor does not capture. |
Definition at line 464 of file formatter.py.
+ +Extractor formatron.formatter.FormatterBuilder.str | +( | +self, | +|
+ | + | * | , | +
+ | + | typing.Union[str, list[str]] | stop = None, | +
+ | + | typing.Optional[str] | capture_name = None ) | +
Create a string extractor.
+The extractor will extract all text until(inclusive) one of the stop strings is encountered. +
stop | The strings for the extractors to stop at. They will be included in text generation and extraction. |
capture_name | The capture name of the extractor, or None if the extractor does not capture. |
Definition at line 479 of file formatter.py.
+ +Extractor formatron.formatter.FormatterBuilder.substr | +( | +self, | +|
+ | + | str | string, | +
+ | + | * | , | +
+ | + | str | capture_name = None, | +
+ | + | bool | extract_empty_substring = False ) | +
Create a substring extractor.
+The extractor will extract a substring of the input string. +
string | The string to extract. |
capture_name | The capture name of the extractor, or None if the extractor does not capture. |
extract_empty_substring | Whether to extract an empty substring as a valid substring. |
Definition at line 502 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 287 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 284 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 289 of file formatter.py.
+ +
+
|
+ +staticprotected | +
Definition at line 278 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 290 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 285 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 288 of file formatter.py.
+ +
+
|
+ +protected | +
Definition at line 286 of file formatter.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.integrations.RWKV.PIPELINE, including all inherited members.
+__init__(self, model, WORD_NAME, FormatterBuilder formatter_builder=None) | formatron.integrations.RWKV.PIPELINE | |
formatter | formatron.integrations.RWKV.PIPELINE | |
generate(self, ctx, token_count=100, args=PIPELINE_ARGS(), callback=None, state=None) | formatron.integrations.RWKV.PIPELINE |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
A wrapper for the pipeline of RWKV. + More...
++Public Member Functions | |
__init__ (self, model, WORD_NAME, FormatterBuilder formatter_builder=None) | |
generate (self, ctx, token_count=100, args=PIPELINE_ARGS(), callback=None, state=None) | |
+Public Attributes | |
formatter | |
formatron.integrations.RWKV.PIPELINE.__init__ | +( | +self, | +|
+ | + | model, | +|
+ | + | WORD_NAME, | +|
+ | + | FormatterBuilder | formatter_builder = None ) | +
formatron.integrations.RWKV.PIPELINE.generate | +( | +self, | +|
+ | + | ctx, | +|
+ | + | token_count = 100, | +|
+ | + | args = PIPELINE_ARGS(), | +|
+ | + | callback = None, | +|
+ | + | state = None ) | +
formatron.integrations.RWKV.PIPELINE.formatter | +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.integrations.RWKV.PIPELINE_ARGS, including all inherited members.
+__init__(self, temperature=1.0, top_p=0.2, top_k=0, alpha_frequency=0.2, alpha_presence=0.2, alpha_decay=0.996, token_ban=[], token_stop=[], chunk_len=256, engine_gen_config=EngineGenerationConfig()) | formatron.integrations.RWKV.PIPELINE_ARGS | |
engine_gen_config | formatron.integrations.RWKV.PIPELINE_ARGS |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
A wrapper for the arguments of the pipeline of RWKV. + More...
++Public Member Functions | |
__init__ (self, temperature=1.0, top_p=0.2, top_k=0, alpha_frequency=0.2, alpha_presence=0.2, alpha_decay=0.996, token_ban=[], token_stop=[], chunk_len=256, engine_gen_config=EngineGenerationConfig()) | |
+Public Attributes | |
engine_gen_config | |
formatron.integrations.RWKV.PIPELINE_ARGS.__init__ | +( | +self, | +|
+ | + | temperature = 1.0, | +|
+ | + | top_p = 0.2, | +|
+ | + | top_k = 0, | +|
+ | + | alpha_frequency = 0.2, | +|
+ | + | alpha_presence = 0.2, | +|
+ | + | alpha_decay = 0.996, | +|
+ | + | token_ban = [], | +|
+ | + | token_stop = [], | +|
+ | + | chunk_len = 256, | +|
+ | + | engine_gen_config = EngineGenerationConfig() ) | +
formatron.integrations.RWKV.PIPELINE_ARGS.engine_gen_config | +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.integrations.exllamav2.FormatterFilter, including all inherited members.
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
ExLlamaV2Filter that uses a formatter to mask logits. + More...
++Public Member Functions | |
__init__ (self, model, tokenizer, FormatterBase formatter, EngineGenerationConfig|None config=None) | |
bool | is_completed (self) |
Check if the formatter is completed. | |
"FormatterFilter" | clone (self, c=None) |
None | begin (self, str prefix_str) |
None | reset (self) |
feed (self, int token) | |
typing.Tuple[typing.Set[int], typing.Set[int]] | next_set (self) |
typing.Tuple[typing.Sequence[int], typing.Sequence[int]] | next (self) |
bool | use_background_worker (self) |
bool | can_mask_logits (self) |
prepare_logit_mask (self) | |
torch.Tensor | mask_logits (self, torch.Tensor logits) |
+Public Attributes | |
eos_logits | |
+Protected Attributes | |
_formatter | |
_config | |
_pass_tokens | |
Properties | |
dict[str, typing.Any] | formatter_captures (self) |
Get the captures of the formatter. | |
ExLlamaV2Filter that uses a formatter to mask logits.
+ +Definition at line 59 of file exllamav2.py.
+formatron.integrations.exllamav2.FormatterFilter.__init__ | +( | +self, | +|
+ | + | model, | +|
+ | + | tokenizer, | +|
+ | + | FormatterBase | formatter, | +
+ | + | EngineGenerationConfig|None | config = None ) | +
Definition at line 61 of file exllamav2.py.
+ +None formatron.integrations.exllamav2.FormatterFilter.begin | +( | +self, | +|
+ | + | str | prefix_str ) | +
Definition at line 89 of file exllamav2.py.
+ +bool formatron.integrations.exllamav2.FormatterFilter.can_mask_logits | +( | +self | ) | ++ |
Definition at line 129 of file exllamav2.py.
+ +"FormatterFilter" formatron.integrations.exllamav2.FormatterFilter.clone | +( | +self, | +|
+ | + | c = None ) | +
Definition at line 77 of file exllamav2.py.
+ +formatron.integrations.exllamav2.FormatterFilter.feed | +( | +self, | +|
+ | + | int | token ) | +
Definition at line 99 of file exllamav2.py.
+ +dict[str, typing.Any] formatron.integrations.exllamav2.FormatterFilter.formatter_captures | +( | +self | ) | ++ |
Get the captures of the formatter.
+ +Definition at line 155 of file exllamav2.py.
+ +bool formatron.integrations.exllamav2.FormatterFilter.is_completed | +( | +self | ) | ++ |
Check if the formatter is completed.
+ +Definition at line 74 of file exllamav2.py.
+ +torch.Tensor formatron.integrations.exllamav2.FormatterFilter.mask_logits | +( | +self, | +|
+ | + | torch.Tensor | logits ) | +
Definition at line 136 of file exllamav2.py.
+ +typing.Tuple[typing.Sequence[int], typing.Sequence[int]] formatron.integrations.exllamav2.FormatterFilter.next | +( | +self | ) | ++ |
Definition at line 115 of file exllamav2.py.
+ +typing.Tuple[typing.Set[int], typing.Set[int]] formatron.integrations.exllamav2.FormatterFilter.next_set | +( | +self | ) | ++ |
Definition at line 106 of file exllamav2.py.
+ +formatron.integrations.exllamav2.FormatterFilter.prepare_logit_mask | +( | +self | ) | ++ |
Definition at line 132 of file exllamav2.py.
+ +None formatron.integrations.exllamav2.FormatterFilter.reset | +( | +self | ) | ++ |
Definition at line 96 of file exllamav2.py.
+ +bool formatron.integrations.exllamav2.FormatterFilter.use_background_worker | +( | +self | ) | ++ |
Definition at line 125 of file exllamav2.py.
+ +
+
|
+ +protected | +
Definition at line 67 of file exllamav2.py.
+ +
+
|
+ +protected | +
Definition at line 64 of file exllamav2.py.
+ +
+
|
+ +protected | +
Definition at line 68 of file exllamav2.py.
+ +formatron.integrations.exllamav2.FormatterFilter.eos_logits | +
Definition at line 69 of file exllamav2.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.integrations.transformers.FormattersLogitsProcessor, including all inherited members.
+__call__(self, input_ids, scores) | formatron.integrations.transformers.FormattersLogitsProcessor | |
__init__(self, typing.Sequence[FormatterBase|None] formatters, int eos_token_id, typing.Sequence[EngineGenerationConfig]|None configs=None) | formatron.integrations.transformers.FormattersLogitsProcessor | |
_eos_token_id | formatron.integrations.transformers.FormattersLogitsProcessor | protected |
_formatters | formatron.integrations.transformers.FormattersLogitsProcessor | protected |
_last_input_id_length | formatron.integrations.transformers.FormattersLogitsProcessor | protected |
configs | formatron.integrations.transformers.FormattersLogitsProcessor | |
formatters_captures(self) | formatron.integrations.transformers.FormattersLogitsProcessor | |
is_completed(self) | formatron.integrations.transformers.FormattersLogitsProcessor | |
reset(self) | formatron.integrations.transformers.FormattersLogitsProcessor |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
Logit processor that uses formatters to mask batch logits. + More...
++Public Member Functions | |
__init__ (self, typing.Sequence[FormatterBase|None] formatters, int eos_token_id, typing.Sequence[EngineGenerationConfig]|None configs=None) | |
None | reset (self) |
list[bool|None] | is_completed (self) |
Check if the formatters are completed. | |
__call__ (self, input_ids, scores) | |
+Public Attributes | |
configs | |
+Protected Attributes | |
_formatters | |
_eos_token_id | |
_last_input_id_length | |
Properties | |
list[dict[str, typing.Any]|None] | formatters_captures (self) |
Get the captures of the formatters. | |
Logit processor that uses formatters to mask batch logits.
+ +Definition at line 74 of file transformers.py.
+formatron.integrations.transformers.FormattersLogitsProcessor.__init__ | +( | +self, | +|
+ | + | typing.Sequence[FormatterBase | None] | formatters, | +
+ | + | int | eos_token_id, | +
+ | + | typing.Sequence[EngineGenerationConfig] | None | configs = None ) | +
Definition at line 76 of file transformers.py.
+ +formatron.integrations.transformers.FormattersLogitsProcessor.__call__ | +( | +self, | +|
+ | + | input_ids, | +|
+ | + | scores ) | +
Definition at line 119 of file transformers.py.
+ +list[dict[str, typing.Any] | None] formatron.integrations.transformers.FormattersLogitsProcessor.formatters_captures | +( | +self | ) | ++ |
Get the captures of the formatters.
+Each element in the list corresponds to the captures of the formatter at the same index. If the formatter is None, the element is None.
+ +Definition at line 106 of file transformers.py.
+ +list[bool | None] formatron.integrations.transformers.FormattersLogitsProcessor.is_completed | +( | +self | ) | ++ |
Check if the formatters are completed.
+Each boolean in the list corresponds to the completion status of the formatter at the same index. If the formatter is None, the element is None.
+ +Definition at line 116 of file transformers.py.
+ +None formatron.integrations.transformers.FormattersLogitsProcessor.reset | +( | +self | ) | ++ |
Definition at line 87 of file transformers.py.
+ +
+
|
+ +protected | +
Definition at line 79 of file transformers.py.
+ +
+
|
+ +protected | +
Definition at line 78 of file transformers.py.
+ +
+
|
+ +protected | +
Definition at line 80 of file transformers.py.
+ +formatron.integrations.transformers.FormattersLogitsProcessor.configs | +
Definition at line 85 of file transformers.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.integrations.vllm.FormattersLogitsProcessor, including all inherited members.
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
Logit processor that uses formatters to mask batch logits. + More...
++Public Member Functions | |
__init__ (self, typing.Sequence[FormatterBase|None] formatters, int eos_token_id, typing.Sequence[EngineGenerationConfig]|None configs=None) | |
list[bool|None] | is_completed (self) |
Check if the formatters are completed. | |
None | reset (self) |
__call__ (self, prompt, generated_tokens, logits) | |
+Protected Member Functions | |
_to_next_batch_step (self) | |
+Protected Attributes | |
_formatters | |
_eos_token_id | |
_last_input_id_length | |
_configs | |
_iter | |
_debug_counter | |
Properties | |
list[dict[str, typing.Any]|None] | formatters_captures (self) |
Logit processor that uses formatters to mask batch logits.
+ + +formatron.integrations.vllm.FormattersLogitsProcessor.__init__ | +( | +self, | +|
+ | + | typing.Sequence[FormatterBase | None] | formatters, | +
+ | + | int | eos_token_id, | +
+ | + | typing.Sequence[EngineGenerationConfig] | None | configs = None ) | +
formatron.integrations.vllm.FormattersLogitsProcessor.__call__ | +( | +self, | +|
+ | + | prompt, | +|
+ | + | generated_tokens, | +|
+ | + | logits ) | +
+
|
+ +protected | +
list[dict[str, typing.Any] | None] formatron.integrations.vllm.FormattersLogitsProcessor.formatters_captures | +( | +self | ) | ++ |
list[bool | None] formatron.integrations.vllm.FormattersLogitsProcessor.is_completed | +( | +self | ) | ++ |
None formatron.integrations.vllm.FormattersLogitsProcessor.reset | +( | +self | ) | ++ |
+
|
+ +protected | +
+
|
+ +protected | +
+
|
+ +protected | +
+
|
+ +protected | +
+
|
+ +protected | +
+
|
+ +protected | +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.schemas.dict_inference.FieldInfo, including all inherited members.
+__init__(self, typing.Type annotation) | formatron.schemas.dict_inference.FieldInfo | |
_annotation | formatron.schemas.dict_inference.FieldInfo | protected |
annotation(self) | formatron.schemas.dict_inference.FieldInfo | |
required(self) | formatron.schemas.dict_inference.FieldInfo |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+Public Member Functions | |
__init__ (self, typing.Type annotation) | |
Initialize the field information. | |
Public Member Functions inherited from formatron.schemas.schema.FieldInfo |
+Protected Attributes | |
_annotation | |
Properties | |
typing.Type[typing.Any]|None | annotation (self) |
Get the type annotation of the field. | |
bool | required (self) |
Check if the field is required for the schema. | |
Definition at line 14 of file dict_inference.py.
+formatron.schemas.dict_inference.FieldInfo.__init__ | +( | +self, | +|
+ | + | typing.Type | annotation ) | +
Initialize the field information.
+annotation | The type annotation of the field. |
Definition at line 23 of file dict_inference.py.
+ +typing.Type[typing.Any] | None formatron.schemas.dict_inference.FieldInfo.annotation | +( | +self | ) | ++ |
Get the type annotation of the field.
+ +Reimplemented from formatron.schemas.schema.FieldInfo.
+ +Definition at line 37 of file dict_inference.py.
+ +bool formatron.schemas.dict_inference.FieldInfo.required | +( | +self | ) | ++ |
Check if the field is required for the schema.
+ +Reimplemented from formatron.schemas.schema.FieldInfo.
+ +Definition at line 53 of file dict_inference.py.
+ +
+
|
+ +protected | +
Definition at line 24 of file dict_inference.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.schemas.json_schema.FieldInfo, including all inherited members.
+__init__(self, typing.Type annotation, bool required) | formatron.schemas.json_schema.FieldInfo | |
_annotation | formatron.schemas.json_schema.FieldInfo | protected |
_required | formatron.schemas.json_schema.FieldInfo | protected |
annotation(self) | formatron.schemas.json_schema.FieldInfo | |
required(self) | formatron.schemas.json_schema.FieldInfo |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+Public Member Functions | |
__init__ (self, typing.Type annotation, bool required) | |
Initialize the field information. | |
Public Member Functions inherited from formatron.schemas.schema.FieldInfo |
+Protected Attributes | |
_annotation | |
_required | |
Properties | |
typing.Type[typing.Any]|None | annotation (self) |
Get the type annotation of the field. | |
bool | required (self) |
Check if the field is required for the schema. | |
Definition at line 18 of file json_schema.py.
+formatron.schemas.json_schema.FieldInfo.__init__ | +( | +self, | +|
+ | + | typing.Type | annotation, | +
+ | + | bool | required ) | +
Initialize the field information.
+annotation | The type annotation of the field. |
required | Whether the field is required for the schema. |
Definition at line 28 of file json_schema.py.
+ +typing.Type[typing.Any] | None formatron.schemas.json_schema.FieldInfo.annotation | +( | +self | ) | ++ |
Get the type annotation of the field.
+ +Reimplemented from formatron.schemas.schema.FieldInfo.
+ +Definition at line 43 of file json_schema.py.
+ +bool formatron.schemas.json_schema.FieldInfo.required | +( | +self | ) | ++ |
Check if the field is required for the schema.
+ +Reimplemented from formatron.schemas.schema.FieldInfo.
+ +Definition at line 59 of file json_schema.py.
+ +
+
|
+ +protected | +
Definition at line 29 of file json_schema.py.
+ +
+
|
+ +protected | +
Definition at line 30 of file json_schema.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.schemas.pydantic.ClassSchema, including all inherited members.
+fields(cls) | formatron.schemas.pydantic.ClassSchema | |
from_json(cls, str _json) | formatron.schemas.pydantic.ClassSchema |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
A wrapper for pydantic BaseModel that implements the Schema interface. + More...
+Class Methods | |
typing.Dict[str, typing.Any] | fields (cls) |
Get the fields of the schema. | |
"ClassSchema" | from_json (cls, str _json) |
Create a ClassSchema from a JSON string. | |
+Additional Inherited Members | |
Public Member Functions inherited from formatron.schemas.schema.Schema |
A wrapper for pydantic BaseModel that implements the Schema interface.
+ +Definition at line 73 of file pydantic.py.
+typing.Dict[str, typing.Any] formatron.schemas.pydantic.ClassSchema.fields | +( | +cls | ) | ++ |
Get the fields of the schema.
+ +Reimplemented from formatron.schemas.schema.Schema.
+ +Definition at line 84 of file pydantic.py.
+ +"ClassSchema" formatron.schemas.pydantic.ClassSchema.from_json | +( | +cls, | +|
+ | + | str | _json ) | +
Create a ClassSchema from a JSON string.
+ +Reimplemented from formatron.schemas.schema.Schema.
+ +Definition at line 103 of file pydantic.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.schemas.pydantic.FieldInfo, including all inherited members.
+__init__(self, pydantic.fields.FieldInfo field) | formatron.schemas.pydantic.FieldInfo | |
__repr__(self) | formatron.schemas.pydantic.FieldInfo | |
__str__(self) | formatron.schemas.pydantic.FieldInfo | |
_annotation | formatron.schemas.pydantic.FieldInfo | protected |
_field | formatron.schemas.pydantic.FieldInfo | protected |
annotation(self) | formatron.schemas.pydantic.FieldInfo | |
required(self) | formatron.schemas.pydantic.FieldInfo |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
A wrapper for pydantic FieldInfo. + More...
++Public Member Functions | |
__init__ (self, pydantic.fields.FieldInfo field) | |
Initialize the field information. | |
__repr__ (self) | |
__str__ (self) | |
Public Member Functions inherited from formatron.schemas.schema.FieldInfo |
+Protected Attributes | |
_field | |
_annotation | |
Properties | |
typing.Type[typing.Any]|None | annotation (self) |
Get the type annotation of the field. | |
bool | required (self) |
Check if the field is required for the schema. | |
A wrapper for pydantic FieldInfo.
+ +Definition at line 19 of file pydantic.py.
+formatron.schemas.pydantic.FieldInfo.__init__ | +( | +self, | +|
+ | + | pydantic.fields.FieldInfo | field ) | +
Initialize the field information.
+ +Definition at line 25 of file pydantic.py.
+ +formatron.schemas.pydantic.FieldInfo.__repr__ | +( | +self | ) | ++ |
Definition at line 63 of file pydantic.py.
+ +formatron.schemas.pydantic.FieldInfo.__str__ | +( | +self | ) | ++ |
Definition at line 66 of file pydantic.py.
+ +typing.Type[typing.Any] | None formatron.schemas.pydantic.FieldInfo.annotation | +( | +self | ) | ++ |
Get the type annotation of the field.
+ +Reimplemented from formatron.schemas.schema.FieldInfo.
+ +Definition at line 45 of file pydantic.py.
+ +bool formatron.schemas.pydantic.FieldInfo.required | +( | +self | ) | ++ |
Check if the field is required for the schema.
+ +Reimplemented from formatron.schemas.schema.FieldInfo.
+ +Definition at line 58 of file pydantic.py.
+ +
+
|
+ +protected | +
Definition at line 27 of file pydantic.py.
+ +
+
|
+ +protected | +
Definition at line 26 of file pydantic.py.
+ +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.schemas.schema.FieldInfo, including all inherited members.
+annotation(self) | formatron.schemas.schema.FieldInfo | |
required(self) | formatron.schemas.schema.FieldInfo |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
An abstract field info that describes a data field in a schema. + More...
+Properties | |
typing.Type[typing.Any]|None | annotation (self) |
Get the type annotation of the field. | |
bool | required (self) |
Check if the field is required for the schema. | |
An abstract field info that describes a data field in a schema.
+ + +typing.Type[typing.Any] | None formatron.schemas.schema.FieldInfo.annotation | +( | +self | ) | ++ |
Get the type annotation of the field.
+ +Reimplemented in formatron.schemas.dict_inference.FieldInfo, formatron.schemas.json_schema.FieldInfo, and formatron.schemas.pydantic.FieldInfo.
+ + + +bool formatron.schemas.schema.FieldInfo.required | +( | +self | ) | ++ |
Check if the field is required for the schema.
+ +Reimplemented in formatron.schemas.dict_inference.FieldInfo, formatron.schemas.json_schema.FieldInfo, and formatron.schemas.pydantic.FieldInfo.
+ + + +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.schemas.schema.Schema, including all inherited members.
+fields(cls) | formatron.schemas.schema.Schema | |
from_json(cls, str json) | formatron.schemas.schema.Schema |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
An abstract schema that describes some data. + More...
+Class Methods | |
dict[str, FieldInfo] | fields (cls) |
Get the fields of the schema. | |
"Schema" | from_json (cls, str json) |
Create a schema from a JSON string. | |
dict[str, FieldInfo] formatron.schemas.schema.Schema.fields | +( | +cls | ) | ++ |
Get the fields of the schema.
+ +Reimplemented in formatron.schemas.pydantic.ClassSchema.
+ + + +"Schema" formatron.schemas.schema.Schema.from_json | +( | +cls, | +|
+ | + | str | json ) | +
Create a schema from a JSON string.
+ +Reimplemented in formatron.schemas.pydantic.ClassSchema.
+ + + +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
A metadata class that indicates that the field is a substring of the given string. + More...
+A metadata class that indicates that the field is a substring of the given string.
+ + +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
This is the complete list of members for formatron.schemas.schema.TypeWithMetadata, including all inherited members.
+__init__(self, typing.Type[typing.Any] type, dict[str, typing.Any]|None metadata) | formatron.schemas.schema.TypeWithMetadata | |
_metadata | formatron.schemas.schema.TypeWithMetadata | protected |
_type | formatron.schemas.schema.TypeWithMetadata | protected |
metadata(self) | formatron.schemas.schema.TypeWithMetadata | |
type(self) | formatron.schemas.schema.TypeWithMetadata |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
A type with metadata. + More...
++Public Member Functions | |
__init__ (self, typing.Type[typing.Any] type, dict[str, typing.Any]|None metadata) | |
+Protected Attributes | |
_type | |
_metadata | |
Properties | |
typing.Type[typing.Any] | type (self) |
Get the type of the type with metadata. | |
dict[str, typing.Any]|None | metadata (self) |
Get the metadata of the type with metadata. | |
formatron.schemas.schema.TypeWithMetadata.__init__ | +( | +self, | +|
+ | + | typing.Type[typing.Any] | type, | +
+ | + | dict[str, typing.Any]|None | metadata ) | +
dict[str, typing.Any]|None formatron.schemas.schema.TypeWithMetadata.metadata | +( | +self | ) | ++ |
typing.Type[typing.Any] formatron.schemas.schema.TypeWithMetadata.type | +( | +self | ) | ++ |
+
|
+ +protected | +
+
|
+ +protected | +
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
Go to the source code of this file.
++Classes | |
class | formatron.config.EngineGenerationConfig |
Configuration for how an KBNF engine should be used in text generation. More... | |
+Namespaces | |
namespace | formatron |
namespace | formatron.config |
Configuration classes for Formatron. | |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
Go to the source code of this file.
++Classes | |
class | formatron.schemas.dict_inference.FieldInfo |
+Namespaces | |
namespace | formatron |
namespace | formatron.schemas |
This subpackage contains modules that define schemas creation from various sources. | |
namespace | formatron.schemas.dict_inference |
This module contains utilities for inferring schemas from dictionaries. | |
+Functions | |
Type[Any] | formatron.schemas.dict_inference._infer_type (Any value) |
typing.Type[schemas.schema.Schema] | formatron.schemas.dict_inference.infer_mapping (collections.abc.Mapping[str, Any] mapping) |
Recursively infer a schema from a mapping. | |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+Files | |
__init__.py | |
json.py | |
regex.py | |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+Files | |
__init__.py | |
dict_inference.py | |
json_schema.py | |
pydantic.py | |
schema.py | |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+Directories | |
formatron | |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+Files | |
__init__.py | |
exllamav2.py | |
RWKV.py | |
transformers.py | |
utils.py | |
vllm.py | |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+Directories | |
formats | |
integrations | |
schemas | |
+Files | |
__init__.py | |
config.py | |
extractor.py | |
formatter.py | |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
Go to the source code of this file.
++Classes | |
class | formatron.integrations.exllamav2.FormatterFilter |
ExLlamaV2Filter that uses a formatter to mask logits. More... | |
+Namespaces | |
namespace | formatron |
namespace | formatron.integrations |
This subpackage contains integrations with other frameworks and libraries. | |
namespace | formatron.integrations.exllamav2 |
This module integrates the ExLlamaV2 library by providing convenience utilities. | |
+Functions | |
kbnf.Vocabulary | formatron.integrations.exllamav2.create_engine_vocabulary (ExLlamaV2Tokenizer tokenizer, typing.Optional[list[typing.Callable]] vocab_processors=None) |
Create a vocabulary for the KBNF engine. | |
ExLlamaV2Filter | formatron.integrations.exllamav2.create_formatter_filter (ExLlamaV2 model, ExLlamaV2Tokenizer tokenizer, FormatterBuilder formatter_builder, EngineGenerationConfig engine_config=None, typing.Optional[list[typing.Callable]] vocab_processors=None) |
Create a formatter filter for the ExLlamaV2 engine. | |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
Go to the source code of this file.
++Classes | |
class | formatron.extractor.Extractor |
An abstract extractor that extracts data from a string and offers its KBNF rules definition. More... | |
class | formatron.extractor.NonterminalExtractor |
An extractor that extracts data corresponding to a nonterminal. More... | |
class | formatron.extractor.LiteralExtractor |
An extractor that extracts a literal string. More... | |
class | formatron.extractor.ChoiceExtractor |
An extractor that uses multiple extractors to extract data. More... | |
class | formatron.extractor.SubstringExtractor |
An extractor that extracts a substring of a given string from the input string. More... | |
+Namespaces | |
namespace | formatron |
namespace | formatron.extractor |
Extractors for extracting data from generated strings. | |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
▼ src | |
▼ formatron | |
▼ formats | |
__init__.py | |
json.py | |
regex.py | |
▼ integrations | |
__init__.py | |
exllamav2.py | |
RWKV.py | |
transformers.py | |
utils.py | |
vllm.py | |
▼ schemas | |
__init__.py | |
dict_inference.py | |
json_schema.py | |
pydantic.py | |
schema.py | |
__init__.py | |
config.py | |
extractor.py | |
formatter.py |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
Go to the source code of this file.
++Namespaces | |
namespace | formatron |
namespace | formatron.formats |
This subpackage contains modules that operate with concrete formats, like json. | |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
Go to the source code of this file.
++Classes | |
class | formatron.formatter.FormatterBase |
An abstract Formatter that enforces a format on the string generated by a language model. More... | |
class | formatron.formatter.Formatter |
class | formatron.formatter.FormatterBuilder |
A builder for creating a Formatter. More... | |
+Namespaces | |
namespace | formatron |
namespace | formatron.formatter |
This module contains the Formatter class and its related classes. | |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
▼Cabc.ABC | |
▼Cformatron.extractor.Extractor | An abstract extractor that extracts data from a string and offers its KBNF rules definition |
Cformatron.extractor.LiteralExtractor | An extractor that extracts a literal string |
▼Cformatron.extractor.NonterminalExtractor | An extractor that extracts data corresponding to a nonterminal |
Cformatron.extractor.ChoiceExtractor | An extractor that uses multiple extractors to extract data |
Cformatron.extractor.SubstringExtractor | An extractor that extracts a substring of a given string from the input string |
Cformatron.formats.json.JsonExtractor | An extractor that loads json data to an object from a string |
Cformatron.formats.regex.RegexComplementExtractor | An extractor that extracts data by matching a regex complement |
Cformatron.formats.regex.RegexExtractor | An extractor that extracts a string using a regular expression |
▼Cformatron.formatter.FormatterBase | An abstract Formatter that enforces a format on the string generated by a language model |
Cformatron.formatter.Formatter | |
▼Cformatron.schemas.schema.FieldInfo | An abstract field info that describes a data field in a schema |
Cformatron.schemas.dict_inference.FieldInfo | |
Cformatron.schemas.json_schema.FieldInfo | |
Cformatron.schemas.pydantic.FieldInfo | A wrapper for pydantic FieldInfo |
▼Cformatron.schemas.schema.Schema | An abstract schema that describes some data |
Cformatron.schemas.pydantic.ClassSchema | A wrapper for pydantic BaseModel that implements the Schema interface |
Cformatron.config.EngineGenerationConfig | Configuration for how an KBNF engine should be used in text generation |
Cformatron.formatter.FormatterBuilder | A builder for creating a Formatter |
Cformatron.integrations.vllm.FormattersLogitsProcessor | Logit processor that uses formatters to mask batch logits |
▼Crwkv.utils.PIPELINE | |
Cformatron.integrations.RWKV.PIPELINE | A wrapper for the pipeline of RWKV |
▼Crwkv.utils.PIPELINE_ARGS | |
Cformatron.integrations.RWKV.PIPELINE_ARGS | A wrapper for the arguments of the pipeline of RWKV |
Cformatron.schemas.schema.SubstringOf | A metadata class that indicates that the field is a substring of the given string |
Cformatron.schemas.schema.TypeWithMetadata | A type with metadata |
▼CBaseModel | |
Cformatron.schemas.pydantic.ClassSchema | A wrapper for pydantic BaseModel that implements the Schema interface |
▼CExLlamaV2Filter | |
Cformatron.integrations.exllamav2.FormatterFilter | ExLlamaV2Filter that uses a formatter to mask logits |
▼CLogitsProcessor | |
Cformatron.integrations.transformers.FormattersLogitsProcessor | Logit processor that uses formatters to mask batch logits |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+
Go to the source code of this file.
++Namespaces | |
namespace | formatron |
namespace | formatron.integrations |
This subpackage contains integrations with other frameworks and libraries. | |
+ Formatron v0.4.9
+
+
+
+ Formatron empowers everyone to control the output format of language models with minimal overhead.
+ |
+