Method and apparatus for training model for text retrieval, device, and computer device
The method of constructing a training model for text retrieval enhances the efficiency of troubleshooting and maintenance guidance methods, enabling accurate and efficient text retrieval by parsing a text file into a four-layer document tree, and constructing training samples with relevance labels to train a model for accurate retrieval.
Patent Information
- Application Number
- PCT/CN2024/102941
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2026-01-08
AI Technical Summary
Traditional troubleshooting and maintenance guidance methods require manual operation by experienced technicians, leading to high costs and inefficiencies, while existing text retrieval models lack domain-specific knowledge and struggle with heterogeneous text types, making them ineffective for large-scale and efficient operations.
A method for training a model for text retrieval involving parsing a text file into a four-layer document tree, constructing training samples with relevance labels, and using these samples to train a model for accurate retrieval, including positive and negative pairs to enhance the model's judgment capabilities.
The method enables the construction of a model that accurately retrieves and answers questions, and enhances the effectiveness of text retrieval by improving the model's ability to handle domain-specific and heterogeneous text types, thereby providing better technical support and customer service.
Smart Images

Figure CN2024102941_08012026_PF_FP_ABST
Abstract
Description
METHOD AND APPARATUS FOR TRAINING MODEL FOR TEXT RETRIEVAL, DEVICE, AND COMPUTER DEVICETECHNICAL FIELD
[0001] This application relates to the field of large models, and in particular, to a method and an apparatus for training a model for text retrieval, a computer device, and a storage medium.BACKGROUND
[0002] In modern industrial and commercial environments, troubleshooting and maintenance guidance, as well as technical support and customer service, are crucial. For a user, capabilities to quickly diagnose problems and find accurate solutions are key to improve productivity and efficiency. Meanwhile, the technical support and the customer service are core requirements for many enterprises and organizations. Providing timely and accurate help for customers is crucial for improving customer satisfaction and loyalty. However, traditional troubleshooting and maintenance guidance methods often require experienced technicians to manually operate, which may lead to high cost and time waste. Similarly, the technical support and the customer service also require a significant amount of manpower to handle problems and needs of the customers. Therefore, it is particularly important to find an efficient, accurate, and economic solution.SUMMARY
[0003] This summary is provided to introduce some selected concepts in a simplified form, which will be further described in the following detailed description. This summary is neither intended to identify any key feature or necessary feature of a claimed subject matter, nor intended to help determine the scope of the claimed subject matter.
[0004] Based on this, this application discloses a method for training a model for text retrieval, including:
[0005] parsing a text file and establishing a document tree;
[0006] constructing a training sample according to the document tree, the training sample including a text pair and a relevance label related to the text pair; and
[0007] training a model by using text and the relevance label in the training sample.
[0008] In above way, valid positive and negative training samples can be established, and a relevance label can be labeled for the training samples, so that the model can be configured for text retrieval after being trained by the text and the relevance label in the training sample, and a retrieval result is accurate and effective accordingly.
[0009] Further, the parsing a text file and establishing a document tree includes:
[0010] constructing a four-layer document tree according to the text file, the document tree including a text root layer of a first layer, a document category layer of a second layer, a product category layer of a third layer, and a product mode layer of a fourth layer.
[0011] In above way, construction of a document tree can help classify the text, construct different training samples by using the document tree at a later stage, and label the relevance label of the text pair in the training sample according to a structure of the document tree.
[0012] Further, the operation that the training sample is constructed according to the document tree, the training sample including a text pair and a relevance label related to the text pair includes:
[0013] constructing a positive sample according to the document tree, the positive sample including a question chapter pair; and
[0014] constructing an intra negative pair sample according to the document tree, a chapter of the intra negative pair sample and a chapter of the positive sample belonging to the same product category layer or the same product mode layer.
[0015] In above way, a positive training sample and a negative training sample are systematically and structurally constructed, thereby comprehensively training the model and preparing for later use of the model for text retrieval.
[0016] Further, the operation that the training sample is constructed according to the document tree, the training sample including a text pair and a relevance label related to the text pair includes:
[0017] constructing an inter negative pair sample according to the document tree, the inter negative pair sample including two groups of chapter pairs and a relevance comparison label of the two groups of chapter pairs; or
[0018] constructing the inter negative pair sample according to the document tree, the inter negative pair sample including two groups of randomly selected question chapter pairs and a relevance comparison label of the two groups of question chapter pairs.
[0019] In above way, the chapter pairs and training samples of the random question chapter pairs can be constructed, so as to enrich varieties and types of the training samples and prepare for model training.
[0020] Further, the inter negative pair sample includes two groups of chapter pairs and a relevance comparison label of the two groups of chapter pairs.
[0021] If chapters of a first chapter pair are from the same text and chapters of a second chapter pair are from different text, the relevance comparison label is 1.
[0022] If a layer number of the document tree that the chapters of the first chapter pair belongs is greater than a layer number of the document tree that the chapters of the second chapter pair belongs, the relevance comparison label is 1.
[0023] In above way, the relevance comparison label may be labeled for the training sample, so as to use the training sample for training the model. The model learns different training samples through the chapter pairs and the relevance comparison label related to the chapter pairs, so as to prepare for later retrieval of an accurate answer for the text.
[0024] Further, this application discloses a method for text retrieval, including performing text retrieval by using the model trained by any of the methods above.
[0025] Further, this application discloses an apparatus for training a model for text retrieval, including:
[0026] an establishment module, configured to parse a text file and establish a document tree;
[0027] a construction module, configured to construct a training sample according to the document tree, the training sample including a text pair and a relevance label related to the text pair; and
[0028] a training module, configured to train the model by using text and the relevance label in the training sample.
[0029] This application further provides a computer device, including a memory and a processor. The memory stores a computer program. The processor implements the above-mentioned method when executing the computer program.
[0030] This application further provides a computer-readable storage medium, which stores a computer program therein. The computer program implements the above-mentioned method when executed by a processor.
[0031] This application further provides a computer program product. The computer program product is tangibly stored on a computer-readable medium and includes computer-executable instructions. The computer-executable instructions enable at least one processor to perform the above-mentioned method when executed.BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Implementations of the present disclosure are described in the form of examples rather than limitations in the accompanying drawings, where similar reference signs in the accompanying drawings indicate the same or similar components.
[0033] FIG. 1 is a schematic flowchart of a method for training a model for text retrieval according to an implementation of this application.
[0034] FIG. 2 is a schematic diagram of an apparatus for training a model for text retrieval according to an implementation of this application.
[0035] FIG. 3 is a schematic diagram of a computer device for a method for training a model for text retrieval according to an implementation of this application.
[0036] FIG. 4 is a schematic diagram of an embodiment of a document tree according to an implementation of this application.
[0037] Reference signs are as follows: S101-S103 Steps 200: Apparatus 201: module 202: module 203: module 300: Computer device 302: Processor 304: MemoryDETAILED DESCRIPTION
[0038] Numerous specific details are elaborated in the following specification for the purpose of explanation. However, it may be understood that, implementations of the present disclosure may be implemented without these specific details. In other examples, known circuits, structures, and technologies are not shown in detail, so as not to affect understanding on the specification.
[0039] Citations throughout the specification for "an implementation" , "implementation" , "exemplary implementation" , "some implementations" , "various implementations" and the like indicate that the described implementation of the present disclosure may include specific features, structures, or characteristics. However, it does not necessarily mean that each implementation has to include these specific features, structures, or characteristics. In addition, some implementations may have some or all of the features described for other implementations, or may not have the features described for other implementations.
[0040] A Large Language Model (LLM) is a powerful tool, which can understand questions of users, and generate a corresponding solution by learning from a large amount of text data. However, although the LLM has powerful language capabilities, it may lack specialized knowledge and experience in specific domains when handling specific problems such as troubleshooting and maintenance guidance. For general enterprises or departments, there are often a large number of files, including operation manuals, installation guides, product samples, standard files, maintenance records, and the like. However, in consideration of security, the knowledge may not appear in a general LLM. Therefore, relevant information needs to be quickly searched and extracted from above document data to enhance processing capability of the LLM. For example, a Retrieval-Augmented Generation (RAG) technology is adopted. Specifically, the relevant information may be retrieved from an existing knowledge base or document, and then a more accurate and more detailed answer is generated in combination with a generation capability of the LLM. The answering quality and accuracy of the LLM can be improved by integrating the RAG to provide better technical support and customer service for the users.
[0041] The RAG is an artificial intelligence framework that supplements internal information representation of the LLM by integrating external knowledge sources, thereby improving the quality of generating replies by the LLM. Implementing the RAG in an LLM-based question answering system has the following main advantages: data security, efficiency improvement, and quality control.
[0042] According to current capabilities of the LLM, the LLM still has a capability of generating a correct answer as long as input content truly contains an answer. Therefore, key to implement the above steps is to improve a retrieval capability to help the LLM better complete a specific task in a specific domain.
[0043] However, traditional troubleshooting and maintenance guidance often rely on manual search and document reading, which is time-consuming and error-prone. The technical support and the customer service often need manual processing, which cannot meet the requirements of large-scale and efficient operations.
[0044] Commonly used retrieval methods are mainly based on a lexical level, such as Best Matching 25 (BM25) , or a semantic level, such as sentence embedding. It is difficult to capture semantic information by a method on the lexical level, while a general sentence embedding method also faces challenges when dealing with a heterogeneous text. The heterogeneous text refers to a situation that there is a significant difference between a question and an answer or text types are different. For example, when the question is an interrogative sentence, while the answer is an explanatory passage or multiple sentences, the question and the answer form the heterogeneous text. In addition, these models have not been finely tuned on enterprise data yet, so the validness of these models may be limited.
[0045] Therefore, this application first discloses a method for training a model for text retrieval, including the following steps:
[0046] S101: Parse a text file and establish a document tree.
[0047] The text may refer to text data in a specific domain, which mainly comes from various formats of documents, such as PDF, Word, Excel, and PPT. Especially in an industrial domain, the data mainly includes operation manuals, installation guides, and standard documents. In some embodiments, it is necessary to parse these documents into a plain text format and divide these documents into logical passages by using specific strategies, so as to combine and use the LLM and the RAG in a later stage to obtain more detailed reference paragraphs.
[0048] Further, the operation that the text file is parsed and the document tree is established includes:
[0049] a four-layer document tree is constructed according to the text file. The document tree includes a text root layer of a first layer, a document category layer of a second layer, a product category layer of a third layer, and a product mode layer of a fourth layer. The first layer is a root, which is the most general. As the number of layers increases, the text will be further refined and classified.
[0050] It is to be noted that different enterprises or departments may have different document classification solutions, so as to lead to differences in constructed document trees. However, general methods are consistent.
[0051] S102: Construct a training sample according to the document tree, the training sample including a text pair and a relevance label related to the text pair.
[0052] The training sample mainly includes the text pair and the relevance label related to the text pair. The text pair may alternatively be referred to as a question chapter pair, or a question passage pair. Specifically, after the text document is parsed into atomic passages, relevant data will be extracted for retrieval model training in this part. This mainly involves extracting common Question &Passage (QP) pairs, which may alternatively be referred to as pairs formed by questions and chapters. A document may be formed by using a Chat Generative Pre-trained Transformer (ChatGPT) or other large models in corresponding QP formats. In summary, in this application, a question may be generated by directly using an atomic passage-based LLM, and a QP pair formed by the generated question and the atomic passage is created.
[0053] In some embodiments, the text pair includes the heterogeneous text formed by the above- mentioned answer and question. Specifically, the text pair may include a question answer pair formed by a question and an answer, or may be referred to as a question chapter pair. The text pair may alternatively include a chapter pair formed by chapters. In this application, different text pairs are used in different embodiments as follows to deal with different training purposes and training scenarios. Finally, the model can accurately retrieve the text.
[0054] In this application, a positive training sample and a negative training sample need to be constructed. The model has more accurate judgment by training the model through different training samples.
[0055] Specifically, there are often dozens or even hundreds of documents in the above-mentioned QP formats for general enterprises or departments. To facilitate construction of the training sample, it is necessary to organize these documents into a multilayer document tree for later use. In some embodiments, this document tree may include a text root layer (or referred to as a root node) , a document category layer, a product category layer, and a product mode layer.
[0056] Further, the operation that the training sample is constructed according to the document tree, the training sample including the text pair and the relevance label related to the text pair includes:
[0057] a positive sample is constructed according to the document tree, the positive sample including a question chapter pair;
[0058] an intra negative pair sample is constructed according to the document tree, a chapter of the intra negative pair sample and a chapter of the positive sample belonging to the same product category layer or the same product mode layer.
[0059] The positive sample includes a question Q and a chapter P of an answer corresponding to the question. A chapter P'of the intra negative pair sample is not the chapter of a correct answer corresponding to a question Q'in the intra negative pair sample, so the intra negative pair sample is referred to as a negative sample. The chapter P'may be selected from the same product category layer that an originally correct chapter P belongs or extracted from other documents of the product mode layer. Therefore, relevance between the question Q'a nd the chapter P'will vary with different selections of the chapter P'. This application aims to construct a training sample with QP pairs with differences, so that the model is trained through these different training samples subsequently, thereby effectively applying the model to text retrieval.
[0060] Further, the operation that the training sample is constructed according to the document tree, the training sample including the text pair and the relevance label related to the text pair includes:
[0061] an inter negative pair sample is constructed according to the document tree, the inter negative pair sample including two groups of chapter pairs and a relevance comparison label of the two groups of chapter pairs; or
[0062] the inter negative pair sample is constructed according to the document tree, the inter negative pair sample including two groups of randomly selected question chapter pairs and a relevance comparison label of the two groups of question chapter pairs.
[0063] The chapter pair is a pair formed by two chapters. A reason is that passage text semantically similar to a passage of text will be retrieved according to this passage of text in subsequent text retrieval. Therefore, the training sample of the chapter pair is constructed for text retrieval of a later model.
[0064] Further, the inter negative pair sample includes two groups of chapter pairs and a relevance comparison label of the two groups of chapter pairs.
[0065] If chapters of a first chapter pair are from the same text and chapters of a second chapter pair are from different text, the relevance comparison label is 1.
[0066] If a layer number of the document tree that the chapters of the first chapter pair belongs is greater than a layer number of the document tree that the chapters of the second chapter pair belongs, the relevance comparison label is 1.
[0067] In some embodiments, the relevance comparison label may be represented by 1 or 0. Where, 1 represents that relevance of the first chapter pair is higher than that of the second chapter pair. On the contrary, when the relevance of the first chapter pair is lower than that of the second chapter pair, the relevance comparison label may be represented by 0.
[0068] S103: Train a model by using text and the relevance label in the training sample.
[0069] Specifically, the model is trained by using the constructed training sample mentioned above and applying some loss functions. Finally, a model with accurate judgment can be obtained.
[0070] Further, this application discloses a method for text retrieval, including the following step: text retrieval is performed by using the model trained by any of the methods mentioned above.
[0071] Main methods for training the model mentioned above will be further introduced in this section. To maintain the integrity of the entire method, this section will include the following parts: parsing of a text document in a specific domain, establishment of a document tree, construction of a training sample and a loss function, and model training and experimental results.
[0072] In some embodiments, the document tree in an example is formed by four layers. A first layer is a root node, a second layer is a file category layer, a third layer is a product category layer, and a fourth layer is a product mode layer. As shown in FIG. 4, leaf nodes labeled as d1, d2, and the like are documents including different QP pairs. Numbers on the right of these nodes are identifiers allocated to these leaf nodes, which mainly facilitate reference in subsequent description.
[0073] Further, the construction of the training sample and the loss function refers to that samples for model training need to be constructed in this application after the document tree is established. The samples in this application are classified into two types, that is, intra pair samples and inter pair samples. Certainly, these two types of samples correspond to different loss functions, which will be elaborated in detail hereinbelow:
[0074] (1) Construction of the intra pair sample
[0075] For the construction of this type of samples, a sample format of this application is (Q, P, Label) , where a value of the label is 1 or 0. Where, 1 represents relevance, and 0 represents irrelevance.
[0076] The samples may include all positive QP pairs extracted from the document tree in a last step, and labels of all QP pairs are set as 1. Then, several hard negative samples need to be generated for each positive QP pair in this application, so that the model can better distinguish between relevance and irrelevance by the solution of this application.
[0077] Specifically, for one QP pair, in this application, all P peer nodes or sub-nodes of the peer nodes of the nodes of the tree where the QP pair is located according to the BM25 method by taking P as a query condition, so as to find K Ps, namely, P1, P2, ..., Pk, and then K QP pairs are formed as hard negative samples with Q.
[0078] For example, P in node 8 may be retrieved according to the QP pair in node 7, as shown in FIG. 4 where two labeled leaf nodes belong to the same rectangle. Ps in node 9, node 10, and node 11 may be retrieved according to the QP pair in node 3, as shown in the rectangle in FIG. 4. This is mainly to ensure that there is relevance between an original P and a retrieved Pk. Both the original P and the retrieved Pk belong to a product category or a product mode, but actual contents are irrelevant, so as to construct the hard negative sample.
[0079] (2) Construction of the inter pair sample
[0080] To construct such samples, this application will consider the following two sample formats: (P1P1', P2P2', Label) and (Q1P1, Q2P2, Label) . P1P1' and P2P2' are four randomly extracted Ps, and the labels may be 1 or 0. Where 1 represents that P1P1' is more relevant than P2P2', and 0 represents that P1P1' is less more relevant than P2P2'. Similarly, Q1 and Q2 are two randomly extracted Qs, and P1 and P2 are two randomly extracted Ps. Where 1 represents that Q1P1' is more relevant than Q2P2, and 0 represents that Q1P1' is less relevant than Q2P2.
[0081] For the value of the label, this application follows in the following principles:
[0082] For (P1P1', P2P2', Label) :
[0083] If one PP pair is in the same document and the other PP pair is in different documents, the relevance of the PP pair in the same document is greater than the relevance of the PP pair in different documents.
[0084] If all PP pairs are in different documents, the relevance of the PP pair located in a node with a deeper minimum common ancestor node is greater than the relevance of the PP pair in a node with a shallower minimum common ancestor.
[0085] For (Q1P1', Q2P2', Label) :
[0086] If both QP pairs are in the same document, the relevance of an initially matched QP pair is greater than the relevance of an unmatched QP pair. In other words, the relevance of the positive QP pair is greater than the relevance of the negative QP pair.
[0087] If one PP pair is located in the same document and the other PP pair is located in different documents, it is considered that the relevance of the PP pair located in the same document is greater than the relevance of the PP pair located in different documents.
[0088] If both QP pairs are in different documents, the relevance of the QP pair located in a node with a deeper minimum common ancestor node is greater than the relevance of the QP pair in a node with a shallower minimum common ancestor.
[0089] For example, in an elliptical wireframe area in FIG. 4, if one Q1P1 is from d8 and d12 and the other Q2P2 is from d6 and d11, at this moment, a common ancestor node is Total Domain Docs, a minimum common ancestor node depth of the node where d8 and d12 are located is 2, a minimum common ancestor node depth of the node where d6 and d11 are located is 3, and it can be obtained that Q2P2 is more relevant than Q1P1. This is because the deeper the node, the finer the division of the document, that is, the higher the relevance.
[0090] In addition, for a model loss function, two types of loss functions need to be used in this application due to different training samples:
[0091] -Intra loss: In this application, a common contrastive learning loss function may be directly used, for example, InfoNCE loss and NCE loss, and a negative sample is combined to better capture the relevance between sentence representation and a retrieval task.
[0092] -Inter loss: For an inter-sentence sample, in this application, cosine loss may be used for learning the structural relevance represented by a sentence in the document.
[0093] In some embodiments, iterative training may be performed by using the above-mentioned loss function in this application, that is, a type of training samples are trained first, and then the other type of training samples are trained. In some embodiments, joint training may alternatively be performed, that is, training is performed by using the two above-mentioned loss functions at the same time.
[0094] The method in this application cannot only capture of the relevance in the retrieval task and the relevance of a document structure can also be learned, so the method is suitable for retrieval tasks such as RAG and Frequently-Asked Questions (FAQ) . Therefore, this application elaborates a set of complete vertical domain LLM implementation plan and provides a tree-based domain text representation solution. The solution may be applied to various text matching scenarios, for example, RAG and FAQ, in a specific domain, and the effectiveness of this solution is verified. Although only a small number of samples are tested, the effectiveness and feasibility of the solution of this application are described.
[0095] In this application, the following methods may be used for detecting whether the solution of this application is used or not.
[0096] First, some key words are checked, for example, LLM, RAG, external knowledge, langchain, text retrieval, text recall, QA, and FAQ. Then, similarities and differences of the solution is compared in detail to confirm whether the solution is used.
[0097] In addition, this application further discloses an effective and feasible document tree-based text retrieval solution. A model is trained by the above-mentioned model training method to enhance the effectiveness of the RAG. This solution may alternatively be applied to other text matching scenarios, such as the FAQ.
[0098] It is to be understood that, although each step of the flowcharts in FIG. 1 is displayed sequentially according to arrows, the steps are not necessarily performed according to an order indicated by arrows. Unless otherwise explicitly specified in this application, execution of the steps is not strictly limited, and the steps may be performed in other sequences. Moreover, at least part of the steps in FIG. 1 may include a plurality of steps or a plurality of stages. These steps or stages are not necessarily performed at the same time, but may be performed at different times. These steps or stages are not necessarily performed sequentially, but may be performed in turn or alternately with other steps or at least part of steps or stages in other steps.
[0099] FIG. 2 provides an apparatus 200 for training a model for text retrieval. The apparatus 200 includes:
[0100] an establishment module 201, configured to parse a text file and establish a document tree;
[0101] a construction module 202, configured to construct a training sample according to the document tree, the training sample including a text pair and a relevance label related to the text pair; and
[0102] a training module 203, configured to train a model by using text and the relevance label in the training sample.
[0103] It is to be noted that the apparatus may include more or fewer modules to realize the described functions. For example, at least one module in FIG. 2 may be further divided into a plurality of different submodules. Each submodule is configured to perform at least a part of operations described in combination with corresponding modules here. In addition, in some examples, the apparatus 200 may further include additional modules, configured to perform other operations that have been described in the specification. In addition, those skilled in the art may understand that the exemplary apparatus 200 may be implemented by using software, hardware, firmware, or any combination thereof.
[0104] FIG. 3 provides a computer device. According to an implementation, the computer device 300 may include a processor 302. The processor 302 executes a computer program stored in a memory 304. The computer program implements the above-mentioned method when executed by the processor.
[0105] Those skilled in the art may understand that the structure shown in FIG. 3 is only a block diagram of a partial structure related to a solution in this application, and does not constitute a limitation to the computer device to which the solution in this application is applied. A specific computer device may include more or fewer parts than those shown in the figure, or combine some parts, or have a different part deployment.
[0106] Those skilled in the art may understand that all or some of procedures of the method in the above-mentioned implementations may be completed by a computer program instructing relevant hardware. The computer program may be stored in a non-volatile computer-readable storage medium. When the computer program is executed, the procedures of the implementations of various methods mentioned above may be included. Any reference to a memory, storage, a database, or other media used in various implementations provided in this application may include at least one of a non-volatile memory or a volatile memory. The non-volatile memory may include a Read-Only Memory (ROM) , a magnetic tape, a floppy disk, a flash memory, an optical storage, or the like. The volatile memory may include a Random Access Memory (RAM) or an external cache. As a description rather than a limitation, the RAM may be in a variety of forms such as a Static Random Access Memory (SRAM) or a Dynamic Random Access Memory (DRAM) .
[0107] This application further provides a computer-readable storage medium, which stores a computer program therein. The computer program implements the steps described above when executed by a processor.
[0108] This application further provides a computer program product. The computer program product is tangibly stored on a computer-readable medium and includes computer-executable instructions. The computer-executable instructions enable at least one processor to perform the above-mentioned method when executed.
[0109] Further, the computer program may be stored and run in a cloud to perform the method. Further, parts of the program may be laid out in a plurality of devices or clouds, for example, corresponding steps may be laid out or run in a local or native computer, or run in different cloud devices to transmit signals through communication connection, or may be laid out or run in a local or native computer. This application does not limit the mode or method, may flexibly lay out or deploy corresponding technologies, and fully use devices and technologies such as a cloud, big data, and supercomputing power to perform and complete the method.
[0110] Some implementations of the present disclosure may include products. The products may include a storage medium, which is configured to store logic. An example of the storage medium may include one or more types of computer-readable storage media that can store electronic data, including a volatile memory or a non-volatile memory, a removable or non-removable memory, an erasable or non-erasable memory, a writable or rewritable memory, and the like. An example of the logic may include various software units such as software parts, programs, applications, computer programs, application programs, system programs, machine programs, operating system software, middleware, firmware, software modules, routines, subroutines, functions, methods, processes, software interfaces, Application Program Interfaces (APIs) , instruction sets, computing code, computer code, code segments, computer code segments, words, values, symbols, or any combination thereof. In some implementations, for example, the products may store executable computer program instructions. The executable computer program instructions enable a processor to perform the method and / or operations described herein when executed by the processor. The executable computer program instructions may include any suitable type of code, such as source code, compiled code, interpreted code, executable code, static code, and dynamic code. The executable computer program instructions may be implemented according to predefined computer languages, modes, or syntax for commanding a computer to perform specific functions. The instructions may be implemented by using any appropriate high-level, low-level, object-oriented, visual, compiled, and / or interpreted programming language.
[0111] An example including a disclosed architecture has already been described above. Certainly, it is not possible to describe every conceivable combination of parts and / or methods, but those skilled in the art may understand that many other combinations and arrangements are feasible. Therefore, this novel architecture is intended to cover all such substitutions, modifications, and variations that fall within the spirit and scope of attached claims.
Claims
1.A method (100) for training a model for text retrieval, comprising:parsing a text file and establishing a document tree;constructing a training sample according to the document tree, the training sample comprising a text pair and a relevance label related to the text pair; andtraining a model by using text and the relevance label in the training sample.2.The method (100) according to claim 1, wherein the parsing a text file and establishing a document tree comprises:constructing a four-layer document tree according to the text file, the document tree comprising a text root layer of a first layer, a document category layer of a second layer, a product category layer of a third layer, and a product mode layer of a fourth layer.3.The method (100) according to claim 2, wherein the constructing a training sample according to the document tree, the training sample comprising a text pair and a relevance label related to the text pair comprises:constructing a positive sample according to the document tree, the positive sample comprising a question chapter pair; andconstructing an intra negative pair sample according to the document tree, a chapter of the intra negative pair sample and a chapter of the positive sample belonging to the same product category layer or the same product mode layer.4.The method (100) according to claim 2, wherein the constructing a training sample according to the document tree, the training sample comprising a text pair and a relevance label related to the text pair comprises:constructing an inter negative pair sample according to the document tree, the inter negative pair sample comprising two groups of chapter pairs and a relevance comparison label of the two groups of chapter pairs; orconstructing the inter negative pair sample according to the document tree, the inter negative pair sample comprising two groups of randomly selected question chapter pairs and a relevance comparison label of the two groups of question chapter pairs.5.The method (100) according to claim 4, the inter negative pair sample comprising two groups of chapter pairs and a relevance comparison label of the two groups of chapter pairs, whereinif two chapters of a first chapter pair are from the same text and two chapters of a second chapter pair are from different text, the relevance comparison label is 1; orif a layer number of the document tree that the chapters of the first chapter pair belongs is greater than a layer number of the document tree that the chapters of the second chapter pair belongs, the relevance comparison label is 1.6.A method for text retrieval, comprising: performing text retrieval by using the model trained by the method according to any of claims 1 to 5.7.An apparatus (200) for training a model for text retrieval, comprising:an establishment module (201) , configured to parse a text file and establish a document tree;a construction module (202) , configured to construct a training sample according to the document tree, the training sample comprising a text pair and a relevance label related to the text pair; anda training module (203) , configured to train a model by using text and the relevance label in the training sample.8.A computer device, comprising a memory and a processor, the memory storing a computer program, wherein the processor implements steps of the method according to any of claims 1 to 6 when executing the computer program.9.A computer-readable storage medium, having a computer program stored therein, wherein the computer program implements steps of the method according to any of claims 1 to 6 when executed by a processor.10.A computer program product, the computer program product being tangibly stored in a computer-readable medium and comprising computer-executable instructions, and the computer-executable instructions enabling at least one processor to perform the method according to any of claims 1 to 6 when executed.
Citation Information
Patent Citations
Online intelligent question answering method and device based on instruction fine tuning and retrieval enhancement generation
CN117688163A
Answer text generation method and device, electronic equipment and computer medium
CN118193690A
Determining relevance of a term to content using a combined model
US20080103886A1
Providing QA training data and training a QA model based on implicit relevance feedbacks
WO2021146003A1
Cited By
Paper evidence-based question and answer optimization method based on semantic segmentation
CN122045354A