Model online updating method and device, equipment and medium
Patent Information
- Application Number
- CN202310672706.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-07
- Publication Date
- 2026-08-28
- Estimated Expiration
- 2043-06-07
AI Technical Summary
[0003]传统技术中,通常采用离线更新,即选择在凌晨时分等少人使用自动化智能回复客服的线上服务的时候,停止当前旧模型提供的线上服务,将新模型部署,长时间处理完海量的业务数据后,以新模型替换旧模型提供线上服务,重启线上服务,可见模型更新过程中长时间中断现有的线上服务,对线上业务造成非常大的影响,由于不能提供业务服务,用户会因为无法完成操作而感到焦虑和失望,这会影响用户的满意度和忠诚度,甚至可能导致客户流失,此外,通常业务数据体量大,基本上无时无刻都在写入数据库存储,而模型处理业务数据的速度有限,故而可能会出现模型重复处理同一业务数据,以及模型处理已经写入的静态业务数据和实时持续写入的动态业务数据可能出现紊乱,导致未处理完成所需处理的所有业务数据便处理失败,无法更新
[0047]This application responds to old model update requests by deploying a new model and continuously pushing incremental similar questions from the database to the real-time queue in the message middleware. It records the data position of the latest similar question in the current database, pushes all similar questions from the current database to the historical queue in the message middleware, pulls all similar questions from the historical queue, calls the new model for processing, obtains the vectorized representation corresponding to each similar question, and stores it in the database. It then pulls all similar questions after the data position in the real-time queue, calls the new model for processing, obtains the vectorized representation corresponding to each similar question, and stores it in the database. When the timestamp of the similar question processed by the new model differs from the current time by less than a preset threshold, the old model is updated with the new model. On one hand, by temporarily placing dynamically incremental similar question data from the database in the real-time queue of the message queue, and temporarily placing statically existing similar questions from the database in the historical queue of the message middleware, it achieves isolation between dynamic and static business data, ensuring that their operations do not interfere with each other. While guaranteeing data stability and reliability, it can process all dynamic and static business data in an orderly and error-free manner. On the other hand, without affecting the normal online service provided by the model, it achieves online model updates that are imperceptible to users, improving user experience and facilitating updates at any time.
Smart Images

