A prompt processing method, device, equipment and storage medium

By inserting trained neural network components into a large language model and adjusting intermediate feature vectors using bias vectors, the semantic inconsistency problem is solved, improving the semantic consistency and reliability of the model.

CN122087553APending Publication Date: 2026-05-26HUAWEI TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2024-11-25
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Large language models suffer from semantic inconsistency when inputting the same semantics but expressing different prompts, which affects their reliability and user experience.

Method used

By inserting trained target neural network components into the target large language model, a target extended language model is constructed, and the semantic consistency is optimized by adjusting the intermediate feature vectors using bias vectors.

Benefits of technology

It improves the semantic consistency of large language models and enhances their output consistency and reliability during the reasoning process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122087553A_ABST
    Figure CN122087553A_ABST
Patent Text Reader

Abstract

This application discloses a prompt processing method, apparatus, device, and storage medium, aiming to improve the semantic consistency of a target large language model. The prompt processing method disclosed in this application includes: inputting the prompt to be inferred into a target extended language model; obtaining a first intermediate feature vector of the target extended language model through the target extended language model; adjusting the first intermediate feature vector based on a bias vector to obtain a target intermediate feature vector, wherein the output position of the first intermediate feature vector is the same as the output position corresponding to the bias vector; and performing inference based on the target intermediate feature vector and the target extended language model to generate the target result of the prompt to be inferred. In the above scheme, the first intermediate feature vector generated by the target extended language model during the inference process can be adjusted and corrected according to the bias vector obtained based on the analysis of the output vector of the target extended language model, thereby achieving optimization and enhancement of the semantic consistency of the target large language model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of deep learning, specifically to a prompting processing method, apparatus, device, and storage medium. Background Technology

[0002] With the rapid development of artificial intelligence, large language models are widely used in natural language processing tasks, including question answering, summarization, and sentiment analysis. However, when given the same semantic input but different prompts, current large language models sometimes still generate semantically inconsistent or even contradictory outputs. This phenomenon is known as semantic inconsistency. If a large language model has semantic inconsistency, it can easily affect its reliability in practical applications and the user experience. Summary of the Invention

[0003] This application provides a prompt processing method, apparatus, device, and storage medium, with the aim of improving the semantic consistency of a target large language model.

[0004] To achieve the above objectives, this application provides the following technical solution:

[0005] A first aspect of this application provides a prompt processing method, the method comprising:

[0006] The inference prompt is input into the target extended language model, and the first intermediate feature vector of the target extended language model is obtained through the target extended language model. The target extended language model is composed of a target large language model and a target neural network component. The target extended language model has a corresponding bias vector, which is obtained by analyzing the output vector of the target extended language model during the training phase.

[0007] The first intermediate feature vector is adjusted based on the bias vector to obtain the target intermediate feature vector, and the output position of the first intermediate feature vector is the same as the output position corresponding to the bias vector.

[0008] Reasoning is performed based on the target intermediate feature vector and the target extended language model to generate the target result to be reasoned.

[0009] In the above implementation scheme, when reasoning about the inference prompt, the target extended language model obtained by inserting the trained target neural network component into the target large language model can be used to reason about the inference prompt. Furthermore, the first intermediate feature vector generated by the target extended language model during the inference process can be adjusted and corrected based on the bias vector obtained by analyzing the output vector of the target extended language model during the training phase. This can optimize and enhance the semantic consistency of the target large language model, thereby improving the semantic consistency of the target large language model.

[0010] In one possible implementation of the first aspect of this application, adjusting the first intermediate feature vector based on the bias vector to obtain the target intermediate feature vector includes:

[0011] The bias vector and the first intermediate feature vector are linearly weighted to obtain the target intermediate feature vector.

[0012] In the above implementation scheme, when adjusting and correcting the first intermediate feature vector generated by the target extended language model during the inference process based on the bias vector, the target intermediate feature vector can be obtained by linearly weighting the bias vector and the first intermediate feature vector, thereby optimizing and enhancing the semantic consistency of the target large language model and improving the semantic consistency of the target large language model.

[0013] In one possible implementation of the first aspect of this application, the method further includes:

[0014] Obtain a target large language model, a target neural network component, and a sample dataset. The sample dataset includes a first dataset, which includes positive prompts and misleading prompts. The positive prompts are prompts that indicate the target large language model is giving the correct output result, the misleading prompts are synonyms of the positive prompts, and the misleading prompts are prompts that indicate the target large language model is giving the wrong output result.

[0015] The target neural network component is inserted into the target large language model to generate the target extended language model;

[0016] The bias vector is obtained based on the first dataset and the target extended language model.

[0017] In the above implementation scheme, during the training phase, a bias vector can be calculated and obtained based on the first dataset in the sample dataset and the target extended language model composed of the trained target neural network components and the trained target large language model. This allows for the adjustment and correction of the first intermediate feature vector generated by the target extended language model during the inference process based on the bias vector, thereby optimizing and enhancing the semantic consistency of the target large language model and improving its semantic consistency.

[0018] In one possible implementation of the first aspect of this application, obtaining the first dataset includes:

[0019] Obtain multiple original prompts and the correct output results corresponding to the multiple original prompts;

[0020] The multiple original prompts are input into the labeled large language model to generate multiple synonym prompts corresponding to the multiple original prompts, with each original prompt corresponding to one or more synonym prompts;

[0021] The multiple original prompts and the multiple synonym prompts are respectively input into the target large language model to generate the output results of the multiple original prompts and the output results of the multiple synonym prompts;

[0022] The first dataset is generated based on the multiple original prompts, the multiple synonym prompts, the output results of the multiple original prompts, the output results of the multiple synonym prompts, and the correct output results corresponding to the multiple original prompts.

[0023] In the above implementation scheme, after obtaining multiple original prompts, synonym prompts for each original prompt can be obtained first based on the labeled large language model. Then, the multiple original prompts and multiple synonym prompts are respectively input into the trained target large language model to obtain the output results of multiple original prompts and multiple synonym prompts. Finally, based on the obtained multiple original prompts, multiple synonym prompts, the output results of multiple original prompts, the output results of multiple synonym prompts, and the correct results corresponding to multiple original prompts, the positive prompts in the original prompts and the misleading prompts in the synonym prompts are determined to generate the first dataset. This allows for further calculation of the bias vector based on the first dataset and the target extended language model. This bias vector allows for adjustment and correction of the first intermediate feature vector generated by the target extended language model during the inference process, thereby optimizing and enhancing the semantic consistency of the target large language model and improving its semantic consistency.

[0024] In one possible implementation of the first aspect of this application, obtaining the target neural network component includes: obtaining the neural network component to be trained and a second dataset, wherein the second dataset includes text data;

[0025] The neural network component is inserted into the target large language model to generate an extended language model;

[0026] The target parameters of the neural network component are calculated based on the second dataset and the extended language model.

[0027] The target neural network component is constructed based on the target parameters and the neural network component.

[0028] In the above implementation scheme, the neural network component to be trained can be inserted into the trained target large language model to generate an extended language model. Then, the extended language model carrying the neural network component to be trained can be trained based on the second dataset to obtain the target parameters of the neural network component to be trained. Finally, the trained target neural network component is generated based on the target parameters, so that the target extended language model can be constructed based on the trained target neural network component and the target large language model. Furthermore, the bias vector can be calculated and obtained so that the first intermediate feature vector generated by the target extended language model during the inference process can be adjusted and corrected based on the bias vector. This can optimize and enhance the semantic consistency of the target large language model, thereby improving the semantic consistency of the target large language model.

[0029] In one possible implementation of the first aspect of this application, the step of calculating the target parameters of the neural network component based on the second dataset and the extended language model includes: inputting the second dataset into the extended language model to generate a feature vector dataset of the neural network component, wherein the feature vector dataset includes an input vector and an output vector corresponding to the input vector;

[0030] The target parameters are determined based on the input vector, the corresponding output vector, and a dictionary.

[0031] In the above implementation scheme, the second dataset can be first input into the extended language model carrying the neural network components to be trained to generate a feature dataset including the input vector and the corresponding output vector. Then, the feature dataset is analyzed based on dictionary learning to determine the target parameters, so that the target neural network components can be constructed based on the target parameters and the neural network components to be trained.

[0032] In one possible implementation of the first aspect of this application, the sample dataset further includes a third dataset, which includes an original prompt, a synonym prompt corresponding to the original prompt, and a semantic consistency label. The semantic consistency label is used to indicate whether the output of the target large language model inputted by the original prompt is consistent with the output of the target large language model inputted by the synonym prompt. The step of inserting the target neural network component into the target large language model to generate a target extended language model includes:

[0033] The original prompts and synonym prompts of the third dataset are input into the target extended language model to generate a second intermediate feature vector corresponding to each output position in the target large language model;

[0034] Based on the semantic consistency labels of the third dataset and the second intermediate feature vector, a first classifier is trained to generate each output position.

[0035] The target neural network component is inserted into the key output position of the target large language model to generate the target extended language model. The key output position is the output position corresponding to the first classifier whose classification accuracy is greater than the first threshold.

[0036] In the above implementation scheme, the key output positions corresponding to the vectors that have a greater impact on semantic consistency in the target large language model can be determined first by using the third dataset and the target large language model. Then, the trained neural network components are inserted into the key output positions of the target large language model to generate the target extended language model, thereby further improving the optimization and enhancement of the target large language model in terms of semantic consistency, and thus improving the semantic consistency of the target large language model.

[0037] In one possible implementation of the first aspect of this application, obtaining the third dataset includes:

[0038] Retrieve multiple original prompts;

[0039] The multiple original prompts are input into the labeled large language model to generate multiple synonym prompts corresponding to the multiple original prompts, with each original prompt corresponding to one synonym prompt.

[0040] The multiple original prompts and the multiple synonym prompts are respectively input into the target large language model to generate the output results of the multiple original prompts and the output results of the multiple synonym prompts;

[0041] The output results of the multiple original prompts and the output results of the multiple synonym prompts are input into the labeled large language model to generate semantically consistent labels;

[0042] The third dataset is generated based on the multiple original prompts, the multiple synonym prompts, the output results of the multiple original prompts, the output results of the multiple synonym prompts, and the semantic consistency labels.

[0043] In the above implementation scheme, multiple synonym prompts corresponding to multiple original prompts can be generated by annotating a large language model, and the output results of multiple original prompts and multiple synonym prompts can be generated by a target large language model. Furthermore, the semantic consistency of the output results of multiple original prompts and multiple synonym prompts can be determined by annotating a large language model to generate semantic consistency labels. Finally, a third dataset can be generated based on multiple original prompts, multiple synonym prompts, the output results of multiple original prompts, the output results of multiple synonym prompts, and the semantic consistency labels.

