CN116662512A - Training method of retrieval model, information retrieval method, device, equipment and medium - Google Patents

Training method of retrieval model, information retrieval method, device, equipment and medium Download PDF

Info

Publication number
CN116662512A
CN116662512A CN202310693790.5A CN202310693790A CN116662512A CN 116662512 A CN116662512 A CN 116662512A CN 202310693790 A CN202310693790 A CN 202310693790A CN 116662512 A CN116662512 A CN 116662512A
Authority
CN
China
Prior art keywords
model
sample
paragraph
query
sub
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310693790.5A
Other languages
Chinese (zh)
Inventor
邢毅然
曲瑛琪
刘璟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202310693790.5A priority Critical patent/CN116662512A/en
Publication of CN116662512A publication Critical patent/CN116662512A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Databases & Information Systems (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure provides a training method, an information retrieval device, equipment and a medium for a retrieval model, relates to the field of artificial intelligence, and particularly relates to the technical fields of deep learning, information retrieval and the like. The training method of the retrieval model comprises the following steps: segmenting at least one first sample paragraph to obtain a plurality of clauses; taking each clause as a sample query, performing the following operations: obtaining a second sample paragraph matched with the sample query by using the first retrieval model; in response to a preset rule being met, taking a first sample paragraph and a second sample paragraph to which the sample query belongs as positive examples and negative examples of the sample query respectively to construct a sample data set, wherein the preset rule comprises that the literal matching degree of the sample query and the first sample paragraph is larger than that of the sample query and the second sample paragraph; placing the sample data set into a literal matching training set; and training a second search model different from the first search model using the literal matching training set.

Description

Training method of retrieval model, information retrieval method, device, equipment and medium
Technical Field
The present disclosure relates to the field of artificial intelligence, and in particular, to the technical fields of deep learning, information retrieval, and the like, and more particularly, to a training method for a retrieval model, an information retrieval method, a training apparatus for a retrieval model, an information retrieval apparatus, an electronic device, a computer readable storage medium, and a computer program product.
Background
Artificial intelligence is the discipline of studying the process of making a computer mimic certain mental processes and intelligent behaviors (e.g., learning, reasoning, thinking, planning, etc.) of a person, both hardware-level and software-level techniques. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing, and the like; the artificial intelligence software technology mainly comprises a computer vision technology, a voice recognition technology, a natural language processing technology, a machine learning/deep learning technology, a big data processing technology, a knowledge graph technology and the like.
The approaches described in this section are not necessarily approaches that have been previously conceived or pursued. Unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section. Similarly, the problems mentioned in this section should not be considered as having been recognized in any prior art unless otherwise indicated.
Disclosure of Invention
The present disclosure provides a training method of a search model, an information search method, a training apparatus of a search model, an information search apparatus, an electronic device, a computer-readable storage medium, and a computer program product.
According to an aspect of the present disclosure, there is provided a training method of a search model, including: segmenting at least one first sample paragraph to obtain a plurality of clauses; taking each clause of the plurality of clauses as a sample query, performing the following operations: obtaining a second sample paragraph matched with the sample query by using the first retrieval model; in response to a preset rule being met, taking a first sample paragraph and a second sample paragraph to which the sample query belongs as positive examples and negative examples of the sample query respectively to construct a sample data set, wherein the preset rule comprises that the literal matching degree of the sample query and the first sample paragraph is larger than that of the sample query and the second sample paragraph; placing the sample data set into a literal matching training set; and training a second search model different from the first search model using the literal matching training set to obtain a trained second search model.
According to an aspect of the present disclosure, there is provided an information retrieval method including: and obtaining an output paragraph matched with the input query of the user by using a retrieval model, wherein the retrieval model is obtained by training by using the training method.
According to an aspect of the present disclosure, there is provided a training apparatus for retrieving a model, including: the segmentation unit is configured to segment at least one first sample paragraph so as to obtain a plurality of clauses; a literal matching training set generating unit configured to perform the following operations with each of the plurality of clauses as a sample query: obtaining a second sample paragraph matched with the sample query by using the first retrieval model; in response to a preset rule being met, taking a first sample paragraph and a second sample paragraph to which the sample query belongs as positive examples and negative examples of the sample query respectively to construct a sample data set, wherein the preset rule comprises that the literal matching degree of the sample query and the first sample paragraph is larger than that of the sample query and the second sample paragraph; placing the sample data set into a literal matching training set; and a training unit configured to train a second search model different from the first search model using the literal matching training set to obtain a trained second search model.
According to an aspect of the present disclosure, there is provided an information retrieval apparatus including: and a retrieval unit configured to acquire an output paragraph matching the input query of the user using a retrieval model obtained by training using the training device.
According to another aspect of the present disclosure, there is provided an electronic device including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method described above.
According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the above-described method.
According to another aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein the computer program, when executed by a processor, implements the above-described method.
According to one or more embodiments of the present disclosure, by automatically constructing a large number of positive samples that are literally matched and negative samples that are acquired using other retrieval means, and further training the retrieval model using a data set that includes the positive samples and the negative samples, the retrieval model can be provided with literally matching capabilities in a low cost manner.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The accompanying drawings illustrate exemplary embodiments and, together with the description, serve to explain exemplary implementations of the embodiments. The illustrated embodiments are for exemplary purposes only and do not limit the scope of the claims. Throughout the drawings, identical reference numerals designate similar, but not necessarily identical, elements.
FIG. 1 illustrates a schematic diagram of an exemplary system in which various methods described herein may be implemented, in accordance with an embodiment of the present disclosure;
FIG. 2 illustrates a flowchart of a training method of a retrieval model according to an exemplary embodiment of the present disclosure;
FIG. 3 illustrates a flowchart for training a second search model different from the first search model using a literal matching training set according to an exemplary embodiment of the present disclosure;
FIG. 4 illustrates a flowchart for training a second search model different from the first search model using a literal matching training set according to an exemplary embodiment of the present disclosure;
FIG. 5 illustrates a flowchart of a retrieve retrieval method according to an exemplary embodiment of the present disclosure;
FIG. 6 illustrates a block diagram of a training apparatus for retrieving a model according to an exemplary embodiment of the present disclosure;
FIG. 7 shows a block diagram of an information retrieval apparatus according to an exemplary embodiment of the present disclosure; and
fig. 8 illustrates a block diagram of an exemplary electronic device that can be used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In the present disclosure, the use of the terms "first," "second," and the like to describe various elements is not intended to limit the positional relationship, timing relationship, or importance relationship of the elements, unless otherwise indicated, and such terms are merely used to distinguish one element from another. In some examples, a first element and a second element may refer to the same instance of the element, and in some cases, they may also refer to different instances based on the description of the context.
The terminology used in the description of the various illustrated examples in this disclosure is for the purpose of describing particular examples only and is not intended to be limiting. Unless the context clearly indicates otherwise, the elements may be one or more if the number of the elements is not specifically limited. Furthermore, the term "and/or" as used in this disclosure encompasses any and all possible combinations of the listed items.
In the related art, the existing retrieval model is generally only based on semantic matching, but such a matching model has poor performance in a scene where both semantic matching and literal matching are required.
In order to solve the problems, the method and the device automatically construct a large number of positive samples which are matched literally and negative samples which are obtained by other retrieval means, and further train a retrieval model by utilizing a data set comprising the positive samples and the negative samples, so that the trained retrieval model has the capacity of matching literally. .
Fig. 1 illustrates a schematic diagram of an exemplary system 100 in which various methods and apparatus described herein may be implemented, in accordance with an embodiment of the present disclosure. Referring to fig. 1, the system 100 includes one or more client devices 101, 102, 103, 104, 105, and 106, a server 120, and one or more communication networks 110 coupling the one or more client devices to the server 120. Client devices 101, 102, 103, 104, 105, and 106 may be configured to execute one or more applications.
In embodiments of the present disclosure, server 120 may run one or more services or software applications that enable execution of a training method or an information retrieval method of a retrieval model.
In some embodiments, server 120 may also provide other services or software applications that may include non-virtual environments and virtual environments. In some embodiments, these services may be provided as web-based services or cloud services, such as provided to users of client devices 101, 102, 103, 104, 105, and/or 106 under a software as a service (SaaS) network.
In the configuration shown in fig. 1, server 120 may include one or more components that implement the functions performed by server 120. These components may include software components, hardware components, or a combination thereof that are executable by one or more processors. A user operating client devices 101, 102, 103, 104, 105, and/or 106 may in turn utilize one or more client applications to interact with server 120 to utilize the services provided by these components. It should be appreciated that a variety of different system configurations are possible, which may differ from system 100. Accordingly, FIG. 1 is one example of a system for implementing the various methods described herein and is not intended to be limiting.
The user may use client devices 101, 102, 103, 104, 105, and/or 106 for human-machine interaction. The client device may provide an interface that enables a user of the client device to interact with the client device. The client device may also output information to the user via the interface. Although fig. 1 depicts only six client devices, those skilled in the art will appreciate that the present disclosure may support any number of client devices.
Client devices 101, 102, 103, 104, 105, and/or 106 may include various types of computer devices, such as portable handheld devices, general purpose computers (such as personal computers and laptop computers), workstation computers, wearable devices, smart screen devices, self-service terminal devices, service robots, gaming systems, thin clients, various messaging devices, sensors or other sensing devices, and the like. These computer devices may run various types and versions of software applications and operating systems, such as MICROSOFT Windows, APPLE iOS, UNIX-like operating systems, linux, or Linux-like operating systems (e.g., GOOGLE Chrome OS); or include various mobile operating systems such as MICROSOFT Windows Mobile OS, iOS, windows Phone, android. Portable handheld devices may include cellular telephones, smart phones, tablet computers, personal Digital Assistants (PDAs), and the like. Wearable devices may include head mounted displays (such as smart glasses) and other devices. The gaming system may include various handheld gaming devices, internet-enabled gaming devices, and the like. The client device is capable of executing a variety of different applications, such as various Internet-related applications, communication applications (e.g., email applications), short Message Service (SMS) applications, and may use a variety of communication protocols.
Network 110 may be any type of network known to those skilled in the art that may support data communications using any of a number of available protocols, including but not limited to TCP/IP, SNA, IPX, etc. For example only, the one or more networks 110 may be a Local Area Network (LAN), an ethernet-based network, a token ring, a Wide Area Network (WAN), the internet, a virtual network, a Virtual Private Network (VPN), an intranet, an extranet, a Public Switched Telephone Network (PSTN), an infrared network, a wireless network (e.g., bluetooth, WIFI), and/or any combination of these and/or other networks.
The server 120 may include one or more general purpose computers, special purpose server computers (e.g., PC (personal computer) servers, UNIX servers, mid-end servers), blade servers, mainframe computers, server clusters, or any other suitable arrangement and/or combination. The server 120 may include one or more virtual machines running a virtual operating system, or other computing architecture that involves virtualization (e.g., one or more flexible pools of logical storage devices that may be virtualized to maintain virtual storage devices of the server). In various embodiments, server 120 may run one or more services or software applications that provide the functionality described below.
The computing units in server 120 may run one or more operating systems including any of the operating systems described above as well as any commercially available server operating systems. Server 120 may also run any of a variety of additional server applications and/or middle tier applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, etc.
In some implementations, server 120 may include one or more applications to analyze and consolidate data feeds and/or event updates received from users of client devices 101, 102, 103, 104, 105, and 106. Server 120 may also include one or more applications to display data feeds and/or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and 106.
In some implementations, the server 120 may be a server of a distributed system or a server that incorporates a blockchain. The server 120 may also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology. The cloud server is a host product in a cloud computing service system, so as to solve the defects of large management difficulty and weak service expansibility in the traditional physical host and virtual private server (VPS, virtual Private Server) service.
The system 100 may also include one or more databases 130. In some embodiments, these databases may be used to store data and other information. For example, one or more of databases 130 may be used to store information such as audio files and video files. Database 130 may reside in various locations. For example, the data store used by the server 120 may be local to the server 120, or may be remote from the server 120 and may communicate with the server 120 via a network-based or dedicated connection. Database 130 may be of different types. In some embodiments, the database used by server 120 may be a database, such as a relational database. One or more of these databases may store, update, and retrieve the databases and data from the databases in response to the commands.
In some embodiments, one or more of databases 130 may also be used by applications to store application data. The databases used by the application may be different types of databases, such as key value stores, object stores, or conventional stores supported by the file system.
The system 100 of fig. 1 may be configured and operated in various ways to enable application of the various methods and apparatus described in accordance with the present disclosure.
According to an aspect of the present disclosure, a training method of a search model is provided. As shown in fig. 2, the training method of the retrieval model includes: step S201, segmenting at least one first sample paragraph to obtain a plurality of clauses; step S202, taking each clause in the plurality of clauses as a sample query, and executing the following operations: step S2021, obtaining a second sample paragraph matched with the sample query by using the first retrieval model; step S2022, in response to the preset rule being satisfied, taking the first sample paragraph and the second sample paragraph to which the sample query belongs as positive examples and negative examples of the sample query respectively to construct a sample data set, wherein the preset rule comprises that the literal matching degree of the sample query and the first sample paragraph is greater than that of the sample query and the second sample paragraph; step S2023, putting the sample data set into a literal matching training set; and step S203, training a second retrieval model different from the first retrieval model by using the literal matching training set to obtain a trained second retrieval model.
Thus, by automatically constructing a large number of positive samples which are literally matched and negative samples which are acquired by other retrieval means, and further training the retrieval model by utilizing a data set comprising the positive samples and the negative samples, the retrieval model can be provided with the literally matching capability in a low-cost manner.
In some embodiments, the first retrieval model may be any type of retrieval model, such as a BM25 model or a retrieval model that has been trained (e.g., a recall model).
In some embodiments, the second retrieval model may be a deep learning based retrieval model to be trained.
In some embodiments, at least one first sample paragraph may be obtained from the candidate prediction library prior to step S201. The candidate prediction library may include a number of text paragraphs that may be obtained from a book, a particular database, a network, or the like. Some of these text paragraphs may be referred to as at least one first sample paragraph.
In some embodiments, in step S201, the first sample paragraph may be cut, for example, with punctuation marks such as commas, periods, exclamation marks, and the like.
In some embodiments, x clauses are randomly selected from the segmented sentences as the sample query q, so that x (q, p+) pairs can be combined as positive examples, and p+ is the first sample paragraph where q is located. For q in each positive example, a second search model may be used to search a second sample paragraph p-from the candidate corpus or other corpus, taking these (q, p-) pairs as negative examples, thereby obtaining a sample data set (q, p+, p-) corresponding to each clause. It should be noted that when constructing the sample data set, it is necessary to determine that the preset rule is satisfied. The preset rule includes at least that the literal match of the sample query and the first sample paragraph is greater than the literal match of the sample query and the second sample paragraph. This ensures that the second search model trained using such a sample data set has literal matching capability.
In addition, a second sample paragraph serving as a negative example is obtained by using the first retrieval model, one of the second sample paragraphs can quickly construct a sample data set, and the other of the second sample paragraphs can increase the difficulty of the negative example and improve the capability of the trained model. In some embodiments, the first retrieval model may be a semantically matching based model, that is, the second sample paragraph and the sample query are semantically matched. By constructing the sample data set with such a second sample paragraph as negative example, the semantic matching capability and the literal matching capability of the second retrieval model can be better adjusted.
In one exemplary embodiment, query "labor save for several days false? "the search purpose is a semantic match with a large probability; the search purpose of the query' Qingchuan calendar hanyang tree, the herb of the Chinese parrot is matched literally.
According to some embodiments, the preset rule may include that the literal match of the sample query and the first sample paragraph is greater than a first preset threshold. Therefore, the positive examples with low literal matching process can be filtered, and only sample data with high matching degree is reserved, so that the second retrieval model can quickly learn literal matching capability.
According to some embodiments, the literal match degree may include an edit distance. The edit distance refers to the degree of difference between two text/strings, which is quantified by measuring the minimum number of operations required to convert one string to another. These operations may include inserting, deleting, or replacing characters. The smaller the edit distance, the higher the degree of literal matching between two text/strings.
According to some embodiments, the preset rule may include that the degree of semantic matching of the sample query and the second sample paragraph is less than a second preset threshold. If the second sample paragraph is significantly matched with the sample query semantics, this indicates that the second sample paragraph is a search result that matches the sample query. Eliminating such samples can avoid a large disturbance to the semantic matching ability of the second search model.
In some embodiments, the first retrieval model may be a semantic matching based retrieval model. In other words, the preset rule may include that the semantic matching degree of the second sample paragraph and the sample query is located within the preset interval.
According to some embodiments, the predetermined rule may include that the lengths of the first sample paragraph and the second sample paragraph are both within a predetermined length range. The length range of the filtering may be determined by first counting the longest query length that the second search model can accommodate, the user's actual query, and/or a distribution of query lengths within the labeled training set that is different from the literally matched training set (e.g., mainly within what length range). Then, when the sample clause is used as a sample query to construct a sample data set, only the clause with the length within the screening range is reserved.
According to some embodiments, the preset rules may include that the sample query is a real query text in the user query log. In some embodiments, a user's query log may be maintained, and only sentences (i.e., real query text) present in the query log are maintained as sample queries when sampling clause construction samples. Through the method, too general clauses (such as 'good' for example) can be screened out, the number of false positive examples is reduced, so that the construction of sample data sets based on the clauses is avoided, the fact that the data sets in the literal matching training set can enable the second retrieval model to judge the positive and negative examples through literal matching is ensured, and the effect of training the literal matching capability is achieved.
According to some embodiments, the second retrieval model may employ a double-tower structure in which the query (query) and the candidate paragraph (para) are encoded separately. That is, the second retrieval model includes a query sub-model and a paragraph sub-model. Each of which may employ a common pre-trained large language model (e.g., ERNIE, BERT, etc.). The usual pre-training task design is semantic-level, so the retrieval model of such a structure can return the results of semantic matching. On the basis of the model structure, the capacity of the model in literal matching can be supplemented by using the literal matching training set, so that the model has good performance in semantic matching and literal matching, and the comprehensive capacity of the model is improved.
As shown in fig. 3, training a second search model different from the first search model using the literal matching training set to obtain a trained second search model may include: step S301, inputting a sample query in a sample data set in a literal matching training set into a query sub-model to obtain a first embedded vector corresponding to the sample query; step S302, inputting a first sample paragraph in the sample data set into a paragraph sub-model to obtain a second embedded vector corresponding to the first sample paragraph; step S303, inputting a second sample paragraph in the sample data set into a paragraph sub-model to obtain a third embedded vector corresponding to the second sample paragraph; step S304, calculating a loss value based on a first similarity between the first embedded vector and the second embedded vector and a second similarity between the first embedded vector and the third embedded vector; and step S305, adjusting parameters of the query sub-model and the paragraph sub-model based on the loss value.
In some embodiments, the query sub-model and the paragraph sub-model may encode the input sample query and the candidate paragraphs, respectively, to generate corresponding embedded vectors. Further, it is possible to calculate the similarity (e.g., dot product of embedded vector) with the sample query q and the positive instance p+ and calculate the similarity between the sample query q and the negative instance p-. In some embodiments, the goal of the training is to have the similarity between q and p+ be greater than the similarity between q and p-. The loss value calculated based on the first similarity and the second similarity may be positively correlated with the first similarity and negatively correlated with the second similarity.
In some embodiments, the second retrieval model may include a recall sub-model and a sort sub-model connected in sequence, both of which are large language models. Recall multiple candidates from massive data by using a recall sub-model, and rank confidence scoring of the recalled multiple candidates by using a ranking sub-model to obtain a final search result, wherein the search mode has become a mainstream mode of current information search. In some embodiments, both the recall sub-model and the sort sub-model may employ a dual tower structure. That is, the recall sub-model and the order sub-model may each include a respective query sub-model and paragraph sub-model.
Training of large language models can generally include two phases: a pre-training phase and a fine-tuning phase. In the pre-training stage, the model may be trained using pre-training tasks to provide the model with preliminary natural language understanding and processing capabilities. The pre-trained models are often unavailable or perform poorly when performing specific downstream tasks. In the fine tuning stage, the pre-trained model may be further trained using a training set associated with the downstream task to enable the fine-tuned model to perform well for the downstream task.
As shown in fig. 4, training a second search model different from the first search model using the literal matching training set to obtain a trained second search model may include: s401, pre-training a recall sub-model to be trained by utilizing a literal matching training set and a semantic-based pre-training task; step S402, performing fine adjustment on the pre-trained recall sub-model by using a labeling training set to obtain the recall sub-model, wherein the labeling training set comprises manually labeled matching data; step S403, pre-training the sequencing submodel to be trained by utilizing a pre-training task based on semantics; and step S404, fine tuning the pre-trained ranking sub-model by utilizing the literal matching training set and the labeling training set to obtain the ranking sub-model.
In some embodiments, during the pre-training and fine-tuning phase, the recall sub-model and the sort sub-model may be trained using the corresponding training sets in the manner described above.
In some embodiments, using step S201-step S202 can cost-effectively generate a literally matching training set comprising a large amount of sample data by way of automatic construction, but the automatically constructed training set may be noisy. In contrast, the labeling training set obtained by manual labeling is less noisy, but is small in number and high in acquisition cost, and the labeling training set generally does not distinguish whether the samples therein are literally or semantically matched.
In addition, the inventor observes that training by using a word face matching training set in a pre-training stage can have a certain influence on the semantic matching capability of the model aiming at the pre-trained large language model, but can obviously improve the word face matching capability of the model; the training by using the word face matching training set in the fine tuning stage does not affect the semantic matching capability of the model, but has limited improvement on the word face matching capability.
Therefore, the training mode described in the step S401-the step S404 is adopted to train the second retrieval model, so that the word matching capability of the recall sub-model is remarkably improved, and the trained recall sub-model can recall a large amount of candidate data meeting the word matching requirement and can recall a certain amount of candidate data meeting the semantic matching requirement. Although the training process has a certain influence on the semantic matching capability of the recall sub-model, since the downstream sorting model reorders and screens the candidate data, this can be compensated for, so that the final result shows both literal matching and semantic matching.
Thus, the training method of the present disclosure can achieve the following technical effects:
1. By pertinently supplementing the literal matching capability, short plates of the double-tower model are supplemented, and the comprehensive capability of the retrieval model is remarkably improved.
2. By utilizing the screening of the preset rules, additional training data which are distributed in the same field as the training data can be easily obtained, higher data quality is maintained, and the semantic matching effect is basically not damaged.
3. The construction mode aiming at the literal matching capability training data is provided, and the training mode is not a specially designed pre-training task, so that the training mode can be easily combined into the training of most of retrieval models, the whole system architecture is kept uniform, and the system architecture has good expansibility.
4. The structure of the retrieval model does not need to be changed, and the characteristics of rapid deployment and efficient retrieval of the retrieval model (particularly a double-tower model) are maintained. When the model needs to be migrated to other fields, the training data of the corresponding field is only needed to be used for generating additional training data aiming at literal matching. The method is simpler, is easy to maintain, and can update iteration rapidly.
According to another aspect of the present disclosure, an information retrieval method is provided. As shown in fig. 5, the information retrieval method includes: step S501, obtaining an output paragraph matched with the input query of the user by utilizing a retrieval model. The search model is obtained by training the search model by the training method. Thus, by training the retrieval model using the training method described above, the trained retrieval model is enabled to return results that literally match the user's input query. According to another aspect of the present disclosure, a training apparatus for retrieving a model is provided. As shown in fig. 6, the apparatus 600 may include: a segmentation unit 610 configured to segment at least one first sample paragraph to obtain a plurality of clauses; the literal matching training set generating unit 620 is configured to perform the following operations with each of the plurality of clauses as a sample query: obtaining a second sample paragraph matched with the sample query by using the first retrieval model; in response to a preset rule being met, taking a first sample paragraph and a second sample paragraph to which the sample query belongs as positive examples and negative examples of the sample query respectively to construct a sample data set, wherein the preset rule comprises that the literal matching degree of the sample query and the first sample paragraph is larger than that of the sample query and the second sample paragraph; placing the sample data set into a literal matching training set; and a training unit 630 configured to train a second search model different from the first search model using the literal matching training set to obtain a trained second search model.
It is understood that the operations of the units 610-630 in the apparatus 600 are similar to the operations of the steps S201-S203 in fig. 2, respectively, and are not described herein.
According to some embodiments, the preset rule may include that the literal match of the sample query and the first sample paragraph is greater than a first preset threshold.
According to some embodiments, the literal match degree may include an edit distance.
According to some embodiments, the preset rule may include that the degree of semantic matching of the sample query and the second sample paragraph is less than a second preset threshold.
According to some embodiments, the predetermined rule may include that the lengths of the first sample paragraph and the second sample paragraph are both within a predetermined length range.
According to some embodiments, the preset rules may include that the sample query is a real query text in the user query log.
According to some embodiments, the second retrieval model may include a query sub-model and a paragraph sub-model. The training unit may include: a first input subunit configured to input a sample query in a sample data set in a literally matching training set into a query sub-model to obtain a first embedded vector corresponding to the sample query; a second input subunit configured to input a first sample paragraph in the sample data set into a paragraph sub-model to obtain a second embedded vector corresponding to the first sample paragraph; a third input subunit configured to input a second sample paragraph in the sample data set into a paragraph sub-model to obtain a third embedded vector corresponding to the second sample paragraph; a calculating subunit configured to calculate a loss value based on a first similarity between the first embedded vector and the second embedded vector, a second similarity between the first embedded vector and the third embedded vector; and a tuning sub-unit configured to adjust parameters of the query sub-model and the paragraph sub-model based on the loss value.
According to some embodiments, the retrieval model may include a recall sub-model and a sort sub-model connected in sequence. Both the recall sub-model and the sort sub-model may be large language models. The training unit may include: a first pre-training subunit configured to pre-train a recall sub-model to be trained using a literally matched training set and a semantic-based pre-training task; a first fine tuning unit configured to fine tune the pre-trained recall sub-model using a labeling training set to obtain the recall sub-model, wherein the labeling training set includes manually labeled matching data; a second pre-training subunit configured to pre-train the ranking sub-model to be trained using a semantic-based pre-training task; and a second fine tuning unit configured to fine tune the pre-trained ranking sub-model using the literal matching training set and the labeling training set to obtain the ranking sub-model.
According to another aspect of the present disclosure, an information retrieval apparatus is provided. As shown in fig. 7, the apparatus 700 may include: the retrieving unit 710 is configured to obtain the output paragraphs matching the input query of the user using a retrieving model, which may be trained using the apparatus 600 described above.
In the technical scheme of the disclosure, the related processes of collecting, storing, using, processing, transmitting, providing, disclosing and the like of the personal information of the user accord with the regulations of related laws and regulations, and the public order colloquial is not violated.
According to embodiments of the present disclosure, there is also provided an electronic device, a readable storage medium and a computer program product.
Referring to fig. 8, a block diagram of an electronic device 800 that may be a server or a client of the present disclosure, which is an example of a hardware device that may be applied to aspects of the present disclosure, will now be described. Electronic devices are intended to represent various forms of digital electronic computer devices, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers. The electronic device may also represent various forms of mobile apparatuses, such as personal digital assistants, cellular telephones, smartphones, wearable devices, and other similar computing apparatuses. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 7, the apparatus 800 includes a computing unit 801 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 802 or a computer program loaded from a storage unit 808 into a Random Access Memory (RAM) 803. In the RAM803, various programs and data required for the operation of the device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to the bus 804.
Various components in device 800 are connected to I/O interface 805, including: an input unit 806, an output unit 807, a storage unit 808, and a communication unit 809. The input unit 806 may be any type of device capable of inputting information to the device 800, the input unit 806 may receive input numeric or character information and generate key signal inputs related to user settings and/or function control of the electronic device, and may include, but is not limited to, a mouse, a keyboard, a touch screen, a trackpad, a trackball, a joystick, a microphone, and/or a remote control. The output unit 807 may be any type of device capable of presenting information and may include, but is not limited to, a display, speakers, video/audio output terminals, vibrators, and/or printers. The storage unit 808 may include, but is not limited to, magnetic disks, optical disks. The communication unit 809 allows the device 800 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers and/or chipsets, such as bluetooth TM Devices, 802.11 devices, wiFi devices, wiMax devices, cellular communication devices, and/or the like.
The computing unit 801 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 801 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning network algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the respective methods and processes described above, such as a training method of a retrieval model and/or an information retrieval method. For example, in some embodiments, the training method of the retrieval model and/or the information retrieval method may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program may be loaded and/or installed onto device 800 via ROM 802 and/or communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of the training method and/or the information retrieval method of the retrieval model described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform the training method of the retrieval model and/or the information retrieval method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service ("Virtual Private Server" or simply "VPS") are overcome. The server may also be a server of a distributed system or a server that incorporates a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel, sequentially or in a different order, provided that the desired results of the disclosed aspects are achieved, and are not limited herein.
Although embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it is to be understood that the foregoing methods, systems, and apparatus are merely exemplary embodiments or examples, and that the scope of the present invention is not limited by these embodiments or examples but only by the claims following the grant and their equivalents. Various elements of the embodiments or examples may be omitted or replaced with equivalent elements thereof. Furthermore, the steps may be performed in a different order than described in the present disclosure. Further, various elements of the embodiments or examples may be combined in various ways. It is important that as technology evolves, many of the elements described herein may be replaced by equivalent elements that appear after the disclosure.

Claims (21)

1. A training method of a search model, comprising:
segmenting at least one first sample paragraph to obtain a plurality of clauses;
Taking each clause of the plurality of clauses as a sample query, performing the following operations:
obtaining a second sample paragraph matched with the sample query by using a first retrieval model;
in response to a preset rule being met, taking a first sample paragraph and a second sample paragraph to which the sample query belongs as positive examples and negative examples of the sample query respectively to construct a sample data set, wherein the preset rule comprises that the literal matching degree of the sample query and the first sample paragraph is larger than that of the sample query and the second sample paragraph; and
placing the sample data set into a literal matching training set; and
and training a second retrieval model different from the first retrieval model by using the literal matching training set to obtain a trained second retrieval model.
2. The method of claim 1, wherein the preset rule comprises a degree of literal matching of the sample query and the first sample paragraph being greater than a first preset threshold.
3. The method of claim 2, wherein the literal match comprises an edit distance.
4. A method according to any of claims 1-3, wherein the preset rule comprises that the degree of semantic matching of the sample query and the second sample paragraph is less than a second preset threshold.
5. The method of any of claims 1-4, wherein the preset rule includes that the lengths of the first and second sample paragraphs are each within a preset length range.
6. The method of any of claims 1-5, wherein the preset rule includes the sample query being real query text in a user query log.
7. The method of any of claims 1-6, wherein the second search model includes a query sub-model and a paragraph sub-model, wherein training a second search model different from the first search model with the literal matching training set to obtain a trained second search model includes:
inputting the sample query in the sample data group in the literal matching training set into the query sub-model to obtain a first embedded vector corresponding to the sample query;
inputting a first sample paragraph in the sample data set into the paragraph sub-model to obtain a second embedded vector corresponding to the first sample paragraph;
inputting a second sample paragraph in the sample data set into the paragraph sub-model to obtain a third embedded vector corresponding to the second sample paragraph;
Calculating a loss value based on a first similarity between the first embedded vector and the second embedded vector, a second similarity between the first embedded vector and the third embedded vector; and
and adjusting parameters of the query sub-model and the paragraph sub-model based on the loss value.
8. The method of any of claims 1-7, wherein the second retrieval model comprises a recall sub-model and a sort sub-model connected in sequence, the recall sub-model and the sort sub-model each being a large language model,
wherein training a second search model different from the first search model using the literal matching training set to obtain a trained second search model comprises:
pre-training the recall sub-model to be trained by utilizing the literal matching training set and the semantic-based pre-training task;
performing fine tuning on the pre-trained recall sub-model by using a labeling training set to obtain the recall sub-model, wherein the labeling training set comprises manually-labeled matching data;
pre-training the sequencing submodel to be trained by utilizing the pre-training task based on the semantic meaning; and
And fine tuning the pre-trained sorting sub-model by utilizing the literal matching training set and the labeling training set to obtain the sorting sub-model.
9. An information retrieval method, comprising:
obtaining an output paragraph matching the input query of the user using a search model, wherein the search model is trained using the method of any one of claims 1-8.
10. A training device for retrieving a model, comprising:
the segmentation unit is configured to segment at least one first sample paragraph so as to obtain a plurality of clauses;
a literal matching training set generating unit configured to perform the following operations with each of the plurality of clauses as a sample query:
obtaining a second sample paragraph matched with the sample query by using a first retrieval model;
in response to a preset rule being met, taking a first sample paragraph and a second sample paragraph to which the sample query belongs as positive examples and negative examples of the sample query respectively to construct a sample data set, wherein the preset rule comprises that the literal matching degree of the sample query and the first sample paragraph is larger than that of the sample query and the second sample paragraph; and
Placing the sample data set into a literal matching training set; and
a training unit configured to train a second search model different from the first search model using the literal matching training set to obtain a trained second search model.
11. The apparatus of claim 10, wherein the preset rule comprises a degree of literal matching of the sample query and the first sample paragraph being greater than a first preset threshold.
12. The apparatus of claim 11, wherein the literal match comprises an edit distance.
13. The apparatus of any of claims 10-12, wherein the preset rule comprises a degree of semantic matching of the sample query and the second sample paragraph being less than a second preset threshold.
14. The apparatus of any of claims 10-13, wherein the preset rule comprises that the lengths of the first and second sample paragraphs are each within a preset length range.
15. The apparatus of any of claims 10-14, wherein the preset rule comprises the sample query being real query text in a user query log.
16. The apparatus of any of claims 10-15, wherein the second retrieval model comprises a query sub-model and a paragraph sub-model, wherein the training unit comprises:
A first input subunit configured to input a sample query in a sample data set in the literal matching training set into the query sub-model to obtain a first embedded vector corresponding to the sample query;
a second input subunit configured to input a first sample paragraph in the sample data set into the paragraph sub-model to obtain a second embedded vector corresponding to the first sample paragraph;
a third input subunit configured to input a second sample paragraph in the sample data set into the paragraph sub-model to obtain a third embedded vector corresponding to the second sample paragraph;
a calculating subunit configured to calculate a loss value based on a first similarity between the first embedded vector and the second embedded vector, a second similarity between the first embedded vector and the third embedded vector; and
and a parameter tuning subunit configured to adjust parameters of the query sub-model and the paragraph sub-model based on the loss value.
17. The apparatus of any of claims 10-16, wherein the retrieval model comprises a recall sub-model and a sort sub-model connected in sequence, the recall sub-model and the sort sub-model each being a large language model,
Wherein the training unit comprises:
a first pre-training subunit configured to pre-train a recall sub-model to be trained using the literal matching training set and a semantic-based pre-training task;
a first fine tuning unit configured to fine tune a pre-trained recall sub-model using a labeling training set to obtain the recall sub-model, wherein the labeling training set includes manually labeled matching data;
a second pre-training subunit configured to pre-train the ranking sub-model to be trained using the semantic-based pre-training task; and
and the second fine tuning unit is configured to fine tune the pre-trained sorting sub-model by utilizing the literal matching training set and the labeling training set so as to obtain the sorting sub-model.
18. An information retrieval apparatus comprising:
a retrieval unit configured to obtain an output paragraph matching an input query of a user using a retrieval model, wherein the retrieval model is trained using the apparatus of any of claims 10-17.
19. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the method comprises the steps of
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-9.
20. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-9.
21. A computer program product comprising a computer program, wherein the computer program, when executed by a processor, implements the method of any of claims 1-9.
CN202310693790.5A 2023-06-12 2023-06-12 Training method of retrieval model, information retrieval method, device, equipment and medium Pending CN116662512A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310693790.5A CN116662512A (en) 2023-06-12 2023-06-12 Training method of retrieval model, information retrieval method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310693790.5A CN116662512A (en) 2023-06-12 2023-06-12 Training method of retrieval model, information retrieval method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN116662512A true CN116662512A (en) 2023-08-29

Family

ID=87725981

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310693790.5A Pending CN116662512A (en) 2023-06-12 2023-06-12 Training method of retrieval model, information retrieval method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN116662512A (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114416927A (en) * 2022-01-24 2022-04-29 招商银行股份有限公司 Intelligent question and answer method, device, equipment and storage medium
CN115329749A (en) * 2022-10-14 2022-11-11 成都数之联科技股份有限公司 Recall and ordering combined training method and system for semantic retrieval

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114416927A (en) * 2022-01-24 2022-04-29 招商银行股份有限公司 Intelligent question and answer method, device, equipment and storage medium
CN115329749A (en) * 2022-10-14 2022-11-11 成都数之联科技股份有限公司 Recall and ordering combined training method and system for semantic retrieval

Similar Documents

Publication Publication Date Title
CN114443989B (en) Ranking method, training method and device of ranking model, electronic equipment and medium
KR20230006601A (en) Alignment methods, training methods for alignment models, devices, electronic devices and media
CN115114424A (en) Response method and device for query request
CN114547252A (en) Text recognition method and device, electronic equipment and medium
CN116541536B (en) Knowledge-enhanced content generation system, data generation method, device, and medium
CN115600646B (en) Language model training method, device, medium and equipment
CN115862031B (en) Text processing method, neural network training method, device and equipment
CN114219046B (en) Model training method, matching method, device, system, electronic equipment and medium
CN114547270B (en) Text processing method, training method, device and equipment for text processing model
CN112905743B (en) Text object detection method, device, electronic equipment and storage medium
CN115578501A (en) Image processing method, image processing device, electronic equipment and storage medium
CN114238745A (en) Method and device for providing search result, electronic equipment and medium
CN116662512A (en) Training method of retrieval model, information retrieval method, device, equipment and medium
CN115713071B (en) Training method for neural network for processing text and method for processing text
CN115809364B (en) Object recommendation method and model training method
CN115879468B (en) Text element extraction method, device and equipment based on natural language understanding
CN113535958B (en) Production line aggregation method, device and system, electronic equipment and medium
CN114120420B (en) Image detection method and device
CN116956905A (en) Training method and device for text processing model, electronic equipment and medium
CN113656534A (en) Corpus expansion method, apparatus, device and medium
CN114611526A (en) Entity linking method and device, equipment and medium
CN117909235A (en) Code risk detection method, training method and device of deep learning model
CN113887417A (en) Text matching method, device, equipment and medium
CN114169440A (en) Model training method, data processing method, device, electronic device and medium
CN116739136A (en) Data prediction method, device, electronic equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination