A method and device for processing a large language model by introducing a dense vector retriever

By introducing a dense vector retriever and feature fusion module into the large language model and using the dense vector database for updating and evaluation, the timeliness problem of the large language model is solved, and the maintenance cost is reduced and the economic value is increased during the knowledge iteration process.

CN119398193BActive Publication Date: 2025-09-26BEIJING DP TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411486178.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-09-26
Estimated Expiration
2044-10-23

AI Technical Summary

Technical Problem

When faced with knowledge updates and iterations, existing large language models require periodic fine-tuning, which leads to a waste of computing power and storage resources, an inability to maintain timeliness, increased maintenance costs, and reduced economic value.

Method used

A dense vector retriever and feature fusion module are introduced to achieve knowledge iteration through dense vector database updates and regular evaluations. Supplementary fine-tuning is only performed when timeliness decreases, maintaining model timeliness and reducing maintenance costs.

Benefits of technology

Without periodic fine-tuning, the model's timeliness is maintained, maintenance costs are reduced, economic value is increased, and the real-time performance of the model is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119398193B_ABST
    Figure CN119398193B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention relates to a method and device for processing a large language model that introduces a dense vector retriever. The method includes: using a class of large language models as a first large language model; initializing a dense vector database based on a directional text corpus used by the first large language model in fine-tuning a corresponding directional NLP task; adding a dense vector retriever and a feature fusion module to the first large language model to form a second large language model and training the second large language model; after training, the second large language model processes the directional NLP task with reference to the dense vector database; regularly updating the dense vector database, regularly evaluating the second large language model based on the latest dense vector database, and fine-tuning the second large language model if the evaluation fails. The present invention can ensure the timeliness of the model, reduce the maintenance cost of the model, and improve the economic value of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a method and device for processing a large language model by introducing a dense vector retriever. Background Art

[0002] Common large language models (LLMs) implemented based on the Transformer model architecture include the BERT series of models, the BART series of models, the GPT series of models, and the T5 series of models. These large language models are widely used in a variety of natural language processing (NLP) tasks, such as machine translation tasks and intelligent question-answering tasks. The conventional training phase of this type of large language model is divided into two steps: 1) the pre-training phase, in which the model's ability to understand natural language and generate text is trained through massive text corpora; 2) the fine-tuning phase, in which the model's task processing performance is improved by specifying targeted text corpora for NLP tasks (machine translation tasks, intelligent question-answering tasks, etc.). After completing the above two stages of training, the model parameters will be solidified, and subsequent user tasks will be processed based on the solidified model parameters.

[0003] In practical applications, we've observed that the knowledge associated with some NLP tasks evolves over time. For example, in machine translation, the meaning of certain vocabulary words may be updated over time, and in intelligent question-answering, the standard answers / options for certain questions may change over time. In these cases, large language models based solely on previously fixed model parameters will not output the latest interpretations or answers for the corresponding machine translation or intelligent question-answering tasks. Currently, the conventional solution to addressing these model timeliness issues is to periodically fine-tune these large language models based on the latest targeted text corpora. However, as we know, the number of parameters in any large language model is enormous, and each fine-tuning operation consumes significant computing power and takes a significant amount of time. After each fine-tuning session, additional storage resources are required to store the newly generated parameter sets. This periodic model fine-tuning mechanism has significant drawbacks: it cannot ensure that the model remains usable at all times, and it results in continuous consumption of computing power and storage resources, which undoubtedly increases model maintenance costs and reduces the model's economic value. Therefore, how to solve / improve the timeliness of the model without periodic fine-tuning has become a technical problem that needs to be solved urgently. Summary of the Invention

[0004] The purpose of the present invention is to address the shortcomings of the existing technology and provide a processing method, device, electronic device and computer-readable storage medium for a large language model that introduces a dense vector searcher. The present invention uses a large language model that is implemented based on the Transformer model architecture and has completed pre-training and fine-tuning for a type of targeted NLP task (such as a machine translation task and an intelligent question-answering task) as the corresponding first large language model; and uses the targeted text corpus used by the first large language model in fine-tuning the corresponding targeted NLP task as the corresponding first data set; and initializes the corresponding dense vector database based on the first data set; and adds a dense vector retriever and a feature fusion module to the first large language model to form a corresponding second large language model; and performs model training on the second large language model based on the first data set; and after the model training is completed, the second large language model processes the targeted NLP task with reference to the dense vector database; and regularly updates the dense vector database; and regularly performs a task processing performance evaluation on the second large language model based on the latest dense vector database to obtain the corresponding evaluation result, and when the evaluation result is unqualified, a model training data set is constructed based on the dense vector database to obtain the corresponding second data set, and the second large language model is fine-tuned based on the second data set, and after the fine-tuning is completed, the second large language model continues to process the targeted NLP task with reference to the dense vector database. The present invention achieves knowledge iteration by updating a dense vector database and solves / improves the timeliness issue of large language models by introducing a dense vector retriever into the large language model that can perform information queries on the dense vector database. The present invention not only maintains the timeliness of the model without periodic fine-tuning, but also enables timely supplementary fine-tuning when the model's timeliness is found to have decreased. The present invention can reduce maintenance costs and increase the economic value of the model while ensuring optimal real-time performance of the model.

[0005] To achieve the above objectives, a first aspect of an embodiment of the present invention provides a method for processing a large language model by introducing a dense vector searcher, the method comprising:

[0006] A large language model implemented based on the Transformer model architecture and having completed pre-training and fine-tuning for a targeted NLP task is used as the corresponding first large language model; the targeted NLP task includes at least a machine translation task and an intelligent question-answering task;

[0007] Using the directional text corpus used by the first language model in fine-tuning the corresponding directional NLP task as the corresponding first data set; and initializing the corresponding dense vector database based on the first data set;

[0008] Adding a dense vector retriever and a feature fusion module to the first language model to form a corresponding second language model; and performing model training on the second language model based on the first data set;

[0009] After the model training is completed, the second largest language model processes the directional NLP task with reference to the dense vector database; and the dense vector database is regularly updated; and the second largest language model is regularly evaluated for task processing performance based on the latest dense vector database to obtain the corresponding evaluation result of the time, and when the evaluation result of the time is unqualified, a model training data set is constructed based on the dense vector database to obtain the corresponding second data set, and the second largest language model is fine-tuned based on the second data set, and after the fine-tuning is completed, the second largest language model continues to process the directional NLP task with reference to the dense vector database; the evaluation result of the time includes qualified and unqualified.

[0010] Preferably, the first data set includes a plurality of first data records; the first data record includes a first target text and a first label text; when the directional NLP task is a machine translation task, the first target text and the first label text correspond to the translation target text and the interpretation label text respectively; when the directional NLP task is an intelligent question-answering task, the first target text and the first label text correspond to the question target text and the answer label text respectively;

[0011] The dense vector database includes a first vector database and a first text database; the first vector database is implemented based on a type of vector database, and the first text database is implemented based on a type of relational database; the vector database includes at least a Faiss or Annoy database; the relational database includes at least an SQL database and a MySQL database;

[0012] The first vector database is used to store a plurality of first vector data records; the first vector data record includes a first vector identification field and a first dense vector field; the first dense vector field is used to store a feature vector of a text in a dense vector format;

[0013] The first text database is used to store multiple first text data records; the first text data record includes a first text identification field, a first text field, a second text field, a second vector identification field, a third vector identification field and a first update field; the first text identification field is a unique identifier of the current text data record; when the directional NLP task is a machine translation task, the first and second text fields are the corresponding translation target text and the latest interpretation label text, respectively; when the directional NLP task is an intelligent question-answering task, the first and second text fields are the corresponding question text and the latest answer label text, respectively; the first and second text fields correspond to one of the first vector data records in the first vector database respectively; the second vector identification field matches the first vector identification field of the first vector data record corresponding to the first text field; the third vector identification field matches the first vector identification field of the first vector data record corresponding to the second text field; the first update field is the latest creation / update time of the current text data record;

[0014] The second data set includes multiple second data records; the second data records include a second target text and a second label text; when the directional NLP task is a machine translation task, the second target text and the second label text are the corresponding translation target text and interpretation label text respectively; when the directional NLP task is an intelligent question and answer task, the second target text and the second label text are the corresponding question target text and answer label text respectively.

[0015] Preferably, the first large language model is used to perform corresponding NLP task text generation processing according to the first task text input by the model and output the corresponding first generated text;

[0016] The model framework of the first language model includes at least a preprocessing module, an embedding encoding module, a feature extraction module and a text generation module;

[0017] The connection relationship between the model components of the first language model is as follows: the input end of the preprocessing module is used to receive the first task text, and the output end is connected to the input end of the embedding coding module; the output end of the embedding coding module is connected to the input end of the feature extraction module; the output end of the feature extraction module is connected to the input end of the text generation module;

[0018] The preprocessing module of the first large language model is used to perform word segmentation, stop word removal and part-of-speech tagging on the first task text to obtain a corresponding first word segmentation sequence and send it to the embedding coding module;

[0019] The embedding coding module of the first large language model is used to perform word embedding coding and word position coding on the first word segmentation sequence to obtain a corresponding first embedding coding vector and send it to the feature extraction module;

[0020] The feature extraction module of the first language model is implemented based on the Encoder or Decoder component structure of the Transformer model; the feature extraction module is used to perform deep learning on the associated features of each segmented text and other segmented texts in the first task text according to the first embedded coding vector to obtain a corresponding first feature vector and send it to the text generation module;

[0021] The text generation module of the first language model is implemented based on a type of text generator model; the text generation module is used to perform text feature decoding and text generation processing according to the first feature vector and output the corresponding first generated text.

[0022] Preferably, the second large language model is used to use the dense vector database as a task reference knowledge base and perform corresponding NLP task text generation processing according to the second task text input by the model and output the corresponding second generated text;

[0023] The model framework of the second language model includes the preprocessing module, the embedded coding module, the feature extraction module, the dense vector retriever, the feature fusion module and the text generation module; the dense vector retriever is connected to the dense vector database;

[0024] The connection relationship between the model components of the second language model is as follows: the input end of the preprocessing module is used to receive the second task text, and the output end is connected to the input end of the embedding coding module; the output end of the embedding coding module is connected to the input end of the feature extraction module; the output end of the feature extraction module is respectively connected to the input end of the dense vector searcher and the first input end of the feature fusion module; the output end of the dense vector searcher is connected to the second input end of the feature fusion module; the output end of the feature fusion module is connected to the input end of the text generation module;

[0025] The preprocessing module of the second language model is used to perform word segmentation, stop word removal and part-of-speech tagging on the second task text to obtain a corresponding second word segmentation sequence and send it to the embedding coding module;

[0026] The embedding coding module of the second language model is used to perform word embedding coding and word position coding on the second word segmentation sequence to obtain a corresponding second embedding coding vector and send it to the feature extraction module;

[0027] The feature extraction module of the second language model is used to perform deep learning on the associated features of each segmented text and other segmented texts in the second task text according to the second embedded coding vector to obtain a corresponding second feature vector and send it to the dense vector retriever and the feature fusion module respectively;

[0028] The dense vector retriever of the second largest language model is used to perform dense vector conversion on the second feature vector in a dense vector format to obtain a corresponding first conversion vector; and to query the first vector data records in the first vector database whose vector feature similarity between the first dense vector field and the first conversion vector exceeds a preset first similarity threshold; and to count the total number of records of the first vector data records obtained by the query to obtain a corresponding first total number A; and to identify whether the first total number A is zero; if the first total number A is zero, the corresponding first reference record sequence is set to empty; if the first total number A is not zero, the vector feature similarity between the first dense vector field and the second feature vector of each first vector data record queried this time is used as the corresponding first correlation coefficient, and the A first vector data records are sequentially sorted in descending order of the first correlation coefficient to form a corresponding first record sequence, and the second vector identification field in the first text database is compared with the first The third vector identification field of the first text data record that matches each first vector identification field of a record sequence is extracted as the corresponding first identification, and the first dense vector field of the first vector data record that matches each first identification field in the first vector database is extracted as the corresponding first reference dense vector, and each first reference dense vector is converted into a corresponding first reference feature vector in a text feature vector format to obtain a corresponding first reference feature vector, and each first reference feature vector and the corresponding first correlation coefficient form a corresponding first reference record, and A first reference records are sequentially sorted in descending order of the first correlation coefficient to form a corresponding first reference record sequence; and the obtained first reference record sequence is sent to the feature fusion module; wherein, the dense vector conversion method from the text feature vector format to the dense vector format is inverse to the text feature vector conversion method from the dense vector format to the text feature vector format;

[0029] The feature fusion module of the second largest language model is used to identify whether the first reference record sequence is empty; if the first reference record sequence is empty, the second feature vector is used as the corresponding first fused feature vector; if the first reference record sequence is not empty, the preset feature fusion mode is identified; if the feature fusion mode is the first mode, the A first reference feature vectors of the first reference record sequence are sequentially vector-spliced ​​in descending order of the first correlation coefficient to obtain the corresponding first spliced ​​feature vector, and the second feature vector and the first spliced ​​feature vector are sequentially vector-spliced ​​and the obtained spliced ​​vector is used as the corresponding first fused feature vector; if the feature fusion mode is the second mode, the A first correlation coefficients of the first reference record sequence are normalized to obtain the corresponding A normalized correlation coefficients, and the inner product calculation result of each normalized correlation coefficient and its corresponding first reference feature vector is used as the corresponding first weighted feature vector, and the mean vector calculation of the obtained A first weighted feature vectors is performed to obtain the corresponding first average feature vector, and The second feature vector and the first average feature vector are sequentially concatenated and the obtained concatenated vector is used as the corresponding first fused feature vector; if the feature fusion mode is the third mode, the attention weights of the second feature vector and each of the first reference feature vectors of the first reference record sequence are predicted based on a class of neural network models to obtain the corresponding first attention weights, and the obtained A first attention weights are normalized to obtain the corresponding A normalized attention weights, and the inner product calculation result of each normalized attention weight and its corresponding first reference feature vector is used as the corresponding first attention feature vector, and the mean vector calculation is performed on the obtained A first attention feature vectors to obtain the corresponding second average feature vector, and the second feature vector and the second average feature vector are sequentially concatenated and the obtained concatenated vector is used as the corresponding first fused feature vector; and the obtained first fused feature vector is sent to the text generation module; the feature fusion mode includes the first, second and third modes; the neural network model includes at least an MLP model and a CNN model;

[0030] The text generation module of the second language model is used to perform text feature decoding and text generation processing according to the first fused feature vector and output the corresponding first generated text.

[0031] Preferably, initializing the corresponding dense vector database based on the first data set specifically includes:

[0032] Step 51: Initialize an empty database based on a class of the vector database and record it as the corresponding first vector database; and initialize an empty database based on a class of the relational database and record it as the corresponding first text database; and form a corresponding first encoder by using the preprocessing module of the first large language model, the embedded coding module, and the feature extraction module;

[0033] Step 52, perform a round of traversal on all the first data records of the first data set; and in this round of traversal, take the first data record currently traversed as the corresponding current record; and take the first target text and the first label text of the current record as the corresponding current target text and current label text; and input the current target text and the current label text into the first encoder respectively for corresponding text preprocessing, embedded coding processing and feature extraction processing to obtain the corresponding current target text feature vector and current label text feature vector; and perform dense vector conversion on the current target text feature vector and the current label text feature vector in dense vector format to obtain the corresponding current target text dense vector and current label text dense vector; and create two new first vector data records in the first vector database as the corresponding first and second newly created records; and assign a unique record identifier to each of the first and second newly created records as the corresponding first and second newly created records. Create an identifier; and set the first vector identification field and the first dense vector field of the first newly created record to the corresponding first newly created identifier and the current target text dense vector; and set the first vector identification field and the first dense vector field of the second newly created record to the corresponding second newly created identifier and the current label text dense vector; and create a new first vector data record in the first text database as the corresponding third newly created record; and assign a unique record identifier to each of the third newly created records as the corresponding third newly created identifier; and use the current time as the corresponding first time; and set the first text identification field, the first text field, the second text field, the second vector identification field, the third vector identification field and the first update field of the third newly created record to the corresponding third newly created identifier, the current target text, the current label text, the first newly created identifier, the second newly created identifier and the first time.

[0034] Preferably, the performing model training on the second language model based on the first data set specifically includes:

[0035] Step 61, performing sub-dataset segmentation processing on the first data set according to a preset first segmentation ratio to obtain corresponding first training set and first evaluation set;

[0036] Wherein, both the first training set and the first evaluation set are composed of a plurality of the first data records; the ratio of the total number of records in the first training set to the total number of records in the first evaluation set satisfies the first segmentation ratio;

[0037] Step 62: extract the first first data record from the first training set as the corresponding current training record;

[0038] Step 63: input the first target text of the current training record into the second language model for processing and use the generated text output by the model as the corresponding first predicted text;

[0039] Step 64: subjecting the first predicted text and the first label text of the current training record to a preset first model loss function; and identifying the preset feature fusion mode; if the feature fusion mode is the first or second mode, then based on a preset first model optimizer, performing a round of modulation on the model parameters of the text generation module of the second largest language model in a direction that minimizes the first model loss function; if the feature fusion mode is the third mode, then based on a preset second model optimizer, performing a round of modulation on the model parameters of the feature fusion module and the text generation module of the second largest language model in a direction that minimizes the first model loss function;

[0040] Wherein, the first model loss function is implemented based on the maximum likelihood loss function; the first and second model optimizers include at least an SGD optimizer and an ADAM optimizer;

[0041] Step 65: Identify whether the current training record is the last first data record in the first training set; if so, proceed to step 66; if not, extract the next first data record in the first training set as the new current training record and return to step 63;

[0042] Step 66: Perform a round of traversal on all the first data records in the first evaluation set; during this round of traversal, use the first data record currently being traversed as the corresponding current evaluation record; input the first target text of the current evaluation record into the second large language model for processing, and use the generated text output by the model as the corresponding second predicted text; and form a corresponding first prediction-label pair from the second predicted text and the first label text of the current training record; and at the end of this round of traversal, bring all the obtained first prediction-label pairs into a preset first model evaluation function to calculate and obtain the corresponding first evaluation value;

[0043] Wherein, the first model evaluation function includes at least a MAE function and an MSE function;

[0044] Step 67, identifying whether the first evaluation value meets the preset first evaluation value range; if not, returning to step 62 to continue training; if satisfied, stopping training and confirming the end of model training.

[0045] Preferably, the second largest language model processes the directional NLP task with reference to the dense vector database, specifically including:

[0046] Receive the task text input by the user as the corresponding current task text; input the current task text into the second largest language model, and the second largest language model uses the dense vector database as the task reference knowledge base and performs corresponding NLP task text generation processing according to the current task text input by the model; and feed back the generated text output by the model as the corresponding current generated text to the user.

[0047] Preferably, the periodic data update processing of the dense vector database specifically includes:

[0048] Step 81: regularly collect big data of the text corpus of the targeted NLP task through multiple big data collection channels at a preset first time frequency to obtain a corresponding first collection data set; and perform text noise reduction, deduplication, compliance verification, and correctness verification on each first collection record of the first collection data set based on manual or other machine model screening methods; and form a corresponding second encoder using the preprocessing module, the embedded coding module, and the feature extraction module of the second large language model;

[0049] Among them, the multiple big data collection channels include at least public text corpora, public network text resources, and public technical standards / textbooks / documents / magazines / journals / paper resources in various fields; the first collection data set includes multiple first collection records; the first collection record includes a first collection target text and a first collection label text; when the directional NLP task is a machine translation task, the first collection target text and the first collection label text are the corresponding translation target text and interpretation label text respectively; when the directional NLP task is an intelligent question-answering task, the first collection target text and the first collection label text are the corresponding question target text and answer label text respectively;

[0050] Step 82: taking the first first acquisition record of the first acquisition data set as the corresponding current acquisition record;

[0051] Step 83: Using the first acquisition target text and the first acquisition label text of the current acquisition record as the corresponding current acquisition target text and the current acquisition label text; inputting the current acquisition target text and the current acquisition label text into the second encoder for corresponding text preprocessing, embedded coding processing, and feature extraction processing to obtain corresponding current target text feature vectors and current label text feature vectors; and performing dense vector conversion on the current target text feature vector and the current label text feature vector in a dense vector format to obtain corresponding current target text dense vectors and current label text dense vectors;

[0052] Step 84, query the first vector data record in the first vector database of the dense vector database in which the vector feature approximation between the first dense vector field and the current target text dense vector is the largest, and use the first vector data record obtained by the query as the corresponding first query record; and use the vector feature approximation between the first dense vector field of the first query record and the current target text dense vector as the corresponding first target approximation; and use the first text data record in which the second vector identification field in the first text database matches the first vector identification field of the first query record as the corresponding second query record; and record the first vector data record in which the first dense vector field in the first vector database matches the third vector identification field of the second query record as the corresponding third query record; and calculate the vector feature approximation between the first dense vector field of the third query record and the current label text dense vector to obtain the corresponding first label approximation;