[0044] In one possible implementation of the first aspect of this application, the calculation of the bias vector based on the first dataset and the target extended language model includes:

[0045] The positive prompt and the misleading prompt are respectively input into the target extended language model to generate a third intermediate feature vector corresponding to the positive prompt and a fourth intermediate feature vector corresponding to the misleading prompt. The third intermediate feature vector and the fourth intermediate feature vector are the output vectors of the target neural network component.

[0046] The difference between the third intermediate feature vector and the fourth intermediate feature vector is calculated to obtain the first bias vector in the bias vector.

[0047] In the above implementation scheme, positive and misleading prompts from the first dataset can be input into the target extended language model. The target neural network component in the target extended language model outputs the third intermediate feature vector corresponding to the positive prompt and the fourth intermediate feature vector corresponding to the misleading prompt. Then, by calculating the difference between the third and fourth intermediate feature vectors, the first bias vector in the bias vector is obtained. This allows for the adjustment and correction of the first intermediate feature vector generated by the target extended language model during the inference process based on the first bias vector. This can optimize and enhance the semantic consistency of the target large language model, thereby improving the semantic consistency of the target large language model.

[0048] In one possible implementation of the first aspect of this application, the step of inputting the positive prompt and the misleading prompt into the target extended language model respectively to generate a third intermediate feature vector corresponding to the positive prompt and a fourth intermediate feature vector corresponding to the misleading prompt includes:

[0049] The positive prompt and the misleading prompt are respectively input into the target extended language model to generate a first original activation vector for the positive prompt and a second original activation vector corresponding to the misleading prompt;

[0050] The first and second original activation vectors are respectively input into the encoder of the target neural network component for compression to obtain the third and fourth intermediate feature vectors. The dimensions of the third and fourth intermediate feature vectors are lower than the dimensions of the first and second original activation vectors.

[0051] In the above implementation scheme, positive prompts and misleading prompts can be input into the target extended language model to generate the first original activation vector corresponding to the positive prompt and the second original activation vector corresponding to the misleading prompt. Then, the target neural network component can compress the first original activation vector into a third intermediate feature vector with a lower dimension and the second original activation vector into a fourth intermediate feature vector with a lower dimension. This allows the first bias vector in the bias vector to be obtained by calculating the difference between the third and fourth intermediate feature vectors.

[0052] In one possible implementation of the first aspect of this application, the step of inputting the positive prompt and the misleading prompt into the target extended language model respectively to generate a third intermediate feature vector corresponding to the positive prompt and a fourth intermediate feature vector corresponding to the misleading prompt includes:

[0053] The positive prompt and the misleading prompt are respectively input into the target extended language model to generate a first original activation vector for the positive prompt and a second original activation vector corresponding to the misleading prompt;

[0054] The first and second original activation vectors are respectively input into the encoder of the target neural network component for encoding to obtain the third and fourth intermediate feature vectors. The dimensions of the third and fourth intermediate feature vectors are higher than the dimensions of the first and second original activation vectors.

[0055] In the above implementation scheme, positive prompts and misleading prompts can be input into the target extended language model to generate the first original activation vector corresponding to the positive prompt and the second original activation vector corresponding to the misleading prompt. Then, the target neural network component can encode the first original activation vector into a third intermediate feature vector with a higher dimension and the second original activation vector into a fourth intermediate feature vector with a higher dimension, so that the first bias vector in the bias vector can be obtained by calculating the difference between the third intermediate feature vector and the fourth intermediate feature vector.

[0056] In one possible implementation of the first aspect of this application, the method further includes:

[0057] The positive prompt and the misleading prompt are respectively input into the target extended language model to generate the fifth intermediate feature vector corresponding to the positive prompt and the sixth intermediate feature vector corresponding to the misleading prompt. The fifth intermediate feature vector and the sixth intermediate feature vector are the output vectors of the target large language model.

[0058] The difference between the fifth intermediate feature vector and the sixth intermediate feature vector is calculated to obtain the second bias vector in the bias vector.

[0059] In the above implementation scheme, the positive and misleading prompts in the first dataset can be input into the target extended language model respectively. The target large language model in the target extended language model outputs the fifth intermediate feature vector corresponding to the positive prompt and the sixth intermediate feature vector corresponding to the misleading prompt. Then, by calculating the difference between the fifth and sixth intermediate feature vectors, the second bias vector in the bias vector is obtained. This allows for further adjustment and correction of the first intermediate feature vector generated by the target extended language model during the inference process based on the second bias vector. This can optimize and enhance the semantic consistency of the target large language model, thereby improving the semantic consistency of the target large language model.

[0060] Secondly, embodiments of this application also provide a prompting processing device, the device comprising:

[0061] The reasoning module is used to input the prompt to be reasoned into the target extended language model, and obtain the first intermediate feature vector of the target extended language model through the target extended language model. The target extended language model is composed of a target large language model and a target neural network component. The target extended language model has a bias vector, which is obtained by analyzing the output vector of the target extended language model.

[0062] The adjustment module is used to adjust the first intermediate feature vector based on the bias vector to obtain the target intermediate feature vector, wherein the output position of the first intermediate feature vector is the same as the output position corresponding to the bias vector.

[0063] The reasoning module is also used to perform reasoning based on the target intermediate feature vector and the target extended language model to generate the target result of the prompt to be reasoned.

[0064] In the above implementation scheme, when reasoning about the inference prompt, the target extended language model obtained by inserting the trained target neural network component into the target large language model can be used to reason about the inference prompt. Furthermore, the first intermediate feature vector generated by the target extended language model during the inference process can be adjusted and corrected based on the bias vector obtained by analyzing the output vector of the target extended language model during the training phase. This can optimize and enhance the semantic consistency of the target large language model, thereby improving the semantic consistency of the target large language model.

[0065] The second aspect of this application indicates that the constituent modules of the processing device can also perform the steps described in the first aspect and various possible implementations, as detailed in the foregoing description of the first aspect and various possible implementations.

[0066] Thirdly, embodiments of this application provide a computer device that may include a memory and a processor, wherein the memory is used to store computer programs or computer instructions, and the processor is used to execute the computer programs or computer instructions stored in the memory, so that the computer and device perform the method of the first aspect of the embodiments of this application or any possible implementation thereof.

[0067] Fourthly, embodiments of this application provide a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the method described in the first aspect above.

[0068] Fifthly, embodiments of this application provide a computer program product containing instructions that, when run on a computer, cause the computer to perform the method described in the first aspect above.

[0069] In a sixth aspect, embodiments of this application provide a communication device, which may include entities such as terminal devices or chips. The communication device includes: a processor and a memory; the memory is used to store instructions; the processor is used to execute the instructions in the memory, causing the communication device to perform the method as described in any one of the preceding first aspects.

[0070] In a seventh aspect, this application provides a chip system including a processor for supporting a prompting processing device in implementing the functions involved in the foregoing aspects, such as transmitting or processing data and / or information involved in the foregoing methods. In one possible design, the chip system further includes a memory for storing program instructions and data necessary for the prompting processing device. This chip system may be composed of chips or may include chips and other discrete devices.

[0071] Eighthly, embodiments of this application provide a chip including one or more interface circuits and one or more processors; the interface circuits are used to receive signals from the memory of an electronic device and send signals to the processors, the signals including computer instructions stored in the memory; when the processor executes the computer instructions, it causes the electronic device to perform the task execution method in the first aspect or any possible implementation of the first aspect.

[0072] The eighth aspect and any implementation thereof correspond to the first aspect and any implementation thereof, respectively. The technical effects corresponding to the eighth aspect and any implementation thereof are similar to those corresponding to the first aspect and any implementation thereof, and will not be repeated here.

[0073] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:

[0074] In this embodiment, when reasoning about the prompts to be reasoned, the target extended language model obtained by inserting the trained target neural network component into the target large language model can be used to reason about the prompts to be reasoned. Furthermore, the first intermediate feature vector generated by the target extended language model during the reasoning process can be adjusted and corrected based on the bias vector obtained by analyzing the output vector of the target extended language model during the training phase. This can optimize and enhance the semantic consistency of the target large language model, thereby improving the semantic consistency of the target large language model. Attached Figure Description

[0075] Figure 1 This is a schematic diagram of an artificial intelligence framework used in this application;

[0076] Figure 2 A schematic diagram of a system architecture is provided for this application;

[0077] Figure 3 Another system architecture diagram provided for this application;

[0078] Figure 4 A flowchart illustrating a prompt processing method provided in an embodiment of this application;

[0079] Figure 5 This is a schematic diagram of the structure of a target extended language model provided in an embodiment of this application;

[0080] Figure 6 A flowchart illustrating another prompt processing method provided in an embodiment of this application;

[0081] Figure 7 This is a schematic diagram of the structure of an operator compiler device provided in an embodiment of this application;

[0082] Figure 8 A schematic diagram of the structure of a computer device provided in an embodiment of this application;

[0083] Figure 9 This is a schematic diagram of the structure of a chip provided in an embodiment of this application. Detailed Implementation

[0084] This application provides an operator compilation method, apparatus, device, and storage medium, with the aim of improving the efficiency of operator development.

[0085] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a branch of computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.

[0086] First, the overall workflow of the artificial intelligence system is described; please refer to [link / reference]. Figure 1 , Figure 1 The diagram illustrates a structural framework for artificial intelligence (AI). The framework is further elaborated below along two dimensions: the "Intelligent Information Chain" (horizontal axis) and the "IT Value Chain" (vertical axis). The "Intelligent Information Chain" reflects a series of processes from data acquisition to processing. For example, it could be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, and intelligent execution and output. In this process, data undergoes a condensation process of "data—information—knowledge—wisdom." The "IT Value Chain" reflects the value that AI brings to the information technology industry, from the underlying infrastructure of human intelligence and information (provided and processed through technological means) to the industrial ecosystem of the system.

[0087] (1) Infrastructure

[0088] Infrastructure provides computing power to support artificial intelligence systems, enabling communication with the external world and providing support through a basic platform. This communication occurs through sensors; computing power is provided by intelligent chips, such as hardware acceleration chips (CPUs, NPUs, GPUs, ASICs, or FPGAs); the basic platform includes distributed computing frameworks and related platform guarantees and support, which may include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to acquire data, which is then provided to intelligent chips in the distributed computing system provided by the basic platform for computation.

