Abstract:
With the widespread adoption of large language models (LLMs) in automated content generation, achieving reliable copyright identification and traceability while preserving generation quality has become an important research problem. Existing watermarking techniques for LLMs typically rely on perturbing the global generation distribution, yet their detection performance degrades significantly under semantic-preserving transformations such as such as paraphrasing or translation. To address this, this paper proposes a prompt-based watermarking method for large language models. In the proposed method, the input prompt is first analyzed using the PageRank algorithm to assign importance scores to its keywords, from which the top-K keywords are selected and mapped to their corresponding token ID sequences. Subsequently, these token ID sequences, along with a secret key, are fed into a cryptographic hash function to generate a pseudorandom hash key and a pseudorandom seed, which are then used to partition the entire language model vocabulary to obtain a green list. During the subsequent text generation process, through systematically boosting the generation probability of tokens in the green list, causing their actual frequency of occurrence to significantly exceed the expected value under a random baseline to enhance the robustness of the watermark against semantically-preserving transformations of the text. Experimental results demonstrate that the proposed method achieves a favorable trade-off between detection accuracy and text quality. In translation attack scenarios, compared with the baseline method, the proposed approach reduces the AUC decay by a factor of 3.4, indicating stronger robustness. These results validate the effectiveness and practical value of the proposed method under semantic-preserving attacks.