Caching method and device for improving access speed of natural language model, storage medium and electronic device

Through the matching technology of cosine vector product and similarity evaluation model, the problems of slow access speed and poor stability of large language model interfaces are solved, efficient caching of natural language models is realized, and user experience is improved.

CN119202136APending Publication Date: 2024-12-27QINGDAO HAIER TECH +2
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411447023.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-16
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

When users access interfaces of large language models, their response speed is slow due to network and device performance limitations, and network fluctuations may lead to unstable service and affect user experience.

Method used

Through the cosine vector product and similarity evaluation model, the user requested eigenvectors are matched with the eigenvectors in the vector database, matched results are generated, and matched results are stored in the cache to improve the access efficiency of natural language models.

Benefits of technology

It significantly improves the access speed and stability of the natural language model interface, reduces waiting time, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119202136A_ABST
    Figure CN119202136A_ABST
Patent Text Reader

Abstract

The invention provides a caching method and device for improving the access speed of a natural language model, a storage medium and an electronic device, and relates to the technical field of smart home, and the method comprises the steps: receiving a to-be-processed access request sent by a user request service; the to-be-processed request is an access request of a user for an external interface of the natural language model; converting request text data contained in the to-be-processed access request into a first feature vector, and matching the first feature vector with a to-be-matched feature vector stored in a vector database to generate a matching result; and if the matching result indicates that the second feature vector matched with the first feature vector exists in the vector database, sending a first response to the user request service. According to the caching method and device for improving the access speed of the natural language model, the storage medium and the electronic device provided by the invention, the access efficiency of the natural language model interface is greatly improved by caching the request result of the natural language model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of smart home technology, and in particular to a caching method, device, storage medium and electronic device for improving the access speed of a natural language model. Background Art

[0002] With the development of big language models, it has become increasingly popular to use big language models to handle daily practices in work and life.

[0003] In related technologies, due to the influence of factors such as network and device performance, users often need to wait for a long time when accessing the interface of a large language model, and the interface responds slowly. During this waiting period, if there is a network fluctuation, the results returned by the large language model may not be received, resulting in unstable service and requiring users to resubmit requests, affecting the user experience.

[0004] Based on this, a natural language model caching method is urgently needed to improve the access speed of the natural language model. Summary of the invention

[0005] The purpose of this application is to provide a caching method, device, storage medium and electronic device for improving the access speed of natural language models, improve the accuracy of request matching results through cosine vector product and similarity evaluation model, and greatly improve the access efficiency of natural language model interface by caching natural language model request results.

[0006] The present application provides a caching method for improving the access speed of a natural language model, including: Receive a pending access request sent by a user request service; the pending request is an access request from the user to an external interface of a natural language model; convert the request text data contained in the pending access request into a first feature vector, and match the first feature vector with the feature vector to be matched stored in a vector database to generate a matching result; if the matching result indicates that the vector database has a second feature vector that matches the first feature vector, send a first response to the user request service; wherein the matching result is obtained based on the cosine vector product of two feature vectors and the output result of a similarity evaluation model; the second request result is the request result fed back by the natural language model based on the access request corresponding to the second feature vector; the first response includes: the second request result corresponding to the second feature vector.

[0007] Optionally, converting the request text data included in the to-be-processed access request into a first feature vector includes: inputting the request text data into a language representation model to obtain the first feature vector corresponding to the request text data.

[0008] Optionally, matching the first feature vector with the feature vector to be matched stored in the vector database to generate a matching result includes: calculating the cosine vector product of the first feature vector and each feature vector to be matched in the vector database to obtain a first calculation result of the first feature vector and each feature vector to be matched, and, sequentially inputting the first feature vector and each feature vector to be matched into the similarity evaluation model for similarity prediction to obtain a second calculation result of the first feature vector and each feature vector to be matched; and generating the matching result based on the first calculation result and the second calculation result.

[0009] Optionally, generating the matching result based on the first calculation result and the second calculation result includes: when the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is greater than a first preset threshold, and the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is greater than a second preset threshold, determining the target feature vector to be matched as the second feature vector; wherein the target feature vector to be matched is any one of the multiple feature vectors to be matched stored in the vector database.