[0089] (2) Data

[0090] The data at the next layer of infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data from traditional devices, including business data from existing systems and sensor data such as force, displacement, liquid level, temperature, and humidity.

[0091] (3) Data processing

[0092] Data processing typically includes methods such as data training, machine learning, deep learning, search, reasoning, and decision-making.

[0093] Among them, machine learning and deep learning can perform intelligent information modeling, extraction, preprocessing, and training of data by symbolizing and formalizing it.

[0094] Reasoning refers to the process in which, in a computer or intelligent system, the machine thinks and solves problems by simulating human intelligent reasoning, based on reasoning control strategies and using formalized information. Typical functions include search and matching.

[0095] Decision-making refers to the process of making decisions based on intelligent information after reasoning, and it typically provides functions such as classification, sorting, and prediction.

[0096] (4) General ability

[0097] After the data processing mentioned above, the results of the data processing can be used to form some general capabilities, such as algorithms or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.

[0098] (5) Smart Products and Industry Applications

[0099] Intelligent products and industry applications refer to products and applications of artificial intelligence systems in various fields. They are the encapsulation of overall artificial intelligence solutions, productizing intelligent information decision-making and realizing practical applications. Their application areas mainly include: intelligent terminals, intelligent transportation, intelligent healthcare, autonomous driving, and safe cities.

[0100] This application relates to applications of deep learning. To better understand the solutions of this application, the relevant terms and concepts of deep learning that may be involved in this application will be introduced below.

[0101] Large Language Models (LLMs) are a class of deep learning-based artificial intelligence models designed to process and generate natural language text. Trained on large-scale text datasets, LLMs can understand and generate text similar to human language, performing various natural language processing tasks including text generation, translation, and sentiment analysis. The core technical architecture of LLMs is the Transformer model, a deep learning model based on a self-attention mechanism. The Transformer architecture captures dependencies in the sequence by calculating the attention score of each element in the input sequence to other elements, thereby achieving efficient processing of natural language.

[0102] Supervised fine-tuning involves training a pre-trained model using labeled data to adjust its parameters, making it better suited for a specific task. The main purpose of this process is to improve the model's performance on specific tasks, such as text classification, sentiment analysis, and translation.

[0103] Neural network components: These refer to the basic units and structures that make up a neural network. These components work together to enable the neural network to learn and process complex data.

[0104] Multilayer Perceptron (MLP): A type of feedforward neural network. An MLP consists of an input layer, multiple hidden layers, and an output layer, and is one of the fundamental models in deep learning.

[0105] Semantic consistency: Semantic consistency mainly refers to the mutual consistency of meaning among the words or phrases in a sentence or text. It requires that the concepts, facts, and arguments within the text remain consistent and avoid semantic contradictions, ambiguities, and confusion. The semantic consistency of a model typically refers to the model producing semantically consistent results given synonymous inputs.

[0106] A prompt is a text or signal that guides the model to generate a specific output.

[0107] Intermediate feature vectors (IMVs) are feature representations generated in intermediate layers of a neural network when processing input data. These IMVs are extracted from the original input data by the neural network through a series of transformations and calculations. They capture the key attributes and patterns of the input data and are used for subsequent classification, regression, or other tasks. Intermediate IMVs play a crucial role in deep learning. They not only provide the model with rich feature representations but also enable the model to learn complex patterns and structures in the input data. By adjusting and optimizing the parameters and structure of the neural network, more expressive and discriminative intermediate IMVs can be generated, thereby improving the model's performance and accuracy.

[0108] The prompting method provided in this application can be executed on a server or on a terminal device. The terminal device can be a mobile phone, tablet personal computer (TPC), media player, smart TV, laptop computer (LC), personal digital assistant (PDA), personal computer (PC), camera, camcorder, smartwatch, wearable device (WD), or autonomous vehicle, etc., and this application does not limit the specific device.

[0109] See appendix Figure 2 This application provides a system architecture 200. This system architecture includes a database 230 and a client device 240. A data acquisition device 260 is used to collect data and store it in the database 230. A training module 202 generates a target model / rule 201 based on the data maintained in the database 230. The following will describe in more detail how the training module 202 obtains the target model / rule 201 based on the data. The target model / rule 201 refers to the various models and neural network components mentioned in the following embodiments of this application. See the following for details. Figures 4-9 The relevant description in the document.

[0110] The computation module may include a training module 202, and the target model / rules obtained from the training module 202 can be applied to different systems or devices. (See appendix...) Figure 2 In this embodiment, the execution device 210 is equipped with a transceiver 212, which can be a wireless transceiver, an optical transceiver, or a wired interface (such as an I / O interface) to interact with external devices. The "user" can input data to the transceiver 212 through the client device 240. For example, in the following embodiments of this application, the client device 240 can send a target task to the execution device 210, request the execution device to build a neural network, and send a database for training to the execution device 210.

[0111] The execution device 210 can call data, code, etc. in the data storage system 250, and can also store data, instructions, etc. in the data storage system 250.

[0112] The calculation module 211 processes the input data using the target model / rule 201. Specifically, the calculation module 211 is used for:

[0113] Finally, transceiver 212 returns the constructed neural network to client device 240 for deployment in client device 240 or other devices.

[0114] At a deeper level, the training module 202 can obtain corresponding target models / rules 201 based on different data for different tasks, so as to provide users with better results.

[0115] In the appendix Figure 2 In the scenario shown, the data input to the execution device 210 can be determined based on the user's input data. For example, the user can operate on the interface provided by the transceiver 212. Alternatively, the client device 240 can automatically input data to the transceiver 212 and obtain results. If the client device 240 needs user authorization to automatically input data, the user can set appropriate permissions on the client device 240. The user can view the results output by the execution device 210 on the client device 240; the specific presentation format can be display, sound, animation, etc. The client device 240 can also act as a data acquisition terminal, storing the acquired data associated with the target task into the database 230.

[0116] The training or update process mentioned in this application can be executed by the training module 202. It is understood that the training process of a neural network is learning how to transform the control space, more specifically, learning the weight matrix. The purpose of training a neural network is to make its output as close as possible to the expected value. Therefore, this can be achieved by comparing the current network's predicted value with the expected value, and then updating the weight vector of each layer of the neural network based on the difference between the two (of course, the weight vector can usually be initialized before the first update, i.e., pre-configured parameters for each layer in the deep neural network). For example, if the network's predicted value is too high, the values ​​of the weights in the weight matrix are adjusted to lower the predicted value. This adjustment continues until the neural network's output value is close to or equal to the expected value. Specifically, the difference between the neural network's predicted value and the expected value can be measured using a loss function or an objective function. Taking the loss function as an example, a higher output value (loss) indicates a greater difference, and the training of the neural network can be understood as a process of minimizing the loss as much as possible. The process of updating the weights of the starting network and training the serial network in the following embodiments of this application can be referred to in this process, and will not be repeated hereafter.

[0117] like Figure 2 As shown, the target model / rule 201 is trained according to the training module 202. The target model / rule 201 may be a network with a Transformer architecture, a deep neural network (DNN), a convolutional neural network (CNN), a recurrent neural network (RNN), or a residual network or other neural networks.

[0118] During the training phase, database 230 stores a set of training samples. Training device 220 generates a target model / rule 201 for processing the samples and iteratively trains the target model / rule 201 using the sample set in the database to obtain a mature target model / rule 201, which is specifically represented as a neural network. The neural network obtained by training device 220 can be applied to different systems or devices.

[0119] During the inference phase, the execution device 210 can access data, code, etc., from the data storage system 250, or it can store data, instructions, etc., in the data storage system 250. The data storage system 250 can be located within the execution device 210, or it can be an external memory relative to the execution device 210. The computing module 211 can process the samples acquired by the execution device 210 through a neural network to obtain prediction results. The specific form of the prediction results is related to the function of the neural network.

[0120] It should be noted that the appendix Figure 2 This is merely an exemplary schematic diagram of a system architecture provided in this application embodiment, and the positional relationships between the devices, components, modules, etc., shown in the diagram do not constitute any limitation. For example, in the appendix... Figure 2 In this context, the data storage system 250 is an external memory relative to the execution device 210. In other scenarios, the data storage system 250 can also be placed within the execution device 210.

[0121] The target model / rule 201 constructed based on the training module 202 can be applied to different systems or devices, such as mobile phones, tablets, laptops, augmented reality (AR) / virtual reality (VR), in-vehicle terminals, servers, or cloud devices.

[0122] The target model / rule 201 in this application embodiment can be the target neural network in this application. Specifically, the target neural network provided in this application embodiment can be a network with a Transformer architecture, a convolutional neural network (CNN), a deep convolutional neural network (DCNN), a recurrent neural network (RNN), etc.

[0123] See appendix Figure 3 This application also provides a system architecture 300. The execution device 210 is implemented by one or more servers, optionally in conjunction with other computing devices, such as data storage, routers, load balancers, etc. The execution device 210 can be deployed on a single physical site or distributed across multiple physical sites. The execution device 210 can use data from the data storage system 350 or call program code from the data storage system 350 to implement the following aspects of this application. Figure 6 The corresponding steps of deep learning training methods for computing devices.

[0124] Users can interact with execution device 210 by operating their respective user devices (e.g., local device 301 and local device 302). Each local device can represent any computing device, such as a personal computer, computer workstation, smartphone, tablet, smart camera, smart car or other type of cellular phone, media consumption device, wearable device, set-top box, game console, etc.

[0125] Each user's local device can interact with execution device 210 through a communication network using any communication mechanism / standard. The communication network can be a wide area network (WAN), a local area network (LAN), a point-to-point connection, or any combination thereof. Specifically, the communication network can include a wireless network, a wired network, or a combination of both. The wireless network includes, but is not limited to, any one or more combinations of: 5th-Generation (5G) systems, Long Term Evolution (LTE) systems, Global System for Mobile Communication (GSM) or Code Division Multiple Access (CDMA) networks, Wideband Code Division Multiple Access (WCDMA) networks, Wireless Fidelity (WiFi), Bluetooth, Zigbee, Radio Frequency Identification (RFID), Long Range (Lora) wireless communication, and Near Field Communication (NFC). The wired network can include fiber optic communication networks or networks composed of coaxial cables.

[0126] In another implementation, one or more aspects of the execution device 210 may be implemented by each local device. For example, local device 301 may provide local data or feedback calculation results to the execution device 210. This local device may also be referred to as a computing device.

