Skip to content

vllm.config.watermarking

Classes:

WatermarkConfig

Configuration for text watermark generation.

Attributes:

  • algorithm (WatermarkingAlgorithm) –

    Algorithm used to watermark generated text.

  • context_width (int) –

    Number of prior output tokens used by the watermark PRF.

  • key (int) –

    Secret key used to watermark generated text.

  • prf (WatermarkPRFName) –

    Pseudorandom function used by the watermarking algorithm.

Source code in vllm/config/watermarking.py
@config
class WatermarkConfig:
    """Configuration for text watermark generation."""

    key: int = Field(ge=0, repr=False, exclude=True)
    """Secret key used to watermark generated text."""
    algorithm: WatermarkingAlgorithm = "gumbel"
    """Algorithm used to watermark generated text."""
    context_width: int = Field(default=4, ge=1)
    """Number of prior output tokens used by the watermark PRF."""
    prf: WatermarkPRFName = "philox"
    """Pseudorandom function used by the watermarking algorithm."""

    @model_validator(mode="after")
    def validate_key(self) -> Self:
        if self.key > 2**64 - 1:
            raise ValueError("philox keys must fit in 64 bits")
        if self.algorithm == "gumbel":
            logger.warning_once(
                "Single-key Gumbel-max watermarking may increase the frequency of "
                "degenerate generations, including repetition loops.",
                scope="global",
            )
        return self

    @property
    def supports_speculative_decoding(self) -> bool:
        return _SPECULATIVE_DECODING_SUPPORT[self.algorithm]

algorithm = 'gumbel' class-attribute instance-attribute

Algorithm used to watermark generated text.

context_width = Field(default=4, ge=1) class-attribute instance-attribute

Number of prior output tokens used by the watermark PRF.

key = Field(ge=0, repr=False, exclude=True) class-attribute instance-attribute

Secret key used to watermark generated text.

prf = 'philox' class-attribute instance-attribute

Pseudorandom function used by the watermarking algorithm.