GraphCanon updated 2w · GitHub synced 2w
Decision brief
vec2text is a Python library for inverting deep text embeddings back to readable text.
Good fit when
- Reverse-engineer text from sentence embeddings accurately
- Explore semantic content of embeddings with high fidelity reconstructions
Avoid when
- When requiring embedding-to-text inversion from models not compatible with vec2text's pre-trained or custom model pipelines.
- For applications that require real-time performance, as the process of inverting embeddings can be computationally intensive.
Observed Jul 12, 2026 · Source: enrich:decision_facts
Verify the decision
Maintenance and security
Full trust report- Maintenance
- Slowing (216d since push)
- As of 2w
- Provenance
- Not a fork · Organization account
- As of 2w
- Security (OSV)
- No criticals
- As of 1mo
Public GitHub metadata and optional OSV scans. Signals, not a guarantee. Trust methodology.
Install
pip install vec2text PyPISimilar tools
Same-category neighbours. No typed graph edges are catalogued for this tool yet.
Evidence and technical details
Sourced facts, taxonomy, compatibility claims, README excerpt, and machine-readable endpoints.
Overview
vec2text is a Python library that provides functionality for inverting deep text embeddings back into human-readable text.
Capability facts
- Languages
- python
Source: github.language · Aug 1, 2026
Categories
Compatibility
Sourced claims from the README excerpt - not unsourced marketing copy.
Tags
README
vec2text
This library contains code for doing text embedding inversion. We can train various architectures that reconstruct text sequences from embeddings as well as run pre-trained models. This repository contains code for the papers "Text Embeddings Reveal (Almost) As Much As Text" and "Language Model Inversion".
To get started, install this on PyPI:
pip install vec2text
Development
If you're training a model you'll need to set up nltk:
import nltk
nltk.download('punkt')
Before pushing any code, please run precommit:
pre-commit run --all
Usage
The library can be used to embed text and then invert it, or invert directly from embeddings. First you'll need to construct a Corrector object which wraps the necessary models, embedders, and tokenizers:
Load a model via load_pretrained_corrector
corrector = vec2text.load_pretrained_corrector("text-embedding-ada-002")
Load a model via load_corrector
If you have trained you own custom models using vec2text, you can load them in using the load_corrector function.
inversion_model = vec2text.models.InversionModel.from_pretrained("jxm/gtr__nq__32")
corrector_model = vec2text.models.CorrectorEncoderModel.from_pretrained("jxm/gtr__nq__32__correct")
corrector = vec2text.load_corrector(inversion_model, corrector_model)
Both vec2text.models.InversionModel and vec2text.models.CorrectorEncoderModel classes inherit transformers.PreTrainedModel therefore you can pass in a Hugging Face model name or path to a local directory.
Invert text with invert_strings
vec2text.invert_strings(
[
"Jack Morris is a PhD student at Cornell Tech in New York City",
"It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity"
],
corrector=corrector,
)
['Morris is a PhD student at Cornell University in New York City',
'It was the age of incredulity, the age of wisdom, the age of apocalypse, the age of apocalypse, it was the age of faith, the age of best faith, it was the age of foolishness']
By default, this will make a single guess (using the hypothesizer). For better results, you can make multiple steps:
vec2text.invert_strings(
[
"Jack Morris is a PhD student at Cornell Tech in New York City",
"It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity"
],
corrector=corrector,
num_steps=20,
)
['Jack Morris is a PhD student in tech at Cornell University in New York City',
'It was the best time of the epoch, it was the worst time of the epoch, it was the best time of the age of wisdom, it was the age of incredulity, it was the age of betrayal']
And for even better results, you can increase the size of the search space by setting sequence_beam_width to a positive integer:
vec2text.invert_strings(
[
"Jack Morris is a PhD student at Cornell Tech in New York City",
"It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity"
],
corrector=corrector,
num_steps=20,
sequence_beam_width=4,
)
['Jack Morris is a PhD student at Cornell Tech in New York City',
'It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity']
Note that this technique has to store sequence_beam_width * sequence_beam_width hypotheses at each step, so
For agents
This page has a .md twin and JSON over the API.