[0127] It should be noted that all the functions of execution device 210 can also be implemented by a local device. For example, local device 301 implements the functions of execution device 210 and provides services to its own users, or provides services to users of local device 302.

[0128] With the rapid development of artificial intelligence, large language models are widely used in natural language processing tasks, including question answering, summarization, and sentiment analysis. However, when given the same semantic input but different prompts, current large language models sometimes still generate semantically inconsistent or even contradictory outputs. This phenomenon is known as semantic inconsistency. If a large language model has semantic inconsistency, it can easily affect its reliability in practical applications and the user experience.

[0129] For example, if the input prompts to the large language model are "What is Xiaoming's favorite sport?" and "What is Xiaoming's favorite sport among all sports?", and the outputs of the large language model are "basketball" and "football" respectively, then the large language model can be considered to have a semantic inconsistency problem. However, if the input prompts to the large language model are "What is Xiaoming's favorite sport?" and "What is Xiaoming's favorite sport among all sports?", and the outputs of the large language model are both "basketball" or both "football", then the large language model can be considered not to have a semantic inconsistency problem.

[0130] Currently, existing technologies typically improve the semantic consistency of large language models through supervised fine-tuning. This involves first constructing the correct output answer for each prompt, then using the large language model to perform synonym expansion on each prompt, generating more extended prompts. By using the original prompts, extended prompts, correct answers, and supervised fine-tuning techniques, the parameters of the large language model are modified, thereby improving the model's semantic consistency. However, supervised fine-tuning methods rely on large fine-tuning datasets, which are costly to construct and label, and the fine-tuning operation can degrade the model's performance on other tasks. Supervised fine-tuning also suffers from insufficient interpretability, making it difficult to analyze how it improves the model's semantic consistency, limiting the possibility of deeper optimization and resulting in limited improvement in the semantic consistency of large language models. Therefore, a method is needed to improve the semantic consistency of the target large language model.

[0131] Therefore, this application provides a suggestion processing method that can improve the semantic consistency of the target large language model. The suggestion processing method provided in this application will be described in detail below.

[0132] This application provides a prompt processing method; please refer to [link / reference]. Figure 4 The prompt processing method provided in this application mainly includes the following steps:

[0133] 401. Input the inference prompt into the target extended language model, and obtain the first intermediate feature vector of the target extended language model through the target extended language model.

[0134] The target extended language model is composed of a target large language model and a target neural network component. The target extended language model has a corresponding bias vector, which is obtained by analyzing the output vector of the target extended language model during the training phase.

[0135] In this embodiment, the large language model to be trained can be trained in advance during the training phase to obtain the target large language model; and the neural network components to be trained can be trained to obtain the target neural network components. Finally, by inserting additional target neural network components into the trained target large language model, the target extended language model is obtained. Specifically, as shown... Figure 5 As shown, a target neural network component can be inserted after the attention layer and / or MLP layer and / or Transformer layer of the target large language model to obtain the target extended language model. Specifically, the target neural network component can be a Low-Rank Adaptation (LoRA) component or a Sparse Autoencoder (SAE) component, and can include an encoder and a decoder. The encoder of the target neural network component can compress or encode the original activation vector input to the target neural network component to generate an intermediate feature vector; then, the decoder of the target neural network component can reconstruct the intermediate feature vector into a reconstructed activation vector with the same dimension as the original activation vector.

[0136] The core idea of ​​the LoRA component is to optimize model parameters by introducing low-rank matrix factorization, thereby reducing computational cost and the number of parameters, and thus lowering the computational resources and storage requirements during training. The SAE component is a neural network-based autoencoder model whose goal is to reconstruct input data through learned sparse representations. Sparse autoencoders introduce sparsity constraints during the encoding process to encourage the network to learn more features. This can be achieved by adding a sparsity loss term, which encourages most neurons to remain silent in the output, i.e., restricting the activation of only a few neurons at any given time.

[0137] Specifically, after constructing the target extended language model in advance during the training phase, the output vectors of the target extended language model can be analyzed. For example, the intermediate feature vectors output by each layer of the target large language model and / or the intermediate feature vectors output by the target neural network components can be analyzed to obtain bias vectors. The bias vectors can be used to adjust and correct the intermediate feature vectors output by the target extended language model, thereby improving the semantic consistency of the target extended language model's output results. In other words, the bias vectors can be vectors used to improve the semantic consistency of the target extended language model. It should be noted that the target extended language model can have one or more bias vectors, and each bias vector can be used to correct intermediate feature vectors with the same output position. That is, the output position of the intermediate feature vector used to obtain the bias vector should be the same as the output position of the intermediate feature vector adjusted and corrected using the bias vector. Here, the output position of the intermediate feature vector refers to the position of the layer or target neural network component that outputs the intermediate feature vector.

[0138] Understandably, during the inference phase, the user-inputted hints, such as questions or other textual data, can be obtained first and then input into the target extended language model. After the target extended language model performs inference using the hints as input data, each layer of the target large language model and the target neural network component within the target extended language model can output intermediate feature vectors corresponding to the hints. This generates multiple intermediate feature vectors corresponding to the hints in the target extended language model. From these multiple intermediate feature vectors, the intermediate feature vector with the same output position as the bias vector can be determined and used as the first intermediate feature vector. Here, the output position corresponding to the bias vector refers to the position of the layer or target neural network component in the target extended language model that outputs the intermediate feature vector used to analyze and obtain the bias vector.

[0139] In one possible implementation of this application embodiment, the bias vector of the target extended language model may include at least one of a first bias vector and a second bias vector. The first bias vector may be obtained by analyzing the output vector of the target neural network component in the target extended language model, and may be a bias vector used to adjust and correct the first intermediate feature vector output by the target neural network component in the target extended language model during inference. The second bias vector may be obtained by analyzing the output vector of the target large language model in the target extended language model, and may be a bias vector used to adjust and correct the first intermediate feature vector output by the target large language model in the target extended language model during inference.

[0140] 402. Adjust the first intermediate feature vector based on the bias vector to obtain the target intermediate feature vector.

[0141] The output position of the first intermediate feature vector is the same as the output position of the bias vector.

[0142] In this embodiment, after determining the first intermediate feature vector, the first intermediate feature vector can be adjusted and corrected using a pre-acquired and stored bias vector to obtain a corrected target intermediate feature vector. This allows for continued inference based on the corrected target intermediate feature vector and the target extended language model, thereby optimizing and enhancing the semantic consistency of the target large language model and improving its semantic consistency. It is understood that the output position of the first intermediate feature vector is the same as the output position of the intermediate feature vector used to analyze and obtain the bias vector.

[0143] In one possible implementation of this application embodiment, step 402 adjusts the first intermediate feature vector based on the bias vector to obtain the target intermediate feature vector, including:

[0144] A1. Linearly weight the bias vector and the first intermediate feature vector to obtain the target intermediate feature vector.

[0145] In this embodiment, after obtaining the bias vector and the first intermediate feature vector, the first intermediate feature vector can be adjusted and corrected by linearly weighting the bias vector and the first intermediate feature vector, thereby obtaining the target intermediate feature vector. It is understood that the specific linear weighting method and the specific weight values ​​can be set according to specific circumstances, and this embodiment does not limit them.

[0146] 403. Based on the target intermediate feature vector and the target extended language model, perform reasoning to generate the target result to be reasoned.

[0147] In this embodiment, after adjusting and correcting the first intermediate feature vector to obtain the target intermediate feature vector, the first intermediate feature vector output by the target extended language model can be replaced with the target intermediate feature vector, and the target extended language model can continue reasoning to generate the target result to be inferred. It is understood that by replacing the first intermediate feature vector generated by the target extended language model during reasoning with the target intermediate feature vector, the target output result of the target extended language model can avoid semantic inconsistencies as much as possible, thereby optimizing and enhancing the semantic consistency of the target large language model and improving its semantic consistency.

[0148] According to the prompt processing method provided in the embodiments of this application, when reasoning about the prompt to be reasoned, the target extended language model obtained by inserting the trained target neural network component on the basis of the target large language model can be used to reason about the prompt to be reasoned. Furthermore, the first intermediate feature vector generated by the target extended language model during the reasoning process can be adjusted and corrected based on the bias vector obtained by analyzing the output vector of the target extended language model during the training phase. This can optimize and enhance the semantic consistency of the target large language model, thereby improving the semantic consistency of the target large language model.

[0149] The foregoing has described the process of the prompt processing method provided in this application. The following section will provide a more detailed description of the process of the prompt processing method provided in this application, taking into account a specific training phase scenario.

[0150] This application provides another method for handling prompts; please refer to [link / reference]. Figure 6 Another prompt processing method provided in this application embodiment mainly includes the following steps:

[0151] 601. Obtain the target large language model, target neural network components, and sample dataset.

[0152] The sample dataset includes a first dataset, which contains positive prompts and misleading prompts. Positive prompts are those that indicate the target large language model will output the correct result, while misleading prompts are synonyms of the positive prompts and those that indicate the target large language model will output the wrong result.

[0153] In this embodiment of the application, during the training phase, a target large language model trained by the large language model to be trained can be obtained, as well as a target neural network component trained by the neural network component to be trained, and a sample dataset including the first dataset can be pre-constructed.

[0154] It is understandable that the target neural network component can specifically be a low-rank adaptive component or a sparse autoencoder component, and the target neural network component can include an encoder and a decoder. The encoder of the target neural network component can compress or encode the original activation vector input to the target neural network component to generate an intermediate feature vector; then the decoder of the target neural network component can reconstruct the intermediate feature vector into a reconstructed activation vector with the same dimension as the original activation vector.

[0155] The first dataset in the sample dataset can include both positive and misleading prompts. Positive and misleading prompts can be synonymous; inputting a positive prompt into the target language model will produce the correct output, while inputting a misleading prompt will produce an incorrect output. For example, if the prompts are "How long is a day?" and "How many hours are in a day?", inputting "How long is a day?" into the target language model will output 24 hours; inputting "How many hours are in a day?" will output 48 hours. Therefore, "How long is a day?" is a positive prompt, and "How many hours are in a day?" is a misleading prompt.

[0156] In one possible implementation of this application embodiment, obtaining the first dataset includes:

[0157] B1. Obtain multiple original prompts and the correct output results corresponding to the multiple original prompts.

[0158] In this embodiment, multiple initial prompts and the correct output result corresponding to each initial prompt can be obtained first. The initial prompts can be pre-annotated prompts that have correct results.

