Skip to content

fix: prevent prompt overflow#157

Merged
rangehow merged 2 commits intomainfrom
fix/prompt-length
Jul 11, 2025
Merged

fix: prevent prompt overflow#157
rangehow merged 2 commits intomainfrom
fix/prompt-length

Conversation

@rangehow
Copy link
Collaborator

The previous logic for truncation by length was too coarse-grained, failing to account for the extra characters used in various connections such as chat templates, templates, headers, and lists. Additionally, it did not consider the measurement discrepancies between different tokenizers (e.g., Qwen and GPT-4o can differ by up to 2k tokens in some cases). To address all these issues, we have proposed a preliminary solution.

We introduced a more refined, albeit more cumbersome, length budget allocation. At the same time, we allow users to pass a Hugging Face tokenizer via GraphRAG parameters to serve as the metric for token counting.

close #146

@rangehow rangehow merged commit 0cea71b into main Jul 11, 2025
1 check failed
@rangehow rangehow deleted the fix/prompt-length branch July 11, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

32768 tokens问题

1 participant