The embodiment of the invention relates to a knowledge editing method and device based on reasoning chain condition constraint, and the method comprises the steps: defining four types of condition constraint rules and a candidate instruction node graph for a target model, and constructing four types of discriminators for the four types of rules; docking the user-specified
knowledge base with the target model; each task problem of the user task set is substituted into the instruction template to generate a multi-step reasoning task instruction, the multi-step reasoning task instruction is input into the target model to carry out one-time multi-step reasoning task
processing, and one-time task pause is carried out every time one-step reasoning is completed in the
processing process; and then updating the node graph according to the current
inference step data, performing constraint condition judgment on the current
inference output by utilizing four types of discriminators, continuing the next
inference when the constraint condition is met, and performing available node retrieval on the node graph when the constraint condition is not met, reconstructing an inference chain based on a
retrieval result, and performing inference again according to a reconstruction chain. The
knowledge learning precision of the target model can be improved, the
knowledge learning deviation is reduced, and the knowledge editing efficiency is improved.