[0159] B2. Input multiple original prompts into the labeled large language model to generate multiple synonym prompts corresponding to the original prompts.

[0160] Each original prompt corresponds to one or more synonym prompts.

[0161] In this embodiment, after obtaining multiple original prompts, each original prompt can be input into a large-scale annotation language model to obtain a synonym prompt corresponding to each original prompt. The large-scale annotation language model can be a large-scale language model used to process the original data and add labels or annotations.

[0162] B3. Input multiple original prompts and multiple synonym prompts into the target large language model respectively, and generate the output results of multiple original prompts and multiple synonym prompts.

[0163] In this embodiment of the application, after obtaining multiple original prompts and multiple synonym prompts, each original prompt and each synonym prompt can be input into the target large language model to generate the output result of each original prompt and the output result of each synonym prompt.

[0164] B4. Generate the first dataset based on multiple original prompts, multiple synonym prompts, the output results of multiple original prompts, the output results of multiple synonym prompts, and the correct output results corresponding to multiple original prompts.

[0165] In this embodiment, after generating the output results of each original prompt and each synonym prompt based on the target large language model, the original prompts whose output results match the correct output results can be identified as candidate positive prompts based on the correct output results and the output results of each original prompt among multiple original prompts. Then, the output results of the synonym prompts corresponding to each candidate positive prompt are compared with the correct output results corresponding to the candidate positive prompts. Candidate positive prompts whose output results of the corresponding synonym prompts do not match the correct output results corresponding to the candidate positive prompts are identified as positive prompts, and the synonym prompts corresponding to the positive prompts are identified as misleading prompts, thereby generating the first dataset.

[0166] In one possible implementation of this application embodiment, the sample dataset may further include a third dataset. The third dataset includes the original prompt, the corresponding synonym prompt, and a semantic consistency label. The semantic consistency label indicates whether the output of the target large language model is consistent with the output of the target large language model when the original prompt is input. In this application embodiment, the obtained sample dataset may further include a third dataset, which may include the original prompt, the corresponding synonym prompt, and a semantic consistency label indicating whether the output of the target large language model when the original prompt is input is consistent with the output of the target large language model when the synonym prompt is input.

[0167] In one possible implementation of this application embodiment, obtaining the third dataset includes:

[0168] C1. Get multiple original prompts.

[0169] C2. Input multiple original prompts into the labeled large language model to generate multiple synonym prompts corresponding to the original prompts, with each original prompt corresponding to one synonym prompt.

[0170] In this embodiment, raw prompts can be obtained first, where raw prompts can be unannotated. After obtaining multiple raw prompts, each raw prompt can be input into the large language annotation model to obtain synonym prompts corresponding to each raw prompt.

[0171] C3. Input multiple original prompts and multiple synonym prompts into the target large language model respectively, and generate the output results of multiple original prompts and multiple synonym prompts.

[0172] In this embodiment, each original prompt and its corresponding synonym can be input into the target large language model to generate the output result of each original prompt and the output result of the corresponding synonym.

[0173] C4. Input the output results of multiple original prompts and multiple synonym prompts into the annotation large language model to generate semantically consistent labels;

[0174] In this embodiment of the application, after obtaining the output results of each original prompt among multiple original prompts and the output results of each synonym prompt among multiple synonym prompts through the target large language model, the output results of each original prompt and the corresponding synonym prompt can be input into the standard large language model to determine whether the output results of each original prompt and the corresponding synonym prompt are consistent. Based on the determination result, a semantic consistency label is output that indicates whether the output results of the original prompt input into the target large language model are consistent with the output results of the synonym prompt input into the target large language model.

[0175] C5. Generate a third dataset based on multiple original prompts, multiple synonym prompts, the output results of multiple original prompts, the output results of multiple synonym prompts, and semantic consistency labels.