[0010] Optionally, generating the matching result based on the first calculation result and the second calculation result includes: when the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is less than or equal to a first preset threshold, and / or the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is less than or equal to a second preset threshold, determining that the second feature vector matching the first feature vector does not exist in the vector feature library; wherein the target feature vector to be matched is any one of a plurality of feature vectors to be matched stored in the vector database.

[0011] Optionally, generating the matching result based on the first calculation result and the second calculation result includes: when the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is less than or equal to a first preset threshold and greater than a third preset threshold, and / or the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is less than or equal to a second preset threshold and greater than a fourth preset threshold, associating the first feature vector with the target feature vector and storing it in a sample database, and training the similarity evaluation model as training samples of the similarity evaluation model after manual annotation; wherein the third preset threshold is less than the first preset threshold; and the fourth preset threshold is less than the second preset threshold.

[0012] Optionally, after matching the first feature vector with the feature vector to be matched stored in the vector database to generate a matching result, the method further includes: if the matching result indicates that the second feature vector matching the first feature vector does not exist in the vector database, sending a second response to the user request service; the second response is used to instruct the user request service to send the access request to the external interface; receiving the first request result sent by the user request service, and associating the first feature vector and the first request result and storing them in a cache database; wherein the first request result is the request result fed back by the external interface in response to the access request.

[0013] The present application also provides a cache device for improving the access speed of a natural language model, comprising: A receiving module, used to receive a pending access request sent by a user request service; the pending request is an access request from the user to an external interface of a natural language model; a matching module, used to convert the request text data contained in the pending access request into a first feature vector, and match the first feature vector with the feature vector to be matched stored in a vector database to generate a matching result; a processing module, used to send a first response to the user request service if the matching result indicates that the vector database has a second feature vector that matches the first feature vector; wherein the matching result is obtained based on the cosine vector product of two feature vectors and the output result of a similarity evaluation model; the second request result is the request result fed back by the natural language model based on the access request corresponding to the second feature vector; the first response includes: the second request result corresponding to the second feature vector.

[0014] Optionally, the matching module is specifically configured to input the request text data into a language representation model to obtain the first feature vector corresponding to the request text data.

[0015] Optionally, the matching module is specifically used to calculate the cosine vector product of the first feature vector and each feature vector to be matched in the vector database to obtain a first calculation result of the first feature vector and each feature vector to be matched, and to input the first feature vector and each feature vector to be matched into the similarity evaluation model in turn for similarity prediction to obtain a second calculation result of the first feature vector and each feature vector to be matched; the matching module is also specifically used to generate the matching result based on the first calculation result and the second calculation result.

[0016] Optionally, the matching module is specifically used to determine the target feature vector to be matched as the second feature vector when the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is greater than a first preset threshold, and the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is greater than a second preset threshold; wherein the target feature vector to be matched is any one of the multiple feature vectors to be matched stored in the vector database.

[0017] Optionally, the matching module is specifically used to determine that the second feature vector that matches the first feature vector does not exist in the vector feature library when the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is less than or equal to a first preset threshold, and / or the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is less than or equal to a second preset threshold; wherein the target feature vector to be matched is any one of the multiple feature vectors to be matched stored in the vector database.

[0018] Optionally, the matching module is specifically used to associate the first feature vector with the target feature vector and store it in a sample database, and train the similarity evaluation model as training samples of the similarity evaluation model after manual annotation, when the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is less than or equal to a first preset threshold and greater than a third preset threshold, and / or the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is less than or equal to a second preset threshold and greater than a fourth preset threshold; wherein the third preset threshold is less than the first preset threshold; and the fourth preset threshold is less than the second preset threshold.

[0019] Optionally, the processing module is also used to send a second response to the user request service if the matching result indicates that the second feature vector matching the first feature vector does not exist in the vector database; the second response is used to instruct the user request service to send the access request to the external interface; the receiving module is also used to receive the first request result sent by the user request service, and associate the first feature vector and the first request result and store them in a cache database; wherein, the first request result is the request result fed back by the external interface in response to the access request.

