Skip to main content

id-phrase

Generate human-readable, LLM-friendly identifier phrases like sharp-spirited-existence-052e.

Installation

pip install id-phrase

Or from source:

git clone https://github.com/afourney/id-phrase
cd id-phrase
uv venv --python python3.11
source venv/bin/activate
uv sync --all-extras

Usage

from id_phrase import generate_id_phrase

print(generate_id_phrase())
# → sharp-spirited-existence-052e

# Override the template:
print(generate_id_phrase("A-N-B"))
# → sharp-existence-a3

# Or supply a list — one is chosen uniformly at random per call:
print(generate_id_phrase(["A-A-N", "A-V-N"]))

Why?

LLMs struggle to accurately copy high-entropy strings like UUIDs and hex identifiers. When asked to reference or reproduce an identifier like a90d0d7d-9c5a-44de-8d3c-5b0da661de7c, models make typos, truncate values, or hallucinate entirely different IDs.

The root cause is tokenization: a UUID consumes ~23 tokens because hex characters and hyphens don't align with the natural language patterns tokenizers are optimized for. Word-based identifiers, by contrast, are tokenized as whole familiar words, making them far more reliably reproduced.

This library generates identifiers in the style of sharp-spirited-existence-052e — a short random hex suffix for uniqueness, combined with natural English words that LLMs handle well.

The evidence

  • BAML Blog — Using UUIDs in prompts is bad (Oct 2025): Benchmarked Claude Haiku on aggregation tasks with 200 items across 100 class IDs. The UUID approach produced 29–68 errors per run; the integer-remapped approach produced only 5–7 errors. Opus 4 reached 100% accuracy with integer IDs but only 80% with UUIDs.
  • Nikhil Verma — LLMs as Unreliable Narrators: Dealing with UUID Hallucination (Nov 2025): Recommends using human-readable identifiers like titles instead of UUIDs in enums, noting that "UUIDs are harder for models to reproduce accurately because they're random. Titles are memorable patterns." Also available on DEV Community.
  • Floris Fok — The Hidden Cost of UUIDs in AI Prompts (Prosus AI Tech Blog): Shows that a single UUID consumes ~23 tokens due to tokenizer inefficiency with hex strings and hyphens, and demonstrates up to 95.6% token reduction by replacing UUIDs with compact identifiers.

The common recommendation across all three sources is the same: if you can avoid giving the model a UUID, do so. id-phrase lets you generate identifiers that are unique enough for practical use and reliable enough for LLMs to work with accurately.

Templates

generate_id_phrase() accepts a template string (or a list of templates to pick from at random). Each letter in the template expands to a random component; any other character is kept verbatim as a separator.

Letter Expands to
A a random adjective (e.g. corporate)
V a random verb — present participle (e.g. asking)
N a random noun (e.g. poetry)
B a random byte as two hex digits (00–ff)

So A-A-N-BB expands to {adjective}-{adjective}-{noun}-{hex4} — e.g. sharp-spirited-existence-052e. Use multiple Bs back-to-back to widen the hex suffix (BB = 4 hex chars / 2 bytes, BBB = 6, etc.).

The default is ["A-A-N-BB", "A-V-N-BB"]: one of the two is chosen uniformly at random per call, which roughly doubles the phrase space at no readability cost. The hex suffix adds uniqueness guarantees while keeping the human-readable words as the primary identifier the LLM interacts with.

License

MIT

Metadata

Release files for id-phrase 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for id-phrase 0.0.2
File Size Uploaded Provenance Actions
id_phrase-0.0.2.tar.gz 29.8 kB Without provenance Details for id_phrase-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for id-phrase 0.0.2
File Interpreter ABI Platform Actions
id_phrase-0.0.2-py3-none-any.whl Python 3 none any Details for id_phrase-0.0.2-py3-none-any.whl

Total release size: 46.8 kB

Release files / id_phrase-0.0.2.tar.gz

Download URL id_phrase-0.0.2.tar.gz
Size 29.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e1c8134b6cee99b65359d966b2e7ec71d8ac32685447342bc296a145998c0aca
BLAKE2b-256 checksum
How to use checksums
965042c84602f633ecf71c1a1fdc52dd348a341e55f213f00dfba7598934fa0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / id_phrase-0.0.2-py3-none-any.whl

Download URL id_phrase-0.0.2-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98882f34a105c415077fd941999404155247402ce08b92d73eca3cf89096d5c5
BLAKE2b-256 checksum
How to use checksums
67dd4e51635009ce2b18792180f3ac5c98450e1778ea2225c6bd47a5e64c76f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for id-phrase 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page