[0176] In this embodiment, after generating semantic consistency labels based on the annotated large language model, a third dataset can be constructed based on multiple original prompts, multiple synonym prompts, the output results of multiple original prompts, the output results of multiple synonym prompts, and the semantic consistency labels. Specifically, the constructed third dataset can be represented by D = {([p, q], [rp, rq, c]). Here, p represents the original prompt, q represents the synonym prompt, rp represents the output result of inputting the original prompt into the target large language model, rq represents the output result of inputting the synonym prompt into the target large language model, and c represents the semantic consistency label.

[0177] In one possible implementation of this application embodiment, obtaining the target neural network component includes:

[0178] D1. Obtain the neural network components to be trained and the second dataset.

[0179] The second dataset includes text data.

[0180] In this embodiment, a neural network component to be trained can be obtained first, and its parameters and weights can be initialized. A second dataset including text data can also be obtained, where the text data can be arbitrary, to facilitate training the neural network component to obtain the target neural network component.

[0181] D2. Insert the neural network components into the target large language model to generate an extended language model.

[0182] In this embodiment, after obtaining the neural network components to be trained, the neural network components can be inserted into the target large language model to obtain an extended language model. Specifically, the neural network components can be inserted after the attention layer and / or MLP layer and / or Transformer layer of the target large language model to obtain the extended language model.

[0183] D3. Calculate the target parameters of the neural network components based on the second dataset and the extended language model.

[0184] In this embodiment of the application, after obtaining the second dataset and the extended language model, the second dataset can be input into the extended language model, and the output vector of the extended language model can be analyzed and calculated to obtain the target parameters of the neural network component, so that the target neural network component can be constructed based on the target parameters.

[0185] In one possible implementation of this application embodiment, step D3 calculates the target parameters of the neural network component based on the second dataset and the extended language model, including:

[0186] D31. Input the second dataset into the extended language model to generate the feature vector dataset of the neural network components.

[0187] The feature vector dataset includes the input vector and the corresponding output vector.

[0188] In this embodiment, the input vector is the input vector of the neural network component in the extended language model, and the output vector is the output vector obtained after inputting the input vector into the neural network component in the extended language model. It can be understood that text data from the second dataset can be input into the extended language model to obtain the input vector to the neural network component, and the output vector obtained by inputting the input vector into the neural network component in the extended language model. Finally, a feature vector dataset for the neural network component is constructed based on the input vector and the corresponding output vector.

[0189] D32. Determine target parameters based on feature vector datasets and dictionary learning.

[0190] In this embodiment, dictionary learning refers to learning a "dictionary" to represent data. This "dictionary" contains all the elements needed for the data; these elements are also called "atoms" or "basis vectors," and can be linearly combined using different weight coefficients to represent any form of data. After obtaining the feature vector dataset of the neural network component, dictionary learning can be used to analyze and calculate the feature vector dataset to determine the target parameters required to construct the target neural network component.

[0191] Specifically, the feature vector dataset of a neural network component can be represented by A = {ai ∈ Rd, i = 1, ..., n}, where Rd represents a vector set with d dimensions. When analyzing the feature vector dataset using dictionary learning, an initial dictionary F = {fk ∈ Rd, k = 1, ..., m} can be selected, where m > d. Then, a sparse coding coefficient C = {ck ∈ R, k = 1, ..., m} is determined, where R is the set of real numbers. That is, for the feature vector dataset, a set of sparse coding coefficients can be found such that the feature vector dataset ai ∈ Rd can be approximated by a linear combination of elements in the initial dictionary. Then, the elements in the dictionary can be updated so that the updated dictionary can better find suitable sparse coding coefficients for representation. Finally, by alternately updating the dictionary and sparse coding coefficients until a specified number of iterations is reached, the target parameters are determined based on the updated dictionary and sparse coding coefficients.

[0192] D4. Construct the target neural network component based on the target parameters and neural network components.

[0193] In this embodiment of the application, after obtaining the target parameters, the target neural network component can be obtained by updating the parameters of the neural network component to be trained to the target parameters.

[0194] 602. Insert the target neural network component into the target large language model to generate the target extended language model.

[0195] In this embodiment, after obtaining the trained target neural network component and the trained target large language model, the target neural network component can be inserted into the target large language model to obtain the target extended language model. Specifically, the target neural network component can be inserted after the attention layer and / or MLP layer and / or Transformer layer of the target large language model to obtain the target extended language model.

[0196] In one possible implementation of this application embodiment, step 602 inserts the target neural network component into the target large language model to generate the target extended language model, including:

[0197] E1. Input the original prompts and synonym prompts from the third dataset into the target large language model to generate the second intermediate feature vector corresponding to each output position in the target large language model.

[0198] In this embodiment, after obtaining the third dataset and the target large language model from the sample dataset, the original prompts from the third dataset can be input into the target large language model to obtain the second intermediate feature vector corresponding to the original prompts output at each output position in the target large language model. Similarly, synonym prompts from the third dataset can be input into the target large language model to obtain the second intermediate feature vector corresponding to the synonym prompts output at each output position in the target large language model. That is, the second intermediate feature vector can include both the second intermediate feature vector corresponding to the original prompts and the second intermediate feature vector corresponding to the synonym prompts. The second intermediate feature vector corresponding to the original prompts can be called the first intermediate feature sub-vector pi, and the second intermediate feature vector corresponding to the synonym prompts can be called the second intermediate feature sub-vector qi. Each output position in the target large language model refers to the position of each layer in the target large language model that can output intermediate feature vectors.

[0199] E2. Based on the semantic consistency labels of the third dataset and the second intermediate feature vector, train to generate the first classifier corresponding to each output position.

[0200] In this embodiment, after generating the second intermediate feature vector, training samples D = {(concat(pi, qi), c), i ∈ 1, 2, ..., N} can be constructed based on the second intermediate feature vector and the semantic consistency labels in the third semantic dataset. Here, pi can be the second intermediate feature vector corresponding to the i-th output position in the target large language model and the original prompt, and qi can be the second intermediate feature vector corresponding to the i-th output position in the target large language model and the synonym prompt. Then, the first classifier corresponding to each output position in the target large language model can be trained based on the constructed training samples. That is, if there are k output positions in the target large language model, k first classifiers can be trained, with one first classifier trained for each output position. The training samples for each first classifier corresponding to an output position include the second intermediate feature vector corresponding to that output position.

[0201] It should be noted that after training the first classifier corresponding to each output position in the target large language model, the classification accuracy of each first classifier can be calculated. Specifically, this can be done by constructing test samples corresponding to the training samples. The higher the classification accuracy of the first classifier, the greater the influence of the output position of the corresponding first classifier in the target large language model on the target large language model.

[0202] E3. Insert the target neural network components into the key output positions of the target large language model to generate the target extended language model.

[0203] The key output position is the output position corresponding to the first classifier whose classification accuracy is greater than the first threshold.

[0204] In this embodiment, after training and generating a first classifier corresponding to each output position in the target large language model, the first classifiers can be sorted according to their classification accuracy. If the classification accuracy of the first classifier is greater than a first threshold, it indicates that the output position in the target large language model corresponding to the first classifier has a significant impact on the target large language model. Therefore, the output position corresponding to the first classifier with an accuracy greater than the first threshold can be identified as a key output position in the target large language model. Furthermore, target neural network components can be inserted into the key output positions in the target large language model to generate a target extended language model, thereby further improving the semantic consistency of the target large language model. It should be noted that after obtaining the bias vector, this bias vector can be stored.

[0205] 603. Obtain the bias vector based on the first dataset and the target extended language model.

[0206] In this embodiment of the application, after obtaining the first dataset from the sample dataset and generating the target extended language model, the data in the first dataset can be input into the target extended language model, and the output vector of the target extended language model can be analyzed and calculated to obtain the bias vector. This allows the first intermediate feature vector generated by the target extended language model during the inference process to be adjusted and corrected based on the bias vector. This enables the optimization and enhancement of the target large language model in terms of semantic consistency, thereby improving the semantic consistency of the target large language model.

[0207] It is understood that the bias vector may include at least one of a first bias vector and a second bias vector. The first bias vector may be obtained by analyzing the output vector of the target neural network component in the target extended language model, and may be a bias vector used to adjust and correct the first intermediate feature vector output by the target neural network component in the target extended language model during inference. The second bias vector may be obtained by analyzing the output vector of the target large language model in the target extended language model, and may be a bias vector used to adjust and correct the first intermediate feature vector output by the target large language model in the target extended language model during inference.

[0208] In one possible implementation of this application embodiment, step 603, obtaining the bias vector based on the first dataset and the target extended language model, includes:

[0209] F1. Input the positive and misleading prompts into the target extended language model respectively to generate the third intermediate feature vector corresponding to the positive prompt and the fourth intermediate feature vector corresponding to the misleading prompt.

[0210] Among them, the third intermediate feature vector and the fourth intermediate feature vector are the output vectors of the target neural network component.

[0211] In this embodiment, positive prompts from the first dataset can be input into the target extended language model to obtain the third intermediate feature vector corresponding to the positive prompts output by the target neural network component in the target extended language model; misleading prompts from the first dataset can also be input into the target extended language model to obtain the fourth intermediate feature vector corresponding to the misleading prompts output by the target neural network component in the target extended language model.

[0212] It is understandable that if multiple output positions in the target extended language model are inserted with target neural network components, that is, if the target extended language model includes multiple target neural network components, then the third intermediate feature vector and the fourth intermediate feature vector corresponding to each target neural network component can be generated. In other words, the output position corresponding to each target neural network component has the corresponding third intermediate feature vector and the fourth intermediate feature vector.

[0213] In one possible implementation of this application embodiment, step F1 inputs positive and misleading prompts into the target extended language model respectively, generating a third intermediate feature vector corresponding to the positive prompt and a fourth intermediate feature vector corresponding to the misleading prompt, including:

[0214] F11. Input the positive and misleading prompts into the target extended language model respectively to generate the first original activation vector of the positive prompt and the second original activation vector corresponding to the misleading prompt.

[0215] In this embodiment, a positive prompt can be input into the target extended language model to obtain a first original activation vector output by the target extended language model corresponding to the positive prompt; a misleading prompt can also be input into the target extended language model to obtain a second original activation vector output by the target extended language model corresponding to the misleading prompt. Both the first and second original activation vectors can be input vectors of the target neural network component in the target extended language model.

[0216] F12. Input the first and second original activation vectors into the encoder of the target neural network component for compression to obtain the third and fourth intermediate feature vectors.

[0217] Among them, the dimensions of the third and fourth intermediate feature vectors are lower than the dimensions of the first and second original activation vectors.

[0218] In this embodiment, when the target neural network component is a LoRA component, the first and second original activation vectors can be input into the target neural network component, respectively. The encoder of the target neural network component compresses the first and second original activation vectors into lower-dimensional third and fourth intermediate feature vectors, respectively. It should be noted that the third and fourth intermediate feature vectors can also be reconstructed by the decoder of the target neural network component into first and second reconstructed activation vectors with the same dimensions as the first and second original activation vectors.

[0219] In one possible implementation of this application embodiment, step F1 inputs positive and misleading prompts into the target extended language model respectively, generating a third intermediate feature vector corresponding to the positive prompt and a fourth intermediate feature vector corresponding to the misleading prompt, including:

[0220] F13. Input the positive and misleading prompts into the target extended language model respectively to generate the first original activation vector of the positive prompt and the second original activation vector corresponding to the misleading prompt.

[0221] In this embodiment, a positive prompt can be input into the target extended language model to obtain a first original activation vector output by the target extended language model corresponding to the positive prompt; a misleading prompt can also be input into the target extended language model to obtain a second original activation vector output by the target extended language model corresponding to the misleading prompt. Both the first and second original activation vectors can be input vectors of the target neural network component in the target extended language model.

[0222] F14. Input the first and second original activation vectors into the encoder of the target neural network component for encoding to obtain the third and fourth intermediate feature vectors.

[0223] Among them, the dimensions of the third and fourth intermediate feature vectors are higher than those of the first and second original activation vectors.

[0224] In this embodiment, when the target neural network component is an SAE component, the first and second original activation vectors can be input into the target neural network component, respectively. The encoder of the target neural network component encodes the first and second original activation vectors into higher-dimensional third and fourth intermediate feature vectors, respectively. It should be noted that the third and fourth intermediate feature vectors can also be reconstructed by the decoder of the target neural network component into first and second reconstructed activation vectors with the same dimensions as the first and second original activation vectors.

[0225] F2. Calculate the difference between the third and fourth intermediate eigenvectors to obtain the first bias vector in the bias vector.

[0226] In this embodiment, when generating the third intermediate feature vector corresponding to the positive prompt and the fourth intermediate feature vector corresponding to the misleading prompt, the difference between the third and fourth intermediate feature vectors can be calculated to obtain the first bias vector in the bias vector. This allows for the adjustment and correction of the first intermediate feature vector corresponding to the first bias vector generated by the target extended language model during the inference process, thereby optimizing and enhancing the semantic consistency of the target large language model and improving its semantic consistency. The first bias vector can be represented as b1 = f3(p) - f4(q), where f3(p) is the third intermediate feature vector and f4(q) is the fourth intermediate feature vector.

[0227] It is understandable that if multiple output positions in the target extended language model are inserted with target neural network components, that is, if the target extended language model includes multiple target neural network components, then the first bias vector corresponding to each target neural network component can be calculated.

[0228] In one possible implementation of this application embodiment, only the first bias vector corresponding to the target neural network component inserted into the key output position in the target extended language model can be calculated. The method for determining the key output position in the target extended language model can refer to steps E1-E2 described above, and will not be repeated here.

[0229] In one possible implementation of this application embodiment, the method further includes:

[0230] F3. Input the positive and misleading prompts into the target extended language model respectively to generate the fifth intermediate feature vector corresponding to the positive prompt and the sixth intermediate feature vector corresponding to the misleading prompt.

[0231] Among them, the fifth intermediate feature vector and the sixth intermediate feature vector are the output vectors of the target large language model.

[0232] In this embodiment of the application, positive prompts from the first dataset can also be input into the target extended language model to obtain the fifth intermediate feature vector corresponding to the positive prompts output by the target large language model in the target extended language model; misleading prompts from the first dataset can also be input into the target extended language model to obtain the sixth intermediate feature vector corresponding to the misleading prompts output by the target large language model in the target extended language model.

[0233] It is understandable that if multiple layers of the target large language model in the target extended language model can output intermediate feature vectors, that is, multiple output positions of the target large language model can output intermediate feature vectors, then the fifth intermediate feature vector and the sixth intermediate feature vector corresponding to each output position in the large language model can be generated. In other words, each output position of the target large language model has a corresponding fifth intermediate feature vector and a sixth intermediate feature vector.

[0234] F4. Calculate the difference between the fifth and sixth intermediate eigenvectors to obtain the second bias vector in the bias vector.

[0235] In this embodiment, when generating the fifth intermediate feature vector corresponding to the positive prompt and the sixth intermediate feature vector corresponding to the misleading prompt, the difference between the fifth and sixth intermediate feature vectors can be calculated to obtain the second bias vector in the bias vector. This allows for the adjustment and correction of the first intermediate feature vector corresponding to the second bias vector generated by the target extended language model during the inference process, further optimizing and enhancing the semantic consistency of the target large language model, thereby improving the semantic consistency of the target large language model. The second bias vector can be represented as b2 = f5(p) - f6(q), where f5(p) is the fifth intermediate feature vector and f4(q) is the sixth intermediate feature vector.

[0236] It is understandable that if multiple output positions of the target large language model in the target extended language model can output intermediate feature vectors, that is, the target large language model has multiple output positions, then the second bias vector corresponding to each output position in the target large language model can be calculated.

[0237] In one possible implementation of this application embodiment, only the second bias vector corresponding to the key output position of the target large language model in the target extended model can be calculated. The method for determining the key output position of the target large language model in the target extended model can refer to steps E1-E2 described above, and will not be repeated here.

[0238] 604. Input the inference prompt into the target extended language model, and obtain the first intermediate feature vector of the target extended language model through the target extended language model.

[0239] The target extended language model is composed of a target large language model and a target neural network component. The target extended language model has a corresponding bias vector, which is obtained by analyzing the output vector of the target extended language model during the training phase.

[0240] 605. Adjust the first intermediate feature vector based on the bias vector to obtain the target intermediate feature vector.

[0241] The output position of the first intermediate feature vector is the same as the output position of the bias vector.

[0242] 606. Based on the target intermediate feature vector and the target extended language model, reasoning is performed to generate the target result to be reasoned.

[0243] Steps 604-606 are similar to steps 401-403 mentioned above, and will not be repeated here.

[0244] According to the prompt processing method provided in the embodiments of this application, when reasoning about the prompt to be reasoned, the target extended language model obtained by inserting the trained target neural network component on the basis of the target large language model can be used to reason about the prompt to be reasoned. Furthermore, the first intermediate feature vector generated by the target extended language model during the reasoning process can be adjusted and corrected based on the bias vector obtained by analyzing the output vector of the target extended language model during the training phase. This can optimize and enhance the semantic consistency of the target large language model, thereby improving the semantic consistency of the target large language model.

[0245] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0246] To facilitate better implementation of the above-described solutions in the embodiments of this application, related apparatus for implementing the above-described solutions is also provided below.