[0053] Step 85: Identify the first target proximity and the first label proximity. If the first target proximity exceeds a preset second proximity threshold and the first label proximity does not exceed the second proximity threshold, proceed to step 86. If the first target proximity does not exceed the second proximity threshold, proceed to step 87. If both the first target proximity and the first label proximity exceed the second proximity threshold, proceed to step 88.

[0054] Wherein, the second similarity threshold value>the first similarity threshold value;

[0055] Step 86: Update the second text field of the second query record to the corresponding currently collected label text; update the first update field of the second query record to the corresponding current time; and update the first dense vector field of the third query record to the corresponding currently collected label text dense vector; and go to step 88;

[0056] Step 87: Add two new vector data records as the corresponding first and second new records in the first vector database; and add one new text data record as the corresponding third new record in the first text database; and assign a unique record identifier to each of the first, second, and third new records as the corresponding first, second, and third new identifiers; and use the current time as the corresponding first new time; and set the first vector identification field and the first dense vector field of the first new record to the corresponding first new identifier and the current target text dense vector; and set the first vector identification field and the first dense vector field of the second new record to the corresponding second new identifier and the current label text dense vector; and set the first text identification field, the first text field, the second text field, the second vector identification field, the third vector identification field, and the first update field of the third new record to the corresponding third new identifier, the current collection target text, the current collection label text, the first new identifier, the second new identifier, and the first new time;

[0057] Step 88, identifying whether the current acquisition record is the last of the first acquisition record in the first acquisition data set; if not, extracting the next first acquisition record in the first acquisition data set as the new current acquisition record and returning to step 83; if so, confirming that the data update process is complete.

[0058] Preferably, the periodic evaluation of the task processing performance of the second largest language model based on the latest dense vector database to obtain the corresponding evaluation result specifically includes:

[0059] Step 91: regularly setting the current time as the corresponding first end time according to a preset second time frequency, and subtracting a preset first duration from the first end time as the corresponding first start time, and forming a corresponding first recent time period from the first start time and the first end time; and extracting all the first text data records whose first update fields satisfy the first recent time period in the first text database of the dense vector database to form a corresponding first record set;

[0060] Step 92: perform a round of traversal on all the first text data records of the first record set; and during this round of traversal, use the first text data record currently traversed as the corresponding current evaluation record; and extract the first text field and the second text field of the current evaluation record as the corresponding current task text and current label text; and input the current task text into the second language model for processing and use the generated text output by the model as the corresponding current predicted text; and form a corresponding second prediction-label pair with the current predicted text and the current label text; and at the end of this round of traversal, bring all the obtained second prediction-label pairs into a preset second model evaluation function to calculate and obtain the corresponding second evaluation value;

[0061] Wherein, the second model evaluation function includes at least a MAE function and an MSE function;

[0062] Step 93, identifying whether the second evaluation value meets the preset second evaluation value range; if so, setting the corresponding evaluation result of the current time as qualified; if not, setting the corresponding evaluation result of the current time as unqualified.

[0063] Preferably, when the evaluation result is unqualified, constructing a model training data set based on the dense vector database to obtain a corresponding second data set specifically includes:

[0064] When the evaluation result is unqualified, a round of traversal is performed on all the first text data records of the first record set; and during this round of traversal, the first text data record currently traversed is used as the corresponding current record; and the first text field and the second text field of the current record are extracted as the corresponding second target text and the second label text to form a corresponding second data record; and at the end of this round of traversal, all the obtained second data records form the corresponding second data set.

[0065] Preferably, fine-tuning the second language model based on the second data set specifically includes:

[0066] Step 111, performing sub-dataset segmentation processing on the second data set according to a preset second segmentation ratio to obtain corresponding second training sets and second evaluation sets;

[0067] Wherein, both the second training set and the second evaluation set are composed of a plurality of second data records; the ratio of the total number of records in the second training set to the total number of records in the second evaluation set satisfies the second segmentation ratio;

[0068] Step 112: extract the first second data record from the second training set as the corresponding current training record;

[0069] Step 113: input the second target text of the current training record into the second large language model for processing and use the generated text output by the model as the corresponding third predicted text;

[0070] Step 114: Substitute the third predicted text and the second label text of the current training record into the first model loss function; and fine-tune the model parameters of the text generation module of the second language model based on a preset third model optimizer in a direction that minimizes the first model loss function.

[0071] Wherein, the third model optimizer includes at least an SGD optimizer and an ADAM optimizer;

[0072] Step 115: Identify whether the current training record is the last second data record in the second training set; if so, proceed to step 116; if not, extract the next second data record in the second training set as the new current training record and return to step 113;

[0073] Step 116: Perform a round of traversal on all the second data records in the second evaluation set; during this round of traversal, use the second data record currently being traversed as the corresponding current evaluation record; input the second target text of the current evaluation record into the second large language model for processing, and use the generated text output by the model as the corresponding fourth predicted text; and form a corresponding third prediction-label pair from the fourth predicted text and the second label text of the current training record; and at the end of this round of traversal, bring all the obtained third prediction-label pairs into a preset third model evaluation function to calculate and obtain a corresponding third evaluation value;

[0074] Wherein, the third model evaluation function includes at least a MAE function and an MSE function;

[0075] Step 117 , identifying whether the third evaluation value meets the preset third evaluation value range; if not, returning to step 112 to continue training; if satisfied, stopping training and confirming the end of this fine-tuning.

[0076] A second aspect of an embodiment of the present invention provides an apparatus for implementing the method for processing a large language model using a dense vector search engine described in the first aspect, the apparatus comprising: a large language model selection module, a dense vector database preparation module, a large language model transformation and training module, and a transformed model application module;

[0077] The large language model selection module is used to select a large language model that is implemented based on the Transformer model architecture and has completed pre-training and fine-tuning for a type of targeted NLP task as the corresponding first large language model; the targeted NLP task includes at least a machine translation task and an intelligent question-answering task;

[0078] The dense vector database preparation module is used to use the directional text corpus used by the first large language model in fine-tuning the corresponding directional NLP task as the corresponding first data set; and initialize the corresponding dense vector database based on the first data set;

[0079] The large language model transformation and training module is used to add a dense vector retriever and a feature fusion module to the first large language model to form a corresponding second large language model; and perform model training on the second large language model based on the first data set;

[0080] The modified model application module is used to, after the model training is completed, use the second large language model to process the directional NLP task with reference to the dense vector database; and regularly update the data of the dense vector database; and regularly perform a task processing performance evaluation on the second large language model based on the latest dense vector database to obtain the corresponding evaluation result of the time, and when the evaluation result of the time is unqualified, construct a model training data set based on the dense vector database to obtain the corresponding second data set, and fine-tune the second large language model based on the second data set, and after the fine-tuning is completed, continue to use the second large language model to process the directional NLP task with reference to the dense vector database; the evaluation result of the time includes qualified and unqualified.

[0081] A third aspect of an embodiment of the present invention provides an electronic device, including: a memory, a processor, and a transceiver;

[0082] The processor is configured to be coupled to the memory, read and execute instructions in the memory, so as to implement the method steps described in the first aspect above;

[0083] The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.

[0084] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed by a computer, the computer executes the instructions of the method described in the first aspect above.

[0085] The embodiment of the present invention provides a processing method, device, electronic device and computer-readable storage medium for a large language model that introduces a dense vector retriever. As can be seen from the above content, the embodiment of the present invention uses a large language model that is implemented based on the Transformer model architecture and has completed pre-training and fine-tuning of a type of directional NLP task (such as machine translation task, intelligent question-answering task) as the corresponding first large language model; and uses the directional text corpus used by the first large language model in fine-tuning the corresponding directional NLP task as the corresponding first data set; and initializes the corresponding dense vector database based on the first data set; and adds a dense vector retriever and a feature fusion module to the first large language model to form the corresponding second large language model; and performs model training on the second large language model based on the first data set. Training; and after the model training is completed, the second largest language model uses the dense vector database as a reference to process the directional NLP task; and the dense vector database is regularly updated; and the second largest language model is regularly evaluated for task processing performance based on the latest dense vector database to obtain the corresponding evaluation result, and when the evaluation result is unqualified, a model training data set is constructed based on the dense vector database to obtain the corresponding second data set, and the second largest language model is fine-tuned based on the second data set, and after the fine-tuning is completed, the second largest language model continues to process the directional NLP task with the dense vector database as a reference. The embodiment of the present invention realizes the update and iteration of knowledge by updating the dense vector database, and solves / improves the timeliness problem of the large language model by introducing a dense vector retriever that can perform information query on the dense vector database into the large language model; the embodiment of the present invention can not only maintain the timeliness of the model without periodic fine-tuning, but also promptly perform supplementary fine-tuning on the model when it is found that the timeliness of the model has decreased; the embodiment of the present invention not only ensures the optimal real-time performance of the model, but also reduces the maintenance cost of the model and improves the economic value of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0086] Figure 1 A schematic diagram of a method for processing a large language model by introducing a dense vector searcher, provided in the first embodiment of the present invention;

[0087] Figure 2 This is a module structure diagram of the first language model before introducing the dense vector searcher provided in the first embodiment of the present invention;

[0088] Figure 3 This is a module structure diagram of the second largest language model after the dense vector searcher is introduced according to the first embodiment of the present invention;

[0089] Figure 4 A module structure diagram of a large language model processing device that introduces a dense vector searcher, provided in the second embodiment of the present invention;

[0090] Figure 5 This is a structural diagram of an electronic device provided in Example 3 of the present invention. DETAILED DESCRIPTION

[0091] To make the objectives, technical solutions, and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings. It should be understood that the embodiments described herein are merely some, rather than all, of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are intended to fall within the scope of protection of the present invention.

[0092] The first embodiment of the present invention provides a method for processing a large language model by introducing a dense vector searcher, such as Figure 1 A schematic diagram of a method for processing a large language model using a dense vector searcher provided in the first embodiment of the present invention is shown. The method mainly includes the following steps:

[0093] Step 1: Use a large language model that is implemented based on the Transformer model architecture and has completed pre-training and fine-tuning for a type of targeted NLP task as the corresponding first large language model.

[0094] Here, the targeted NLP tasks in the embodiment of the present invention include at least machine translation tasks and intelligent question-answering tasks. The first large language model in the embodiment of the present invention includes at least a BERT series model, a BART series model, a GPT series model, a T5 series model, etc.; the first large language model is used to generate the corresponding NLP task text based on the first task text input by the model and output the corresponding first generated text.

[0095] like Figure 2 As shown in the module structure diagram of the first language model before the introduction of the dense vector retriever provided in the first embodiment of the present invention, the model framework of the first language model of the embodiment of the present invention includes at least a preprocessing module, an embedded coding module, a feature extraction module and a text generation module.

