resolve_repetition_penalty (fun_asr_nano/vllm_utils.py)

FunASR · funasr/models/fun_asr_nano/vllm_utils.py · python · MIT
ai, tag:embed-classified

Utility to adjust repetition penalty for vLLM prompt-embed mode.

# Source: https://github.com/modelscope/FunASR | License: MIT | Copyright 2025 FunASR
# Provided via justclaw.it.com; keep this notice with the code.
"""Helpers shared by the Fun-ASR-Nano vLLM serving paths.

Kept dependency-free (standard library only) so it can be imported and unit
tested without a CUDA device or a vLLM installation.
"""

import logging

logger = logging.getLogger("funasr.fun_asr_nano.vllm")

# A repetition penalty of 1.0 is the identity value, i.e. "no penalty".
NEUTRAL_REPETITION_PENALTY = 1.0

# Warn only once per process so streaming/batch loops do not spam the log.
_warned_prompt_embeds = False


def resolve_repetition_penalty(repetition_penalty, *, prompt_embeds=True):
    """Return a repetition penalty that is safe for the requested vLLM mode.

    Fun-ASR-Nano fe

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key