[0247] Please see Figure 7 As shown in the figure, an embodiment of this application provides a prompting processing device 700, including:

[0248] The reasoning module 701 is used to input the prompt to be reasoned into the target extended language model, and obtain the first intermediate feature vector of the target extended language model through the target extended language model. The target extended language model is composed of a target large language model and a target neural network component. The target extended language model has a bias vector, which is obtained after analyzing the output vector of the target extended language model.

[0249] The adjustment module 702 is used to adjust the first intermediate feature vector based on the bias vector to obtain the target intermediate feature vector, wherein the output position of the first intermediate feature vector is the same as the output position corresponding to the bias vector.

[0250] The reasoning module 701 is further configured to perform reasoning based on the target intermediate feature vector and the target extended language model to generate the target result of the reasoning prompt.

[0251] In one possible implementation of this application embodiment, the adjustment module 702 is specifically used for:

[0252] The bias vector and the first intermediate feature vector are linearly weighted to obtain the target intermediate feature vector.

[0253] In one possible implementation of this application embodiment, the apparatus further includes:

[0254] The acquisition module is used to acquire the target large language model, the target neural network component, and the sample dataset. The sample dataset includes a first dataset, which includes positive prompts and misleading prompts. The positive prompts are prompts that indicate the target large language model gives the correct output result, the misleading prompts are synonyms of the positive prompts, and the misleading prompts are prompts that indicate the target large language model gives the wrong output result.

[0255] A generation module is used to insert the target neural network component into the target large language model to generate a target extended language model;

[0256] The acquisition module is also used to acquire the bias vector based on the first dataset and the target extended language model.

[0257] In one possible implementation of this application embodiment, the acquisition module is specifically used for:

[0258] Obtain multiple original prompts and the correct output results corresponding to the multiple original prompts;

[0259] The multiple original prompts are input into the labeled large language model to generate multiple synonym prompts corresponding to the multiple original prompts, with each original prompt corresponding to one or more synonym prompts;

[0260] The multiple original prompts and the multiple synonym prompts are respectively input into the target large language model to generate the output results of the multiple original prompts and the output results of the multiple synonym prompts;

[0261] The first dataset is generated based on the multiple original prompts, the multiple synonym prompts, the output results of the multiple original prompts, the output results of the multiple synonym prompts, and the correct output results corresponding to the multiple original prompts.

[0262] In one possible implementation of this application embodiment, the acquisition module is specifically used for:

[0263] Obtain the neural network components to be trained and a second dataset, the second dataset including text data;

[0264] The neural network component is inserted into the target large language model to generate an extended language model;

[0265] The target parameters of the neural network component are calculated based on the second dataset and the extended language model.

[0266] The target neural network component is constructed based on the target parameters and the neural network component.

[0267] In one possible implementation of this application embodiment, the acquisition module is specifically used for:

[0268] The second dataset is input into the extended language model to generate the feature vector dataset of the neural network component, the feature vector dataset including the input vector and the output vector corresponding to the input vector;

[0269] The target parameters are determined based on the feature vector dataset and dictionary learning.

[0270] In one possible implementation of this application embodiment, the sample dataset further includes a third dataset, which includes the original prompt, the synonym prompt corresponding to the original prompt, and a semantic consistency label. The semantic consistency label is used to indicate whether the output result of the original prompt input into the target large language model is consistent with the output result of the synonym prompt input into the target large language model; the generation module is specifically used for:

[0271] The original prompts and synonym prompts of the third dataset are input into the target large language model to generate a second intermediate feature vector corresponding to each output position in the target large language model;

[0272] Based on the semantic consistency labels of the third dataset and the second intermediate feature vector, a first classifier is trained to generate each output position.

[0273] The target neural network component is inserted into the key output position of the target large language model to generate the target extended language model. The key output position is the output position corresponding to the first classifier whose classification accuracy is greater than the first threshold.

[0274] In one possible implementation of this application embodiment, the acquisition module is specifically used for:

[0275] Retrieve multiple original prompts;

[0276] The multiple original prompts are input into the labeled large language model to generate multiple synonym prompts corresponding to the multiple original prompts, with each original prompt corresponding to one synonym prompt.

[0277] The multiple original prompts and the multiple synonym prompts are respectively input into the target large language model to generate the output results of the multiple original prompts and the output results of the multiple synonym prompts;

[0278] The output results of the multiple original prompts and the output results of the multiple synonym prompts are input into the labeled large language model to generate semantically consistent labels;

[0279] The third dataset is generated based on the multiple original prompts, the multiple synonym prompts, the output results of the multiple original prompts, the output results of the multiple synonym prompts, and the semantic consistency labels.

[0280] In one possible implementation of this application embodiment, the acquisition module is specifically used for:

[0281] The positive prompt and the misleading prompt are respectively input into the target extended language model to generate a third intermediate feature vector corresponding to the positive prompt and a fourth intermediate feature vector corresponding to the misleading prompt. The third intermediate feature vector and the fourth intermediate feature vector are the output vectors of the target neural network component.

[0282] The difference between the third intermediate feature vector and the fourth intermediate feature vector is calculated to obtain the first bias vector in the bias vector.

[0283] In one possible implementation of this application embodiment, the acquisition module is specifically used for:

[0284] The positive prompt and the misleading prompt are respectively input into the target extended language model to generate a first original activation vector for the positive prompt and a second original activation vector corresponding to the misleading prompt;

[0285] The first and second original activation vectors are respectively input into the encoder of the target neural network component for compression to obtain the third and fourth intermediate feature vectors. The dimensions of the third and fourth intermediate feature vectors are lower than the dimensions of the first and second original activation vectors.

[0286] In one possible implementation of this application embodiment, the acquisition module is specifically used for:

[0287] The positive prompt and the misleading prompt are respectively input into the target extended language model to generate a first original activation vector for the positive prompt and a second original activation vector corresponding to the misleading prompt;

[0288] The first and second original activation vectors are respectively input into the encoder of the target neural network component for encoding to obtain the third and fourth intermediate feature vectors. The dimensions of the third and fourth intermediate feature vectors are higher than the dimensions of the first and second original activation vectors.

[0289] In one possible implementation of this application embodiment, the acquisition module is further configured to:

[0290] The positive prompt and the misleading prompt are respectively input into the target extended language model to generate the fifth intermediate feature vector corresponding to the positive prompt and the sixth intermediate feature vector corresponding to the misleading prompt. The fifth intermediate feature vector and the sixth intermediate feature vector are the output vectors of the target large language model.

[0291] The difference between the fifth intermediate feature vector and the sixth intermediate feature vector is calculated to obtain the second bias vector in the bias vector.

[0292] According to the prompt processing device provided in the embodiments of this application, when performing reasoning on the prompt to be reasoned, the target extended language model obtained by inserting the trained target neural network component on the basis of the target large language model can be used to perform reasoning on the prompt to be reasoned. Furthermore, the first intermediate feature vector generated by the target extended language model during the reasoning process can be adjusted and corrected based on the bias vector obtained by analyzing the output vector of the target extended language model during the training phase. This can achieve optimization and enhancement of the semantic consistency of the target large language model, thereby improving the semantic consistency of the target large language model.

[0293] In this embodiment, the module is an example of a software functional unit, and the data processing device may include code running on a computing instance. The computing instance may be at least one of a physical host (computer device), a virtual machine, a container, or other computer device. Further, the aforementioned computer device may be one or more. For example, the data processing device may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the application may be distributed in the same region or in different regions. The multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one or more geographically proximate data centers. Typically, a region may include multiple AZs.

[0294] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same Virtual Private Cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a single region. Communication between two VPCs within the same region, and between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.

[0295] As an example of a hardware functional unit, a data processing device may include at least one computer device, such as a server. Alternatively, the data processing device may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The aforementioned PLD may be implemented using a complex PLD (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof.

[0296] The data processing device comprises multiple computer devices that can be distributed within the same region or in different regions. Similarly, the multiple computer devices can be distributed within the same Availability Zone (AZ) or in different AZs. Likewise, the multiple computer devices can be distributed within the same Virtual Private Cloud (VPC) or multiple VPCs. These multiple computer devices can be any combination of computer devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.

[0297] This application also provides a computer device 130. For example... Figure 8 As shown, computer device 130 includes a bus 132, a processor 134, a memory 136, and a communication interface 138. The processor 134, memory 136, and communication interface 138 communicate with each other via the bus 132. Computer device 130 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in computer device 130.

[0298] Bus 132 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 8 The bus 134 is represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 134 may include a path for transmitting information between various components of the computer device 130 (e.g., memory 136, processor 134, communication interface 138).

[0299] The processor 134 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0300] Memory 136 may include volatile memory, such as random access memory (RAM). Processor 134 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0301] The memory 136 stores executable program code, and the processor 134 executes the executable program code to implement the functions of the aforementioned acquisition module and training module, thereby realizing the data processing method applied to the computer device cluster in the above embodiment. That is, the memory 136 stores instructions for executing the data processing method applied to the computer device cluster in the above embodiment.

[0302] The communication interface 138 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computer device 130 and other devices or communication networks.

[0303] This application also provides a computer program product that, when run on a computer, causes the computer to execute the steps performed by the prompting processing device in the method described in the foregoing embodiments.

[0304] The prompting processing device provided in this application embodiment can be a chip, which includes a processing unit and a communication unit. The processing unit can be, for example, a processor, and the communication unit can be, for example, an input / output interface, pins, or circuits. The processing unit can execute computer execution instructions stored in the storage unit to cause the chip within the server to execute the prompting processing method described in the above embodiments. Optionally, the storage unit can be a storage unit within the chip, such as a register or cache. Alternatively, the storage unit can be a storage unit located outside the chip within the wireless access device, such as a read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions, such as random access memory (RAM).