[0096] like Figure 2 As shown, the connection relationship between the various model components of the first large language model is: the input end of the preprocessing module is used to receive the first task text, and the output end is connected to the input end of the embedded coding module; the output end of the embedded coding module is connected to the input end of the feature extraction module; the output end of the feature extraction module is connected to the input end of the text generation module.

[0097] The functions of each model component of the first large language model are as follows: 1) The preprocessing module is used to perform word segmentation, stop word removal and part-of-speech tagging on the first task text to obtain the corresponding first word segmentation sequence and send it to the embedding coding module; 2) The embedding coding module is used to perform word embedding coding and word position coding on the first word segmentation sequence to obtain the corresponding first embedded coding vector and send it to the feature extraction module; 3) The feature extraction module is implemented based on the Encoder or Decoder component structure of the Transformer model; the feature extraction module is used to perform deep learning on the correlation features of each word segmentation text and other word segmentation texts in the first task text according to the first embedded coding vector to obtain the corresponding first feature vector and send it to the text generation module; 4) The text generation module is implemented based on a class of text generator models; the text generation module is used to perform text feature decoding and text generation processing according to the first feature vector and output the corresponding first generated text.

[0098] Step 2: Using the directional text corpus used by the first language model in fine-tuning the corresponding directional NLP task as the corresponding first dataset; and initializing the corresponding dense vector database based on the first dataset;

[0099] Specifically comprising: step 21, using the directional text corpus used by the first large language model in fine-tuning the corresponding directional NLP task as the corresponding first data set;

[0100] Here, the first data set of the embodiment of the present invention includes multiple first data records; the first data record includes a first target text and a first label text; when the directional NLP task is a machine translation task, the first target text and the first label text are the corresponding translation target text and interpretation label text respectively; when the directional NLP task is an intelligent question-answering task, the first target text and the first label text are the corresponding question target text and answer label text respectively;

[0101] Step 22, initializing a corresponding dense vector database based on the first data set;

[0102] The dense vector database includes a first vector database and a first text database; the first vector database is implemented based on a first-class vector database, and the first text database is implemented based on a first-class relational database.

[0103] The first vector database is used to store a plurality of first vector data records; the first vector data record includes a first vector identification field and a first dense vector field; the first dense vector field is used to store a feature vector of a text in a dense vector format;

[0104] The first text database is used to store multiple first text data records; the first text data record includes a first text identification field, a first text field, a second text field, a second vector identification field, a third vector identification field and a first update field; the first text identification field is a unique identifier of the current text data record; when the directional NLP task is a machine translation task, the first and second text fields are the corresponding translation target text and the latest interpretation label text, respectively; when the directional NLP task is an intelligent question-answering task, the first and second text fields are the corresponding question text and the latest answer label text, respectively; the first and second text fields correspond to a first vector data record in the first vector database respectively; the second vector identification field matches the first vector identification field of the first vector data record corresponding to the first text field; the third vector identification field matches the first vector identification field of the first vector data record corresponding to the second text field; the first update field is the latest creation / update time of the current text data record;

[0105] The current step 22 specifically includes:

[0106] Step 221: Initialize an empty database based on a first-class vector database as a corresponding first vector database; initialize an empty database based on a first-class relational database as a corresponding first text database; and form a corresponding first encoder by using a preprocessing module, an embedding coding module, and a feature extraction module of a first large language model;

[0107] Here, in the embodiment of the present invention, the type of vector database includes at least Faiss or Annoy database; the type of relational database includes at least SQL database and MySQL database;

[0108] Step 222, a round of traversal is performed on all first data records of the first data set; and in this round of traversal, the first data record currently traversed is used as the corresponding current record; and the first target text and the first label text of the current record are used as the corresponding current target text and current label text; and the current target text and the current label text are respectively input into the first encoder for corresponding text preprocessing, embedding coding processing and feature extraction processing to obtain the corresponding current target text feature vector and current label text feature vector; and according to the dense vector (Dense Vector) format is used to perform dense vector conversion on the current target text feature vector and the current label text feature vector to obtain the corresponding current target text dense vector and current label text dense vector; and two first vector data records are created in the first vector database as the corresponding first and second newly created records; and a unique record identifier is assigned to each of the first and second newly created records as the corresponding first and second newly created identifiers; and the first vector identification field and the first dense vector field of the first newly created record are set to the corresponding first newly created identifier and the current target text dense vector; and the first vector identification field and the first dense vector field of the second newly created record are set to the corresponding second newly created identifier and the current label text dense vector; and a first vector data record is created in the first text database as the corresponding third newly created record; and a unique record identifier is assigned to each of the third newly created records as the corresponding third newly created identifier; and the current time is used as the corresponding first time; and the first text identification field, the first text field, the second text field, the second vector identification field, the third vector identification field and the first update field of the third newly created record are set to the corresponding third newly created identifier, the current target text, the current label text, the first newly created identifier, the second newly created identifier and the first time.

[0109] Here, in the embodiment of the present invention, the dense vector conversion method from the text feature vector format to the dense vector format corresponds to a vector conversion / projection function A, and the text feature vector conversion method from the dense vector format to the text feature vector format corresponds to another vector conversion / projection function A. - , and these two transformations are inverse to each other, namely, vector transformation / projection functions A and A - mutually inverse; and these two vector transformation / projection functions A, A - The specific function form of can be configured according to actual application requirements. The embodiment of the present invention does not limit the specific function forms of these two vector conversion / projection functions;

[0110] Step 3: Add a dense vector retriever and a feature fusion module to the first language model to form a corresponding second language model; and perform model training on the second language model based on the first data set;

[0111] Specifically comprising: step 31, adding a dense vector retriever and a feature fusion module to the first language model to form a corresponding second language model;

[0112] Here, the second language model of the embodiment of the present invention is used to use the dense vector database as the task reference knowledge base and perform corresponding NLP task text generation processing according to the second task text input by the model and output the corresponding second generated text;

[0113] like Figure 3 As shown in the module structure diagram of the second language model after the introduction of the dense vector searcher provided in Example 1 of the present invention, the model framework of this second language model, which adds the dense vector searcher and feature fusion module to the first language model, includes a preprocessing module, an embedded coding module, a feature extraction module, a dense vector searcher, a feature fusion module, and a text generation module. The internal dense vector searcher is connected to the external dense vector database.

[0114] The connection relationship between the model components of the second language model is as follows: the input end of the preprocessing module is used to receive the second task text, and the output end is connected to the input end of the embedding coding module; the output end of the embedding coding module is connected to the input end of the feature extraction module; the output end of the feature extraction module is connected to the input end of the dense vector searcher and the first input end of the feature fusion module respectively; the output end of the dense vector searcher is connected to the second input end of the feature fusion module; the output end of the feature fusion module is connected to the input end of the text generation module;

[0115] The functions of the model components of the second largest language model are as follows:

[0116] 1) The preprocessing module is used to perform word segmentation, stop word removal and part-of-speech tagging on the second task text to obtain a corresponding second word segmentation sequence and send it to the embedding coding module;

[0117] 2) The embedding coding module is used to perform word embedding coding and word position coding on the second word segmentation sequence to obtain a corresponding second embedding coding vector and send it to the feature extraction module;

[0118] 3) The feature extraction module is used to perform deep learning on the correlation features of each segmented text and other segmented texts in the second task text according to the second embedded coding vector to obtain a corresponding second feature vector, which is sent to the dense vector retriever and the feature fusion module respectively;

[0119] 4) The dense vector retriever is used to perform dense vector conversion on the second eigenvector in a dense vector format to obtain a corresponding first conversion vector; and to query the first vector data record in the first vector database whose vector feature similarity between the first dense vector field and the first conversion vector exceeds a preset first similarity threshold; and to count the total number of records of the first vector data records obtained by the query to obtain a corresponding first total number A; and to identify whether the first total number A is zero; if the first total number A is zero, then set the corresponding first reference record sequence to empty; if the first total number A is not zero, then use the vector feature similarity between the first dense vector field and the second eigenvector of each first vector data record queried this time as the corresponding first correlation coefficient, and sort the A first vector data records in descending order of the first correlation coefficient to form a corresponding first record. sequence, and extract the third vector identification field of the first text data record whose second vector identification field in the first text database matches each first vector identification field of the first record sequence as the corresponding first identification, and extract the first dense vector field of the first vector data record whose first vector identification field in the first vector database matches each first identification as the corresponding first reference dense vector, and perform corresponding text feature vector conversion on each first reference dense vector in a text feature vector format to obtain a corresponding first reference feature vector, and form a corresponding first reference record from each first reference feature vector and the corresponding first correlation coefficient, and sequentially sort the A first reference records in descending order of the first correlation coefficient to form a corresponding first reference record sequence; and send the obtained first reference record sequence to the feature fusion module;

[0120] Here, the first similarity threshold is a preset threshold parameter; in the embodiment of the present invention, the algorithm used to calculate the vector feature similarity can be a cosine similarity algorithm or an inner product similarity algorithm;

[0121] 5) The feature fusion module is used to identify whether the first reference record sequence is empty; if the first reference record sequence is empty, the second feature vector is used as the corresponding first fused feature vector; if the first reference record sequence is not empty, the preset feature fusion mode is identified; if the feature fusion mode is the first mode, the A first reference feature vectors of the first reference record sequence are sequentially vector-spliced ​​in descending order of the first correlation coefficient to obtain the corresponding first spliced ​​feature vector, and the second feature vector and the first spliced ​​feature vector are sequentially vector-spliced ​​and the obtained spliced ​​vector is used as the corresponding first fused feature vector; if the feature fusion mode is the second mode, the A first correlation coefficients of the first reference record sequence are normalized to obtain the corresponding A normalized correlation coefficients, and the inner product calculation result of each normalized correlation coefficient and its corresponding first reference feature vector is used as the corresponding first weighted feature vector, and the obtained A first weighted feature vectors are averaged. Calculate the corresponding first average feature vector, and sequentially concatenate the second feature vector and the first average feature vector, and use the obtained concatenation vector as the corresponding first fused feature vector; if the feature fusion mode is the third mode, predict the attention weights of the second feature vector and each first reference feature vector of the first reference record sequence based on a class of neural network models to obtain the corresponding first attention weights, and perform normalization calculation on the obtained A first attention weights to obtain the corresponding A normalized attention weights, and use the inner product calculation result of each normalized attention weight and its corresponding first reference feature vector as the corresponding first attention feature vector, and perform mean vector calculation on the obtained A first attention feature vectors to obtain the corresponding second average feature vector, and sequentially concatenate the second feature vector and the second average feature vector, and use the obtained concatenation vector as the corresponding first fused feature vector; and send the obtained first fused feature vector to the text generation module;

[0122] Here, the feature fusion mode includes the first, second and third modes; the neural network model includes at least the MLP model and the CNN model;

