Skip to content

Commit 4f09520

Browse files
hmellorepwalsh
authored andcommitted
Improve documentation of ModelConfig.try_get_generation_config to prevent future confusion (vllm-project#21526)
Signed-off-by: Harry Mellor <[email protected]>
1 parent 37724cd commit 4f09520

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

vllm/config.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,18 @@ def get_multimodal_config(self) -> "MultiModalConfig":
15751575
return self.multimodal_config
15761576

15771577
def try_get_generation_config(self) -> dict[str, Any]:
1578-
if self.generation_config in ("auto", "vllm"):
1578+
"""
1579+
This method attempts to retrieve the non-default values of the
1580+
generation config for this model.
1581+
1582+
The generation config can contain information about special tokens, as
1583+
well as sampling parameters. Which is why this method exists separately
1584+
to `get_diff_sampling_param`.
1585+
1586+
Returns:
1587+
A dictionary containing the non-default generation config.
1588+
"""
1589+
if self.generation_config in {"auto", "vllm"}:
15791590
config = try_get_generation_config(
15801591
self.hf_config_path or self.model,
15811592
trust_remote_code=self.trust_remote_code,
@@ -1594,13 +1605,18 @@ def try_get_generation_config(self) -> dict[str, Any]:
15941605

15951606
def get_diff_sampling_param(self) -> dict[str, Any]:
15961607
"""
1597-
This method returns a dictionary containing the parameters
1598-
that differ from the default sampling parameters. If
1599-
`generation_config` is `"vllm"`, an empty dictionary is returned.
1608+
This method returns a dictionary containing the non-default sampling
1609+
parameters with `override_generation_config` applied.
1610+
1611+
The default sampling parameters are:
1612+
1613+
- vLLM's neutral defaults if `self.generation_config="vllm"`
1614+
- the model's defaults if `self.generation_config="auto"`
1615+
- as defined in `generation_config.json` if
1616+
`self.generation_config="path/to/generation_config/dir"`
16001617
16011618
Returns:
1602-
dict[str, Any]: A dictionary with the differing sampling
1603-
parameters, if `generation_config` is `"vllm"` an empty dictionary.
1619+
A dictionary containing the non-default sampling parameters.
16041620
"""
16051621
if self.generation_config == "vllm":
16061622
config = {}

0 commit comments

Comments
 (0)