Search

CN-122020083-A - Test data generation method, device, equipment and medium

CN122020083ACN 122020083 ACN122020083 ACN 122020083ACN-122020083-A

Abstract

The disclosure provides a test data generation method, device, equipment and medium, relates to the technical field of artificial intelligence, and particularly relates to the technical fields of machine learning, deep learning, large models and the like. The method comprises the steps of inputting target instruction features into a neural network model, obtaining original activation features output by an intermediate layer of the neural network model, utilizing preset semantic control features to offset the original activation features to obtain target activation features, obtaining target results output by subsequent layers, located behind the intermediate layer, in the neural network model based on the target activation features, inputting test features to be optimized into the neural network model after combining the test features and the target instruction features, obtaining controlled activation features output by the intermediate layer and controlled results output by the subsequent layers, and carrying out back propagation optimization on the test features based on the target activation features, the controlled activation features, the target results and the controlled results to obtain target test data.

Inventors

  • YANG HAIYAN
  • GAO LEI
  • YANG WULI
  • BAO CHENFU

Assignees

  • 北京百度网讯科技有限公司

Dates

Publication Date
20260512
Application Date
20260122

Claims (14)

  1. 1. A test data generation method for a neural network model, comprising: Inputting target instruction characteristics into a neural network model, and acquiring original activation characteristics output by an intermediate layer of the neural network model; shifting the original activation feature by using a preset semantic control feature to obtain a target activation feature; acquiring a target result output by a subsequent layer positioned behind the middle layer in the neural network model based on the target activation characteristic; the test feature to be optimized and the target instruction feature are combined and then input into the neural network model, and the controlled activation feature output by the middle layer and the controlled result output by the subsequent layer are obtained, and And performing back propagation optimization on the test feature based on the target activation feature, the controlled activation feature, the target result and the controlled result to obtain target test data.
  2. 2. The method of claim 1, wherein the back-propagation optimizing the test feature based on the target activation feature, the controlled activation feature, the target result, and the controlled result to obtain target test data comprises: determining a first loss value based on the target activation feature and the controlled activation feature; Determining a second loss value based on the target result and the controlled result; combining the first loss value and the second loss value to obtain a combined loss value, and And carrying out back propagation optimization on the test features by utilizing the comprehensive loss value.
  3. 3. The method of claim 2, wherein the determining a first loss value based on the target activation feature and the controlled activation feature comprises: The first loss value is determined based on an L2 distance or cosine similarity between the target activation feature and the controlled activation feature.
  4. 4. The method of claim 2, wherein the determining a second loss value based on the target result and the controlled result comprises: The second loss value is determined based on a KL divergence between the target result and the controlled result.
  5. 5. The method of any of claims 1-4, wherein the combining the test feature to be optimized with the target instruction feature, inputting into the neural network model, and obtaining controlled activation features of the intermediate layer output and controlled results of the subsequent layer output comprises: and splicing the test feature to be optimized with the target instruction feature as a prefix, and inputting a splicing result into the neural network model.
  6. 6. The method of any of claims 1-4, wherein the semantic control feature is to switch an output response of the neural network model from a first behavioral mode to a second behavioral mode, the subsequent layer of the neural network model configured to output an original result corresponding to the first behavioral mode based on the original activation feature, the original result being different from the target result.
  7. 7. The method of claim 6, wherein the semantic control feature is obtained by: Acquiring a first sample set capable of triggering the first behavior mode and a second sample set capable of triggering the second behavior mode; inputting the first sample set and the second sample set into the neural network model respectively, and acquiring a first sample activation characteristic output by the intermediate layer based on the first sample set and a second sample activation characteristic output based on the second sample set, and The semantic control feature is determined based on the first sample activation feature and the second sample activation feature.
  8. 8. The method of any of claims 1-4, wherein the offsetting the original activation feature with a preset semantic control feature to obtain a target activation feature comprises: Subtracting the semantic control feature from the original activation feature to obtain the target activation feature.
  9. 9. The method of any of claims 1-4, wherein the neural network model is a large language model, the target instruction features are derived by embedding target instruction text, the target results include target probability distributions on a vocabulary and target text results generated based on the target probability distributions, and the controlled results include controlled probability distributions on the vocabulary and controlled text results generated based on the controlled probability distributions.
  10. 10. The method of any of claims 1-4, further comprising: And combining the target test data with the target instruction characteristics, and inputting the combined target test data into a model to be tested to obtain a test result output by the model to be tested.
  11. 11. A test data generation apparatus for a neural network model, comprising: A first acquisition unit configured to input target instruction features into a neural network model and acquire original activation features output by an intermediate layer of the neural network model; the offset unit is configured to offset the original activation feature by utilizing a preset semantic control feature to obtain a target activation feature; a second acquisition unit configured to acquire a target result output by a subsequent layer located after the intermediate layer in the neural network model based on the target activation feature; A third acquisition unit configured to input the test feature to be optimized and the target instruction feature into the neural network model, and acquire the controlled activation feature of the intermediate layer output and the controlled result of the subsequent layer output, and And the optimizing unit is configured to perform back propagation optimization on the test feature based on the target activation feature, the controlled activation feature, the target result and the controlled result so as to obtain target test data.
  12. 12. An electronic device, the electronic device comprising: at least one processor, and A memory communicatively coupled to the at least one processor, wherein The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-10.
  13. 13. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method of any one of claims 1-10.
  14. 14. A computer program product comprising a computer program, wherein the computer program, when executed by a processor, implements the method of any of claims 1-10.