[0123] 6) The text generation module is used to perform text feature decoding and text generation processing according to the first fused feature vector and output a corresponding first generated text;

[0124] Step 32: training the second language model based on the first data set;

[0125] Specifically, it includes: step 321, performing sub-dataset segmentation processing on the first data set according to a preset first segmentation ratio to obtain a corresponding first training set and a first evaluation set;

[0126] The first split ratio is a preset ratio parameter, such as 8:2; the first training set and the first evaluation set both consist of a plurality of first data records; and the ratio of the total number of records in the first training set to the total number of records in the first evaluation set satisfies the first split ratio;

[0127] Step 322, extracting the first first data record of the first training set as the corresponding current training record;

[0128] Step 323: Input the first target text of the current training record into the second largest language model for processing and use the generated text output by the model as the corresponding first predicted text;

[0129] Step 324: Submit the first predicted text and the first label text of the current training record into a preset first model loss function; and identify a preset feature fusion mode; if the feature fusion mode is the first or second mode, then, based on a preset first model optimizer, perform a round of modulation on the model parameters of the text generation module of the second largest language model in a direction that minimizes the first model loss function; if the feature fusion mode is the third mode, then, based on a preset second model optimizer, perform a round of modulation on the model parameters of the feature fusion module and the text generation module of the second largest language model in a direction that minimizes the first model loss function;

[0130] The first model loss function is implemented based on the maximum likelihood loss function; the first and second model optimizers include at least an SGD optimizer and an ADAM optimizer;

[0131] Step 325: Identify whether the current training record is the last first data record of the first training set; if so, go to step 326; if not, extract the next first data record of the first training set as the new current training record and return to step 323;

[0132] Step 326: Perform a round of traversal on all first data records in the first evaluation set. During this round of traversal, the first data record currently being traversed is used as the corresponding current evaluation record. The first target text of the current evaluation record is input into the second language model for processing, and the generated text output by the model is used as the corresponding second predicted text. The second predicted text and the first label text of the current training record are combined to form a corresponding first prediction-label pair. At the end of this round of traversal, all the obtained first prediction-label pairs are input into the preset first model evaluation function to calculate and obtain the corresponding first evaluation value.

[0133] Wherein, the first model evaluation function includes at least a MAE function and an MSE function;

[0134] Step 327 , identifying whether the first evaluation value satisfies the preset first evaluation value range; if not, returning to step 322 to continue training; if satisfied, stopping training and confirming the completion of model training.

[0135] Here, the first evaluation value range is a preset evaluation value range.

[0136] Step 4: After the model training is completed, the second largest language model uses the dense vector database as a reference to process the directional NLP task; and the dense vector database is regularly updated; and the second largest language model is regularly evaluated for task processing performance based on the latest dense vector database to obtain the corresponding evaluation result. If the evaluation result is unqualified, the model training data set is constructed based on the dense vector database to obtain the corresponding second data set, and the second largest language model is fine-tuned based on the second data set. After the fine-tuning is completed, the second largest language model continues to process the directional NLP task with the dense vector database as a reference.

[0137] Specifically, the method includes: step 41, after the model training is completed, the second language model processes the directional NLP task with reference to the dense vector database;

[0138] Specifically, the process includes: receiving a task text input by a user as the corresponding current task text; inputting the current task text into a second language model, and the second language model uses a dense vector database as a task reference knowledge base and performs corresponding NLP task text generation processing based on the current task text input by the model; and feeding back the generated text output by the model as the corresponding current generated text to the user;

[0139] Step 42, and regularly update the dense vector database;

[0140] Specifically, the method includes: step 421, regularly collecting text corpus of a targeted NLP task through multiple big data collection channels at a preset first time frequency to obtain a corresponding first collection data set; performing text noise reduction, deduplication, compliance verification, and correctness verification on each first collection record of the first collection data set based on manual or other machine model screening methods; and forming a corresponding second encoder from a preprocessing module, an embedding coding module, and a feature extraction module of a second large language model;

[0141] Wherein, the first time frequency is a preset time frequency parameter;

[0142] Multiple big data collection channels include at least public text corpora, public online text resources, and public technical standards / textbooks / documents / magazines / journals / paper resources in various fields;

[0143] The first acquisition data set includes a plurality of first acquisition records; the first acquisition record includes a first acquisition target text and a first acquisition label text; when the directional NLP task is a machine translation task, the first acquisition target text and the first acquisition label text are the corresponding translation target text and interpretation label text respectively; when the directional NLP task is an intelligent question-answering task, the first acquisition target text and the first acquisition label text are the corresponding question target text and answer label text respectively;

[0144] Step 422: taking the first first acquisition record of the first acquisition data set as the corresponding current acquisition record;

[0145] Step 423: The first acquisition target text and the first acquisition label text of the current acquisition record are used as the corresponding current acquisition target text and the current acquisition label text; the current acquisition target text and the current acquisition label text are respectively input into a second encoder for corresponding text preprocessing, embedding coding processing, and feature extraction processing to obtain corresponding current target text feature vectors and current label text feature vectors; and dense vector conversion is performed on the current target text feature vector and the current label text feature vector in a dense vector format to obtain corresponding current target text dense vectors and current label text dense vectors;

[0146] Step 424, query the first vector data record whose first dense vector field in the first vector database of the dense vector database has the largest vector feature approximation with the current target text dense vector and use the first vector data record obtained by the query as the corresponding first query record; use the vector feature approximation between the first dense vector field of the first query record and the current target text dense vector as the corresponding first target approximation; use the first text data record whose second vector identification field in the first text database matches the first vector identification field of the first query record as the corresponding second query record; and record the first vector data record whose first dense vector field in the first vector database matches the third vector identification field of the second query record as the corresponding third query record; and calculate the vector feature approximation between the first dense vector field of the third query record and the current label text dense vector to obtain the corresponding first label approximation;

[0147] Step 425: Identify the first target proximity and the first label proximity. If the first target proximity exceeds a preset second proximity threshold and the first label proximity does not exceed the second proximity threshold, proceed to step 426. If the first target proximity does not exceed the second proximity threshold, proceed to step 427. If both the first target proximity and the first label proximity exceed the second proximity threshold, proceed to step 428.

[0148] Here, the second similarity threshold is a preset threshold parameter, and the second similarity threshold is greater than the first similarity threshold. Under normal circumstances, the second similarity threshold is set to a similarity threshold close to 1 by default. If the first target similarity exceeds the second similarity threshold and the first label similarity does not exceed the second similarity threshold, it means that a translation / question text that is highly similar (or even identical) to the current collected target text already exists in the dense vector database, but the corresponding translation / answer label text has been updated. Therefore, it is necessary to go to 426 to update the record fields related to the label text. If the first target similarity does not exceed the second similarity threshold, it means that the translation / question text corresponding to the current collected target text has not appeared in the dense vector database. Therefore, it is necessary to go to 427 to create a new record. If both the first target similarity and the first label similarity exceed the second similarity threshold, it means that a translation / question text that is highly similar (or even identical) to the current collected target text already exists in the dense vector database, and the corresponding translation / answer label text has not been updated. Therefore, no update / creation operation will be performed on the dense vector database at this time, and only the process will be jumped to 428 to determine whether to jump to the next collected record for processing.

[0149] Step 426: Update the second text field of the second query record to the corresponding currently collected label text; update the first update field of the second query record to the corresponding current time; and update the first dense vector field of the third query record to the corresponding currently collected label text dense vector; and go to step 428;

[0150] Step 427: Add two first vector data records in the first vector database as corresponding first and second newly added records; and add a first text data record in the first text database as corresponding third newly added record; and assign a unique record identifier to each of the first, second, and third newly added records as corresponding first newly added identifier, second newly added identifier, and third newly added identifier; and use the current time as the corresponding first newly added time; and set the first vector identification field and the first dense vector field of the first newly added record to the corresponding first newly added identifier and the current target text dense vector; and set the first vector identification field and the first dense vector field of the second newly added record to the corresponding second newly added identifier and the current label text dense vector; and set the first text identification field, the first text field, the second text field, the second vector identification field, the third vector identification field, and the first update field of the third newly added record to the corresponding third newly added identifier, the current collected target text, the current collected label text, the first newly added identifier, the second newly added identifier, and the first newly added time;

[0151] Step 428: Identify whether the current acquisition record is the last first acquisition record of the first acquisition data set; if not, extract the next first acquisition record of the first acquisition data set as the new current acquisition record and return to step 423; if so, confirm that the data update process is complete;

[0152] Step 43, periodically perform a task processing performance evaluation on the second largest language model based on the latest dense vector database to obtain the corresponding evaluation result. If the evaluation result is unqualified, a model training dataset is constructed based on the dense vector database to obtain a corresponding second dataset. The second largest language model is fine-tuned based on the second dataset. After the fine-tuning is completed, the second largest language model continues to process the directional NLP task with reference to the dense vector database.

[0153] Specifically, the method includes: step 431 , periodically performing a task processing performance evaluation on the second largest language model based on the latest dense vector database to obtain a corresponding evaluation result;

[0154] Specifically, step 4311 includes periodically setting the current time as the corresponding first end time according to a preset second time frequency, and subtracting a preset first duration from the first end time as the corresponding first start time, and forming a corresponding first recent time period from the first start time and the first end time; and extracting all first text data records whose first updated fields satisfy the first recent time period from the first text database of the dense vector database to form a corresponding first record set;

[0155] Here, the second time frequency is a preset time frequency parameter;

[0156] Step 4312: Perform a round of traversal on all first text data records of the first record set; during this round of traversal, use the currently traversed first text data record as the corresponding current evaluation record; extract the first text field and the second text field of the current evaluation record as the corresponding current task text and current label text; input the current task text into the second largest language model for processing, and use the generated text output by the model as the corresponding current predicted text; and form a corresponding second prediction-label pair from the current predicted text and the current label text; and at the end of this round of traversal, bring all the obtained second prediction-label pairs into the preset second model evaluation function to calculate and obtain the corresponding second evaluation value;

[0157] Wherein, the second model evaluation function includes at least a MAE function and an MSE function;

[0158] Step 4313: Identify whether the second evaluation value meets the preset second evaluation value range; if so, set the corresponding evaluation result of the current time as qualified; if not, set the corresponding evaluation result of the current time as unqualified;

[0159] Here, the second evaluation value range is a preset evaluation value range; the evaluation results include qualified and unqualified;

[0160] Step 432: When the evaluation result is unqualified, a model training data set is constructed based on the dense vector database to obtain a corresponding second data set;

[0161] The second data set includes a plurality of second data records; the second data records include a second target text and a second label text; when the directional NLP task is a machine translation task, the second target text and the second label text are the corresponding translation target text and interpretation label text respectively; when the directional NLP task is an intelligent question-answering task, the second target text and the second label text are the corresponding question target text and answer label text respectively;

