Hot update method of sentence resource library, sentence recommendation method and related device
By filtering and updating new sentences in the sentence resource library, the problem of lagging update of the sentence resource library is solved, and the effect of sentence recommendation and customer experience are improved.
Patent Information
- Application Number
- CN202111626947.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-12-28
AI Technical Summary
The existing sentence resource library cannot be updated in time, resulting in outdated sentence recommendation results, poor customer experience, and inability to effectively utilize new sentences accumulated by the front-end application system.
By obtaining new sentences accumulated online by the front-end application system, calculating the similarity between them and existing sentences, filtering new sentences that meet the threshold range, assigning them semantic labels, and storing them in the database. Then, new sentences that meet the conditions will be stored in the database. The sentences flow back to the sentence resource library for update.
It realizes the hot update of sentence resource library, improves the accuracy and real-time performance of sentence recommendation, and improves customer experience.
Smart Images

Figure CN114386431B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of natural language processing, and specifically relates to a hot update method for a sentence resource library, a sentence recommendation method and related devices. Background Art
[0002] With the development of technologies such as the Internet and big data, all walks of life are generating massive amounts of data all the time. How to quickly mine similar sentences from these massive amounts of data is becoming increasingly important in business, and it is of great significance to reducing labor costs and quickly completing effect optimization. Taking the financial scenario as an example, bank customer service generates thousands of call recording data every day, and there are many sentences with similar meanings but different expressions buried in these call recording data. When a semantic label and the corresponding existing sentence are given, retrieving multiple similar extended sentences from massive data plays an increasingly important role in quickly responding to business needs and shortening the business optimization cycle. Therefore, it is particularly important to make sentence recommendations accurate and real-time.
[0003] At present, the sentences in the sentence resource library are relatively fixed, and the latest accumulated sentences cannot be updated to the sentence resource library in a timely manner, resulting in outdated recommended sentences and poor customer experience. Summary of the invention
[0004] The present application provides a hot update method for a sentence resource library, a sentence recommendation method and related devices, which can update the sentence resource library in a timely manner to achieve better sentence recommendation results.
[0005] In order to solve the above technical problems, a technical solution adopted in the present application is: to provide a hot update method for a sentence resource library, including: obtaining multiple new sentences accumulated online by a front-end application system; for each of the new sentences, obtaining a first similarity between the new sentence and each existing sentence in the current sentence resource library; in response to at least one of the first similarities related to the current new sentence being within a threshold range, obtaining a semantic tag to which the new sentence belongs, and putting the new sentence into a first database; extracting at least one of the new sentences from the first database, and storing the new sentence in the sentence resource library under the corresponding semantic tag after vectorizing the new sentence.
[0006] To solve the above technical problems, another technical solution adopted in the present application is: to provide a sentence recommendation method, comprising: obtaining an input sentence; obtaining a third similarity between the input sentence and each existing sentence in a sentence resource library; wherein the sentence resource library is updated using the hot update method described in any of the above embodiments; and outputting a plurality of the existing sentences with a higher third similarity.
[0007] In order to solve the above technical problems, another technical solution adopted in the present application is: to provide a hot update device for a sentence resource library, including: an acquisition module, used to obtain multiple new sentences accumulated online by a front-end application system; a filtering module, connected to the acquisition module, used to obtain, for each of the new sentences, a first similarity between the new sentence and each existing sentence in the current sentence resource library; in response to at least one of the first similarities related to the current new sentence being within a threshold range, obtaining a semantic label to which the new sentence belongs, and placing the new sentence into a first database; an extraction module, connected to the filtering module, used to extract at least one of the new sentences from the first database, and vectorize the new sentence and store it under the corresponding semantic label in the sentence resource library.
[0008] In order to solve the above-mentioned technical problems, another technical solution adopted in the present application is: to provide an electronic device, comprising a memory and a processor coupled to each other, wherein the memory stores program instructions, and the processor is used to execute the program instructions to implement the hot update method of the sentence resource library described in any of the above-mentioned embodiments, or the sentence recommendation method described in any of the above-mentioned embodiments.
[0009] To solve the above technical problems, another technical solution adopted in the present application is: providing a storage device storing program instructions that can be run by a processor, and the processor is used to execute the program instructions to implement the hot update method of the sentence resource library described in any of the above embodiments, or the sentence recommendation method described in any of the above embodiments.
[0010] Different from the prior art, the beneficial effect of the present application is that: in the hot update method of the sentence resource library provided by the present application, for multiple new sentences accumulated online in the front-end application system, the multiple new sentences will be screened first, and the new sentences that meet the threshold range will be put into the first database; subsequently, at least one new sentence can be retrieved from the first database and returned to the sentence resource library to achieve hot update of the sentence resource library. The hot update method is relatively simple, and the sentences in the sentence resource library can be updated in a timely manner to improve the sentence recommendation effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work, among which:
[0012] Figure 1 A flowchart of an implementation method of a hot update method of a sentence resource library of the present application;
[0013] Figure 2a for Figure 1 A schematic diagram of a flow chart of an implementation method of obtaining the first similarity in step S102;
[0014] Figure 2b for Figure 1 In step S102, a schematic diagram of a model structure corresponding to the first similarity is obtained;
[0015] Figure 3 This is a flowchart of an implementation method of the sentence recommendation method of this application;
[0016] Figure 4 This is a structural diagram of an implementation method of a hot update device for a sentence resource library of the present application;
[0017] Figure 5 This is a schematic diagram of the structure of an embodiment of an electronic device of the present application;
[0018] Figure 6 This is a schematic structural diagram of an implementation of a storage device of the present application. DETAILED DESCRIPTION
[0019] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions 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 are within the scope of protection of this application.
[0020] See also Figure 1 , Figure 1 This is a flow chart of an implementation method of a hot update method for a sentence resource library of the present application, and the hot update method includes:
[0021] S101: Obtain multiple new sentences accumulated online by the front-end application system.
[0022] Specifically, the above sentences can also be called similar questions. The front-end application system can be a financial customer service system, etc. The front-end application system will continuously accumulate new sentences input manually or new sentences automatically generated by the machine based on voice recognition. For example, the new sentence can be "I can transfer your call later, and use the self-service voice to log in to the telephone banking. After resetting the password, you can open the SMS reminder service, okay?", or "Hey, hello, I want to ask that my bank card is not available. Now I don’t have the SMS reminder. I want to apply for an SMS reminder. Do I need to go to the business hall?", or "Okay, after transferring your call to the self-service voice, follow the system prompts, enter your card number and ID number, and after entering the withdrawal password, set a six-digit telephone banking login password, and follow the prompts to open an SMS reminder. Is it okay? Is it okay to follow the system prompts?".
[0023] When the number of new sentences accumulated by the front-end application system exceeds a threshold, subsequent steps S101 to S103 may be triggered. Optionally, the threshold may be 50, 100, etc., which may be set manually.
[0024] S102: For each new sentence, obtain a first similarity between the new sentence and each existing sentence in the current sentence resource library; in response to at least one first similarity related to the current new sentence being within a threshold range, obtain a semantic tag to which the new sentence belongs, and put the new sentence into the first database.
[0025] Specifically, in one embodiment, see Figure 2a and Figure 2b , Figure 2a for Figure 1 A flowchart of an implementation method of obtaining the first similarity in step S102, Figure 2b for Figure 1 A schematic diagram of a model structure corresponding to the first similarity obtained in step S102. A schematic diagram of a flow chart of an implementation method of obtaining the first similarity between the new sentence and each existing sentence in the current sentence resource library in step S102. The specific process of obtaining the first similarity can be:
[0026] S201: Obtain a first vector representation of a new sentence using the pre-trained model 10.
[0027] Specifically, in this embodiment, the pre-trained model 10 may be a BERT model or the like; after a new sentence is input into the pre-trained model 10, the embedding layer of the pre-trained model 10 maps the new sentence text into a matrix with a dimension of R (m×n) The first vector representation of has position information and context information, and contains deep connections with each position vector. It is expressed as follows:
[0028] E=Bert Emb (T),E∈R m×n ;
[0029] Among them, E is the first vector representation and T is the new sentence.
[0030] S202: Encode the first vector representation using encoder 12 to obtain a first joint encoding vector.
[0031] Specifically, when the new sentence is a long text, if RNN is used to encode the first vector representation, the gradient vanishing problem often occurs, causing the front content of the new sentence to be ignored by the model. In this embodiment, the encoding layer (Transformers-Encoder) of the encoder 12 is used to encode the first vector representation, which can solve the gradient vanishing problem. The encoding layer of the encoder 12 can output the first joint encoding vector containing context information. It can be expressed as follows:
[0032] T C =Transformer Encoder (E),H∈R m×h
[0033] Among them, T C is the first joint coding vector, and E is the first vector representation.
[0034] S203: Obtain the cosine similarity between the first joint encoding vector and the second joint encoding vector of each existing sentence in the current sentence resource library; wherein the cosine similarity is used as the first similarity.
[0035] Specifically, the process of obtaining the second joint encoding vector of each existing sentence in the current sentence resource library is similar to the above steps S201 and S202, which will not be described in detail here; for example, Figure 2b The pre-trained model 10 in the example obtains a second vector representation of the existing sentence; the encoder 12 is used to encode the second vector representation to obtain a second joint encoding vector.
[0036] Furthermore, the above cosine similarity mainly calculates the cosine distance between the first joint coding vector and the second joint coding vector, taking the angle between the first joint coding vector and the second joint coding vector as the consideration angle, and taking the inner product of the first joint coding vector and the second joint coding vector (the sum of the corresponding elements multiplied) to the product of the modulus of the first joint coding vector and the second joint coding vector as the calculation result. It is expressed as follows:
[0037]
[0038] Where similarity is the first similarity, A represents the first joint coding vector, B represents the second joint coding vector, and A i represents the i-th element in the first joint coding vector, B i Represents the i-th element in the second joint coding vector.
[0039] In yet another embodiment, before the above step S102, a process of setting a threshold range may be further included, which specifically includes:
[0040] A. Obtain the second similarity between multiple existing sentences under each semantic tag (also known as knowledge point) in the current sentence resource library. Specifically, the above second similarity can be cosine similarity. When the current sentence resource library is established, different existing sentences will be aggregated to different semantic tags through similarity, and only two existing sentences with a similarity exceeding a certain value will be attributed to the same semantic tag. Assuming that the current sentence resource library contains 10 semantic tags, and there are 100 existing sentences corresponding to each of the 10 semantic tags, then the second similarity between any two existing sentences under each semantic tag can be obtained.
[0041] B. Obtain the maximum similarity value and the minimum similarity value of all the second similarities under all semantic tags. Specifically, after obtaining multiple second similarities through the above step A, they can be sorted from high to low to obtain the maximum similarity value S max and the minimum similarity value S min .
[0042] C. Setting the maximum threshold of the threshold range according to the maximum similarity value, and setting the minimum threshold of the threshold range according to the minimum similarity value. max The first product of max , and the second coefficient λ2 and the minimum similarity value S min The second product is taken as the minimum threshold P min ; Wherein, the first coefficient λ1 and the second coefficient λ2 are greater than 0 and less than or equal to 1; At this time, the threshold range is [λ1*P min ,λ2*P max ]. Optionally, the first coefficient and the second coefficient may be the same.
[0043] The above method of setting the threshold range is relatively simple, and this method can expand the semantic range covered by similar questions (i.e., sentences). max If the threshold value is too high, the new sentences will be very similar to the existing sentences and will not make much sense. minIf the coefficient is too low, the new sentences selected will deviate too far from the existing sentences and will not be very meaningful. Therefore, in general, the first coefficient and the second coefficient can be set to about 0.8. Of course, in other application scenarios, the threshold range can also be pre-defined artificially, for example, the threshold range can be directly defined as [0.5, 0.8].
[0044] Furthermore, in the above step S102, in response to at least one first similarity related to the current new sentence being within a threshold range, the semantic tag to which the new sentence belongs is obtained, and the specific implementation process of placing the new sentence into the first database may be: A. For each semantic tag in the current sentence resource library, obtain the first number within the threshold range of the first similarity between the new sentence and the existing sentences under the current semantic tag, and obtain the ratio of the first number to the second number of the existing sentences under the current semantic tag. B. Use the semantic tag corresponding to the maximum ratio as the semantic tag of the new sentence, and place the new sentence into the first database. Optionally, the above first database may be an ES (ElasticSearch) database. The above process of determining the semantic tag to which the new sentence belongs is relatively simple and easy to implement.
[0045] In an application scenario, suppose there are 100 existing sentences in the current sentence resource library, which are divided into two semantic labels, 60 existing sentences under the L1 semantic label, and 40 existing sentences under the L2 semantic label. Then the new sentence must calculate the first similarity with the original 100 existing sentences, and a total of 100 first similarities are obtained. For these 100 first similarities, first determine whether any of the 100 first similarities fall within the threshold range. If all 100 first similarities are outside the threshold range, it means that the new sentence is irrelevant to the semantic label in the current sentence resource library, and the new sentence can be discarded. If at least one of the 100 first similarities is within the threshold range, it is determined which semantic label the new sentence belongs to. Specifically, it can be determined by proportion to see which semantic label has a higher proportion. For example, the first similarity of the new sentence with 30 existing sentences under the L1 semantic label is within the threshold range, and the first similarity with 25 existing sentences under the L2 semantic label is within the threshold range; since 30 / 60<25 / 40, the new sentence can be attributed to the L2 semantic label and placed in the first database.
[0046] Generally speaking, the first database is provided with a first maximum storage quantity M1, and the first maximum storage quantity M1 can be configured according to actual needs. In response to the number of new sentences stored in the first database exceeding the first maximum storage quantity M1, at least one new sentence stored (i.e., entered) earlier in the first database can be deleted. This design method can control the total amount of new sentences subsequently flowing back to the sentence resource library to ensure operational efficiency. In this embodiment, the new sentences that meet the threshold range can be first stored in the first database, and then the step of deleting the sentences that entered earlier in the first database is executed. In other embodiments, it can also be determined whether the current first database can still accommodate the current new sentence entry. If it can, the new sentence is directly stored in the first database; if not, the sentences that entered earlier in the first database are deleted first, and then the new sentence is stored in the first database.
[0047] S103: extract at least one new sentence from the first database, and vectorize the new sentence and store it under a corresponding semantic tag in the sentence resource library.
[0048] Specifically, the new sentences stored in the first database may include not only the current batch obtained through the screening of step S102, but also the historical batch obtained through the screening of step S102 but not extracted and deleted. Before extracting new sentences from the first database in the above step S103, the upper limit of the new sentences that can be extracted for each semantic tag in the sentence resource library may be set first; the specific process may be: obtaining the total number N of semantic tags in the current sentence resource library, and taking the ratio M1 / N of the first maximum storage quantity M1 of the first database to the total number N as the upper limit of the new sentences that can be reflowed under each semantic tag. The setting of this upper limit can ensure that the number of new sentences reflowed under each semantic tag will not differ too much, so that the sentence recommendation effect is better in the subsequent application process.
[0049] Furthermore, when at least one new sentence is extracted from the first database in step S103, the number of new sentences with the same semantic tag is less than or equal to the upper limit M1 / N. At this time, after the new sentence is extracted, the data related to the new sentence is deleted from the first database accordingly.
[0050] For each semantic tag, when the total number of new sentences belonging to the semantic tag in the first database is less than or equal to the upper limit M1 / N, all new sentences belonging to the semantic tag in the first database can be returned to the current sentence resource library.
[0051] Alternatively, for each semantic tag, when the total number of new sentences belonging to the semantic tag contained in the first database is greater than the upper limit M1 / N, the M1 / N new sentences belonging to the semantic tag in the first database can be returned to the current sentence resource library. The screening principle for the M1 / N new sentences returned to the current sentence resource library can be: screening according to the time of entering the first database; for example, the M1 / N new sentences that entered the first database later can be returned.
[0052] In addition, the implementation process of vectorizing the new sentences and storing them in the sentence resource library under the corresponding semantic tag in the above step S103 can be: the resource compilation engine of the calling engine vectorizes all the reflow new sentences, and the vectorized reflow resources (i.e., new sentences) need to be written into the resource update directory file and merged into the existing current sentence resource library, and the engine periodically detects and loads new resources. In the next round of hot update, or when the sentence resource library is used for sentence recommendation, the new sentences currently merged into the sentence resource library can be regarded as existing sentences in the sentence resource library.
[0053] In addition, in the present embodiment, the sentence resource library may also be provided with a second maximum storage quantity M2, and the second maximum storage quantity M2 may be configured according to actual needs. In response to the number of existing sentences stored in the sentence resource library exceeding the second maximum storage quantity M2, at least one existing sentence stored (i.e., entered) earlier in the sentence resource library may be deleted. This design method may control the total amount of existing sentences in the sentence resource library to ensure operational efficiency. In the present embodiment, the extracted new sentences may be first returned to the sentence resource library, and then the step of deleting the existing sentences with earlier entry time in the sentence resource library may be executed. In other embodiments, it may also be possible to determine whether the current sentence resource library can still accommodate the entry of the current number of new sentences before the new sentences are returned to the sentence resource library. If so, the new sentences of the current number may be directly returned to the sentence resource library; if not, the existing sentences with earlier entry time in the sentence resource library may be deleted first, and then the new sentences of the current number may be returned to the sentence resource library.
[0054] In the hot update method of the sentence resource library provided in the above steps S101 to S103, for the multiple new sentences accumulated online in the front-end application system, the multiple new sentences will be screened first, and the new sentences that meet the threshold range will be put into the first database; subsequently, at least one new sentence can be retrieved from the first database and returned to the sentence resource library to achieve hot update of the sentence resource library. This hot update method is relatively simple and can make the sentences in the sentence resource library updated in a timely manner to improve the sentence recommendation effect.
[0055] See also Figure 3 , Figure 3This is a flow chart of an implementation method of a sentence recommendation method of the present application, and the sentence recommendation method includes:
[0056] S301: Obtain an input sentence.
[0057] Specifically, the user can input a sentence (also referred to as a similar question) through voice, keyboard, etc.
[0058] S302: Obtain a third similarity between the input sentence and each existing sentence in the sentence resource library.
[0059] Specifically, the sentence resource library is updated using the hot update method mentioned in any of the above embodiments. The processor can call the deep learning model to vectorize the received input sentence, measure it with the existing sentences in the sentence resource library pre-built in the engine, and calculate the third similarity.
[0060] Optionally, the specific implementation process of the above step S302 may be: using Figure 2b The pre-trained model 10 in the sentence structure obtains a second vector representation of the input sentence; the encoder 12 is used to encode the second vector representation to obtain a third joint encoding vector; and the cosine similarity between the third joint encoding vector and the fourth joint encoding vector of each existing sentence in the sentence resource library is obtained, and the cosine similarity is the third similarity.
[0061] S303: Output a plurality of existing sentences having a third higher similarity.
[0062] Specifically, all the third similarities obtained in the above step S302 may be sorted to return the top K sentences with higher third similarities, and the specific size of K may be manually defined.
[0063] See also Figure 4 , Figure 4 This is a structural diagram of an implementation of a hot update device for a sentence resource library of the present application. The hot update device includes an acquisition module 20, a filtering module 22 and an extraction module 24.
[0064] Among them, the acquisition module 20 is used to obtain multiple new sentences accumulated online in the front-end application system. The filtering module 22 is connected to the acquisition module 20, and is used to obtain, for each new sentence, the first similarity between the new sentence and each existing sentence in the current sentence resource library; in response to at least one first similarity related to the current new sentence being within the threshold range, the semantic label to which the new sentence belongs is obtained, and the new sentence is placed in the first database. The extraction module 24 is connected to the acquisition module 22, and is used to extract at least one new sentence from the first database, and vectorize the new sentence and store it under the corresponding semantic label in the sentence resource library.
[0065] In one embodiment, if Figure 4 As shown, the hot update device provided by the present application also includes a first setting module 26, which is connected to the filtering module 22 and is used to obtain the second similarities between multiple existing sentences under each semantic tag in the current sentence resource library before the filtering module 22 is executed; obtain the maximum similarity value and the minimum similarity value among all second similarities under all semantic tags; set the maximum threshold of the threshold range according to the maximum similarity value, and set the minimum threshold of the threshold range according to the minimum similarity value.
[0066] Optionally, the above steps of setting the maximum threshold of the threshold range according to the maximum similarity value, and setting the minimum threshold of the threshold range according to the minimum similarity value, include: taking a first product of a first coefficient and the maximum similarity value as the maximum threshold, and taking a second product of a second coefficient and the minimum similarity value as the minimum threshold; wherein the first coefficient and the second coefficient are greater than 0 and less than or equal to 1.
[0067] In another embodiment, in response to at least one first similarity related to the current new sentence being within a threshold range, the step of obtaining the semantic label to which the new sentence belongs in the above-mentioned filtering module 22 specifically includes: for each semantic label in the current sentence resource library, obtaining a first number within the threshold range of the first similarity between the new sentence and the existing sentences under the semantic label, and obtaining the ratio of the first number to the second number of the existing sentences under the semantic label; and taking the semantic label corresponding to the maximum ratio as the semantic label of the new sentence.
[0068] In another embodiment, the first database is set with a maximum storage quantity; the hot update device provided in the present application may also include a second setting module 28, connected to the extraction module 24, for obtaining the total number of semantic tags in the current sentence resource library before the extraction module 24 is executed, and taking the ratio of the maximum storage quantity to the total number as the upper limit of the new sentences that can be reflowed under each semantic tag. At this time, when the extraction module 24 extracts at least one new sentence from the first database, the number of new sentences with the same semantic tag extracted is less than or equal to the upper limit.
[0069] In another embodiment, the hot update device provided in the present application may also include a deletion module, connected to the filtering module 22, for deleting at least one new sentence stored earlier in the first database in response to the number of new sentences stored in the first database exceeding the maximum storage number.
[0070] In another embodiment, the step of obtaining the first similarity between the new sentence and each existing sentence in the current sentence resource library in the above-mentioned filtering module 22 specifically includes: using a pre-trained model to obtain a first vector representation of the new sentence; using an encoder to encode the first vector representation to obtain a first joint coding vector; obtaining the cosine similarity between the first joint coding vector and the second joint coding vector of each existing sentence; wherein the cosine similarity is used as the first similarity.
[0071] See also Figure 5 , Figure 5 The structural diagram of an embodiment of an electronic device of the present application, the electronic device comprises: a memory 32 and a processor 30 coupled to each other, the memory 32 stores program instructions, and the processor 30 is used to execute the program instructions to implement any of the above-mentioned sentence resource library hot update methods, or sentence recommendation methods. Specifically, the electronic device includes but is not limited to: a desktop computer, a laptop computer, a tablet computer, a server, etc., which are not limited here. In addition, the processor 30 can also be referred to as a CPU (Center Processing Unit). The processor 30 may be an integrated circuit chip with signal processing capabilities. The processor 30 may also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. In addition, the processor 30 may be implemented by an integrated circuit chip.
[0072] See also Figure 6 , Figure 6 This is a structural diagram of an embodiment of a storage device of the present application. The storage device 40 stores program instructions 400 that can be executed by a processor. The program instructions 400 are used to implement any of the above-mentioned hot update methods of the sentence resource library or sentence recommendation methods.
[0073] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0074] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0075] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0076] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method 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 and other media that can store program code.
[0077] The above are merely embodiments of the present application and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for hot updating a sentence resource library, characterized in that: include: Obtain multiple new sentences accumulated online by the front-end application system; For each of the new sentences, obtain a first similarity between the new sentence and each existing sentence in the current sentence resource library; in response to at least one of the first similarities related to the current new sentence being within a threshold range, obtain a semantic tag to which the new sentence belongs, and put the new sentence into the first database; Extract at least one of the new sentences from the first database, and vectorize the new sentences and store them under the corresponding semantic label in the sentence resource library; Wherein, the first database is set with a maximum storage quantity; Before extracting at least one new sentence from the first database, the method includes: obtaining the total number of the semantic tags in the current sentence resource library, and taking the ratio of the maximum storage quantity to the total number as the upper limit value of the new sentences flowing back to the sentence resource library under each semantic tag; When extracting at least one of the new sentences from the first database, the number of the extracted new sentences having the same semantic label is less than or equal to the upper limit.
2. The hot update method according to claim 1, characterized in that: Before the step of obtaining the semantic tag to which the new sentence belongs and putting the new sentence into the first database in response to at least one of the first similarities related to the current new sentence being within a threshold range, the method includes: Obtaining a second similarity between a plurality of existing sentences under each of the semantic tags in the current sentence resource library; Obtaining a maximum similarity value and a minimum similarity value among all the second similarities under all the semantic tags; A maximum threshold of the threshold range is set according to the maximum similarity value, and a minimum threshold of the threshold range is set according to the minimum similarity value.
3. The hot update method according to claim 2, characterized in that: The step of setting the maximum threshold of the threshold range according to the maximum similarity value, and setting the minimum threshold of the threshold range according to the minimum similarity value, comprises: A first product of a first coefficient and the maximum similarity value is used as the maximum threshold, and a second product of a second coefficient and the minimum similarity value is used as the minimum threshold; wherein the first coefficient and the second coefficient are greater than 0 and less than or equal to 1.
4. The hot update method according to claim 1, characterized in that: The step of obtaining the semantic label to which the new sentence belongs in response to at least one of the first similarities related to the current new sentence being within a threshold range comprises: For each of the semantic tags in the current sentence resource library, obtain a first number within the threshold range of the first similarity between the new sentence and the existing sentence under the semantic tag, and obtain a ratio of the first number to a second number of the existing sentence under the semantic tag; The semantic label corresponding to the maximum ratio is used as the semantic label of the new sentence.
5. The hot update method according to claim 1, characterized in that: Also includes: In response to the number of the new sentences stored in the first database exceeding the maximum storage number, at least one of the new sentences stored in the first database at an earlier time is deleted.
6. The hot update method according to claim 1, characterized in that: The step of obtaining a first similarity between the new sentence and each existing sentence in the current sentence resource library comprises: Obtaining a first vector representation of the new sentence using a pre-trained model; encoding the first vector representation using an encoder to obtain a first joint encoded vector; Obtain the cosine similarity between the first joint encoding vector and the second joint encoding vector of each of the existing sentences; wherein the cosine similarity is used as the first similarity.
7. A sentence recommendation method, characterized in that: include: Get the input sentence; Obtaining a third similarity between the input sentence and each existing sentence in the sentence resource library; wherein the sentence resource library is updated using the hot update method described in any one of claims 1 to 6; Output the K existing sentences ranked first by the third similarity.
8. A hot update device for a sentence resource library, characterized in that: include: An acquisition module is used to obtain multiple new sentences accumulated online by the front-end application system; A filtering module connected to the obtaining module, for obtaining, for each of the new sentences, a first similarity between the new sentence and each existing sentence in the current sentence resource library; in response to at least one of the first similarities related to the current new sentence being within a threshold range, obtaining a semantic tag to which the new sentence belongs, and putting the new sentence into the first database; An extraction module, connected to the filtering module, for extracting at least one new sentence from the first database, and vectorizing the new sentence and storing it in the sentence resource library under the corresponding semantic label; Wherein, the first database is set with a maximum storage quantity; Before extracting at least one new sentence from the first database, the method includes: obtaining the total number of the semantic tags in the current sentence resource library, and taking the ratio of the maximum storage quantity to the total number as the upper limit value of the new sentences flowing back to the sentence resource library under each semantic tag; When extracting at least one of the new sentences from the first database, the number of the extracted new sentences having the same semantic label is less than or equal to the upper limit.
9. An electronic device, characterized in that: It comprises a memory and a processor coupled to each other, wherein the memory stores program instructions, and the processor is used to execute the program instructions to implement the hot update method of the sentence resource library described in any one of claims 1 to 6, or the sentence recommendation method described in claim 7.
10. A storage device, characterized in that: Program instructions that can be executed by a processor are stored, and the processor is used to execute the program instructions to implement the hot update method of the sentence resource library described in any one of claims 1 to 6, or the sentence recommendation method described in claim 7.
