{"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/k-semstamp-a-clustering-based-semantic","title":"k-SemStamp: A Clustering-Based Semantic Watermark for Detection of Machine-Generated Text","arxiv_id":"2402.11399","date":"2024-02-17","proceeding":null,"authors":["Abe Bohan Hou","Jingyu Zhang","Yichen Wang","Daniel Khashabi","Tianxing He"],"abstract":"Recent watermarked generation algorithms inject detectable signatures during language generation to facilitate post-hoc detection. While token-level watermarks are vulnerable to paraphrase attacks, SemStamp (Hou et al., 2023) applies watermark on the semantic representation of sentences and demonstrates promising robustness. SemStamp employs locality-sensitive hashing (LSH) to partition the semantic space with arbitrary hyperplanes, which results in a suboptimal tradeoff between robustness and speed. We propose k-SemStamp, a simple yet effective enhancement of SemStamp, utilizing k-means clustering as an alternative of LSH to partition the embedding space with awareness of inherent semantic structure. Experimental results indicate that k-SemStamp saliently improves its robustness and sampling efficiency while preserving the generation quality, advancing a more effective tool for machine-generated text detection.","url_abs":"https://arxiv.org/abs/2402.11399v2","url_pdf":"https://arxiv.org/pdf/2402.11399v2.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":"k-semstamp-a-clustering-based-semantic","repo_url":"https://github.com/bohanhou14/semstamp","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"k-semstamp-a-clustering-based-semantic","repo_url":"https://github.com/DabiriAghdam/SimMark","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"text-detection","task_name":"Text Detection"},{"task_slug":"text-generation","task_name":"Text Generation"}],"methods":[{"method_slug":"k-means-clustering","method_name":"k-Means Clustering"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2402.11399","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.11399"}},"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/DabiriAghdam/SimMark","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/bohanhou14/semstamp","reach":{"status":"ok"}}],"summary":{"ran":9},"by_repo_kind":{"official":{"samples":9,"ran":9,"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":9,"samples":[{"code_sha256_prefix":"252038271136f9a2","entry":"build_bigrams","repo":"bohanhou14/semstamp","repo_kind":"official","path":"paraphrase_gen_utils.py","file_url":"https://github.com/bohanhou14/semstamp/blob/HEAD/paraphrase_gen_utils.py","link_basis":"first_harvest_node","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":"252038271136f9a2"}},{"code_sha256_prefix":"a32125170b197212","entry":"cosine_distance_matrix","repo":"bohanhou14/semstamp","repo_kind":"official","path":"contrastive_trainer.py","file_url":"https://github.com/bohanhou14/semstamp/blob/HEAD/contrastive_trainer.py","link_basis":"first_harvest_node","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":"a32125170b197212"}},{"code_sha256_prefix":"b0ef99aecaf6802e","entry":"encode","repo":"bohanhou14/semstamp","repo_kind":"official","path":"contrastive_trainer.py","file_url":"https://github.com/bohanhou14/semstamp/blob/HEAD/contrastive_trainer.py","link_basis":"first_harvest_node","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":"b0ef99aecaf6802e"}},{"code_sha256_prefix":"3ce739cd9bb13e99","entry":"extract_list","repo":"bohanhou14/semstamp","repo_kind":"official","path":"paraphrase_gen_utils.py","file_url":"https://github.com/bohanhou14/semstamp/blob/HEAD/paraphrase_gen_utils.py","link_basis":"first_harvest_node","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":"3ce739cd9bb13e99"}},{"code_sha256_prefix":"278efa1abd622842","entry":"flatten_gens_and_paras","repo":"bohanhou14/semstamp","repo_kind":"official","path":"detection_utils.py","file_url":"https://github.com/bohanhou14/semstamp/blob/HEAD/detection_utils.py","link_basis":"first_harvest_node","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":"278efa1abd622842"}},{"code_sha256_prefix":"58cb2caaccc3a3f8","entry":"mean_pooling","repo":"bohanhou14/semstamp","repo_kind":"official","path":"contrastive_trainer.py","file_url":"https://github.com/bohanhou14/semstamp/blob/HEAD/contrastive_trainer.py","link_basis":"first_harvest_node","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":"58cb2caaccc3a3f8"}},{"code_sha256_prefix":"fc54ec274332d741","entry":"text_entropy","repo":"bohanhou14/semstamp","repo_kind":"official","path":"eval_clm.py","file_url":"https://github.com/bohanhou14/semstamp/blob/HEAD/eval_clm.py","link_basis":"first_harvest_node","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":"fc54ec274332d741"}},{"code_sha256_prefix":"eed1c0b474e01b4a","entry":"tokenize","repo":"bohanhou14/semstamp","repo_kind":"official","path":"paraphrase_gen_utils.py","file_url":"https://github.com/bohanhou14/semstamp/blob/HEAD/paraphrase_gen_utils.py","link_basis":"first_harvest_node","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":"eed1c0b474e01b4a"}},{"code_sha256_prefix":"e92afd771667c4aa","entry":"tokenize_untokenize","repo":"bohanhou14/semstamp","repo_kind":"official","path":"eval_quality.py","file_url":"https://github.com/bohanhou14/semstamp/blob/HEAD/eval_quality.py","link_basis":"first_harvest_node","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":"e92afd771667c4aa"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}