base
Base class for all backends.
BaseBackend
Bases: ABC
Base class for all backends.
The subclasses must implement methods that create a logits processor from a JSON schema, regex, CFG or FSM.
Source code in outlines/backends/base.py
get_cfg_logits_processor(grammar)
abstractmethod
Create a logits processor from a context-free grammar.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grammar
|
str
|
The context-free grammar to create a logits processor from. |
required |
Returns:
Type | Description |
---|---|
LogitsProcessorType
|
The logits processor. |
Source code in outlines/backends/base.py
get_fsm_logits_processor(fsm)
abstractmethod
Create a logits processor from an interegular FSM.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fsm
|
FSM
|
The interegular FSM to create a logits processor from. |
required |
Returns:
Type | Description |
---|---|
LogitsProcessorType
|
The logits processor. |
Source code in outlines/backends/base.py
get_json_schema_logits_processor(json_schema)
abstractmethod
Create a logits processor from a JSON schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_schema
|
str
|
The JSON schema to create a logits processor from. |
required |
Returns:
Type | Description |
---|---|
LogitsProcessorType
|
The logits processor. |
Source code in outlines/backends/base.py
get_regex_logits_processor(regex)
abstractmethod
Create a logits processor from a regex.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
regex
|
str
|
The regex to create a logits processor from. |
required |
Returns:
Type | Description |
---|---|
LogitsProcessorType
|
The logits processor. |