[0162] Specifically, the method includes: when the evaluation result is unqualified, performing a round of traversal on all first text data records of the first record set; and during this round of traversal, taking the currently traversed first text data record as the corresponding current record; and extracting the first text field and the second text field of the current record as the corresponding second target text and the second label text to form a corresponding second data record; and at the end of this round of traversal, forming a corresponding second data set from all the obtained second data records;

[0163] Step 433: fine-tune the second language model based on the second data set;

[0164] Specifically comprising: step 4331, performing sub-dataset segmentation processing on the second data set according to a preset second segmentation ratio to obtain corresponding second training sets and second evaluation sets;

[0165] The second split ratio is a preset ratio parameter, such as 8:2; the second training set and the second evaluation set both consist of a plurality of second data records; and the ratio of the total number of records in the second training set to the total number of records in the second evaluation set satisfies the second split ratio;

[0166] Step 4332: extract the first second data record of the second training set as the corresponding current training record;

[0167] Step 4333: Input the second target text of the current training record into the second largest language model for processing and use the generated text output by the model as the corresponding third predicted text;

[0168] Step 4334: Substitute the third predicted text and the second label text of the current training record into the first model loss function; and fine-tune the model parameters of the text generation module of the second language model based on a preset third model optimizer in a direction that minimizes the first model loss function.

[0169] Wherein, the third model optimizer includes at least an SGD optimizer and an ADAM optimizer;

[0170] Step 4335: Identify whether the current training record is the last second data record of the second training set; if so, go to step 4336; if not, extract the next second data record of the second training set as the new current training record and return to step 4333;

[0171] Step 4336: Perform a round of traversal on all second data records in the second evaluation set. During this round of traversal, the currently traversed second data record is used as the corresponding current evaluation record. The second target text of the current evaluation record is input into the second largest language model for processing, and the generated text output by the model is used as the corresponding fourth predicted text. The fourth predicted text and the second label text of the current training record are combined to form a corresponding third prediction-label pair. At the end of this round of traversal, all the obtained third prediction-label pairs are input into the preset third model evaluation function to calculate and obtain the corresponding third evaluation value.

[0172] Wherein, the third model evaluation function includes at least a MAE function and an MSE function;

[0173] Step 4337: Identify whether the third evaluation value meets the preset third evaluation value range; if not, return to step 4332 to continue training; if so, stop training and confirm the end of this fine-tuning;

[0174] Here, the third evaluation value range is a preset evaluation value range;

[0175] Step 434 , after the fine-tuning is completed, the second language model continues to process the directional NLP task using the dense vector database as a reference;

[0176] Specifically, it includes: receiving the task text input by the user as the corresponding current task text; inputting the current task text into the second largest language model, and the second largest language model uses the latest dense vector database as the task reference knowledge base and performs corresponding NLP task text generation processing based on the current task text input by the model; and feeding back the generated text output by the model as the corresponding current generated text to the user.

[0177] Figure 4This is a module structure diagram of a processing device for a large language model that introduces a dense vector searcher provided in the second embodiment of the present invention. The device is a terminal device or server that implements the aforementioned method embodiment, and can also be a device that enables the aforementioned terminal device or server to implement the aforementioned method embodiment. For example, the device can be a device or chip system of the aforementioned terminal device or server. Figure 4 As shown, the device includes: a large language model selection module 201, a dense vector database preparation module 202, a large language model transformation and training module 203 and a transformation model application module 204.

[0178] The large language model selection module 201 is used to use a large language model that is implemented based on the Transformer model architecture and has completed pre-training and fine-tuning for a type of targeted NLP task as the corresponding first large language model; the targeted NLP task includes at least a machine translation task and an intelligent question-answering task.

[0179] The dense vector database preparation module 202 is used to use the directional text corpus used by the first large language model in fine-tuning the corresponding directional NLP task as the corresponding first data set; and initialize the corresponding dense vector database based on the first data set.

[0180] The large language model transformation and training module 203 is used to add a dense vector retriever and a feature fusion module to the first large language model to form a corresponding second large language model; and perform model training on the second large language model based on the first data set.

[0181] The modified model application module 204 is used to, after the model training is completed, use the second largest language model to process the directional NLP task with reference to the dense vector database; and regularly update the data of the dense vector database; and regularly perform a task processing performance evaluation on the second largest language model based on the latest dense vector database to obtain the corresponding evaluation result of the time, and when the evaluation result of the time is unqualified, construct a model training data set based on the dense vector database to obtain the corresponding second data set, and fine-tune the second largest language model based on the second data set, and continue to use the second largest language model to process the directional NLP task with reference to the dense vector database after the fine-tuning is completed; the evaluation result of the time includes qualified and unqualified.

[0182] An embodiment of the present invention provides a processing device for a large language model that introduces a dense vector retriever, which can execute the method steps in the above method embodiment. Its implementation principles and technical effects are similar and will not be repeated here.

[0183] It should be noted that the division of the various modules of the above devices is merely a division of logical functions. In actual implementation, they can be fully or partially integrated into a single physical entity or physically separated. Furthermore, these modules can be implemented entirely in software called by a processing element; or entirely in hardware; or some modules can be implemented in software called by a processing element, and some modules in hardware. For example, the large language model selection module can be a separate processing element, or it can be integrated into a chip of the above device. Furthermore, it can be stored in the memory of the above device in the form of program code, called by a processing element of the above device to perform the functions of the above-determined module. The implementation of other modules is similar. Furthermore, these modules can be fully or partially integrated together, or implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. During implementation, each step of the above method or each of the above modules can be completed by hardware integrated logic circuits in the processor element or by software instructions.

