Skip to content

Conversation

YorkieDev
Copy link
Contributor

Summary

Adds a --verbose flag to the lms chat CLI command to improve output visibility and help users debug model behavior in terminal use cases.

This directly addresses issue #238, where users requested better visibility into token-level stats when using lms chat.


Features

When --verbose is passed, the CLI logs:

  • Stop Reason
  • Tokens per Second
  • Time to First Token
  • GPU Layer Info
  • Prompt / Predicted / Total Token Counts

Example

lms chat -p "Hello world" --verbose

Copy link

github-actions bot commented Jun 17, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@YorkieDev
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@github-actions github-actions bot added the CLA signed Indicates if all contributors have signed the CLA label Jun 17, 2025
@yagil
Copy link
Member

yagil commented Jun 20, 2025

Thanks for the contribution! 🦾 Can you please show screenshots of what the output looks like when this is used?

@YorkieDev
Copy link
Contributor Author

image
image

Think it might need a little polishing to make it better for a release candidate and I need to get -v working but it feels like a good start @yagil

Copy link
Collaborator

@ryan-the-crayon ryan-the-crayon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Left a couple comments.

});
}

function displayVerboseStats(stats: any, logger: any) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please type those two parameters.

stats should be of type LLMPredictionStats (from @lmstudio/lms-shared-types)

logger should be of type SimpleLogger (from @lmstudio/lms-common)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actioned.

if (stats.tokensPerSecond !== undefined) {
logger.info(` Tokens/Second: ${stats.tokensPerSecond.toFixed(2)}`);
}
if (stats.numGpuLayers !== undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stat is currently not populated. Probably hide for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actioned.

short: "s",
description: "Custom system prompt to use for the chat",
}),
verbose: flag({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--verbose is one of the global flags in lms that enables debugging logging regarding connection, etc. Maybe --stats?

…ve emoji and GPU layers stat

- Add proper types for displayVerboseStats function parameters
- Rename --verbose flag to --stats to avoid conflict with global verbose flag
- Add short flag -t for --stats
- Remove emoji from stats output for cleaner appearance
- Hide numGpuLayers stat as it's not currently populated
Co-authored-by: Yagil Burowski <[email protected]>
}),
stats: flag({
long: "stats",
short: "t",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe no short flag for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actioned :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still here fyi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorted, sorry!

}

function displayVerboseStats(stats: LLMPredictionStats, logger: SimpleLogger) {
logger.info("\nPrediction Stats:");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's have 2 * \n here to create an empty buffer line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actioned :)

@ryan-the-crayon ryan-the-crayon merged commit 159dff7 into lmstudio-ai:main Jun 20, 2025
1 check passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 20, 2025
@ryan-the-crayon
Copy link
Collaborator

Merged. Expecting to ship this in 0.3.17+7. Thanks for the contribution!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

CLA signed Indicates if all contributors have signed the CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants