{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/language-model-inversion","title":"Language Model Inversion","arxiv_id":"2311.13647","date":"2023-11-22","proceeding":null,"authors":["John X. Morris","Wenting Zhao","Justin T. Chiu","Vitaly Shmatikov","Alexander M. Rush"],"abstract":"Language models produce a distribution over the next token; can we use this information to recover the prompt tokens? We consider the problem of language model inversion and show that next-token probabilities contain a surprising amount of information about the preceding text. Often we can recover the text in cases where it is hidden from the user, motivating a method for recovering unknown prompts given only the model's current distribution output. We consider a variety of model access scenarios, and show how even without predictions for every token in the vocabulary we can recover the probability vector through search. On Llama-2 7b, our inversion method reconstructs prompts with a BLEU of $59$ and token-level F1 of $78$ and recovers $27\\%$ of prompts exactly. Code for reproducing all experiments is available at http://github.com/jxmorris12/vec2text.","url_abs":"https://arxiv.org/abs/2311.13647v1","url_pdf":"https://arxiv.org/pdf/2311.13647v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"language-model-inversion","repo_url":"https://github.com/jxmorris12/vec2text","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"NOASSERTION"}},{"paper_slug":"language-model-inversion","repo_url":"https://github.com/justinchiu/openlogprobs","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok"}}],"tasks":[{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"model","task_name":"model"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2311.13647","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2311.13647"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/justinchiu/openlogprobs","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/jxmorris12/vec2text","reach":{"status":"ok","spdx":"NOASSERTION"}}],"summary":{"ran":5},"by_repo_kind":{"official":{"samples":5,"ran":5,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":5,"samples":[{"code_sha256_prefix":"1c13cb7bbcec5b37","entry":"args_from_config","repo":"jxmorris12/vec2text","repo_kind":"official","path":"vec2text/analyze_utils.py","file_url":"https://github.com/jxmorris12/vec2text/blob/HEAD/vec2text/analyze_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1c13cb7bbcec5b37"}},{"code_sha256_prefix":"d1d22f33b80e6898","entry":"create_omi_ex","repo":"jxmorris12/vec2text","repo_kind":"official","path":"vec2text/data_helpers.py","file_url":"https://github.com/jxmorris12/vec2text/blob/HEAD/vec2text/data_helpers.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d1d22f33b80e6898"}},{"code_sha256_prefix":"041dd4c56f3a3a34","entry":"create_ompi_ex","repo":"jxmorris12/vec2text","repo_kind":"official","path":"vec2text/data_helpers.py","file_url":"https://github.com/jxmorris12/vec2text/blob/HEAD/vec2text/data_helpers.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"041dd4c56f3a3a34"}},{"code_sha256_prefix":"9ce3fa900ab6c176","entry":"load_results_from_folder","repo":"jxmorris12/vec2text","repo_kind":"official","path":"vec2text/analyze_utils.py","file_url":"https://github.com/jxmorris12/vec2text/blob/HEAD/vec2text/analyze_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9ce3fa900ab6c176"}},{"code_sha256_prefix":"025c70307306970e","entry":"retain_dataset_columns","repo":"jxmorris12/vec2text","repo_kind":"official","path":"vec2text/data_helpers.py","file_url":"https://github.com/jxmorris12/vec2text/blob/HEAD/vec2text/data_helpers.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"025c70307306970e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}