[0020] The present application also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of any of the above-mentioned caching methods for improving the access speed of a natural language model.

[0021] The present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the cache method for improving the access speed of the natural language model as described in any one of the above are implemented.

[0022] The present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the cache method for improving the access speed of a natural language model as described in any one of the above are implemented.

[0023] The cache method, device, storage medium and electronic device for improving the access speed of the natural language model provided by the present application first receive a pending access request sent by a user request service; the pending request is a user's access request for the external interface of the natural language model; then, the request text data contained in the pending access request is converted into a first feature vector, and the first feature vector is matched with the feature vector to be matched stored in the vector database to generate a matching result; finally, if the matching result indicates that the vector database has a second feature vector that matches the first feature vector, the second request result corresponding to the second feature vector is sent to the user request service; wherein the matching result is obtained based on the cosine vector product of the two feature vectors and the output result of the similarity evaluation model; the second request result is the request result of the natural language model based on the access request corresponding to the second feature vector. In this way, the accuracy of the request matching result is improved by the cosine vector product and the similarity evaluation model, and the access efficiency of the natural language model interface is greatly improved by caching the natural language model request result. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions in the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0025] Figure 1 is a schematic diagram of a hardware environment of an interaction method of a smart device according to an embodiment of the present application; Figure 2 It is a schematic diagram of the system architecture used by the cache method for improving the access speed of the natural language model provided in this application; Figure 3 It is a flowchart of a caching method for improving the access speed of a natural language model provided by the present application; Figure 4 It is a schematic diagram of the structure of a cache device for improving the access speed of a natural language model provided by the present application; Figure 5 It is a schematic diagram of the structure of the electronic device provided in this application. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0028] According to one aspect of an embodiment of the present application, a caching method for improving the access speed of a natural language model is provided. The caching method for improving the access speed of a natural language model is widely used in smart home (Smart Home), smart home, smart home device ecology, smart residential (Intelligence House) ecology and other whole-house intelligent digital control application scenarios. Optionally, in this embodiment, the above-mentioned caching method for improving the access speed of a natural language model can be applied to Figure 2 In the hardware environment composed of the terminal device 102 and the server 104 shown in FIG. Figure 2As shown, the server 104 is connected to the terminal device 102 via a network, and can be used to provide services (such as application services, etc.) for the terminal or a client installed on the terminal. A database can be set on the server or independently of the server to provide data storage services for the server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.

[0029] The network may include but is not limited to at least one of the following: wired network, wireless network. The wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 may be but is not limited to a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing equipment, a smart dishwasher, a smart projection equipment, a smart TV, a smart clothes drying rack, a smart curtain, a smart audio and video, a smart socket, a smart speaker, a smart speaker, a smart fresh air equipment, a smart kitchen and bathroom equipment, a smart bathroom equipment, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification equipment, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.

[0030] In view of the technical problems of slow access speed and poor stability of natural language models in related technologies, the embodiments of the present application provide a caching method for improving the access speed of natural language models, such as Figure 2 The figure shows the system architecture diagram for applying the method. The system includes: an HTTP interface layer connected to the user request service and the external interface of the natural language model; a language representation model for extracting features from text data and obtaining corresponding feature vectors (the Bert model is used in the embodiment of the present application, and other models can also be used); a similarity evaluation model for evaluating the similarity of two feature vectors; a sample database for storing questions to be confirmed; and a cache database for storing request results fed back by the external interface.

[0031] The following, in conjunction with the accompanying drawings, describes in detail the caching method for improving the access speed of the natural language model provided by the embodiment of the present application through specific embodiments and their application scenarios.

[0032] like Figure 3 As shown, an embodiment of the present application provides a caching method for improving the access speed of a natural language model, and the method may include the following steps 301 to 303: Step 301: Receive a pending access request sent by a user request service.

[0033] The access request to be processed is an access request from a user to an external interface of a natural language model.

[0034] Exemplarily, when a user asks a question to the natural language model through the user request service, the user request service converts the user's question into an access request and processes it through the HTTP interface layer.

