Skip to content

Calculate Accurate Prompt Tokens for Chat Completions in vLLM Client #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vivekk16 opened this issue Mar 31, 2025 · 2 comments
Open

Comments

@vivekk16
Copy link
Contributor

Identify and resolve discrepancies in prompt token calculation for chat completion requests in the vLLM client. Currently, there's a consistent mismatch between the actual usage reported by vLLM server and estimated token count (~100–150 additional tokens) through custom tokenizer.

This issue will track improvements separately from the PR #43 to avoid scope creep.

@vivekk16
Copy link
Contributor Author

vivekk16 commented Apr 2, 2025

Kindly assign this to me.
@SachinVarghese I'd appreciate your inputs on this implementation.

@SachinVarghese
Copy link
Contributor

Sounds good @vivekk16

One of the other ideas here would be to convert the current tokenizer component to a more specific token counter component. This way we can have different kinds of token counters - based on API response and configuration - and simplify the vllm client code that can be extended to other model clients. As an example,

class CustomTokenCounter:
    def __init__(self):
        pass

    def count_tokens(self, api_type: APIType, input:str, output:str) -> (input_token_count int, output_token_count int):
        pass

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

No branches or pull requests

2 participants