This invention discloses a cross-
language code vulnerability remediation method based on dual constraints of
knowledge graph and
large model, comprising: receiving multi-language heterogeneous
vulnerability code samples, performing feature
standardization processing, and extracting the language context and core
vulnerability intent tags of the code; inputting the vulnerability intent tags into a pre-built cross-language security
knowledge graph, performing cross-level
pathfinding matching based on risk patterns, and dynamically extracting the necessary security interfaces for vulnerability remediation and prohibited dangerous functions; using a context-aware mechanism, fusing and concatenating the original vulnerability code with
whitelist rules to construct prompt words as soft constraint intent guidance at the input end of the
large model; simultaneously, mapping
blacklist rules to a set of underlying lexical indexes, introducing a log-probability interceptor in the decoding and
inference stage of the
large model, forcibly modifying the generation log-probability of blacklisted lexical elements to negative infinity, and implementing hard constraint interception at the underlying level; finally, combining the soft guidance at the input end and the hard interception at the decoding end, bidirectionally controlling the autoregressive
generation process of the pre-trained
language model, thereby eliminating model illusion and outputting the optimal security remediation patch that conforms to the target language specification.