[0035] Exemplarily, the HTTP interface layer will forward the request to the system for processing. If the cache hits, the cache result will be sent directly to the user request service; if the cache does not hit, the access request will be forwarded to the external interface of the natural language model for processing by the natural language model.

[0036] Step 302: Convert the request text data contained in the access request to be processed into a first feature vector, and match the first feature vector with the feature vector to be matched stored in the vector database to generate a matching result.

[0037] The matching result is obtained based on the cosine vector product of two feature vectors and the output result of the similarity evaluation model.

[0038] Exemplarily, in an embodiment of the present application, it is possible to comprehensively judge whether the meanings of the text contents corresponding to the two feature vectors are consistent by using the cosine vector product of the two feature vectors and the output result of the similarity evaluation model.

[0039] Specifically, in the above step 302, the step of converting the request text data included in the to-be-processed access request into a first feature vector may further include the following step 302a: Step 302a: input the request text data into a language representation model to obtain the first feature vector corresponding to the request text data.

[0040] Exemplarily, the above-mentioned language representation model is used to extract features from the request text data to obtain a first feature vector corresponding to the request text data. The first feature vector is used to perform similarity matching with other feature vectors to be matched stored in the vector database to determine whether the result data requested by this access request is stored in the cache.

[0041] For example, Figure 2 As shown, after receiving an access request from a user requesting a service, the text data in the access request is input into the Bert model (ie, the above-mentioned language representation model) for feature extraction to obtain a feature vector corresponding to the text data (ie, the above-mentioned first feature vector).

[0042] Specifically, in the above step 302, the step of matching the first feature vector with the feature vector to be matched stored in the vector database to generate a matching result may also include the following steps 302b and 302c: Step 302b, calculate the cosine vector product of the first feature vector and each feature vector to be matched in the vector database to obtain a first calculation result of the first feature vector and each feature vector to be matched, and input the first feature vector and each feature vector to be matched into the similarity evaluation model in turn to perform similarity prediction to obtain a second calculation result of the first feature vector and each feature vector to be matched.

[0043] Exemplarily, the first calculation result and the second calculation result can be performed simultaneously or in any order. The first calculation result is the cosine vector product of two feature vectors, and the second calculation result is the similarity result of the two feature vectors output by the similarity evaluation model.

[0044] Step 302c: Generate the matching result based on the first calculation result and the second calculation result.

[0045] Exemplarily, based on the first calculation result and the second calculation result obtained above, it can be determined whether the result data requested by the current access request is stored in the cache.

[0046] Exemplarily, in the embodiment of the present application, the matching result includes two different matching results, namely: a first matching result in which the text data corresponding to the two feature vectors have the same meaning, and a second matching result in which the text data corresponding to the two feature vectors have different meanings.

[0047] Exemplarily, the second matching result may include the following two matching results: a first sub-matching result in which the similarity between the two feature vectors is very high, but it is not possible to determine whether the meanings of the text data corresponding to the two feature vectors are the same, and a second sub-matching result in which it is determined that the meanings of the text data corresponding to the two feature vectors are completely different. There are different processing methods for different matching results.

[0048] Specifically, for the first matching result, the step 302c may further include the following step 302c1: Step 302c1: when the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is greater than a first preset threshold, and the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is greater than a second preset threshold, determine the target feature vector to be matched as the second feature vector.

[0049] The target feature vector to be matched is any one of the multiple feature vectors to be matched stored in the vector database.

[0050] Exemplarily, when the cosine vector product of two feature vectors is greater than a first preset threshold value, and the similarity value is greater than a second preset threshold value, it can be determined that the text data corresponding to the two feature vectors have the same meaning.

[0051] Specifically, for the second matching result, the step 302c may further include the following step 302c2: Step 302c2: When the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is less than or equal to a first preset threshold, and / or the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is less than or equal to a second preset threshold, determine that the second feature vector that matches the first feature vector does not exist in the vector feature library.

[0052] The target feature vector to be matched is any one of the multiple feature vectors to be matched stored in the vector database.

