nemo_evaluator.adapters.interceptors.reasoning_interceptor#

Reasoning interceptor that strips reasoning from responses and tracks reasoning information.

Module Contents#

Classes#

ResponseReasoningInterceptor

Adds reasoning information to responses and tracks reasoning metrics.

API#

class nemo_evaluator.adapters.interceptors.reasoning_interceptor.ResponseReasoningInterceptor(params: Params)[source]#

Bases: nemo_evaluator.adapters.types.ResponseInterceptor, nemo_evaluator.adapters.types.PostEvalHook

Adds reasoning information to responses and tracks reasoning metrics.

Tracks the following statistics:

  • Total responses processed

  • Responses with reasoning content

  • Reasoning completion status (started/finished)

  • Word counts for reasoning, original content, and updated content

  • Maximum reasoning length

  • Average reasoning and content lengths

Initialization

Initialize the reasoning interceptor.

Args: params: Configuration parameters

class Params(/, **data: Any)[source]#

Bases: nemo_evaluator.logging.BaseLoggingParams

Configuration parameters for reasoning interceptor.

Initialization

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

add_reasoning: bool#

‘Field(…)’

cache_dir: str#

‘Field(…)’

enable_caching: bool#

‘Field(…)’

enable_reasoning_tracking: bool#

‘Field(…)’

end_reasoning_token: str#

‘Field(…)’

include_if_not_finished: bool#

‘Field(…)’

logging_aggregated_stats_interval: int#

‘Field(…)’

migrate_reasoning_content: bool#

‘Field(…)’

start_reasoning_token: str | None#

‘Field(…)’

stats_file_saving_interval: int | None#

‘Field(…)’

add_reasoning: bool#

None

cache_dir: str | None#

None

enable_caching: bool#

None

enable_reasoning_tracking: bool#

None

end_reasoning_token: str#

None

include_if_not_finished: bool#

None

intercept_response(
resp: nemo_evaluator.adapters.types.AdapterResponse,
context: nemo_evaluator.adapters.types.AdapterGlobalContext,
) nemo_evaluator.adapters.types.AdapterResponse[source]#

Remove reasoning tokens from assistant message content in the response and track reasoning info.

logging_aggregated_stats_interval: int#

None

migrate_reasoning_content: bool#

None

post_eval_hook(
context: nemo_evaluator.adapters.types.AdapterGlobalContext,
) None[source]#

Write collected reasoning statistics to eval_factory_metrics.json.

start_reasoning_token: str | None#

None

stats_file_saving_interval: int | None#

None