The invention discloses a method for embedding a text
watermark during Logs generation based on a large
language model. The method comprises the following steps of: analyzing a generated text tl-1 of a
large model through dependency
syntax analysis, constructing a dependency
syntax tree of the generated text tl-1, sorting according to scores of a dependency
syntax relationship, and selecting and adding biased Logs; a candidate
word list is generated, probability distribution corresponding to each dependency type is calculated, the selection probability of the candidate
word list is adjusted, vocabularies are sampled and generated at key positions from the candidate
word list according to a set rule, and a
watermark embedded text is obtained; the candidate word
list comprises a first
list and a second
list, and the selection probability of the first list is higher than that of the second list; and extracting a to-be-detected fragment in the
watermark-embedded text, detecting the watermark of the text, and outputting a detection result. According to the method, the problem that the anti-
attack capability of adding watermarks to the generated text is insufficient is solved, and meanwhile, the problems of text quality and large long text calculation amount of a current watermarking method in the Logits generation period based on a
large model are solved.