[0305] Specifically, the aforementioned processing unit or processor can be a central processing unit (CPU), a neural-network processing unit (NPU), a graphics processing unit (GPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.

[0306] For example, please refer to Figure 9 , Figure 9 This is a schematic diagram of a chip provided in an embodiment of this application. The chip can be represented as a neural network processor (NPU) 120. The NPU 120 is mounted as a coprocessor on the host CPU, and tasks are assigned by the host CPU. The core part of the NPU is the arithmetic circuit 120, which is controlled by the controller 1204 to extract matrix data from the memory and perform multiplication operations.

[0307] In some implementations, the arithmetic circuit 1203 internally includes multiple process engines (PEs). In some implementations, the arithmetic circuit 1203 is a two-dimensional pulsating array. The arithmetic circuit 1203 can also be a one-dimensional pulsating array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 1203 is a general-purpose matrix processor.

[0308] For example, suppose we have an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from the weight memory 1202 and caches it in each PE of the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from the input memory 1201 and performs matrix operations with matrix B. The partial result or the final result of the obtained matrix is ​​stored in the accumulator 1208.

[0309] Unified memory 1206 is used to store input and output data. Weight data is directly transferred to weight memory 1202 via direct memory access controller (DMAC) 1205. Input data is also transferred to unified memory 1206 via DMAC.

[0310] The bus interface unit (BIU) 1210 is used for interaction between the bus and the DMAC and the instruction fetch buffer (IFB) 1209.

[0311] The bus interface unit 1210 (BIU) is used by the instruction fetch memory 1209 to fetch instructions from external memory, and also by the memory access controller 1205 to fetch the original data of the input matrix A or the weight matrix B from external memory.

[0312] The DMAC is mainly used to move input data from external memory DDR to unified memory 1206, or to weight data to weight memory 1202, or to input data to input memory 1201.

[0313] The vector computation unit 1207 includes multiple arithmetic processing units that, when needed, further process the output of the computation circuit, such as vector multiplication, vector addition, exponential operations, logarithmic operations, size comparisons, etc. It is mainly used for computation in non-convolutional / fully connected layers of neural networks, such as batch normalization, pixel-level summation, and upsampling of feature planes.

[0314] In some implementations, the vector computation unit 1207 can store the processed output vector in the unified memory 1206. For example, the vector computation unit 1207 can apply linear and / or nonlinear functions to the output of the computation circuit 1203, such as performing linear interpolation on the feature planes extracted by the convolutional layer, or, for example, accumulating a vector of values ​​to generate activation values. In some implementations, the vector computation unit 1207 generates normalized values, pixel-level summed values, or both. In some implementations, the processed output vector can be used as an activation input to the computation circuit 1203, for example, for use in subsequent layers of the neural network.

[0315] The instruction fetch buffer 1209 connected to the controller 1204 is used to store the instructions used by the controller 1204;

[0316] Unified memory 1206, input memory 1201, weight memory 1202, and instruction fetch memory 1209 are all on-chip memories. External memory is proprietary to this NPU hardware architecture.

[0317] The operations of each layer in the recurrent neural network can be performed by the operation circuit 1203 or the vector calculation unit 1207.

[0318] The processor mentioned above can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits used to control the execution of the program for the above-described prompt processing method.

[0319] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.

[0320] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0321] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.

[0322] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0323] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0324] Finally, it should be noted that the above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A prompt processing method, characterized in that, The method includes: The inference prompt is input into the target extended language model, and the first intermediate feature vector of the target extended language model is obtained through the target extended language model. The target extended language model is composed of a target large language model and a target neural network component. The target extended language model has a corresponding bias vector, which is obtained by analyzing the output vector of the target extended language model during the training phase. The first intermediate feature vector is adjusted based on the bias vector to obtain the target intermediate feature vector, and the output position of the first intermediate feature vector is the same as the output position corresponding to the bias vector. Reasoning is performed based on the target intermediate feature vector and the target extended language model to generate the target result to be reasoned.

2. The method according to claim 1, characterized in that, The step of adjusting the first intermediate feature vector based on the bias vector to obtain the target intermediate feature vector includes: The bias vector and the first intermediate feature vector are linearly weighted to obtain the target intermediate feature vector.

3. The method according to claim 1 or 2, characterized in that, The method further includes: Obtain a target large language model, a target neural network component, and a sample dataset. The sample dataset includes a first dataset, which includes positive prompts and misleading prompts. The positive prompts are prompts that indicate the target large language model is giving the correct output result, the misleading prompts are synonyms of the positive prompts, and the misleading prompts are prompts that indicate the target large language model is giving the wrong output result. The target neural network component is inserted into the target large language model to generate the target extended language model; The bias vector is obtained based on the first dataset and the target extended language model.

4. The method according to claim 3, characterized in that, Obtain the first dataset, including: Obtain multiple original prompts and the correct output results corresponding to the multiple original prompts; The multiple original prompts are input into the labeled large language model to generate multiple synonym prompts corresponding to the multiple original prompts, with each original prompt corresponding to one or more synonym prompts; The multiple original prompts and the multiple synonym prompts are respectively input into the target large language model to generate the output results of the multiple original prompts and the output results of the multiple synonym prompts; The first dataset is generated based on the multiple original prompts, the multiple synonym prompts, the output results of the multiple original prompts, the output results of the multiple synonym prompts, and the correct output results corresponding to the multiple original prompts.

5. The method according to claim 3, characterized in that, Obtain the target neural network components, including: Obtain the neural network components to be trained and a second dataset, the second dataset including text data; The neural network component is inserted into the target large language model to generate an extended language model; The target parameters of the neural network component are calculated based on the second dataset and the extended language model. The target neural network component is constructed based on the target parameters and the neural network component.

6. The method according to claim 5, characterized in that, The target parameters of the neural network component calculated based on the second dataset and the extended language model include: The second dataset is input into the extended language model to generate the feature vector dataset of the neural network component, the feature vector dataset including the input vector and the output vector corresponding to the input vector; The target parameters are determined based on the feature vector dataset and dictionary learning.

7. The method according to any one of claims 3 to 6, characterized in that, The sample dataset also includes a third dataset, which includes the original prompt, the synonym prompt corresponding to the original prompt, and a semantic consistency label. The semantic consistency label is used to indicate whether the output result of the original prompt input into the target large language model is consistent with the output result of the synonym prompt input into the target large language model. The step of inserting the target neural network component into the target large language model to generate the target extended language model includes: The original prompts and synonym prompts of the third dataset are input into the target large language model to generate a second intermediate feature vector corresponding to each output position in the target large language model; Based on the semantic consistency labels of the third dataset and the second intermediate feature vector, a first classifier is trained to generate each output position. The target neural network component is inserted into the key output position of the target large language model to generate the target extended language model. The key output position is the output position corresponding to the first classifier whose classification accuracy is greater than the first threshold.

8. The method according to claim 7, characterized in that, Obtain the third dataset, including: Retrieve multiple original prompts; The multiple original prompts are input into the labeled large language model to generate multiple synonym prompts corresponding to the multiple original prompts, with each original prompt corresponding to one synonym prompt. The multiple original prompts and the multiple synonym prompts are respectively input into the target large language model to generate the output results of the multiple original prompts and the output results of the multiple synonym prompts; The output results of the multiple original prompts and the output results of the multiple synonym prompts are input into the labeled large language model to generate semantically consistent labels; The third dataset is generated based on the multiple original prompts, the multiple synonym prompts, the output results of the multiple original prompts, the output results of the multiple synonym prompts, and the semantic consistency labels.

9. The method according to any one of claims 3 to 6, characterized in that, The calculation of the bias vector based on the first dataset and the target extended language model includes: The positive prompt and the misleading prompt are respectively input into the target extended language model to generate a third intermediate feature vector corresponding to the positive prompt and a fourth intermediate feature vector corresponding to the misleading prompt. The third intermediate feature vector and the fourth intermediate feature vector are the output vectors of the target neural network component. The difference between the third intermediate feature vector and the fourth intermediate feature vector is calculated to obtain the first bias vector in the bias vector.

10. The method according to claim 9, characterized in that, The step of inputting the positive prompt and the misleading prompt into the target extended language model respectively to generate a third intermediate feature vector corresponding to the positive prompt and a fourth intermediate feature vector corresponding to the misleading prompt includes: The positive prompt and the misleading prompt are respectively input into the target extended language model to generate a first original activation vector for the positive prompt and a second original activation vector corresponding to the misleading prompt; The first and second original activation vectors are respectively input into the encoder of the target neural network component for compression to obtain the third and fourth intermediate feature vectors. The dimensions of the third and fourth intermediate feature vectors are lower than the dimensions of the first and second original activation vectors.

11. The method according to claim 9, characterized in that, The step of inputting the positive prompt and the misleading prompt into the target extended language model respectively to generate a third intermediate feature vector corresponding to the positive prompt and a fourth intermediate feature vector corresponding to the misleading prompt includes: The positive prompt and the misleading prompt are respectively input into the target extended language model to generate a first original activation vector for the positive prompt and a second original activation vector corresponding to the misleading prompt; The first and second original activation vectors are respectively input into the encoder of the target neural network component for encoding to obtain the third and fourth intermediate feature vectors. The dimensions of the third and fourth intermediate feature vectors are higher than the dimensions of the first and second original activation vectors.

12. The method according to claim 9, characterized in that, The method further includes: The positive prompt and the misleading prompt are respectively input into the target extended language model to generate the fifth intermediate feature vector corresponding to the positive prompt and the sixth intermediate feature vector corresponding to the misleading prompt. The fifth intermediate feature vector and the sixth intermediate feature vector are the output vectors of the target large language model. The difference between the fifth intermediate feature vector and the sixth intermediate feature vector is calculated to obtain the second bias vector in the bias vector.

13. A notification processing device, characterized in that, The device includes: The reasoning module is used to input the prompt to be reasoned into the target extended language model, and obtain the first intermediate feature vector of the target extended language model through the target extended language model. The target extended language model is composed of a target large language model and a target neural network component. The target extended language model has a bias vector, which is obtained by analyzing the output vector of the target extended language model. The adjustment module is used to adjust the first intermediate feature vector based on the bias vector to obtain the target intermediate feature vector, wherein the output position of the first intermediate feature vector is the same as the output position corresponding to the bias vector. The reasoning module is also used to perform reasoning based on the target intermediate feature vector and the target extended language model to generate the target result of the prompt to be reasoned.

14. A computer device, characterized in that, The device includes: Memory is used to store computer programs or computer instructions; A processor for executing a computer program or computer instructions stored in the memory, causing the computer device to perform the method as described in any one of claims 1 to 12.

15. A computer storage medium for storing a computer program, which, when executed, performs the method according to any one of claims 1 to 12.

16. A computer program product comprising instructions that, when run on a computer, cause the computer to perform the method as described in any one of claims 1 to 12.

17. A chip, the chip comprising a processor and a data interface, the processor reading instructions stored in a memory through the data interface to execute the method as described in any one of claims 1 to 12.