Skip to content

Commit

Permalink
Adding default parameter for max_new_tokens in TransformersModel (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
matfrei authored Feb 13, 2025
1 parent a427c84 commit f3ee605
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/smolagents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,16 @@ def __init__(
model_id = default_model_id
logger.warning(f"`model_id`not provided, using this default tokenizer for token counts: '{model_id}'")
self.model_id = model_id

default_max_tokens = 5000
max_new_tokens = kwargs.get("max_new_tokens") or kwargs.get("max_tokens")
if not max_new_tokens:
kwargs["max_new_tokens"] = default_max_tokens
logger.warning(
f"`max_new_tokens` not provided, using this default value for `max_new_tokens`: {default_max_tokens}"
)
self.kwargs = kwargs

if device_map is None:
device_map = "cuda" if torch.cuda.is_available() else "cpu"
logger.info(f"Using device: {device_map}")
Expand Down

0 comments on commit f3ee605

Please sign in to comment.