deepseek-ai / deepseek-ai/DeepSeek-Coder

DEFAULT_MAX_NEW_TOKENS = 1024 != MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))

Open
#603 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
24.3k
Forks
2.9k
PR merge metrics
No merged PRs in 30d

Description

Looking at app.py under demo folder I see the following code:
MAX_MAX_NEW_TOKENS = 2048
DEFAULT_MAX_NEW_TOKENS = 1024

MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))

This could lead to an overflow issue.

Implications
This discrepancy might lead to:
Truncated output: If the model generates tokens beyond the max_new_tokens limit, the output might be truncated, potentially losing important information.
Inconsistent behavior: Depending on the model's implementation, exceeding max_new_tokens might cause errors or unexpected behavior.

I suggest a mitigation strategy:
To address this issue:
Increase DEFAULT_MAX_NEW_TOKENS: Consider raising the default value to match or exceed MAX_INPUT_TOKEN_LENGTH.
Dynamic max_new_tokens calculation: Calculate max_new_tokens based on input length to ensure sufficient tokens for generation.
Input length validation: Validate input length before processing and raise an error if it exceeds MAX_INPUT_TOKEN_LENGTH.

Contributor guide

No contributing guide indexed for this repository

Research direction

Read demo/app.py, starting with the MAX_NEW_TOKENS and MAX_INPUT_TOKEN_LENGTH definitions and the generation path that uses them. Trace how input length and max_new_tokens are handled; done means the selected limits are consistent and oversized inputs or generated outputs have defined behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.