Figure CN116701420B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of e-commerce technology, and in particular to a method for online model updating and the corresponding apparatus, computer equipment, and computer-readable storage medium. Background Technology
[0002] In the e-commerce sector, automated and intelligent customer service is an indispensable part of e-commerce operations. In order to provide high-quality online services, the models supporting these services need to be continuously iterated, and the new models need to update the old models from the previous iterations.
[0003] Traditional technologies typically employ offline updates. This involves stopping the online service provided by the old model during the early morning hours when fewer people are using the automated intelligent customer service, deploying the new model, and then replacing the old model with the new one after processing massive amounts of business data for an extended period. The online service is then restarted. It's clear that this prolonged interruption of existing online services during model updates has a significant impact on online business. Users experience anxiety and disappointment due to the inability to complete operations, affecting user satisfaction and loyalty, and potentially leading to customer churn. Furthermore, business data is often large and continuously written to the database, while the model's processing speed is limited. This can lead to the model processing the same business data repeatedly, and the model may become disorganized between processing already written static business data and continuously written dynamic business data. This can result in processing failures before all required business data is processed, preventing updates from being completed.
[0004] Given the shortcomings of traditional technologies, the applicant has long been engaged in research in related fields and has therefore explored alternative approaches to solve industry problems in the e-commerce sector. Summary of the Invention
[0005] The primary objective of this application is to solve at least one of the above-mentioned problems by providing a method for online model updating and the corresponding apparatus, computer equipment, and computer-readable storage medium.
[0006] To achieve the various objectives of this application, the following technical solution is adopted:
[0007] A method for online model updating provided to meet one of the purposes of this application includes the following steps:
[0008] In response to old model update requests, deploy new models and continuously push incremental similar questions from the database to the real-time queue in the message middleware.
[0009] Record the data location of the latest similar question in the current database, and push all similar questions in the current database to the historical queue in the message middleware;
[0010] The new model is called to process all similar questions retrieved from the historical queue, and the vectorized representation of each similar question is obtained and stored in the database.
[0011] After retrieving the data point from the real-time queue, all similar questions are processed by the new model to obtain the vectorized representation of each similar question and store it in the database.
[0012] When the timestamp of the similar time processed by the new model differs from the current time by less than a preset threshold, the old model is updated with the new model.
[0013] In a further embodiment, all similar data points after the data point in the real-time queue are retrieved and processed using the new model to obtain the vectorized representation corresponding to each similar data point, which is then stored in the database. This includes the following steps:
[0014] Retrieve all similar questions after the data point in the real-time queue, identify the preset idempotency key corresponding to each similar question, and the idempotency key indicates whether the corresponding similar question has been processed;
[0015] When the idempotent key represents a similarity question that has not been processed, the new model is invoked to process the similarity question of the idempotent key and obtain the corresponding vectorized representation. When the idempotent key represents a similarity question that has been processed, the processing of the similarity question of the idempotent key is skipped.
[0016] In a further embodiment, updating the old model with the new model includes the following steps:
[0017] Obtain the similarity questions processed by the new model in the database and their vectorized representations;
[0018] Based on whether two similar questions are similar, corresponding positive and negative samples are determined. Two similar questions in the positive samples are similar to each other, and two similar questions in the negative samples are not similar to each other.
[0019] The accuracy of the new model is evaluated by using the similarity between the vectorized representations of two corresponding similar samples in the positive and negative samples as the prediction value.
[0020] When the accuracy reaches the preset standard, the new model is determined to have passed the verification, and the new model replaces the old model and goes online.
[0021] When the accuracy does not meet the preset standard, it is determined that the new model fails the verification and an old model update failure event is triggered.
[0022] In a further embodiment, based on whether there is similarity between any two similar samples, corresponding positive and negative samples are determined, wherein two similar samples in the positive samples are similar to each other, and two similar samples in the negative samples are dissimilar to each other, including the following steps:
[0023] Clustering algorithms are used to cluster multiple similar questions to identify multiple similar question groups, and different similar question groups correspond to different intentions;
[0024] Two similar questions that are closest to the cluster center in the same similar question group are constructed as positive samples, and two similar questions that express different intentions in the same similar question group are constructed as negative samples.
[0025] In a further embodiment, after replacing the old model with the new model and going live, the following steps are included:
[0026] The old model that is offline will continue to work in parallel with the new model;
[0027] In response to an abnormal event in the new model, the old model is used to replace the new model and it is then deployed online.
[0028] In response to the old model being taken offline, the old model is taken offline, and the vectorized representation of similar questions processed by the old model is deleted from the database.
[0029] In a further embodiment, responding to a failure to update the old model includes the following steps:
[0030] Obtain the similar questions processed by the old model in the database and their vectorized representations, construct positive samples and negative samples, and label the positive samples and negative samples with supervision labels according to the similarity between the vectorized representations of two similar questions in the positive samples and negative samples respectively. The two similar questions in the positive samples are similar, and the two similar questions in the negative samples are not similar.
[0031] The new model is called to process the positive and negative samples to obtain the vectorized representations of two similarities in the positive and negative samples respectively. The similarity between the vectorized representations of the two similarities is calculated to obtain the predicted values of the positive and negative samples respectively.
[0032] Using the supervision labels of the positive and negative samples respectively, the loss values of the predicted values of the positive and negative samples are determined. When the loss value does not reach the preset threshold, the weights of the new model are updated, and other positive and negative samples are used to carry out iterative training until the new model converges.
[0033] In a further embodiment, after updating the old model with the new model, the following steps are included:
[0034] Respond to customer service requests and obtain the user's input question text;
[0035] The new model is invoked to process the question text and obtain the corresponding vectorized representation;
[0036] Based on the vectorized representation of the question text, similar questions that match the question text in the database are identified, and the answers associated with the similar questions are obtained and pushed to the user as reply text.
[0037] On the other hand, a model online update device provided to meet one of the purposes of this application includes a request response module, a history push module, a history processing module, a real-time processing module, and a model update module. The request response module is used to respond to old model update requests, deploy a new model, and continuously push incremental similar questions from the database to a real-time queue in the message middleware. The history push module is used to record the data position of the latest similar question in the current database and push all similar questions in the current database to a history queue in the message middleware. The history processing module is used to pull all similar questions from the history queue, call the new model for processing, and obtain a vectorized representation corresponding to each similar question, storing it in the database. The real-time processing module is used to pull all similar questions after the data position in the real-time queue, call the new model for processing, and obtain a vectorized representation corresponding to each similar question, storing it in the database. The model update module is used to update the old model with the new model when the timestamp of the similar question processed by the new model differs from the current time by less than a preset threshold.
[0038] In a further embodiment, the real-time processing module includes: an idempotent key identification submodule, used to retrieve all similar questions after the data point in the real-time queue, identify a preset idempotent key corresponding to each similar question, the idempotent key indicating whether the corresponding similar question has been processed; and an idempotent key processing submodule, used to call the new model to process the similar question with the idempotent key when the idempotent key indicates that the corresponding similar question has not been processed, and obtain the corresponding vectorized representation; and to skip the processing of the similar question with the idempotent key when the idempotent key indicates that the corresponding similar question has been processed.
[0039] In a further embodiment, the model update module includes: a data acquisition submodule, used to acquire similar questions and their vectorized representations processed by the new model in the database; a positive and negative sample determination submodule, used to determine corresponding positive and negative samples based on whether two similar questions are similar, wherein two similar questions in the positive samples are similar and two similar questions in the negative samples are dissimilar; an accuracy evaluation submodule, used to evaluate the accuracy of the new model by using the similarity between the vectorized representations of the corresponding two similar questions in the positive and negative samples as a prediction value; a verification pass submodule, used to determine that the new model passes verification when the accuracy reaches a preset standard, and to replace the old model with the new model and go online; and a verification fail submodule, used to determine that the new model fails verification when the accuracy does not reach the preset standard, and to respond to the old model update failure event.
[0040] In a further embodiment, the positive and negative sample determination submodule includes: a similarity question clustering unit, used to cluster multiple similar questions using a clustering algorithm to determine multiple similar question groups, with different similar question groups corresponding to different intentions; and a positive and negative sample construction unit, used to construct two similar questions in the same similar question group that are closest to the cluster center point as positive samples, and construct two similar questions in the same similar question group that express different intentions as negative samples.
[0041] In a further embodiment, after the positive and negative sample determination submodule, the system includes: a parallel operation submodule, used to keep the offline old model and the new model working in parallel; a first event response submodule, used to respond to a new model exception event and replace the new model with the old model to go online; and a second event response submodule, used to respond to an old model offline event, take the old model offline, and delete the vectorized representation of similar questions processed by the old model from the database.
[0042] In a further embodiment, the verification failure submodule includes: a sample construction and labeling unit, used to obtain similar questions processed by the old model in the database and their vectorized representations, construct positive samples and negative samples, and label the positive samples and negative samples with supervision labels according to the similarity between the vectorized representations of two similar questions in the positive samples and negative samples respectively, wherein the two similar questions in the positive samples are similar and the two similar questions in the negative samples are dissimilar; a model prediction unit, used to call the new model to process the positive samples and negative samples, obtain the vectorized representations of two similar questions in the positive samples and negative samples respectively, calculate the similarity between the vectorized representations of the two similar questions, and obtain the predicted values of the positive samples and negative samples respectively; and an iterative training unit, used to use the supervision labels of the positive samples and negative samples respectively to determine the loss value of the predicted values of the positive samples and negative samples respectively, and when the loss value does not reach a preset threshold, to update the weights of the new model and continue to call other positive samples and negative samples to perform iterative training until the new model converges.
[0043] In a further embodiment, after the model update module, the module includes: a question acquisition module, used to respond to customer service reply requests and acquire the question text input by the user; a question processing module, used to call the new model to process the question text and obtain the corresponding vectorized representation; and a reply push module, used to determine similar questions in the database that match the question text based on the vectorized representation of the question text, and to obtain the answers associated with the similar questions as reply text and push them to the user.
[0044] In another aspect, a computer device provided for one of the purposes of this application includes a central processing unit and a memory, the central processing unit being used to invoke and run a computer program stored in the memory to perform the steps of the online model update method described in this application.
[0045] In another aspect, a computer-readable storage medium is provided to suit another purpose of this application, which stores, in the form of computer-readable instructions, a computer program implemented according to the described online model update method, which, when invoked by a computer, performs the steps included in the method.
[0046] The technical solution of this application has many advantages, including but not limited to the following aspects:
[0047] This application responds to old model update requests by deploying a new model and continuously pushing incremental similar questions from the database to the real-time queue in the message middleware. It records the data position of the latest similar question in the current database, pushes all similar questions from the current database to the historical queue in the message middleware, pulls all similar questions from the historical queue, calls the new model for processing, obtains the vectorized representation corresponding to each similar question, and stores it in the database. It then pulls all similar questions after the data position in the real-time queue, calls the new model for processing, obtains the vectorized representation corresponding to each similar question, and stores it in the database. When the timestamp of the similar question processed by the new model differs from the current time by less than a preset threshold, the old model is updated with the new model. On one hand, by temporarily placing dynamically incremental similar question data from the database in the real-time queue of the message queue, and temporarily placing statically existing similar questions from the database in the historical queue of the message middleware, it achieves isolation between dynamic and static business data, ensuring that their operations do not interfere with each other. While guaranteeing data stability and reliability, it can process all dynamic and static business data in an orderly and error-free manner. On the other hand, without affecting the normal online service provided by the model, it achieves online model updates that are imperceptible to users, improving user experience and facilitating updates at any time. Attached Figure Description
[0048] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0049] Figure 1 This is a flowchart illustrating a typical embodiment of the online model update method of this application;
[0050] Figure 2 This is a schematic diagram illustrating the process of corresponding processing based on the idempotent key for each similarity question in an embodiment of this application;
[0051] Figure 3 This is a flowchart illustrating the process of verifying a new model in an embodiment of this application, updating the old model if the verification passes, and failing to update if the verification fails.
[0052] Figure 4 This is a schematic diagram illustrating the process of constructing positive and negative samples using a clustering algorithm in an embodiment of this application.
[0053] Figure 5 This is a schematic diagram illustrating the process of rolling back or taking offline an old model in an embodiment of this application;
[0054] Figure 6 This is a flowchart illustrating the fine-tuning training process of the new model in an embodiment of this application;
[0055] Figure 7 This is a flowchart illustrating the process of responding to user questions in an embodiment of this application;
[0056] Figure 8 This is a schematic block diagram of the online model update device of this application;
[0057] Figure 9 This is a schematic diagram of the structure of a computer device used in this application. Detailed Implementation
[0058] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0059] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this application means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.
[0060] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0061] Those skilled in the art will understand that the terms "client," "terminal," and "terminal device" as used herein include both devices that receive wireless signals, devices that only possess wireless signal receiver capabilities without transmission capabilities, and devices with receiving and transmitting hardware, devices that have receiving and transmitting hardware capable of bidirectional communication over a bidirectional communication link. Such devices may include: cellular or other communication devices such as personal computers or tablets, having single-line displays, multi-line displays, or cellular or other communication devices without multi-line displays; PCS (Personal Communications Service) that can combine voice, data processing, fax, and / or data communication capabilities; PDA (Personal Digital Assistant) that may include a radio frequency receiver, pager, internet / intranet access, web browser, notepad, calendar, and / or GPS (Global Positioning System) receiver; and conventional laptops and / or handheld computers or other devices that have and / or include radio frequency receivers. As used herein, "client," "terminal," and "terminal device" can be portable, transportable, installed in a means of transportation (air, sea, and / or land), or suitable and / or configured to operate locally and / or in a distributed manner, operating in any other location on Earth and / or in space. "Client," "terminal," and "terminal device" as used herein can also be a communication terminal, an internet access terminal, or a music / video playback terminal, such as a PDA, a MID (Mobile Internet Device), and / or a mobile phone with music / video playback capabilities, or a smart TV, set-top box, etc.
[0062] The hardware referred to by the names "server," "client," and "service node" in this application is essentially an electronic device with the equivalent capabilities of a personal computer. It is a hardware device with the necessary components revealed by the von Neumann architecture, such as a central processing unit (including an arithmetic logic unit and a control unit), memory, input devices, and output devices. The computer program is stored in its memory, and the central processing unit loads the program stored in the secondary storage into the main memory to run it, execute the instructions in the program, and interact with the input and output devices to complete specific functions.
[0063] It should be noted that the concept of "server" used in this application can also be extended to apply to server clusters. Based on network deployment principles as understood by those skilled in the art, the servers should be logically divided; physically, these servers can be independent yet accessible through interfaces, or they can be integrated into a single physical computer or a computer cluster. Those skilled in the art should understand this flexibility and should not use it to constrain the implementation of the network deployment method described in this application.
[0064] One or more of the technical features of this application, unless explicitly specified herein, can be deployed on a server and accessed by a client remotely calling the online service interface provided by the server, or can be directly deployed and run on a client to access the service.
[0065] Unless otherwise specified, the neural network models referenced or potentially referenced in this application may be deployed on a remote server and invoked remotely on the client, or deployed on a client with the capability to invoke directly. In some embodiments, when running on the client, the corresponding intelligence may be acquired through transfer learning in order to reduce the requirements on the client's hardware resources and avoid excessive consumption of the client's hardware resources.
[0066] Unless otherwise specified, all data involved in this application may be stored remotely on a server or on a local terminal device, as long as it is suitable for use by the technical solution of this application.
[0067] Those skilled in the art will understand that although the various methods in this application are described based on the same concept and thus present commonality among them, they can be performed independently unless otherwise specified. Similarly, the various embodiments disclosed in this application are all based on the same inventive concept; therefore, concepts expressed in the same way, as well as concepts that are appropriately changed for convenience but are expressed differently, should be understood equivalently.
[0068] Unless otherwise expressly stated, the various embodiments disclosed in this application can be combined in a cross-cutting manner to flexibly construct new embodiments, as long as such combination does not depart from the inventive spirit of this application and can meet the needs of the prior art or solve a certain deficiency in the prior art. Those skilled in the art should be aware of such modifications.
[0069] The online model update method of this application can be programmed into a computer program product and deployed on a client or server. For example, in an exemplary application scenario of this application, it can be deployed on the server of an e-commerce platform. In this way, the method can be executed by human-computer interaction with the process of the computer program product through a graphical user interface by accessing the interface opened after the computer program product is run.
[0070] Please see Figure 1 The online model update method of this application, in its typical embodiment, includes the following steps:
[0071] Step S1100: Respond to the old model update request, deploy the new model, and continuously push incremental similar questions from the database to the real-time queue in the message middleware.
[0072] Kafka can be used as a message broker. Kafka is a high-throughput distributed publish-subscribe messaging system. A Kafka cluster typically contains multiple servers, called brokers. Programs that send messages to the brokers are called producers. Programs that subscribe to and consume messages from the brokers are called consumers. Each message published to the broker has a category called a topic, and each message belongs to one and only one topic. Each topic has at least one partition, and different partitions within the same topic contain different messages. All brokers, producers, and consumers in the Kafka cluster rely on ZooKeeper to ensure system availability.
[0073] The producer pushes messages to a specified topic within the service broker. Upon receiving the message, the service broker writes it to that topic to save the message. The consumer retrieves messages from the specified topic through the service broker and then performs business processing to consume the messages. In this process, the service broker acts as an intermediary, acting as a message relay station.
[0074] Typically, models are continuously optimized and upgraded to improve their performance and service quality. When the new model, obtained by optimizing and upgrading the old model, has been trained to converge and learn the ability to determine the vectorized representation of the input text, and can provide the corresponding online services, it is necessary to launch the new model to update the old model and generate an old model update request to send to the server.
[0075] The server receives and responds to the old model update request. In order to update the old model online without affecting the normal online service provided by the model, a new process is opened to deploy the new model online while maintaining the current process's call to the old model to provide online services. In addition, in one embodiment, the database is implemented using MySQL. It can be understood that the database continuously stores real-time generated similar questions. The real-time generated similar questions, i.e., the incremental similar questions, are compared with the similar questions already stored in the database. The binlog algorithm, which is suitable for MySQL to connect to Kafuka for message interaction between the database and the message middleware, is used. The database acts as the producer, and the messages it provides are the incremental similar questions. These similar questions are continuously pushed to a topic specified in the service broker of the message middleware, and the topic is used as a real-time queue.
[0076] It is easy to understand that when different users consult the customer service of the e-commerce platform and / or online stores, they will ask different questions for the same purpose. Therefore, in order to adapt to the different questions asked by different users, multiple similar questions are pre-constructed and stored in the database. The multiple similar questions are the texts of different ways of asking the same purpose. Those skilled in the art can flexibly construct the similar questions according to the disclosure here and the business needs.
[0077] Step S1200: Record the data location of the latest similar question in the current database, and push all similar questions in the current database to the historical queue in the message middleware;
[0078] The unique identifier of the latest similar query in the current database is retrieved using an SQL query statement and used as the data location. The unique identifier is used to distinguish different similar queries and has uniqueness. It can be an ID or the like. Those skilled in the art can flexibly generate the unique identifier corresponding to each similar query in the database, for example, by using hash algorithms, UUID algorithms, auto-incrementing algorithms, timestamp algorithms, etc.
[0079] In one embodiment, a binlog algorithm suitable for MySQL to connect to Kafuka for message interaction between the database and the message middleware is used. The database is used as the producer, and the messages it provides are all similar messages in the current database. These similar messages are pushed to another topic in the service broker of the message middleware that is different from the real-time queue, and this topic is used as the historical queue.
[0080] Step S1300: Retrieve all similar questions from the historical queue, call the new model to process them, and obtain the vectorized representation corresponding to each similar question, which is then stored in the database;
[0081] The model in this application is a deep learning model based on deep semantic learning suitable for extracting semantic features of text in the field of NLP (Natural Language Processing), such as LSTM, BiLSTM, or the open-source framework Sentence Transformers, which provides a large number of pre-trained Transformer models that have converged, such as BERT, RoBERTa, XLM-RoBERTa, and MPNet. The specific selection can be flexibly chosen by those skilled in the art.
[0082] A new data processing service is constructed as a consumer, pulling all similar queries from the historical queue in the message middleware. The new model is then invoked to consume these similar queries as input. The model's word segmenter is used to segment the similar queries, resulting in a corresponding word segmentation sequence. This word segmenter can be implemented based on algorithms such as jieba, n-gram, and wordpiece; any such implementation can be flexibly chosen by those skilled in the art. The word segmentation sequence is then input into the hidden layer of the model to extract the corresponding deep semantic information, i.e., the intent expressed by the similar query. In a recommended embodiment, the hidden layer includes multiple stacked multi-head self-attention layers and fully connected layers to extract the corresponding deep semantic information of the word segmentation sequence. Specifically, for each word in the segmentation sequence, multi-head attention is calculated when passing through the multi-head attention layer, thereby weighting the different dimensions of the word segmentation to obtain a corresponding weighted vector representation. After passing through the fully connected layer, the vectorized representation corresponding to each word in the segmentation sequence is obtained.
[0083] The vectorized representation of each similar question in the historical sequence, along with its unique identifier, is stored in the database.
[0084] Step S1400: Retrieve all similar data points after the data point in the real-time queue, call the new model to process them, and obtain the vectorized representation corresponding to each similar data point and store it in the database;
[0085] When the new data processing service retrieves all similar questions from the historical queue for the new model to process, and all are consumed, the new data processing service acts as a consumer, retrieving all similar questions from the real-time queue in the message middleware. The new model then consumes these similar questions as input, using a word segmenter within the model to segment them and obtain corresponding word sequences. The word segmenter can be implemented based on algorithms such as jieba, n-gram, and wordpiece, and can be flexibly adapted by those skilled in the art. The word sequences are then input into the hidden layer of the model to extract the corresponding deep semantic information, i.e., the intent expressed by the similar question. In a recommended embodiment, the hidden layer includes multiple stacked multi-head self-attention layers and fully connected layers to extract the corresponding deep semantic information of the word sequences. Specifically, for each word in the word sequence, multi-head attention is calculated when passing through the multi-head attention layer, thereby weighting the different dimensions of the word with self-attention to obtain a corresponding weighted vector representation. After passing through the fully connected layer, the vectorized representation corresponding to each word in the word sequence is obtained.
[0086] The vectorized representation of each similar question in the real-time sequence, along with its unique identifier, is stored in the database.
[0087] Step S1500: When the timestamp of the similarity processed by the new model differs from the current time by less than a preset threshold, the old model is updated with the new model.
[0088] It's easy to understand that similar questions are continuously stored in the database in real time. When a similar question is stored, its timestamp is also stored along with it. Then, the similar questions in the database are pushed to the message middleware and pulled by the new data processing service for the new model to process. Therefore, to ensure that the similar questions processed by the new model are, to some extent, the latest similar questions, and to prepare for the new model to go live, the timestamp of the similar questions currently being processed by the new model is obtained, and it is determined whether the time difference between the timestamp and the current time is less than a preset threshold. When the time difference is less than the preset threshold, it indicates that the similar questions being processed by the new model are the latest similar questions, and the old model can be updated by the new model. Specifically, the current process providing online services using the old model is taken offline, and a newly opened process providing online services using the new model is brought online. When the time difference is not less than the preset threshold, it indicates that the similar questions being processed by the new model are not yet the latest similar questions, but are still processing previously similar questions that were processed earlier in time. The preset threshold can be flexibly set by those skilled in the art based on prior knowledge or experimental data, for example, 1 second.
[0089] As can be seen from the typical embodiments of this application, the technical solution of this application has many advantages, including but not limited to the following aspects:
[0090] This application responds to old model update requests by deploying a new model and continuously pushing incremental similar questions from the database to the real-time queue in the message middleware. It records the data position of the latest similar question in the current database, pushes all similar questions from the current database to the historical queue in the message middleware, pulls all similar questions from the historical queue, calls the new model for processing, obtains the vectorized representation corresponding to each similar question, and stores it in the database. It then pulls all similar questions after the data position in the real-time queue, calls the new model for processing, obtains the vectorized representation corresponding to each similar question, and stores it in the database. When the timestamp of the similar question processed by the new model differs from the current time by less than a preset threshold, the old model is updated with the new model. On one hand, by temporarily placing dynamically incremental similar question data from the database in the real-time queue of the message queue, and temporarily placing statically existing similar questions from the database in the historical queue of the message middleware, it achieves isolation between dynamic and static business data, ensuring that their operations do not interfere with each other. While guaranteeing data stability and reliability, it can process all dynamic and static business data in an orderly and error-free manner. On the other hand, without affecting the normal online service provided by the model, it achieves online model updates that are imperceptible to users, improving user experience and facilitating updates at any time.
[0091] Please see Figure 2 In a further embodiment, step S1300, which involves retrieving all similar data points from the real-time queue and then calling the new model to process them to obtain the vectorized representation corresponding to each similar data point and storing it in the database, includes the following steps:
[0092] Step S1310: Retrieve all similar questions after the data point in the real-time queue, identify the preset idempotent key corresponding to each similar question, and the idempotent key indicates whether the corresponding similar question has been processed;
[0093] It is understood that some similar questions after the data point in the real-time queue may also exist in the historical queue due to uncontrollable factors such as network latency. These similar questions are consumed by the new data processing service in the historical queue and then retrieved by the new data service in the real-time queue for processing by the new model. This results in duplicate consumption of these similar questions. Therefore, to ensure the idempotency of consumption, that is, to ensure that these similar questions can only be consumed once, an idempotency key is pre-defined for each similar question stored in the database. For example, the unique identifier of the similar question can be used as the idempotency key. Furthermore, the consumption status associated with the idempotency key is identified. The consumption status includes consumed and unconsumed. When the corresponding similar question has been processed by the new model and obtained a vectorized representation, the consumption status of the idempotency key of the similar question is identified as consumed. When the corresponding similar question has not been processed by the new model, the consumption status of the idempotency key of the similar question is identified as unconsumed.
[0094] Step S1320: When the idempotent key represents a similarity question that has not been processed, the new model is called to process the similarity question of the idempotent key to obtain the corresponding vectorized representation. When the idempotent key represents a similarity question that has been processed, the processing of the similarity question of the idempotent key is skipped.
[0095] Query the consumption status of the idempotent key. If the consumption status is not consumed, that is, the similarity question of the idempotent key has not been processed by the new model, call the new model to process it according to step S1400. If the consumption status is consumed, that is, the similarity question of the idempotent key has been processed by the new model and obtained a vectorized representation, then there is no need to repeat the processing, and the current processing of the similarity question of the idempotent key can be skipped.
[0096] In this embodiment, by retrieving all similar queries after the data point in the real-time queue, identifying the idempotent key corresponding to each similar query, and processing or skipping the similar queries accordingly, the idempotency of consumption is ensured and the execution efficiency is improved.
[0097] Please see Figure 3 In a further embodiment, step S1500, updating the old model with the new model, includes the following steps:
[0098] Step S1510: Obtain the similarity questions processed by the new model in the database and their vectorized representations;
[0099] The similarity questions processed by the new model and their vectorized representations can be stored separately in the database from those processed by the old model, achieving data isolation and ensuring that the data does not affect each other. For example, the similarity questions processed by the new model and their vectorized representations can be stored in separate new and old data tables. Therefore, by querying the new data table in the database, the similarity questions processed by the new model and their vectorized representations can be obtained.
[0100] Step S1520: Determine the corresponding positive and negative samples based on whether there is similarity between each pair of similar samples. The two similar samples in the positive samples are similar to each other, and the two similar samples in the negative samples are not similar to each other.
[0101] It is understandable that similar questions in the database are pre-constructed based on texts with different wording of the same intent. Therefore, two similar questions expressing the same intent are similar, while two similar questions expressing different intents are dissimilar. Based on this, every two similar questions in the database can be used as positive samples, and every two dissimilar similar questions can be used as negative samples.
[0102] Step S1530: Use the similarity between the vectorized representations of two corresponding similar samples in the positive and negative samples as the prediction value to evaluate the accuracy of the new model;
[0103] The similarity between the vectorized representations of two corresponding similar samples in the positive and negative samples is used as the predicted value, and the corresponding AUC value is calculated as the accuracy of the new model. An example formula is provided below:
[0104]
[0105] in:
[0106] M is the number of positive samples, N is the number of negative samples, and P 正样本 P represents the similarity between the vectorized representations of two similar samples in the positive samples. 负样本 The similarity between two similar samples is the vectorized representation of their similarity.
[0107] The similarity calculation can be implemented using any available vector distance algorithm, including but not limited to any of the following: cosine similarity algorithm, vector dot product algorithm, Manhattan distance, Euclidean distance algorithm, Pearson correlation coefficient, etc.
[0108] Step S1540: When the accuracy reaches the preset standard, determine that the new model has passed the verification and replace the old model with the new model to go online;
[0109] Accuracy can be measured by a preset threshold. An accuracy greater than the preset threshold is considered to have met the preset standard; otherwise, it is considered not to have met the preset standard. When the accuracy is greater than the preset threshold, it indicates that the error of the new model is extremely small, and the new model is deemed to have passed the validation, thus replacing the old model and going live. The preset threshold can be flexibly set by those skilled in the art based on prior knowledge or experimental data, for example, it can be set as the accuracy of the old model.
[0110] Step S1550: When the accuracy does not reach the preset standard, determine that the new model fails the verification and respond to the old model update failure event.
[0111] When the accuracy fails to meet the preset standard, it indicates that the new model has a large error and is therefore deemed unqualified. Unable to handle the error, the new model replaces the old model, updating the old model and triggering an old-to-old-model update failure event. Fine-tuning training is then performed on the new model to improve its accuracy, enabling it to meet the preset standard. This fine-tuning training is further disclosed in subsequent embodiments; this step will not be discussed further here. Such fine-tuning training can also be flexibly implemented by those skilled in the art.
[0112] In this embodiment, the accuracy of the model is verified by the similarity between the vectorized representations of pairwise similarities processed by the new model. If the verification passes, the new model is used to replace the old model and is launched online. If the verification fails, the new model is launched online to ensure that the error of the launched new model is minimal.
[0113] Please see Figure 4 In a further embodiment, step S1520, determining the corresponding positive and negative samples based on whether two similar samples are similar, wherein two similar samples in the positive samples are similar and two similar samples in the negative samples are dissimilar, includes the following steps:
[0114] Step S1521: Use a clustering algorithm to cluster multiple similar questions to determine multiple similar question groups. Different similar question groups correspond to different intentions.
[0115] The clustering algorithm can be k-means, KNN, etc., and those skilled in the art can choose one to implement as needed.
[0116] Clustering algorithms are used to cluster questions based on the intent expressed by each similar question, thereby identifying multiple similar question groups that express different intents. All similar questions in the same similar question group express the same intent. The specific number of similar question groups can be determined by algorithms such as the elbow method, silhouette coefficient method, Gap statistic method, DB index method, and hierarchical clustering method. Those skilled in the art can choose one to implement as needed.
[0117] Step S1522: Construct two similar questions that are closest to the cluster center point in the same similar question group as positive samples, and construct two similar questions that express different intentions in the same similar question group as negative samples.
[0118] It is easy to understand that the two similar questions closest to the cluster center in the same similar question group indicate that the two similar questions are highly similar in expressing the same intention, and are constructed as positive samples.
[0119] Furthermore, the similar questions in the database are pre-constructed based on texts with different wording of the same intent. That is, each similar question has its corresponding expressed intent. Based on this, two similar questions expressing different intents in the same similar question group can be identified. This indicates that clustering algorithms have difficulty distinguishing such two similar questions and incorrectly classify them as expressing the same intent when they actually express different intents. Similarly, the model in this application also has difficulty accurately determining the vectorized representation of such two similar questions, resulting in a low similarity between the two vectorized representations. This indicates that the two similar questions are not similar. Therefore, such two similar questions are constructed as negative samples.
[0120] In this embodiment, a clustering algorithm is used to cluster multiple similar questions. Among the resulting multiple similar question groups, the two most similar questions in the same similar question group are taken as positive samples, and the two similar questions in the same similar question group that express different intentions are constructed as negative samples. This makes the boundary between positive and negative samples clear. The similar questions in the positive samples are clearly similar, while the similar questions in the negative samples are difficult for the model to accurately determine the corresponding vectorized representation. With the help of the positive and negative samples, the accuracy of the model can be accurately verified.
[0121] Please see Figure 5 In a further embodiment, after step S1540, replacing the old model with the new model and going online, the following steps are included:
[0122] Step S1541: The old model that has been taken offline is kept to work in parallel with the new model;
[0123] While the current thread calls the new model to provide online services, the previous thread continues to call the old model to provide online services. The two threads work in parallel, each processing real-time similarity questions and determining the corresponding vectorized representation.
[0124] Step S1542: Respond to the new model exception event and replace the new model with the old model and go online;
[0125] During the online operation of the new model, abnormal situations may occur, such as the new model occupying too much storage space, which does not meet the client load, the new model having a long processing latency, which does not meet the timeliness of online services, and the new model's semantic understanding of similar questions not meeting user expectations, which will negatively impact the user experience. When an abnormal situation occurs, a new model abnormal event is triggered, and in response, the previous thread is reactivated to call the old model to provide online services, and the current process is taken offline to replace the new model to provide services online.
[0126] Step S1543: In response to the old model offline event, the old model is taken offline, and the vectorized representation of similar questions processed by the old model is deleted from the database.
[0127] When the new model is running normally online, an event to take the old model offline is triggered. In response, the process that calls the old model to provide online services is taken offline, memory is released, the table storing the vectorized representation of similar questions processed by the old model is queried in the database, and the table is deleted.
[0128] In this embodiment, by having the old model and the new model work in parallel, the old model can be rolled back to be used when an anomaly occurs in the new model. When the new model is running normally online, the old model is taken offline, and the vectorized representation of similar questions processed by the old model is deleted from the database. This reasonably releases memory, ensuring the robustness and continuity of online services and guaranteeing user satisfaction.
[0129] Please see Figure 6 In a further embodiment, step S1550, responding to the old model update failure event, includes the following steps:
[0130] Step S1551: Obtain the similar questions processed by the old model in the database and their vectorized representations, construct positive samples and negative samples, and label the positive samples and negative samples with supervision labels according to the similarity between the vectorized representations of two similar questions in the positive samples and negative samples respectively. The two similar questions in the positive samples are similar, and the two similar questions in the negative samples are not similar.
[0131] The similarity between the vectorized representations of pairwise similarities processed by the old model is calculated. The similarity calculation can be implemented using any available vector distance algorithm, including but not limited to any of the following: cosine similarity algorithm, vector dot product algorithm, Manhattan distance, Euclidean distance algorithm, Pearson correlation coefficient, etc.
[0132] When the similarity is greater than a preset threshold, the two corresponding similar questions are determined to be similar and constructed as positive samples. The supervision label for the positive samples is the similarity between the vectorized representations of the two similar questions. When the similarity is less than the preset threshold, the two corresponding similar questions are determined to be dissimilar and constructed as negative samples. The supervision label for the negative samples is the similarity between the vectorized representations of the two similar questions. The preset threshold can be flexibly set by those skilled in the art based on prior knowledge or experimental data.
[0133] Step S1552: Call the new model to process the positive and negative samples, obtain the vectorized representations of two similarities in the positive and negative samples respectively, calculate the similarity between the vectorized representations of the two similarities, and obtain the predicted values of the positive and negative samples respectively.
[0134] For the positive and negative samples, the similarity questions in a single sample are input into the new model. The word segmenter in the model is used to segment the similarity questions, resulting in corresponding word segmentation sequences. The word segmenter can be implemented based on word segmentation algorithms such as jieba, n-gram, and wordpiece, and can be flexibly adapted by those skilled in the art. The word segmentation sequences are input into the hidden layer of the model to extract the corresponding deep semantic information, i.e., the intent expressed by the similarity questions. In a recommended embodiment, the hidden layer includes stacked multi-head self-attention layers and fully connected layers to extract the corresponding deep semantic information of the word segmentation sequences. Specifically, for each word in the word segmentation sequence, multi-head attention is calculated when passing through the multi-head attention layer, thereby performing self-attention weighting on different dimensions of the word segmentation to obtain the corresponding weighted vector representation. After passing through the fully connected layer, the vectorized representation corresponding to each word in the word segmentation sequence is obtained.
[0135] Furthermore, the similarity between the vectorized representations of two similar samples determined by the new model in the positive and negative samples is calculated and used as the predicted values for the positive and negative samples, respectively.
[0136] Step S1553: Using the supervision labels of the positive and negative samples respectively, determine the loss value of the predicted value of the positive and negative samples respectively. When the loss value does not reach the preset threshold, update the weights of the new model and continue to call other positive and negative samples to carry out iterative training until the new model converges.
[0137] The preset cross-entropy loss function is invoked. This function can be flexibly set by those skilled in the art based on prior knowledge or experimental experience. Based on the supervision labels of the positive and negative samples, the cross-entropy loss values of the predicted values of the positive and negative samples are calculated. When the cross-entropy loss value reaches the preset threshold, it indicates that the new model has been trained to a convergent state. The vectorized representation of the similarity question determined by the new model is very close to the vectorized representation of the similarity question determined by the old model. From the result perspective, the predicted value and supervision label of the same sample are extremely similar, so the training of the new model can be terminated.
[0138] If the loss value does not reach the preset threshold, it indicates that the new model has not converged. Therefore, the gradient of the new model is updated according to the cross-entropy loss value. Usually, the weight parameters of each stage of the multilingual encoder are corrected through backpropagation to make the new model closer to convergence. Then, other positive and negative samples are called to iteratively train the new model until the new model is trained to convergence.
[0139] The preset threshold can be flexibly set by those skilled in the art based on the information disclosed herein.
[0140] This embodiment reveals the training process of fine-tuning the new model until convergence, ensuring that the new model can achieve the same accuracy as the old model, thereby meeting the needs of online services.
[0141] Please see Figure 7 In a further embodiment, after step S1500, updating the old model with the new model, the following steps are included:
[0142] Step S1600: Respond to the customer service reply request and obtain the question text entered by the user;
[0143] When different users on an e-commerce platform consult the platform's and / or online store's customer service, a customer service response request is generated and submitted to the server. The server accepts and responds to the customer service response request, retrieving the question text entered by the user when consulting customer service.
[0144] Step S1700: Call the new model to process the question text and obtain the corresponding vectorized representation;
[0145] The question text is input into the new model, and the word segmenter in the model is used to segment the similar questions, resulting in a corresponding word segmentation sequence. The word segmenter can be implemented based on word segmentation algorithms such as jieba, n-gram, and wordpiece, and can be flexibly adapted by those skilled in the art. The word segmentation sequence is input into the hidden layer of the model to extract the corresponding deep semantic information, i.e., the intent expressed by the similar questions. In a recommended embodiment, the hidden layer includes multiple stacked multi-head self-attention layers and fully connected layers to extract the corresponding deep semantic information of the word segmentation sequence. Specifically, for each word in the word segmentation sequence, multi-head attention is calculated when passing through the multi-head attention layer, thereby performing self-attention weighting on different dimensions of the word segmentation to obtain a corresponding weighted vector representation. After passing through the fully connected layer, the vectorized representation corresponding to each word in the word segmentation sequence is obtained.
[0146] Step S1800: Based on the vectorized representation of the question text, determine the similar questions in the database that match the question text, and obtain the answers associated with the similar questions as reply text to push to the user.
[0147] It is understood that similar questions in the database are pre-constructed based on different ways of asking the same question with the same intent. At the same time, the same answer associated with similar questions expressing the same intent is also pre-constructed. Those skilled in the art can flexibly construct the similar questions and their associated answers according to the disclosure herein and business needs.
[0148] The similarity between the vectorized representation of each similar question in the database and the vectorized representation of the question text is calculated. Similar questions with a similarity greater than a preset threshold are identified and matched with the question text. The answers associated with the similar questions in the database are obtained and used as the reply text to the user's question text, and then pushed to the user.
[0149] In this embodiment, by responding to a user's customer service reply request, the system retrieves similar questions from the database that match the user's input question text and pushes them to the user for reply. This enables automated and intelligent customer service responses to users, improving the user experience.
[0150] Please see Figure 8This invention provides an online model update device to meet one of the purposes of this application. It is a functional embodiment of the online model update method of this application. On another aspect, this online model update device, also to meet one of the purposes of this application, includes a request response module 1100, a history push module 1200, a history processing module 1300, a real-time processing module 1400, and a model update module 1500. The request response module 1100 is used to respond to old model update requests, deploy new models, and continuously push incremental similarity queries from the database to the real-time queue in the message middleware. The history push module 1200 is used to record the latest similarity queries in the current database. The data location is used to push all similar questions in the current database to the historical queue in the message middleware; the historical processing module 1300 is used to pull all similar questions in the historical queue, call the new model for processing, and obtain the vectorized representation corresponding to each similar question and store it in the database; the real-time processing module 1400 is used to pull all similar questions after the data location in the real-time queue, call the new model for processing, and obtain the vectorized representation corresponding to each similar question and store it in the database; the model update module 1500 is used to update the old model with the new model when the timestamp of the similar question processed by the new model differs from the current time by less than a preset threshold.
[0151] In a further embodiment, the real-time processing module 1400 includes: an idempotent key identification submodule, used to retrieve all similar questions after the data point in the real-time queue, identify a preset idempotent key corresponding to each similar question, the idempotent key indicating whether the corresponding similar question has been processed; and an idempotent key processing submodule, used to call the new model to process the similar question of the idempotent key when the idempotent key indicates that the corresponding similar question has not been processed, and obtain the corresponding vectorized representation; and to skip the processing of the similar question of the idempotent key when the idempotent key indicates that the corresponding similar question has been processed.
[0152] In a further embodiment, the model update module 1500 includes: a data acquisition submodule, used to acquire similar questions and their vectorized representations processed by the new model in the database; a positive and negative sample determination submodule, used to determine corresponding positive and negative samples based on whether two similar questions are similar, wherein two similar questions in the positive samples are similar and two similar questions in the negative samples are dissimilar; an accuracy evaluation submodule, used to evaluate the accuracy of the new model by using the similarity between the vectorized representations of two corresponding similar questions in the positive and negative samples as a prediction value; a verification pass submodule, used to determine that the new model passes verification when the accuracy reaches a preset standard, and to replace the old model with the new model and go online; and a verification fail submodule, used to determine that the new model fails verification when the accuracy does not reach the preset standard, and to respond to the old model update failure event.
[0153] In a further embodiment, the positive and negative sample determination submodule includes: a similarity question clustering unit, used to cluster multiple similar questions using a clustering algorithm to determine multiple similar question groups, with different similar question groups corresponding to different intentions; and a positive and negative sample construction unit, used to construct two similar questions in the same similar question group that are closest to the cluster center point as positive samples, and construct two similar questions in the same similar question group that express different intentions as negative samples.
[0154] In a further embodiment, after the positive and negative sample determination submodule, the system includes: a parallel operation submodule, used to keep the offline old model and the new model working in parallel; a first event response submodule, used to respond to a new model exception event and replace the new model with the old model to go online; and a second event response submodule, used to respond to an old model offline event, take the old model offline, and delete the vectorized representation of similar questions processed by the old model from the database.
[0155] In a further embodiment, the verification failure submodule includes: a sample construction and labeling unit, used to obtain similar questions processed by the old model in the database and their vectorized representations, construct positive samples and negative samples, and label the positive samples and negative samples with supervision labels according to the similarity between the vectorized representations of two similar questions in the positive samples and negative samples respectively, wherein the two similar questions in the positive samples are similar and the two similar questions in the negative samples are dissimilar; a model prediction unit, used to call the new model to process the positive samples and negative samples, obtain the vectorized representations of two similar questions in the positive samples and negative samples respectively, calculate the similarity between the vectorized representations of the two similar questions, and obtain the predicted values of the positive samples and negative samples respectively; and an iterative training unit, used to use the supervision labels of the positive samples and negative samples respectively to determine the loss value of the predicted values of the positive samples and negative samples respectively, and when the loss value does not reach a preset threshold, to update the weights of the new model and continue to call other positive samples and negative samples to perform iterative training until the new model converges.
[0156] In a further embodiment, after the model update module 1500, it includes: a question acquisition module, used to respond to customer service reply requests and acquire the question text input by the user; a question processing module, used to call the new model to process the question text and obtain the corresponding vectorized representation; and a reply push module, used to determine similar questions in the database that match the question text based on the vectorized representation of the question text, and to obtain the answers associated with the similar questions as reply text and push them to the user.
[0157] To address the aforementioned technical problems, embodiments of this application also provide computer equipment. For example... Figure 9The diagram shows the internal structure of a computer device. The computer device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. The computer-readable storage medium stores an operating system, a database, and computer-readable instructions. The database may store a sequence of control information. When the computer-readable instructions are executed by the processor, they enable the processor to implement an online model update method. The processor of the computer device provides computing and control capabilities, supporting the operation of the entire computer device. The memory of the computer device may store computer-readable instructions. When these computer-readable instructions are executed by the processor, they enable the processor to execute the online model update method of this application. The network interface of the computer device is used for communication with a terminal. Those skilled in the art will understand that… Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0158] In this embodiment, the processor is used to execute... Figure 8 The system contains the specific functions of each module and its sub-modules. The memory stores the program code and various data required to execute these modules or sub-modules. The network interface is used for data transmission between the user terminal and the server. In this embodiment, the memory stores the program code and data required to execute all modules / sub-modules in the online model update device of this application. The server can call the server's program code and data to execute the functions of all sub-modules.
[0159] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the online model update method of any embodiment of this application.
[0160] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0161] In summary, this application, on the one hand, enables smooth online model updates and orderly and error-free processing of all business data required for model updates; on the other hand, it enables control over performance verification before model deployment and rollback of anomalies after deployment, thereby ensuring the accuracy of models provided online and the robustness of model updates.
[0162] Those skilled in the art will understand that the steps, measures, and solutions in the various operations, methods, and processes discussed in this application can be alternated, modified, combined, or deleted. Furthermore, other steps, measures, and solutions in the various operations, methods, and processes discussed in this application can also be alternated, modified, rearranged, decomposed, combined, or deleted. Furthermore, steps, measures, and solutions in the prior art that are similar to those disclosed in this application can also be alternated, modified, rearranged, decomposed, combined, or deleted.
[0163] The above description is only a partial embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for online model updating, characterized in that, Includes the following steps: In response to old model update requests, deploy new models and continuously push incremental similar questions from the database to the real-time queue in the message middleware. Record the data location of the latest similar question in the current database, and push all similar questions in the current database to the historical queue in the message middleware; The new model is called to process all similar questions retrieved from the historical queue, and the vectorized representation of each similar question is obtained and stored in the database. The process involves: retrieving all similar questions following the data point in the real-time queue, calling the new model for processing, and obtaining a vectorized representation of each similar question, which is then stored in the database. This includes: retrieving all similar questions following the data point in the real-time queue; identifying a preset idempotent key for each similar question; the idempotent key indicating whether the corresponding similar question has been processed; the idempotent key indicating that the consumption state associated with a processed idempotent key is consumed; and the idempotent key indicating that the consumption state associated with an unprocessed idempotent key is unprocessed. When the idempotent key indicates that the corresponding similar question has not been processed, the new model is called to process the similar question with that idempotent key, obtaining the corresponding vectorized representation. When the idempotent key indicates that the corresponding similar question has been processed, the processing of the similar question with that idempotent key is skipped. When the timestamp of the similar time processed by the new model differs from the current time by less than a preset threshold, the old model is updated with the new model.
2. The online model update method according to claim 1, characterized in that, Updating the old model with the new model includes the following steps: Obtain the similarity questions processed by the new model in the database and their vectorized representations; Based on whether two similar questions are similar, corresponding positive and negative samples are determined. Two similar questions in the positive samples are similar to each other, and two similar questions in the negative samples are not similar to each other. The accuracy of the new model is evaluated by using the similarity between the vectorized representations of two corresponding similar samples in the positive and negative samples as the prediction value. When the accuracy reaches the preset standard, the new model is determined to have passed the verification, and the new model replaces the old model and goes online. When the accuracy does not meet the preset standard, it is determined that the new model fails the verification and an old model update failure event is triggered.
3. The online model update method according to claim 2, characterized in that, Based on whether any two similar questions are similar, corresponding positive and negative samples are determined. The positive samples contain two similar questions that are similar to each other, while the negative samples contain two similar questions that are dissimilar to each other. This process includes the following steps: Clustering algorithms are used to cluster multiple similar questions to identify multiple similar question groups, and different similar question groups correspond to different intentions; Two similar questions that are closest to the cluster center in the same similar question group are constructed as positive samples, and two similar questions that express different intentions in the same similar question group are constructed as negative samples.
4. The online model update method according to claim 2, characterized in that, After replacing the old model with the new model and going live, the following steps are included: The old model that is offline will continue to work in parallel with the new model; In response to an abnormal event in the new model, the old model is used to replace the new model and it is then deployed online. In response to the old model being taken offline, the old model is taken offline, and the vectorized representation of similar questions processed by the old model is deleted from the database.
5. The online model update method according to claim 2, characterized in that, Responding to a failure to update the old model includes the following steps: Obtain the similar questions processed by the old model in the database and their vectorized representations, construct positive samples and negative samples, and label the positive samples and negative samples with supervision labels according to the similarity between the vectorized representations of two similar questions in the positive samples and negative samples respectively. The two similar questions in the positive samples are similar, and the two similar questions in the negative samples are not similar. The new model is called to process the positive and negative samples to obtain the vectorized representations of two similarities in the positive and negative samples respectively. The similarity between the vectorized representations of the two similarities is calculated to obtain the predicted values of the positive and negative samples respectively. Using the supervision labels of the positive and negative samples respectively, the loss values of the predicted values of the positive and negative samples are determined. When the loss value does not reach the preset threshold, the weights of the new model are updated, and other positive and negative samples are used to carry out iterative training until the new model converges.
6. The online model update method according to claim 1, characterized in that, After updating the old model with the new model, the following steps are included: Respond to customer service requests and obtain the user's input question text; The new model is invoked to process the question text and obtain the corresponding vectorized representation; Based on the vectorized representation of the question text, similar questions that match the question text in the database are identified, and the answers associated with the similar questions are obtained and pushed to the user as reply text.
7. A model online update device, characterized in that, include: The request and response module is used to respond to old model update requests, deploy new models, and continuously push incremental similar questions from the database to the real-time queue in the message middleware. The historical push module is used to record the data position of the latest similar question in the current database and push all similar questions in the current database to the historical queue in the message middleware; The history processing module is used to retrieve all similar questions from the history queue, call the new model to process them, and obtain the vectorized representation of each similar question and store it in the database. A real-time processing module is used to retrieve all similar questions after the data point in the real-time queue, call the new model to process them, and obtain a vectorized representation corresponding to each similar question, which is then stored in the database. This includes: retrieving all similar questions after the data point in the real-time queue; identifying a preset idempotent key corresponding to each similar question; the idempotent key indicating whether the corresponding similar question has been processed; the idempotent key indicating that the consumption state associated with a processed idempotent key is consumed; and the idempotent key indicating that the consumption state associated with an unprocessed idempotent key is unprocessed; when the idempotent key indicates that the corresponding similar question has not been processed, calling the new model to process the similar question with that idempotent key and obtaining the corresponding vectorized representation; and when the idempotent key indicates that the corresponding similar question has been processed, skipping the processing of the similar question with that idempotent key. The model update module is used to update the old model with the new model when the timestamp of the similar time processed by the new model differs from the current time by less than a preset threshold.
8. The online model update device according to claim 7, characterized in that, The real-time processing module includes: an idempotent key identification submodule, used to retrieve all similar questions after the data point in the real-time queue, identify a preset idempotent key corresponding to each similar question, the idempotent key indicating whether the corresponding similar question has been processed; and an idempotent key processing submodule, used to call the new model to process the similar questions of the idempotent key when the idempotent key indicates that the corresponding similar question has not been processed, and obtain the corresponding vectorized representation; and to skip the processing of the similar questions of the idempotent key when the idempotent key indicates that the corresponding similar question has been processed.
9. A computer device comprising a central processing unit and a memory, characterized in that, The central processing unit is used to invoke and run a computer program stored in the memory to perform the steps of the method as described in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that, It stores, in the form of computer-readable instructions, a computer program implemented according to any one of claims 1 to 6, which, when invoked by a computer, executes the steps included in the corresponding method.
Citation Information
Patent Citations
Model hot update processing method and device, equipment, medium and product
CN114327546A