[0184] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented by scheduling program code through a processing element, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0185] In the above embodiments, all or part of the embodiments may be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the above method embodiments are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The above-mentioned computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the above-mentioned computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, Bluetooth, microwave, etc.) means. The above-mentioned computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The above-mentioned available medium can be a magnetic medium (such as a floppy disk, hard disk, tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.

[0186] Figure 5 This is a schematic diagram of the structure of an electronic device provided in the third embodiment of the present invention. The electronic device can be a terminal device or server that implements the method of the aforementioned embodiment, or it can be a terminal device or server that implements the method of the aforementioned embodiment connected to the aforementioned terminal device or server. Figure 5 As shown, the electronic device may include: a processor 301 (such as a CPU), a memory 302, and a transceiver 303; the transceiver 303 is coupled to the processor 301, and the processor 301 controls the transceiver 303's transceiver actions. Various instructions may be stored in the memory 302 for completing various processing functions and implementing the processing steps described in the aforementioned embodiment method. Preferably, the electronic device involved in the embodiment of the present invention further includes: a power supply 304, a system bus 305, and a communication port 306. The system bus 305 is used to realize communication connections between components. The above-mentioned communication port 306 is used for connecting and communicating between the electronic device and other peripherals.

[0187] exist Figure 5The system bus 305 mentioned in the figure can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface is used to realize communication between the database access device and other devices (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory (Non-Volatile Memory), such as at least one disk storage.

[0188] The above-mentioned processors can be general-purpose processors, including central processing units (CPUs), network processors (NPs), graphics processing units (GPUs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0189] It should be noted that an embodiment of the present invention further provides a computer-readable storage medium, which stores instructions. When the computer-readable storage medium is run on a computer, it enables the computer to execute the methods and processing procedures provided in the above embodiments.

[0190] The embodiment of the present invention provides a processing method, device, electronic device and computer-readable storage medium for a large language model that introduces a dense vector retriever. As can be seen from the above content, the embodiment of the present invention uses a large language model that is implemented based on the Transformer model architecture and has completed pre-training and fine-tuning of a type of directional NLP task (such as machine translation task, intelligent question-answering task) as the corresponding first large language model; and uses the directional text corpus used by the first large language model in fine-tuning the corresponding directional NLP task as the corresponding first data set; and initializes the corresponding dense vector database based on the first data set; and adds a dense vector retriever and a feature fusion module to the first large language model to form the corresponding second large language model; and performs model training on the second large language model based on the first data set. Training; and after the model training is completed, the second largest language model uses the dense vector database as a reference to process the directional NLP task; and the dense vector database is regularly updated; and the second largest language model is regularly evaluated for task processing performance based on the latest dense vector database to obtain the corresponding evaluation result, and when the evaluation result is unqualified, a model training data set is constructed based on the dense vector database to obtain the corresponding second data set, and the second largest language model is fine-tuned based on the second data set, and after the fine-tuning is completed, the second largest language model continues to process the directional NLP task with the dense vector database as a reference. The embodiment of the present invention realizes the update and iteration of knowledge by updating the dense vector database, and solves / improves the timeliness problem of the large language model by introducing a dense vector retriever that can perform information query on the dense vector database into the large language model; the embodiment of the present invention can not only maintain the timeliness of the model without periodic fine-tuning, but also promptly perform supplementary fine-tuning on the model when it is found that the timeliness of the model has decreased; the embodiment of the present invention not only ensures the optimal real-time performance of the model, but also reduces the maintenance cost of the model and improves the economic value of the model.

[0191] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0192] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for processing a large language model by introducing a dense vector retriever, characterized in that: The method comprises: A large language model implemented based on the Transformer model architecture and having completed pre-training and fine-tuning for a targeted NLP task is used as the corresponding first large language model; the targeted NLP task includes at least a machine translation task and an intelligent question-answering task; Using the directional text corpus used by the first language model in fine-tuning the corresponding directional NLP task as the corresponding first data set; and initializing the corresponding dense vector database based on the first data set; Adding a dense vector retriever and a feature fusion module to the first language model to form a corresponding second language model; and performing model training on the second language model based on the first data set; After the model training is completed, the second largest language model processes the directional NLP task with reference to the dense vector database; and the dense vector database is regularly updated; and the second largest language model is regularly evaluated for task processing performance based on the latest dense vector database to obtain the corresponding evaluation result of the current time, and when the evaluation result of the current time is unqualified, a model training data set is constructed based on the dense vector database to obtain the corresponding second data set, and the second largest language model is fine-tuned based on the second data set, and after the fine-tuning is completed, the second largest language model continues to process the directional NLP task with reference to the dense vector database; the evaluation result of the current time includes qualified and unqualified; The periodic updating of the dense vector database specifically includes: Step 81: regularly collect big data of the text corpus of the targeted NLP task through multiple big data collection channels at a preset first time frequency to obtain a corresponding first collection data set; and perform text noise reduction, deduplication, compliance verification, and correctness verification on each first collection record of the first collection data set based on manual or other machine model screening methods; and form a corresponding second encoder using the preprocessing module, embedded coding module, and feature extraction module of the second large language model; Among them, the multiple big data collection channels include at least public text corpora, public network text resources, and public technical standards / textbooks / documents / magazines / journals / paper resources in various fields; the first collection data set includes multiple first collection records; the first collection record includes a first collection target text and a first collection label text; when the directional NLP task is a machine translation task, the first collection target text and the first collection label text are the corresponding translation target text and interpretation label text respectively; when the directional NLP task is an intelligent question-answering task, the first collection target text and the first collection label text are the corresponding question target text and answer label text respectively; Step 82: taking the first first acquisition record of the first acquisition data set as the corresponding current acquisition record; Step 83: Using the first acquisition target text and the first acquisition label text of the current acquisition record as the corresponding current acquisition target text and the current acquisition label text; inputting the current acquisition target text and the current acquisition label text into the second encoder for corresponding text preprocessing, embedded coding processing, and feature extraction processing to obtain corresponding current target text feature vectors and current label text feature vectors; and performing dense vector conversion on the current target text feature vector and the current label text feature vector in a dense vector format to obtain corresponding current target text dense vectors and current label text dense vectors; Step 84, query the first vector data record whose first dense vector field in the first vector database of the dense vector database has the largest vector feature similarity with the current target text dense vector and use the first vector data record obtained by the query as the corresponding first query record; and use the vector feature similarity between the first dense vector field of the first query record and the current target text dense vector as the corresponding first target similarity; and use the first text data record whose second vector identification field in the first text database matches the first vector identification field of the first query record as the corresponding second query record; and record the first vector data record whose first dense vector field in the first vector database matches the third vector identification field of the second query record as the corresponding third query record; and calculate the vector feature similarity between the first dense vector field of the third query record and the current label text dense vector to obtain the corresponding first label similarity; Step 85: Identify the first target proximity and the first label proximity. If the first target proximity exceeds a preset second proximity threshold and the first label proximity does not exceed the second proximity threshold, proceed to step 86. If the first target proximity does not exceed the second proximity threshold, proceed to step 87. If both the first target proximity and the first label proximity exceed the second proximity threshold, proceed to step 88. Wherein, the second similarity threshold value>the first similarity threshold value; Step 86: Update the second text field of the second query record to the corresponding currently collected label text; update the first update field of the second query record to the corresponding current time; and update the first dense vector field of the third query record to the corresponding currently collected label text dense vector; and go to step 88; Step 87: Add two new vector data records as the corresponding first and second new records in the first vector database; and add one new text data record as the corresponding third new record in the first text database; and assign a unique record identifier to each of the first, second, and third new records as the corresponding first, second, and third new identifiers; and use the current time as the corresponding first new time; and set the first vector identification field and the first dense vector field of the first new record to the corresponding first new identifier and the current target text dense vector; and set the first vector identification field and the first dense vector field of the second new record to the corresponding second new identifier and the current label text dense vector; and set the first text identification field, the first text field, the second text field, the second vector identification field, the third vector identification field, and the first update field of the third new record to the corresponding third new identifier, the current collection target text, the current collection label text, the first new identifier, the second new identifier, and the first new time; Step 88, identifying whether the current acquisition record is the last of the first acquisition record in the first acquisition data set; if not, extracting the next first acquisition record in the first acquisition data set as the new current acquisition record and returning to step 83; if so, confirming that the data update process is complete.

2. The method for processing a large language model using a dense vector search engine according to claim 1, wherein: The first data set includes a plurality of first data records; the first data record includes a first target text and a first label text; when the directional NLP task is a machine translation task, the first target text and the first label text correspond to the translation target text and the interpretation label text respectively; when the directional NLP task is an intelligent question-answering task, the first target text and the first label text correspond to the question target text and the answer label text respectively; The dense vector database includes a first vector database and a first text database; the first vector database is implemented based on a type of vector database, and the first text database is implemented based on a type of relational database; the vector database includes at least a Faiss or Annoy database; the relational database includes at least an SQL database and a MySQL database; The first vector database is used to store a plurality of first vector data records; the first vector data record includes a first vector identification field and a first dense vector field; the first dense vector field is used to store a feature vector of a text in a dense vector format; The first text database is used to store multiple first text data records; the first text data record includes a first text identification field, a first text field, a second text field, a second vector identification field, a third vector identification field and a first update field; the first text identification field is a unique identifier of the current text data record; when the directional NLP task is a machine translation task, the first and second text fields are the corresponding translation target text and the latest interpretation label text, respectively; when the directional NLP task is an intelligent question-answering task, the first and second text fields are the corresponding question text and the latest answer label text, respectively; the first and second text fields correspond to one of the first vector data records in the first vector database respectively; the second vector identification field matches the first vector identification field of the first vector data record corresponding to the first text field; the third vector identification field matches the first vector identification field of the first vector data record corresponding to the second text field; the first update field is the latest creation / update time of the current text data record; The second data set includes multiple second data records; the second data records include a second target text and a second label text; when the directional NLP task is a machine translation task, the second target text and the second label text are the corresponding translation target text and interpretation label text respectively; when the directional NLP task is an intelligent question and answer task, the second target text and the second label text are the corresponding question target text and answer label text respectively.

3. The method for processing a large language model using a dense vector search engine according to claim 2, The first language model is used to perform corresponding NLP task text generation processing according to the first task text input by the model and output the corresponding first generated text; The model framework of the first language model includes at least a preprocessing module, an embedding encoding module, a feature extraction module and a text generation module; The connection relationship between the model components of the first language model is as follows: the input end of the preprocessing module is used to receive the first task text, and the output end is connected to the input end of the embedding coding module; the output end of the embedding coding module is connected to the input end of the feature extraction module; the output end of the feature extraction module is connected to the input end of the text generation module; The preprocessing module of the first large language model is used to perform word segmentation, stop word removal and part-of-speech tagging on the first task text to obtain a corresponding first word segmentation sequence and send it to the embedding coding module; The embedding coding module of the first large language model is used to perform word embedding coding and word position coding on the first word segmentation sequence to obtain a corresponding first embedding coding vector and send it to the feature extraction module; The feature extraction module of the first language model is implemented based on the Encoder or Decoder component structure of the Transformer model; the feature extraction module is used to perform deep learning on the associated features of each segmented text and other segmented texts in the first task text according to the first embedded coding vector to obtain a corresponding first feature vector and send it to the text generation module; The text generation module of the first language model is implemented based on a type of text generator model; the text generation module is used to perform text feature decoding and text generation processing according to the first feature vector and output the corresponding first generated text.

4. The method for processing a large language model using a dense vector search engine according to claim 3, The second largest language model is used to use the dense vector database as a task reference knowledge base and perform corresponding NLP task text generation processing according to the second task text input by the model and output the corresponding second generated text; The model framework of the second language model includes the preprocessing module, the embedded coding module, the feature extraction module, the dense vector retriever, the feature fusion module and the text generation module; the dense vector retriever is connected to the dense vector database; The connection relationship between the model components of the second language model is as follows: the input end of the preprocessing module is used to receive the second task text, and the output end is connected to the input end of the embedding coding module; the output end of the embedding coding module is connected to the input end of the feature extraction module; the output end of the feature extraction module is respectively connected to the input end of the dense vector searcher and the first input end of the feature fusion module; the output end of the dense vector searcher is connected to the second input end of the feature fusion module; the output end of the feature fusion module is connected to the input end of the text generation module; The preprocessing module of the second language model is used to perform word segmentation, stop word removal and part-of-speech tagging on the second task text to obtain a corresponding second word segmentation sequence and send it to the embedding coding module; The embedding coding module of the second language model is used to perform word embedding coding and word position coding on the second word segmentation sequence to obtain a corresponding second embedding coding vector and send it to the feature extraction module; The feature extraction module of the second language model is used to perform deep learning on the associated features of each segmented text and other segmented texts in the second task text according to the second embedded coding vector to obtain a corresponding second feature vector and send it to the dense vector retriever and the feature fusion module respectively; The dense vector retriever of the second largest language model is used to perform dense vector conversion on the second feature vector in a dense vector format to obtain a corresponding first conversion vector; and query the first vector data records in the first vector database for which the vector feature similarity between the first dense vector field and the first conversion vector exceeds a preset first similarity threshold; and count the total number of the first vector data records obtained from the query to obtain a corresponding first total number A; and identifying whether the first total A is zero; If the first total number A is zero, the corresponding first reference record sequence is set to empty; if the first total number A is not zero, the vector feature approximation between the first dense vector field and the second feature vector of each first vector data record queried this time is used as the corresponding first correlation coefficient, and the A first vector data records are sequentially sorted in descending order of the first correlation coefficient to form a corresponding first record sequence, and the third vector identification field of the first text data record whose second vector identification field in the first text database matches the first vector identification field of each first record sequence is extracted as the corresponding first identification, and the first vector identification field in the first vector database that matches the first identification field of each first identification is extracted as the corresponding first identification. The first dense vector field of the first vector data record is extracted as the corresponding first reference dense vector, and the corresponding text feature vector conversion is performed on each of the first reference dense vectors in a text feature vector format to obtain a corresponding first reference feature vector, and each of the first reference feature vectors and the corresponding first correlation coefficient forms a corresponding first reference record, and the A first reference records are sequentially sorted in descending order of the first correlation coefficient to form a corresponding first reference record sequence; and the obtained first reference record sequence is sent to the feature fusion module; wherein, the dense vector conversion method from the text feature vector format to the dense vector format is inverse to the text feature vector conversion method from the dense vector format to the text feature vector format; The feature fusion module of the second largest language model is used to identify whether the first reference record sequence is empty; if the first reference record sequence is empty, the second feature vector is used as the corresponding first fused feature vector; if the first reference record sequence is not empty, the preset feature fusion mode is identified; if the feature fusion mode is the first mode, the A first reference feature vectors of the first reference record sequence are sequentially vector-spliced ​​in descending order of the first correlation coefficient to obtain the corresponding first spliced ​​feature vector, and the second feature vector and the first spliced ​​feature vector are sequentially vector-spliced ​​and the obtained spliced ​​vector is used as the corresponding first fused feature vector; if the feature fusion mode is the second mode, the A first correlation coefficients of the first reference record sequence are normalized to obtain the corresponding A normalized correlation coefficients, and the inner product calculation result of each normalized correlation coefficient and its corresponding first reference feature vector is used as the corresponding first weighted feature vector, and the mean vector calculation of the obtained A first weighted feature vectors is performed to obtain the corresponding first average feature vector, and The second feature vector and the first average feature vector are sequentially concatenated and the obtained concatenated vector is used as the corresponding first fused feature vector; if the feature fusion mode is the third mode, the attention weights of the second feature vector and each of the first reference feature vectors of the first reference record sequence are predicted based on a class of neural network models to obtain the corresponding first attention weights, and the obtained A first attention weights are normalized to obtain the corresponding A normalized attention weights, and the inner product calculation result of each normalized attention weight and its corresponding first reference feature vector is used as the corresponding first attention feature vector, and the mean vector calculation is performed on the obtained A first attention feature vectors to obtain the corresponding second average feature vector, and the second feature vector and the second average feature vector are sequentially concatenated and the obtained concatenated vector is used as the corresponding first fused feature vector; and the obtained first fused feature vector is sent to the text generation module; the feature fusion mode includes the first, second and third modes; the neural network model includes at least an MLP model and a CNN model; The text generation module of the second language model is used to perform text feature decoding and text generation processing according to the first fused feature vector and output the corresponding first generated text.

5. The method for processing a large language model using a dense vector search engine according to claim 3, wherein: Initializing the corresponding dense vector database based on the first data set specifically includes: Step 51: Initialize an empty database based on a class of the vector database and record it as the corresponding first vector database; and initialize an empty database based on a class of the relational database and record it as the corresponding first text database; and form a corresponding first encoder by using the preprocessing module of the first large language model, the embedded coding module, and the feature extraction module; Step 52, perform a round of traversal on all the first data records of the first data set; and in this round of traversal, take the first data record currently traversed as the corresponding current record; and take the first target text and the first label text of the current record as the corresponding current target text and current label text; and input the current target text and the current label text into the first encoder respectively for corresponding text preprocessing, embedded coding processing and feature extraction processing to obtain the corresponding current target text feature vector and current label text feature vector; and perform dense vector conversion on the current target text feature vector and the current label text feature vector in dense vector format to obtain the corresponding current target text dense vector and current label text dense vector; and create two new first vector data records in the first vector database as the corresponding first and second newly created records; and assign a unique record identifier to each of the first and second newly created records as the corresponding first and second newly created records. Create an identifier; and set the first vector identification field and the first dense vector field of the first newly created record to the corresponding first newly created identifier and the current target text dense vector; and set the first vector identification field and the first dense vector field of the second newly created record to the corresponding second newly created identifier and the current label text dense vector; and create a new first vector data record in the first text database as the corresponding third newly created record; and assign a unique record identifier to each of the third newly created records as the corresponding third newly created identifier; and use the current time as the corresponding first time; and set the first text identification field, the first text field, the second text field, the second vector identification field, the third vector identification field and the first update field of the third newly created record to the corresponding third newly created identifier, the current target text, the current label text, the first newly created identifier, the second newly created identifier and the first time.

6. The method for processing a large language model using a dense vector search engine according to claim 4, wherein: The performing model training on the second language model based on the first data set specifically includes: Step 61, performing sub-dataset segmentation processing on the first data set according to a preset first segmentation ratio to obtain corresponding first training set and first evaluation set; Wherein, both the first training set and the first evaluation set are composed of a plurality of the first data records; the ratio of the total number of records in the first training set to the total number of records in the first evaluation set satisfies the first segmentation ratio; Step 62: extract the first first data record from the first training set as the corresponding current training record; Step 63: input the first target text of the current training record into the second language model for processing and use the generated text output by the model as the corresponding first predicted text; Step 64: subjecting the first predicted text and the first label text of the current training record to a preset first model loss function; and identifying the preset feature fusion mode; if the feature fusion mode is the first or second mode, then based on a preset first model optimizer, performing a round of modulation on the model parameters of the text generation module of the second largest language model in a direction that minimizes the first model loss function; if the feature fusion mode is the third mode, then based on a preset second model optimizer, performing a round of modulation on the model parameters of the feature fusion module and the text generation module of the second largest language model in a direction that minimizes the first model loss function; Wherein, the first model loss function is implemented based on the maximum likelihood loss function; the first and second model optimizers include at least an SGD optimizer and an ADAM optimizer; Step 65: Identify whether the current training record is the last first data record in the first training set; if so, proceed to step 66; if not, extract the next first data record in the first training set as the new current training record and return to step 63; Step 66: Perform a round of traversal on all the first data records in the first evaluation set; during this round of traversal, use the first data record currently being traversed as the corresponding current evaluation record; input the first target text of the current evaluation record into the second large language model for processing, and use the generated text output by the model as the corresponding second predicted text; and form a corresponding first prediction-label pair from the second predicted text and the first label text of the current training record; and at the end of this round of traversal, bring all the obtained first prediction-label pairs into a preset first model evaluation function to calculate and obtain the corresponding first evaluation value; Wherein, the first model evaluation function includes at least a MAE function and an MSE function; Step 67, identifying whether the first evaluation value meets the preset first evaluation value range; if not, returning to step 62 to continue training; if satisfied, stopping training and confirming the end of model training.

7. The method for processing a large language model using a dense vector search engine according to claim 4, wherein: The second largest language model processes the directional NLP task with reference to the dense vector database, specifically including: Receive the task text input by the user as the corresponding current task text; input the current task text into the second largest language model, and the second largest language model uses the dense vector database as the task reference knowledge base and performs corresponding NLP task text generation processing according to the current task text input by the model; and feed back the generated text output by the model as the corresponding current generated text to the user.

8. The method for processing a large language model using a dense vector search engine according to claim 4, wherein: The periodic task processing performance evaluation of the second largest language model based on the latest dense vector database is performed to obtain the corresponding evaluation result, specifically including: Step 91: regularly setting the current time as the corresponding first end time according to a preset second time frequency, and subtracting a preset first duration from the first end time as the corresponding first start time, and forming a corresponding first recent time period from the first start time and the first end time; and extracting all the first text data records whose first update fields satisfy the first recent time period in the first text database of the dense vector database to form a corresponding first record set; Step 92: perform a round of traversal on all the first text data records of the first record set; and during this round of traversal, use the first text data record currently traversed as the corresponding current evaluation record; and extract the first text field and the second text field of the current evaluation record as the corresponding current task text and current label text; and input the current task text into the second language model for processing and use the generated text output by the model as the corresponding current predicted text; and form a corresponding second prediction-label pair with the current predicted text and the current label text; and at the end of this round of traversal, bring all the obtained second prediction-label pairs into a preset second model evaluation function to calculate and obtain the corresponding second evaluation value; Wherein, the second model evaluation function includes at least a MAE function and an MSE function; Step 93, identifying whether the second evaluation value meets the preset second evaluation value range; if so, setting the corresponding evaluation result of the current time as qualified; if not, setting the corresponding evaluation result of the current time as unqualified.

9. The method for processing a large language model using a dense vector search engine according to claim 8, wherein: When the evaluation result is unqualified, constructing a model training data set based on the dense vector database to obtain a corresponding second data set specifically includes: When the evaluation result is unqualified, a round of traversal is performed on all the first text data records of the first record set; and during this round of traversal, the first text data record currently traversed is used as the corresponding current record; and the first text field and the second text field of the current record are extracted as the corresponding second target text and the second label text to form a corresponding second data record; and at the end of this round of traversal, all the obtained second data records form the corresponding second data set.

10. The method for processing a large language model using a dense vector search engine according to claim 6, wherein: Fine-tuning the second language model based on the second data set specifically includes: Step 111, performing sub-dataset segmentation processing on the second data set according to a preset second segmentation ratio to obtain corresponding second training sets and second evaluation sets; Wherein, both the second training set and the second evaluation set are composed of a plurality of second data records; the ratio of the total number of records in the second training set to the total number of records in the second evaluation set satisfies the second segmentation ratio; Step 112: extract the first second data record from the second training set as the corresponding current training record; Step 113: input the second target text of the current training record into the second large language model for processing and use the generated text output by the model as the corresponding third predicted text; Step 114: Substitute the third predicted text and the second label text of the current training record into the first model loss function; and fine-tune the model parameters of the text generation module of the second language model based on a preset third model optimizer in a direction that minimizes the first model loss function. Wherein, the third model optimizer includes at least an SGD optimizer and an ADAM optimizer; Step 115: Identify whether the current training record is the last second data record in the second training set; if so, proceed to step 116; if not, extract the next second data record in the second training set as the new current training record and return to step 113; Step 116: Perform a round of traversal on all the second data records in the second evaluation set; during this round of traversal, use the second data record currently being traversed as the corresponding current evaluation record; input the second target text of the current evaluation record into the second large language model for processing, and use the generated text output by the model as the corresponding fourth predicted text; and form a corresponding third prediction-label pair from the fourth predicted text and the second label text of the current training record; and at the end of this round of traversal, bring all the obtained third prediction-label pairs into a preset third model evaluation function to calculate and obtain a corresponding third evaluation value; Wherein, the third model evaluation function includes at least a MAE function and an MSE function; Step 117 , identifying whether the third evaluation value meets the preset third evaluation value range; if not, returning to step 112 to continue training; if satisfied, stopping training and confirming the end of this fine-tuning.

11. A device for executing the method for processing a large language model using a dense vector search engine according to any one of claims 1 to 10, characterized in that: The device includes: a large language model selection module, a dense vector database preparation module, a large language model transformation and training module, and a transformation model application module; The large language model selection module is used to select a large language model that is implemented based on the Transformer model architecture and has completed pre-training and fine-tuning for a type of targeted NLP task as the corresponding first large language model; the targeted NLP task includes at least a machine translation task and an intelligent question-answering task; The dense vector database preparation module is used to use the directional text corpus used by the first large language model in fine-tuning the corresponding directional NLP task as the corresponding first data set; and initialize the corresponding dense vector database based on the first data set; The large language model transformation and training module is used to add a dense vector retriever and a feature fusion module to the first large language model to form a corresponding second large language model; and perform model training on the second large language model based on the first data set; The modified model application module is used to, after the model training is completed, use the second large language model to process the directional NLP task with reference to the dense vector database; and regularly update the data of the dense vector database; and regularly perform a task processing performance evaluation on the second large language model based on the latest dense vector database to obtain the corresponding evaluation result of the time, and when the evaluation result of the time is unqualified, construct a model training data set based on the dense vector database to obtain the corresponding second data set, and fine-tune the second large language model based on the second data set, and after the fine-tuning is completed, continue to use the second large language model to process the directional NLP task with reference to the dense vector database; the evaluation result of the time includes qualified and unqualified.

12. An electronic device, characterized in that: include: memory, processors, and transceivers; The processor is configured to be coupled to the memory, read and execute instructions in the memory, so as to implement the method according to any one of claims 1 to 10; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.

13. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a computer, the computer is caused to execute the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Word embedding data processing method and device, electronic equipment and storage medium

    CN118673110A

  • Method and apparatus for automatically generating inference questions and answers

    WO2021184311A1