[0053] For example, when it is not possible to determine whether the text data corresponding to two feature vectors have the same meaning, the two feature vectors can be associated and stored in a sample database, and then manually annotated and used as training data to train the similarity assessment model to improve the accuracy of the model prediction.

[0054] Specifically, for the first sub-matching result in the second matching result, the step 302c may further include the following step 302c3: Step 302c3, when the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is less than or equal to the first preset threshold and greater than the third preset threshold, and / or the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is less than or equal to the second preset threshold and greater than the fourth preset threshold, the first feature vector is associated with the target feature vector and stored in a sample database, and after manual annotation, it is used as a training sample of the similarity evaluation model to train the similarity evaluation model.

[0055] Among them, the third preset threshold is smaller than the first preset threshold; and the fourth preset threshold is smaller than the second preset threshold.

[0056] For example, Figure 2As shown in the figure, when the cosine vector product and / or similarity value of two feature vectors are high, but not enough to determine whether the meanings of the text data corresponding to the two feature vectors are the same, the two feature vectors can be used as training data to train the model to improve the accuracy of model prediction. For example, the similarity value of "turn on the air conditioner at 6 am" and "turn on the air conditioner at 6 pm" is high, but the meanings of the two text data are different.

[0057] Specifically, for the second sub-matching result in the second matching result, the step 302c may further include the following step 302c4: Step 302c4: When the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is less than or equal to the third preset threshold, and the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is less than or equal to the fourth preset threshold, determine that the second feature vector that matches the first feature vector does not exist in the vector feature library.

[0058] Exemplarily, after the second matching result appears, a second response may be sent to the user request service, so that the user request service directly accesses the external environment to obtain the required data.

[0059] Specifically, after the above step 302, the caching method for improving the access speed of the natural language model provided in the embodiment of the present application may further include the following steps 401 and 402: Step 401: If the matching result indicates that the second feature vector matching the first feature vector does not exist in the vector database, a second response is sent to the user requesting service.

[0060] The second response is used to instruct the user request service to send the access request to the external interface.

[0061] Step 402: Receive a first request result sent by the user request service, and associate the first feature vector and the first request result and store them in a cache database.

[0062] The first request result is a request result fed back by the external interface in response to the access request.

[0063] Exemplarily, when a cache miss occurs, the miss result can be sent to the user request service via a second response. After receiving the second response, the user request service directly sends the access request to the external interface, which is processed by the natural language model and receives the request result data output by the natural language model.

[0064] Exemplarily, after receiving the request result data, the user request service can associate and store the request result data (i.e., the first request result mentioned above) and the first feature vector in the cache database, and store the first feature vector in the vector feature library as data cache to improve access efficiency.

[0065] Step 303: If the matching result indicates that the vector database has a second feature vector that matches the first feature vector, a first response is sent to the user requesting service.

[0066] The first response includes: a second request result corresponding to the second feature vector; the second request result is a request result fed back by the natural language model based on the access request corresponding to the second feature vector.

[0067] For example, Figure 2 As shown, after a cache hit, the second request result associated with the second feature vector can be directly obtained from the cache database, and the second request result can be sent to the user request service. In this way, the required result data can be directly obtained from the cache without accessing the external interface, thereby improving the access efficiency of the natural language model.

[0068] The caching method for improving the access speed of the natural language model provided in the embodiment of the present application first receives a pending access request sent by a user request service; the pending request is a user's access request for an external interface of the natural language model; then, the request text data contained in the pending access request is converted into a first feature vector, and the first feature vector is matched with the feature vector to be matched stored in the vector database to generate a matching result; finally, if the matching result indicates that the vector database has a second feature vector that matches the first feature vector, the second request result corresponding to the second feature vector is sent to the user request service; wherein the matching result is obtained based on the cosine vector product of the two feature vectors and the output result of the similarity evaluation model; the second request result is the request result of the natural language model based on the access request corresponding to the second feature vector. In this way, the accuracy of the request matching result is improved by the cosine vector product and the similarity evaluation model, and the access efficiency of the natural language model interface is greatly improved by caching the natural language model request results.

