Formatron v0.4.9
Formatron empowers everyone to control the output format of language models with minimal overhead.
Loading...
Searching...
No Matches
formatron.integrations.vllm Namespace Reference

This module integrates the vllm library by providing convenience utilities. More...

Classes

class  FormattersLogitsProcessor
 Logit processor that uses formatters to mask batch logits. More...
 

Functions

kbnf.Vocabulary create_engine_vocabulary (AnyTokenizer tokenizer, typing.Optional[list[typing.Callable]] vocab_processors=None)
 Create a vocabulary for the KBNF engine.
 
FormattersLogitsProcessor create_formatters_logits_processor (LLM llm, typing.Sequence[FormatterBuilder|None]|FormatterBuilder formatter_builders, typing.Sequence[EngineGenerationConfig] configs=None, typing.Optional[list[typing.Callable]] vocab_processors=None)
 Create a formatter logits processor.
 

Detailed Description

This module integrates the vllm library by providing convenience utilities.

Function Documentation

◆ create_engine_vocabulary()

kbnf.Vocabulary formatron.integrations.vllm.create_engine_vocabulary ( AnyTokenizer tokenizer,
typing.Optional[list[typing.Callable]] vocab_processors = None )

Create a vocabulary for the KBNF engine.

Parameters
tokenizerThe tokenizer.
vocab_processorsList of callables with signature (token_to_char: typing.Dict[bytes, bytes])->None. Callables can be used to "unmangle" encoded characters to original characters. If None, processors will be auto-detected.

Definition at line 116 of file vllm.py.

◆ create_formatters_logits_processor()

FormattersLogitsProcessor formatron.integrations.vllm.create_formatters_logits_processor ( LLM llm,
typing.Sequence[FormatterBuilder | None] | FormatterBuilder formatter_builders,
typing.Sequence[EngineGenerationConfig] configs = None,
typing.Optional[list[typing.Callable]] vocab_processors = None )

Create a formatter logits processor.

Parameters
llmThe LLM.
formatter_buildersThe formatter builders.
configsThe engine generation configurations.
vocab_processorsList of callables with signature (token_to_char: typing.Dict[bytes, bytes])->None. Callables can be used to "unmangle" encoded characters to original characters. If None, processors will be auto-detected.

Definition at line 133 of file vllm.py.