The invention discloses a similarity comparison-based
large model supply chain automatic
restoration method and device, and the method comprises the steps: firstly carrying out the semantic coding of an original
vulnerability code through a pre-training model, and constructing a semantic and structure parallel dual-channel representation in combination with an
abstract syntax tree and other program structures; cWE type intelligent classification is performed on vulnerabilities by using a locally deployed large
language model subjected to LoRA
fine tuning, and meanwhile, a zero sample
semantic matching mechanism is introduced, so that the recognition capability of unknown
vulnerability types is improved. And searching the closest historical case from the
knowledge base through similarity vector comparison, and extracting a repair abstract to construct a model to generate a prompt. Patch codes and repair instructions are generated through a
large model, automatic filing and
knowledge base updating are supported, and the continuously-enhanced automatic repair capacity is achieved. The method can be widely applied to automatic
vulnerability repair scenes of supply chain components such as
large model plug-ins, code interfaces and dependent packages, and the safety, functionality and
interpretability of code repair patches are greatly improved.