[0069] It should be noted that the caching method for improving the access speed of a natural language model provided in the embodiment of the present application can be executed by a caching device for improving the access speed of a natural language model, or a control module in the caching device for improving the access speed of a natural language model for executing the caching method for improving the access speed of a natural language model. In the embodiment of the present application, the caching method for improving the access speed of a natural language model performed by a caching device for improving the access speed of a natural language model is taken as an example to illustrate the caching device for improving the access speed of a natural language model provided in the embodiment of the present application.

[0070] It should be noted that, in the embodiments of the present application, the caching methods for improving the access speed of the natural language model shown in the above-mentioned method drawings are all illustrated by taking one of the drawings in the embodiments of the present application as an example. In specific implementation, the caching methods for improving the access speed of the natural language model shown in the above-mentioned method drawings can also be implemented in combination with any other drawings that can be combined as shown in the above-mentioned embodiments, which will not be repeated here.

[0071] The following is a description of the cache device for improving the access speed of the natural language model provided in the present application. The cache method for improving the access speed of the natural language model described below can be referenced to each other in correspondence with the cache method for improving the access speed of the natural language model described above.

[0072] Figure 4 A schematic diagram of the structure of a cache device for improving the access speed of a natural language model provided in an embodiment of the present application, such as Figure 4 As shown, specifically including: A receiving module 401 is used to receive a pending access request sent by a user request service; the pending request is an access request from a user to an external interface of a natural language model; a matching module 402 is used to convert the request text data contained in the pending access request into a first feature vector, and match the first feature vector with the feature vector to be matched stored in a vector database to generate a matching result; a processing module 403 is used to send a first response to the user request service if the matching result indicates that the vector database has a second feature vector that matches the first feature vector; wherein the matching result is obtained based on the cosine vector product of two feature vectors and the output result of a similarity evaluation model; the second request result is the request result fed back by the natural language model based on the access request corresponding to the second feature vector; the first response includes: the second request result corresponding to the second feature vector.

[0073] Optionally, the matching module 402 is specifically configured to input the request text data into a language representation model to obtain the first feature vector corresponding to the request text data.

[0074] Optionally, the matching module 402 is specifically used to calculate the cosine vector product of the first feature vector and each feature vector to be matched in the vector database to obtain a first calculation result of the first feature vector and each feature vector to be matched, and to input the first feature vector and each feature vector to be matched into the similarity evaluation model in turn to perform similarity prediction to obtain a second calculation result of the first feature vector and each feature vector to be matched; the matching module 402 is also specifically used to generate the matching result based on the first calculation result and the second calculation result.

[0075] Optionally, the matching module 402 is specifically used to determine the target feature vector to be matched as the second feature vector when the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is greater than a first preset threshold, and the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is greater than a second preset threshold; wherein the target feature vector to be matched is any one of the multiple feature vectors to be matched stored in the vector database.

[0076] Optionally, the matching module 402 is specifically used to determine that the second feature vector that matches the first feature vector does not exist in the vector feature library when the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is less than or equal to a first preset threshold, and / or the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is less than or equal to a second preset threshold; wherein the target feature vector to be matched is any one of the multiple feature vectors to be matched stored in the vector database.

[0077] Optionally, the matching module 402 is specifically used to associate the first feature vector with the target feature vector and store it in a sample database, and train the similarity evaluation model as training samples of the similarity evaluation model after manual annotation, when the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is less than or equal to a first preset threshold and greater than a third preset threshold, and / or the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is less than or equal to a second preset threshold and greater than a fourth preset threshold; wherein the third preset threshold is less than the first preset threshold; and the fourth preset threshold is less than the second preset threshold.

[0078] Optionally, the processing module 403 is also used to send a second response to the user request service if the matching result indicates that the second feature vector matching the first feature vector does not exist in the vector database; the second response is used to instruct the user request service to send the access request to the external interface; the receiving module 401 is also used to receive the first request result sent by the user request service, and associate the first feature vector and the first request result and store them in a cache database; wherein the first request result is the request result fed back by the external interface in response to the access request.

