{"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/watermarking-text-generated-by-black-box","title":"Watermarking Text Generated by Black-Box Language Models","arxiv_id":"2305.08883","date":"2023-05-14","proceeding":null,"authors":["Xi Yang","Kejiang Chen","Weiming Zhang","Chang Liu","Yuang Qi","Jie Zhang","Han Fang","Nenghai Yu"],"abstract":"LLMs now exhibit human-like skills in various fields, leading to worries about misuse. Thus, detecting generated text is crucial. However, passive detection methods are stuck in domain specificity and limited adversarial robustness. To achieve reliable detection, a watermark-based method was proposed for white-box LLMs, allowing them to embed watermarks during text generation. The method involves randomly dividing the model vocabulary to obtain a special list and adjusting the probability distribution to promote the selection of words in the list. A detection algorithm aware of the list can identify the watermarked text. However, this method is not applicable in many real-world scenarios where only black-box language models are available. For instance, third-parties that develop API-based vertical applications cannot watermark text themselves because API providers only supply generated text and withhold probability distributions to shield their commercial interests. To allow third-parties to autonomously inject watermarks into generated text, we develop a watermarking framework for black-box language model usage scenarios. Specifically, we first define a binary encoding function to compute a random binary encoding corresponding to a word. The encodings computed for non-watermarked text conform to a Bernoulli distribution, wherein the probability of a word representing bit-1 being approximately 0.5. To inject a watermark, we alter the distribution by selectively replacing words representing bit-0 with context-based synonyms that represent bit-1. A statistical test is then used to identify the watermark. Experiments demonstrate the effectiveness of our method on both Chinese and English datasets. Furthermore, results under re-translation, polishing, word deletion, and synonym substitution attacks reveal that it is arduous to remove the watermark without compromising the original semantics.","url_abs":"https://arxiv.org/abs/2305.08883v1","url_pdf":"https://arxiv.org/pdf/2305.08883v1.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":"watermarking-text-generated-by-black-box","repo_url":"https://github.com/kiode/text_watermark_language_models","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"adversarial-robustness","task_name":"Adversarial Robustness"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"specificity","task_name":"Specificity"},{"task_slug":"text-generation","task_name":"Text Generation"}],"methods":[{"method_slug":"aware","method_name":"AWARE"},{"method_slug":"test","method_name":"Test"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2305.08883","atlas_url":"https://app.syntology.ai/?focus=2305.08883","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2305.08883"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+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/kiode/text_watermark_language_models","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"unverified":7},"by_repo_kind":{"official":{"samples":7,"ran":0,"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":0,"samples":[{"code_sha256_prefix":"6faa0fe832f7f3cd","entry":"binary_encoding_function","repo":"kiode/text_watermark_language_models","repo_kind":"official","path":"models/watermark_faster.py","file_url":"https://github.com/kiode/text_watermark_language_models/blob/HEAD/models/watermark_faster.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"6faa0fe832f7f3cd"}},{"code_sha256_prefix":"3d3d2a7f0e46342a","entry":"cut_sent","repo":"kiode/text_watermark_language_models","repo_kind":"official","path":"models/watermark_faster.py","file_url":"https://github.com/kiode/text_watermark_language_models/blob/HEAD/models/watermark_faster.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"3d3d2a7f0e46342a"}},{"code_sha256_prefix":"70a2b707d9af6700","entry":"is_subword","repo":"kiode/text_watermark_language_models","repo_kind":"official","path":"models/watermark_faster.py","file_url":"https://github.com/kiode/text_watermark_language_models/blob/HEAD/models/watermark_faster.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"70a2b707d9af6700"}},{"code_sha256_prefix":"0baba2baaa6449b4","entry":"precise_watermark_detect","repo":"kiode/text_watermark_language_models","repo_kind":"official","path":"demo_CLI.py","file_url":"https://github.com/kiode/text_watermark_language_models/blob/HEAD/demo_CLI.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"0baba2baaa6449b4"}},{"code_sha256_prefix":"4b580a882bcab7d4","entry":"preprocess","repo":"kiode/text_watermark_language_models","repo_kind":"official","path":"DeepTextMark/dataset.py","file_url":"https://github.com/kiode/text_watermark_language_models/blob/HEAD/DeepTextMark/dataset.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4b580a882bcab7d4"}},{"code_sha256_prefix":"668a7ae303f1448d","entry":"watermark_embed_demo","repo":"kiode/text_watermark_language_models","repo_kind":"official","path":"demo_CLI.py","file_url":"https://github.com/kiode/text_watermark_language_models/blob/HEAD/demo_CLI.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"668a7ae303f1448d"}},{"code_sha256_prefix":"287fadd38bc70b9c","entry":"watermark_extract","repo":"kiode/text_watermark_language_models","repo_kind":"official","path":"demo_CLI.py","file_url":"https://github.com/kiode/text_watermark_language_models/blob/HEAD/demo_CLI.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"287fadd38bc70b9c"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}