lmstudio-ai / lmstudio-ai/lmstudio-python

Add detokenize (tokens to text) method to Python SDK

Open
#156 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
875
Forks
166
PR merge metrics
No merged PRs in 30d

Description

Description:
The Python SDK currently provides a .tokenize() method to convert text into token IDs, but there is no .detokenize() (decode) method to convert token IDs back to text. This feature is important for chunking workflows, debugging custom inputs/outputs, and for compatibility with other token-based workflows (similar to Hugging Face's decode). Please consider adding .detokenize(token_ids) to allow round-trip conversion between text and token IDs.

Use Case:
- Splitting large text based on token count and reconstructing text for summarization or analysis.
- Making LM Studio SDK workflows more flexible and developer-friendly.

Thank you!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Python SDK's existing tokenize() method and reading how it converts text into token IDs. Add the corresponding detokenize(token_ids) entry point, then verify that tokenizing and detokenizing representative text supports the stated round-trip and chunking workflows.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.