[0079] The cache device for improving the access speed of the natural language model provided by the present application first receives a pending access request sent by a user request service; the pending request is a user's access request for the external interface of the natural language model; then, the request text data contained in the pending access request is converted into a first feature vector, and the first feature vector is matched with the feature vector to be matched stored in the vector database to generate a matching result; finally, if the matching result indicates that the vector database has a second feature vector that matches the first feature vector, the second request result corresponding to the second feature vector is sent to the user request service; wherein the matching result is obtained based on the cosine vector product of the two feature vectors and the output result of the similarity evaluation model; the second request result is the request result fed back by the natural language model based on the access request corresponding to the second feature vector. In this way, the accuracy of the request matching result is improved by the cosine vector product and the similarity evaluation model, and the access efficiency of the natural language model interface is greatly improved by caching the natural language model request results.

[0080] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5As shown, the electronic device may include: a processor (processor) 510, a communication interface (Communications Interface) 520, a memory (memory) 530 and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call the logic instructions in the memory 530 to execute a caching method for improving the access speed of the natural language model, the method comprising: first, receiving a pending access request sent by a user request service; the pending request is a user's access request for an external interface of a natural language model; then, converting the request text data contained in the pending access request into a first feature vector, and matching the first feature vector with the feature vector to be matched stored in a vector database to generate a matching result; finally, if the matching result indicates that the vector database has a second feature vector that matches the first feature vector, then sending a second request result corresponding to the second feature vector to the user request service; wherein the matching result is obtained based on the cosine vector product of two feature vectors and the output result of a similarity evaluation model; the second request result is the request result of the natural language model based on the access request corresponding to the second feature vector. In this way, the accuracy of the request matching result is improved by the cosine vector product and the similarity evaluation model, and the access efficiency of the natural language model interface is greatly improved by caching the natural language model request result.

[0081] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0082] On the other hand, the present application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the caching method for improving the access speed of the natural language model provided by the above-mentioned methods, and the method includes: first, receiving a pending access request sent by a user request service; the pending request is an access request from the user to an external interface of the natural language model; then, converting the request text data contained in the pending access request into a first feature vector, and matching the first feature vector with the feature vector to be matched stored in a vector database to generate a matching result; finally, if the matching result indicates that there is a second feature vector in the vector database that matches the first feature vector, then sending a second request result corresponding to the second feature vector to the user request service; wherein the matching result is obtained based on the cosine vector product of two feature vectors and the output result of a similarity evaluation model; the second request result is the request result fed back by the natural language model based on the access request corresponding to the second feature vector. In this way, the accuracy of request matching results is improved by using the cosine vector product and similarity evaluation model, and the access efficiency of the natural language model interface is greatly improved by caching the natural language model request results.

[0083] On the other hand, the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it is implemented to execute the above-mentioned caching method for improving the access speed of the natural language model, the method comprising: first, receiving a pending access request sent by a user request service; the pending request is a user's access request for an external interface of a natural language model; then, converting the request text data contained in the pending access request into a first feature vector, and matching the first feature vector with the feature vector to be matched stored in a vector database to generate a matching result; finally, if the matching result indicates that the vector database has a second feature vector that matches the first feature vector, then sending the second request result corresponding to the second feature vector to the user request service; wherein the matching result is obtained based on the cosine vector product of the two feature vectors and the output result of the similarity evaluation model; the second request result is the request result of the natural language model based on the access request corresponding to the second feature vector. In this way, the accuracy of the request matching result is improved by the cosine vector product and the similarity evaluation model, and the access efficiency of the natural language model interface is greatly improved by caching the natural language model request result.

[0084] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0085] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0086] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A caching method for improving the access speed of a natural language model, characterized in that: include: Receive pending access requests sent by user request services; The access request to be processed is an access request from a user to an external interface of a natural language model; Converting the request text data contained in the to-be-processed access request into a first feature vector, and matching the first feature vector with the to-be-matched feature vector stored in the vector database to generate a matching result; If the matching result indicates that the vector database has a second feature vector that matches the first feature vector, sending a first response to the user requesting service; Among them, the matching result is obtained based on the cosine vector product of two feature vectors and the output result of the similarity evaluation model; the first response includes: the second request result corresponding to the second feature vector; the second request result is the request result feedback of the natural language model based on the access request corresponding to the second feature vector;.

