generator
Encapsulate a model and an output type into a reusable object.
AsyncBlackBoxGenerator
Asynchronous generator for which we don't control constrained generation.
The output type provided is not compiled into a logits processor, but is instead directly passed on to the model.
Source code in outlines/generator.py
__call__(prompt, **inference_kwargs)
async
Generate a response from the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
Any
|
The prompt to use to generate a response. |
required |
**inference_kwargs
|
Additional keyword arguments to pass to the model. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The response generated by the model. |
Source code in outlines/generator.py
__init__(model, output_type)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
AsyncBlackBoxModel
|
An instance of an Outlines model. |
required |
output_type
|
Optional[Any]
|
The output type that will be used to constrain the generation. |
required |
Source code in outlines/generator.py
stream(prompt, **inference_kwargs)
async
Generate a stream of responses from the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
Any
|
The prompt to use to generate a response. |
required |
**inference_kwargs
|
Additional keyword arguments to pass to the model. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The response generated by the model. |
Source code in outlines/generator.py
BlackBoxGenerator
Synchronous generator for which we don't control constrained generation.
The output type provided is not compiled into a logits processor, but is instead directly passed on to the model.
Source code in outlines/generator.py
__call__(prompt, **inference_kwargs)
Generate a response from the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
Any
|
The prompt to use to generate a response. |
required |
**inference_kwargs
|
Additional keyword arguments to pass to the model. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The response generated by the model. |
Source code in outlines/generator.py
__init__(model, output_type)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
BlackBoxModel
|
An instance of an Outlines model. |
required |
output_type
|
Optional[Any]
|
The output type that will be used to constrain the generation. |
required |
Source code in outlines/generator.py
stream(prompt, **inference_kwargs)
Generate a stream of responses from the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
Any
|
The prompt to use to generate a response. |
required |
**inference_kwargs
|
Additional keyword arguments to pass to the model. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The response generated by the model. |
Source code in outlines/generator.py
SteerableGenerator
Represents a generator for which we control constrained generation.
The generator is responsible for building and storing the logits processor (which can be quite expensive to build), and then passing it to the model when the generator is called.
The argument defining constrained generation can be of 2 types associated
to different methods to create an instance of the generator:
- output_type
(through __init__
): an output type as defined in the
outlines.types
module
- processor
(through from_processor
): an already built logits processor
as defined in the outlines.processors
module
The 2 parameters are mutually exclusive.
Source code in outlines/generator.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
__call__(prompt, **inference_kwargs)
Generate a response from the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
Any
|
The prompt to use to generate a response. |
required |
**inference_kwargs
|
Additional keyword arguments to pass to the model. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The response generated by the model. |
Source code in outlines/generator.py
__init__(model, output_type)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
SteerableModel
|
An instance of an Outlines model. |
required |
output_type
|
Optional[Any]
|
The output type expressed as a Python type |
required |
Source code in outlines/generator.py
from_processor(model, processor)
classmethod
Create a generator from a logits processor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
SteerableModel
|
An instance of an Outlines model. |
required |
processor
|
OutlinesLogitsProcessor
|
An instance of an OutlinesLogitsProcessor. |
required |
Source code in outlines/generator.py
stream(prompt, **inference_kwargs)
Generate a stream of responses from the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
Any
|
The prompt to use to generate a response. |
required |
**inference_kwargs
|
Additional keyword arguments to pass to the model. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The response generated by the model. |
Source code in outlines/generator.py
Generator(model, output_type=None, *, processor=None)
Create a generator for the given model and output parameters.
The 2 parameters output_type and processor are mutually exclusive. The parameters processor is only supported for SteerableModel instances (typically local models) and is intended to be only used by advanced users.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Union[Model, AsyncModel]
|
An instance of an Outlines model. |
required |
output_type
|
Optional[Any]
|
The output type expressed as a Python type or a type defined in the outlines.types.dsl module. |
None
|
processor
|
Optional[OutlinesLogitsProcessor]
|
An instance of an OutlinesLogitsProcessor. |
None
|
Returns:
Type | Description |
---|---|
Union[SteerableGenerator, BlackBoxGenerator, AsyncBlackBoxGenerator]
|
A generator instance. |