input-pipeInput Transformer

gllm-inferencearrow-up-right | Tutorial: Input Transformer | API Referencearrow-up-right

Supported by: All LM invokers

What is Input Transformer?

Input transformer is a module that transforms the input messages of LM invoker before invocations. This is useful for specific scenarios where certain kind of message transformation is required.

By default, LM invokers use the IdentityInputTransformer, which returns the input messages as is. The input transformer can be set through the input_transformer parameter.

Let's take a look at the available input transformer options!

Identity Input Transformer

This input transformer performs identity transformation, meaning that it essentially performs no transformation to the input messages. This is the default input transformer for all LM invokers.

Example:

import asyncio
from gllm_inference.lm_invoker import OpenAILMInvoker
from gllm_inference.model import OpenAILM
from gllm_inference.schema import InputTransformerType

lm_invoker = OpenAILMInvoker(
    OpenAILM.GPT_5_NANO, 
    input_transformer=InputTransformerType.IDENTITY,  # Optional, as it is the default value
)

Filter Empty Input Transformer

This input transformer filters out any empty strings or whitespace only strings from the message contents. This is useful for models where empty strings are unsupported.

circle-exclamation

Example:

Last updated

Was this helpful?