2. The method according to claim 1, characterized in that The converting the request text data contained in the to-be-processed access request into a first feature vector includes: The request text data is input into a language representation model to obtain the first feature vector corresponding to the request text data.

3. The method according to claim 1 or 2, characterized in that: The step of matching the first feature vector with the feature vector to be matched stored in the vector database to generate a matching result includes: Calculating the cosine vector product of the first feature vector and each feature vector to be matched in the vector database to obtain a first calculation result of the first feature vector and each feature vector to be matched, and sequentially inputting the first feature vector and each feature vector to be matched into the similarity evaluation model to perform similarity prediction to obtain a second calculation result of the first feature vector and each feature vector to be matched; The matching result is generated based on the first calculation result and the second calculation result.

4. The method according to claim 3, characterized in that The generating the matching result based on the first calculation result and the second calculation result includes: When the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is greater than a first preset threshold, and the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is greater than a second preset threshold, determining the target feature vector to be matched as the second feature vector; The target feature vector to be matched is any one of the multiple feature vectors to be matched stored in the vector database.

5. The method according to claim 3, characterized in that: The generating the matching result based on the first calculation result and the second calculation result includes: When the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is less than or equal to a first preset threshold, and / or the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is less than or equal to a second preset threshold, determining that the second feature vector matching the first feature vector does not exist in the vector feature library; The target feature vector to be matched is any one of the multiple feature vectors to be matched stored in the vector database.

6. The method according to claim 3, characterized in that The generating the matching result based on the first calculation result and the second calculation result includes: When the first calculation result indicates that the cosine vector product of the first feature vector and the target feature vector to be matched is less than or equal to a first preset threshold and greater than a third preset threshold, and / or the second calculation result indicates that the similarity value between the first feature vector and the target feature vector to be matched is less than or equal to a second preset threshold and greater than a fourth preset threshold, the first feature vector is associated with the target feature vector and stored in a sample database, and the first feature vector is used as a training sample of the similarity evaluation model to train the similarity evaluation model after manual annotation; Among them, the third preset threshold is smaller than the first preset threshold; and the fourth preset threshold is smaller than the second preset threshold.

7. The method according to claim 1, characterized in that After matching the first feature vector with the feature vector to be matched stored in the vector database to generate a matching result, the method further includes: If the matching result indicates that the second feature vector matching the first feature vector does not exist in the vector database, sending a second response to the user request service; the second response is used to instruct the user request service to send the access request to the external interface; receiving a first request result sent by the user request service, and associating and storing the first feature vector and the first request result in a cache database; The first request result is a request result fed back by the external interface in response to the access request.

8. A cache device for improving the access speed of a natural language model, characterized in that: The device comprises: A receiving module, used to receive a pending access request sent by a user requesting a service; the pending request is a user's access request for an external interface of a natural language model; A matching module, configured to convert the request text data contained in the access request to be processed into a first feature vector, and match the first feature vector with the feature vector to be matched stored in the vector database to generate a matching result; a processing module, configured to send a first response to the user requesting service if the matching result indicates that the vector database has a second feature vector matching the first feature vector; Among them, the matching result is obtained based on the cosine vector product of two feature vectors and the output result of the similarity evaluation model; the second request result is the request result feedback of the natural language model based on the access request corresponding to the second feature vector; the first response includes: the second request result corresponding to the second feature vector.

9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the caching method for improving the access speed of the natural language model as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the steps of the cache method for improving the access speed of a natural language model as described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Intelligent question and answer method, device and equipment and storage medium

    CN117591658A

  • Intelligent question answering method based on vector database and language model

    CN118394902A

  • Method, device and equipment for searching target domain based on large language model, and medium

    CN118467595A

  • Automatic question answering method and device, electronic equipment and computer storage medium

    CN118626615A

  • Training An Intent Matching Engine Of A Contact Center

    US20240244136A1