Description

Test data generation method, device, equipment and medium Technical Field The present disclosure relates to the field of artificial intelligence, and in particular, to the technical fields of machine learning, deep learning, large models, and the like, and in particular, to a test data generation method, a test data generation apparatus, an electronic device, a computer-readable storage medium, and a computer program product. Background Artificial intelligence is the discipline of studying the process of making a computer mimic certain mental processes and intelligent behaviors (e.g., learning, reasoning, thinking, planning, etc.) of a person, both hardware-level and software-level techniques. The artificial intelligence hardware technology generally comprises technologies such as a sensor, a special artificial intelligence chip, cloud computing, distributed storage, big data processing and the like, and the artificial intelligence software technology mainly comprises natural language processing technology, computer vision technology, voice recognition technology, machine learning/deep learning, big data processing technology, knowledge graph technology and the like. The approaches described in this section are not necessarily approaches that have been previously conceived or pursued. Unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section. Similarly, the problems mentioned in this section should not be considered as having been recognized in any prior art unless otherwise indicated. Disclosure of Invention The present disclosure provides a test data generation method, a test data generation apparatus, an electronic device, a computer-readable storage medium, and a computer program product. According to one aspect of the disclosure, a test data generation method for a neural network model is provided, and the test data generation method comprises the steps of inputting target instruction features into the neural network model, obtaining original activation features output by an intermediate layer of the neural network model, offsetting the original activation features by using preset semantic control features to obtain target activation features, obtaining target results output by a subsequent layer, located behind the intermediate layer, in the neural network model based on the target activation features, obtaining the target results output by the subsequent layer, combining the test features to be optimized with the target instruction features, inputting the combined test features into the neural network model, obtaining controlled activation features output by the intermediate layer and controlled results output by the subsequent layer, and performing back propagation optimization on the test features based on the target activation features, the controlled activation features, the target results and the controlled results to obtain target test data. According to another aspect of the disclosure, a test data generating device for a neural network model is provided, and the test data generating device comprises a first acquisition unit, a shifting unit, a second acquisition unit, a third acquisition unit and an optimization unit, wherein the first acquisition unit is configured to input target instruction features into the neural network model and acquire original activation features output by an intermediate layer of the neural network model, the shifting unit is configured to shift the original activation features by utilizing preset semantic control features to obtain target activation features, the second acquisition unit is configured to acquire target results output by subsequent layers, located behind the intermediate layer, in the neural network model based on the target activation features, the third acquisition unit is configured to combine the test features to be optimized with the target instruction features and input the combined test features into the neural network model, and acquire controlled activation features output by the intermediate layer and controlled results output by the subsequent layers, and the optimization unit is configured to conduct back propagation optimization on the test features based on the target activation features, the controlled activation features, the target results and the controlled results to obtain target test data. According to another aspect of the present disclosure, there is provided an electronic device comprising at least one processor, and a memory communicatively coupled to the at least one processor, wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the above-described method. According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to