Large model knowledge retrieval method and device, medium, electronic equipment and program product
By segmenting the knowledge document to generate text segments and building a high-information concentration index, the problem of insufficient context in understanding and generating replies by large language models is solved, and the accuracy and completeness of the output is improved.
Patent Information
- Application Number
- CN202510963708.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-11
- Publication Date
- 2025-08-15
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing large language models lack sufficient context in understanding and generating replies, resulting in too scattered or too broad search results, affecting output accuracy.
By segmenting the knowledge document, generating text segments, and building indexes with higher information concentration, these indexes are used to retrieve and recall target text segments as the context of the big model to improve information integrity.
Improves the accuracy and contextual integrity of the big model's response generation, ensuring that the output information is concentrated and relevant.
Smart Images

Figure CN120492594A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of computer technology and large model technology, and in particular to a large model knowledge retrieval method, device, medium, electronic device and program product. Background Art
[0002] The context of a large model, also known as a large language model (LLM), refers to the information that the large language model relies on when understanding and generating responses to user questions. Therefore, the context affects the large language model's understanding of the question and its output. Summary of the Invention
[0003] This summary is provided to briefly introduce concepts that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0004] In a first aspect, the present disclosure provides a large model knowledge retrieval method, comprising: Get the target question; According to the target question, a target index matching the target question is retrieved from an index library, wherein the index library includes a plurality of indexes, each index uniquely corresponding to a text segment, the text segment being obtained by segmenting the corresponding knowledge document, and the index corresponding to the text segment including a first index, the first index being used to describe a segmentation result obtained by segmenting the corresponding text segment; Recalling a target text segment from all the text segments based on the target index; The target text segment is determined as a target context for the target question, wherein the target context is used by the large model to generate a target answer to the target question.
[0005] In a second aspect, the present disclosure provides a large model knowledge retrieval device, comprising: The first acquisition module is used to obtain the target question; A retrieval module is configured to retrieve a target index matching the target question in an index library according to the target question, wherein the index library includes a plurality of indexes, each index uniquely corresponding to a text segment, the text segment being obtained by segmenting the corresponding knowledge document, and the index corresponding to the text segment including a first index, the first index being used to describe a segmentation result obtained by segmenting the corresponding text segment; a recall module, configured to recall a target text segment from all the text segments based on the target index; A first determination module is configured to determine the target text segment as a target context for the target question, wherein the target context is used by the large model to generate a target response to the target question.
[0006] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which implements the steps of the method described in the first aspect when executed by a processing device.
[0007] In a fourth aspect, the present disclosure provides an electronic device, comprising: a storage device having a computer program stored thereon; A processing device is used to execute the computer program in the storage device to implement the steps of the method described in the first aspect above.
[0008] In a fifth aspect, the present disclosure provides a computer program product, comprising a computer program, which implements the steps of the method described in the first aspect when executed by a processor.
[0009] Through the above technical solution, text segmentation is obtained by segmenting the corresponding knowledge document, and the index uniquely corresponds to a text segment. Furthermore, the first index corresponding to the text segment is used to describe the segmentation result obtained by segmenting the corresponding text segment. Therefore, the information concentration of the first index is higher than the information concentration of the text segment. On this basis, the target index matching the target question is retrieved based on the first index with higher information concentration, which can improve the accuracy of the hit; further, the target text segment containing more information than the target index is recalled based on the target index, and the target text segment is determined as the target context of the target question, thereby improving the completeness of the context on which the large model relies to generate the response to the target question.
[0010] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The above and other features, advantages and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale. In the drawings: Figure 1 is a flowchart of a large model knowledge retrieval method according to an embodiment of the present disclosure; Figure 2 is a schematic diagram of a large model knowledge retrieval process according to an embodiment of the present disclosure; Figure 3 is a flowchart illustrating a method of constructing an index according to an embodiment of the present disclosure; Figure 4 is a schematic diagram of a preprocessing process according to an embodiment of the present disclosure; Figure 5 is a block diagram of a large model knowledge retrieval device according to an embodiment of the present disclosure; Figure 6 It is a structural diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0012] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0013] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0014] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.
[0015] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0016] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0017] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0018] It is understandable that before using the technical solutions disclosed in the various embodiments of this disclosure, the type, scope of use, usage scenarios, etc. of the personal information involved in this disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0019] For example, in response to a user's active request, a prompt message is sent to the user to clearly inform the user that the operation requested will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the electronic device, application, server, storage medium, or other software or hardware that performs the operations of the disclosed technical solution based on the prompt message.
[0020] As an optional but non-limiting implementation, in response to receiving a user's active request, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. Furthermore, the pop-up window may also contain a selection control for the user to select "agree" or "disagree" to provide personal information to the electronic device.
[0021] It is understandable that the above notification and user authorization process are merely illustrative and do not limit the implementation of the present disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0022] At the same time, it is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0023] When processing natural language tasks, the Large Language Model (LLM) can simultaneously leverage retrieved external knowledge and its own generative capabilities to generate more accurate and richer responses. This external knowledge serves as the context that the LLM relies on when understanding and generating responses to user questions. As described in the background technology above, this context influences the LLM's understanding of questions and its output.
[0024] In related technologies, the retrieval results of external knowledge are either too scattered, resulting in the large language model lacking sufficient context to interpret the problem; or too broad, causing context overload and low accuracy of the retrieval results, thereby affecting the language model's understanding of the problem and the output of the large language model.
[0025] In view of this, the present disclosure provides a large model knowledge retrieval method, apparatus, medium, electronic device, and program product. The present disclosure is further explained and illustrated below with reference to the accompanying drawings.
[0026] Figure 1This is a flow chart of a large model knowledge retrieval method according to an embodiment of the present disclosure. The large model knowledge retrieval method can be applied to electronic devices. The large model knowledge retrieval method can be executed by a large model knowledge retrieval device, wherein the large model knowledge retrieval device can be implemented by software and / or hardware, and the software and / or hardware can be configured in the electronic device. Figure 1 The large model knowledge retrieval method may include step 110, step 120, step 130 and step 140.
[0027] In step 110 , a target question is obtained.
[0028] The target question may be a question input by the user. For example, the user may input the question "What is Einstein's theory of relativity?"
[0029] In step 120, based on the target question, a target index matching the target question is retrieved in the index library, wherein the index library includes multiple indexes, each index uniquely corresponds to a text segment, and the text segment is obtained by segmenting the corresponding knowledge document. The index corresponding to the text segment includes a first index, and the first index is used to describe the segmentation result obtained by segmenting the corresponding text segment.
[0030] The knowledge document can be a plain text document, and each text segment has complete semantic information. The text segmentation can be obtained by preprocessing the knowledge document, which preprocessing includes at least segmentation. For the preprocessing of the knowledge document, please refer to the following related embodiments, which will not be described in detail in this embodiment.
[0031] The index corresponding to the text segment includes at least one first index. The number of first indexes depends on the number of segmentation results obtained by segmenting the text segment, and each segmentation result uniquely corresponds to a first index. It is worth noting that since the segmentation results are sentence-level results, the information concentration of the first index is greater than that of the text segment. This makes the information concentration of the first index constructed based on the segmentation results higher than that of the index constructed based on the text segment, which can provide a data basis for improving hit accuracy.
[0032] The target index can be determined based on the matching degree between the target question and each index in the index library. The index with the higher matching degree is given priority as the target index. The method of determining the target index based on the matching degree can be referred to the following related embodiments, which will not be described in detail in this embodiment.
[0033] In step 130 , a target text segment is retrieved from all text segments based on the target index.
[0034] In some examples, the target text segment may include a first text segment; in some other examples, the target text segment may include a first text segment and a second text segment, and the second text segment is adjacent to the first text segment in the corresponding knowledge document. The user can determine whether the target text segment includes the second text segment by turning on or off the third index enhancement function. It can be understood that the third index enhancement function is used to expand the amount of information of the context on which the large model relies when outputting the target reply. For example, the user can determine whether to turn on the third index enhancement function based on the amount of information of the text segment, and the amount of information of the text segment can be measured based on the number of characters in the text segment. Furthermore, when the number of characters is set to be small, the user can turn on the third index enhancement function; when the number of characters is set to be large, the user can turn off the third index enhancement function, thereby balancing the information completeness of the context on which the large model relies to generate the reply and the amount of computation required for the large model to generate the reply.
[0035] Based on the above, step 130 may be implemented in the following manner: based on the target index, recalling the first text segment corresponding to the target index from all text segments; determining that the third index enhancement function is not enabled; and determining the first text segment as the target text segment.
[0036] Based on the above, step 130 can be implemented in the following manner: based on the target index, recall the first text segment corresponding to the target index from all text segments; determine that the third index enhancement function is turned on; recall the second text segment from all text segments; and determine the first text segment and the second text segment as the target text segment. Among them, all text segments can be maintained in a knowledge base, and based on the correspondence between the index and the text segment, the text segment corresponding to the target index can be recalled from all text segments, and this text segment is the first text segment. Furthermore, based on the position of the text segment in the knowledge document, a text segment adjacent to the first text segment can be determined, and this text segment is used as the second text segment.
[0037] In step 140 , the target text segment is determined as a target context of the target question, wherein the target context is used by the large model to generate a target answer to the target question.
[0038] Continuing with the example of the target question being "What is Einstein's theory of relativity", the target text segmentation can be the text segmentation of keywords such as "Einstein" and "relativity".
[0039] As an example, the big model can provide a prompt word, fill the target context and target question into the prompt word, and thus obtain the question text. The big model understands the target question based on the question text, and thus generates a target response.
[0040] Figure 2This is a schematic diagram of the process of large model knowledge retrieval according to an embodiment of the present disclosure. Figure 2 , preprocesses the knowledge document to obtain multiple text segments; then, segments the text segments to obtain different segmentation results. Based on each segmentation result, a corresponding index is constructed. This index is a vector representation of the corresponding segmentation result. Based on this, a vector representation of the target question entered by the user is obtained. The target index is retrieved from the index based on the vector representation. The target text segment is then recalled based on the target index. The large model generates a target response to the target question based on the target question and its target context, and feeds this target response back to the user.
[0041] Through the above technical solution, text segmentation is obtained by segmenting the corresponding knowledge document, and the index uniquely corresponds to a text segment. Furthermore, the first index corresponding to the text segment is used to describe the segmentation result obtained by segmenting the corresponding text segment. Therefore, the information concentration of the first index is higher than the information concentration of the text segment. On this basis, the target index matching the target question is retrieved based on the first index with higher information concentration, which can improve the accuracy of the hit; further, the target text segment containing more information than the target index is recalled based on the target index, and the target text segment is determined as the target context of the target question, thereby improving the completeness of the context on which the large model relies to generate the response to the target question.
[0042] In some embodiments, the first index can be obtained by: obtaining text segments; denoising the text segments to obtain denoised text segments; determining that the first index enhancement function is turned on; segmenting the denoised text segments to obtain segmentation results; constructing the first index based on the segmentation results, and storing the first index in the index library.
[0043] The first index enhancement function may be manually configured to be enabled or disabled.
[0044] Denoising is used to remove interference information in the text segment to ensure that the constructed index is semantically sound. For example, interference information in the text segment may be links.
[0045] Among them, the first index is constructed based on the corresponding segmentation result. From the above content, it can be seen that the first index can be the vector representation corresponding to the segmentation result, or the first index can also be a keyword in the segmentation result, etc.
[0046] Figure 3 This is a flowchart of constructing an index according to an embodiment of the present disclosure, referring to Figure 3If it is determined that the first index enhancement function is turned on, the denoised text segments are segmented to obtain segmentation results, and based on each segmentation result, the first index corresponding to each segmentation result is constructed, and the first index is stored in the index library; if it is determined that the first index enhancement function is not turned on, the corresponding index is constructed based on the denoised text segments, and the index is stored in the index library.
[0047] In this way, regardless of whether the first index enhancement function is enabled or not, a corresponding index can be created to improve the richness of the index, thereby increasing the possibility of providing context for the large language model.
[0048] In some embodiments, similar to the first index, the index corresponding to the denoised text segment can be a vector representation corresponding to the text segment, or a keyword in the text segment, etc.
[0049] In some embodiments, the step of segmenting the denoised text segments to obtain segmentation results may be implemented in the following manner: segmenting the denoised text segments according to the data type to which the denoised text segments belong to obtain segmentation results.
[0050] Among them, the data type of the text segment can be ordinary text and table. For ordinary text, the text segment can be segmented according to the set delimiter, which can be, for example, "\n\n", ".", "," and "."; for a table, a table usually includes a header and a body. The header is the first row (or the first column) of the table, which is used to describe the meaning of the data in each row (or each column) of the table. The body is the part of the table other than the header, usually other rows (or other columns) except the first row (or the first column). The body represents the actual data record. The data in each row (or each column) usually represents a record, and the data in each row (or each column) represents the value of a field. Therefore, it can be segmented by rows or columns, and each segmentation result includes not only the header in the table, but also the body corresponding to a row or a column.
[0051] In some embodiments, the index corresponding to the text segment also includes a second index, and the second index is obtained in the following manner: determining that the second index enhancement function is turned on; generating questions based on the denoised text segment, wherein the questions are used to characterize questions that can be asked based on the denoised text segment; constructing a second index based on the questions, and storing the second index in the index library.
[0052] The text generation model can be called upon to generate questions based on the denoised text segments. The text generation model can be obtained by pre-training. For example, sample text segments and sample questions are obtained, and training is performed based on the sample text segments and sample questions to obtain the text generation model. It is understood that the explanation and description of the sample text segments and sample questions can refer to the explanation and description of the text segments and questions described above, and this embodiment will not be repeated here.
[0053] In some embodiments, similar to the first index enhancement function, the second index enhancement function can be manually configured. Figure 3 In the example shown, after constructing the first index or the index corresponding to the denoised text segment, it is determined whether the second index enhancement function is turned on. If so, a question is generated based on the denoised text segment, a second index is constructed based on the question, and the second index is stored in the index library. If not, the construction of this index is terminated.
[0054] In this way, the index library includes not only the first-category index (such as the first index, or the index corresponding to the denoised text segment), but also the second index, thereby improving the richness of the index.
[0055] In some embodiments, the method further includes the following steps: obtaining a knowledge document; segmenting the knowledge document to obtain multiple initial text blocks of the knowledge document; traversing the multiple initial text blocks in sequence according to their positions in the knowledge document until all initial text blocks have been traversed; when the character length of the traversed initial text block is greater than a preset character length, taking the first character of the initial text block as the starting position, cutting off a sub-text segment of the initial text block that does not exceed the preset character length as a text segment, and using the remaining part after cutting off the sub-text segment as a new initial text block.
[0056] In this embodiment, the knowledge document segmentation process may be performed according to at least one of the following rules: Segmentation rules based on layout; Segmentation rules based on user-defined delimiters.
[0057] As an example, when following the layout-based segmentation rule, the knowledge document is segmented based on the layout, and the title, body paragraphs, pictures, and tables in the knowledge document are segmented into independent initial text blocks.
[0058] As an example, when a segmentation rule based on a user-defined separator is used, the knowledge document is segmented based on the user-defined separator to obtain independent initial text blocks, wherein the user-defined separator can be specified by the user.
[0059] As an example, when following the segmentation rules based on layout and the segmentation rules based on user-defined delimiters, the knowledge document can be segmented for the first time based on the layout; on this basis, the segmentation results of the first segmentation are segmented for the second time based on the segmentation rules based on user-defined delimiters, thereby obtaining independent initial text blocks.
[0060] In this embodiment, after the initial text blocks are obtained by segmentation, the initial text blocks are traversed to merge or further segment the initial text blocks.
[0061] For example, when the character length of the traversed initial text block is greater than the preset character length, the first character of the initial text block is used as the starting position, and a sub-text segment of the initial text block that does not exceed the preset character length is cut off as a text segment, and the remaining part after cutting off the sub-text segment is used as a new initial text block; when the character length of the traversed initial text block is less than the preset character length, other initial text blocks are merged downward until any of the following preset stop merging conditions is met, wherein the merged result is used as a text segment; when the character length of the traversed initial text block is equal to the preset character length, it can be directly used as a text segment.
[0062] Among them, the preset character length is the maximum character length of the set text segment. Since the text segment will be recalled as the target context of the target question, in order to avoid the breadth of information, it is necessary to reasonably set the maximum character length of the text segment. Therefore, when the character length of the initial text block is greater than the preset character length, the initial text block needs to be further truncated according to the preset character length. When truncating, the semantic integrity and the maximum character length of the text segment can be considered at the same time. With the first character of the initial text block as the starting position, the sub-text segment of the initial text block that does not exceed the preset character length and is semantically complete is intercepted as a text segment, and the remaining part after the sub-text segment is intercepted is used as the new initial text block to participate in the next round of merging or segmentation.
[0063] As an example, the preset stop merging condition includes that the initial text block is obtained based on the segmentation rule of the user-defined delimiter, and the next initial text block of the currently traversed initial text block contains the user-defined delimiter. It can be understood that when the next initial text block contains the user-defined delimiter, it represents that the user tends to treat the initial text block containing the user-defined delimiter as a separate text segment. Therefore, in this case, the next initial text block should not be merged with the currently traversed initial text block.
[0064] As an example, the preset stop merging condition includes that the initial text block is obtained based on the segmentation rules of the layout, and the next initial text block of the currently traversed initial text block is an initial text block of a preset type, and the initial text block of the preset type is that the user tends to treat it as an independent text segment. The preset type can be, for example, a title type. It is understandable that in layout segmentation, the content corresponding to different titles tends to be treated as an independent text segment. Therefore, when segmentation is based on the layout and the next initial text block is an initial text block of the title type, the next initial text block should not be merged with the currently traversed initial text block.
[0065] For example, the preset merging stop condition includes the character length of the merged result of the currently traversed initial text block and the initial text block next to the initial text block exceeding the preset character length. To avoid information bloating, it is necessary to ensure that the character length of each text segment does not exceed the preset character length. Therefore, if the character length of the merged result exceeds the preset character length, the merge will not be performed.
[0066] In some embodiments, the above pre-processing may further include cleaning. Therefore, after obtaining the text segments, the text segments may be cleaned to remove interference information in the text segments, such as removing spaces in the text segments.
[0067] In some embodiments, the above pre-processing can also include AutoContext (automatic context injection). Therefore, after obtaining text segments, AutoContext technology can be used to inject document-level context information into the text segments, enabling them to better capture the content and meaning of the text, thereby improving retrieval accuracy.
[0068] Figure 4 FIG. 1 is a schematic diagram of a pre-processing process according to an embodiment of the present disclosure. Figure 4 Loading knowledge text can be understood as acquiring knowledge documents. After acquiring the knowledge documents, the knowledge documents are segmented. The segmentation here includes the above-mentioned process of determining the initial text block, traversing the initial text block, and merging the initial text blocks. After segmentation, the obtained text segments are cleaned. Finally, AutoContext processing is performed on the cleaned text segments to obtain the text segments that the index is based on. The processing process involved in the preprocessing in this embodiment can be referred to the above-mentioned related embodiments, and this embodiment will not be repeated here.
[0069] In some embodiments, the above-mentioned step of retrieving a target index that matches the target question in the index library based on the target question can be implemented in the following manner: determining the matching degree between the target question and each index in the index library based on the target question; determining the index corresponding to the matching degree arranged in front of a preset number of indexes; deduplicating the index based on the text segmentation corresponding to the index to obtain a target index that matches the target question.
[0070] As can be seen from the above, the indexes in the index library can be vector representations of the segmentation results, keywords within the segmentation results, and so on. Therefore, as an example, the target question can be represented by a vector, and similarity can be calculated based on the vector. This similarity is used to represent the matching degree between the target question and the index. The higher the similarity, the higher the matching degree. As another example, keywords can be extracted from the target question, and the matching degree between the target question and the index can be determined based on the matching of the keywords.
[0071] The matching degree can be represented by a score, and it is understood that the higher the score, the higher the matching degree. Then, based on the matching degree, the indexes corresponding to the matching degrees that are ranked first by a preset number are determined. As an example, the preset number can be 10, which can be configured according to actual conditions.
[0072] It is understandable that since a text segment may correspond to multiple indices, the text segments to which the indices corresponding to the first preset number of matching degrees belong may be duplicated. Therefore, to avoid repeated recall of the same text segment, the indices corresponding to the first preset number of matching degrees can be deduplicated, and the remaining indices after deduplication can be used as target indices. As an example, when deduplicating, for indices belonging to the same text segment, any one of the indices can be retained as the target index.
[0073] In some embodiments, the large model knowledge retrieval method may further include the following steps: determining the number of hits of the text segment, wherein the number of hits is the number of times the text segment is determined as a target text segment.
[0074] Among them, the number of hits of the text segment can be maintained by configuring the field, and after each recall of the target text segment, the field used to describe the number of hits of the target text segment is directly increased by 1, thereby updating the number of hits of the text segment in real time. On this basis, the number of hits of the text segment is determined by accessing the field.
[0075] By providing the number of hits of the text segment, it can be used to analyze the value of the text segment and thus obtain the value of the knowledge document.
[0076] In some embodiments, the target text segment can be encapsulated in a data packet, and then the data packet is provided to the large model. As an example, the data structure of the data packet can be a JSON structure.
[0077] In some embodiments, in addition to the target text segment, the data packet may also include the segmentation results described by the index of the target text segment and the score corresponding to the index. Specifically, the index may include the target index and may also include the index that was not used as the target index in the above-mentioned deduplication. If there are multiple indexes, the segmentation results are sorted according to the scores corresponding to the indexes.
[0078] In some embodiments, in a target reply given by a large model, if the target reply quotes content related to the index, a corresponding superscript may be provided in the target reply, and the superscript is used to mark the source of the quote.
[0079] Figure 5 1 is a block diagram of a large model knowledge retrieval device according to an embodiment of the present disclosure. Figure 5 , the large model knowledge retrieval device 500 includes: A first acquisition module 501 is used to acquire a target question; A retrieval module 502 is configured to retrieve a target index that matches the target question in an index library based on the target question, wherein the index library includes multiple indexes, each index uniquely corresponding to a text segment, the text segment being obtained by segmenting the corresponding knowledge document, and the index corresponding to the text segment including a first index, the first index being used to describe a segmentation result obtained by segmenting the corresponding text segment; A recall module 503 is configured to recall a target text segment from all the text segments based on the target index; The first determination module 504 is configured to determine the target text segment as a target context for the target question, wherein the target context is used by the large model to generate a target response to the target question.
[0080] Optionally, the large model knowledge retrieval device 500 further includes: A second acquisition module, configured to acquire the text segment; A denoising module, configured to denoise the text segment to obtain denoised text segment; A second determining module is used to determine whether the first index enhancement function is enabled; The first segmentation module is used to segment the denoised text into segments to obtain segmentation results; The first construction module is used to construct the first index based on the segmentation result and store the first index in the index library.
[0081] Optionally, the first segmentation module is further used to segment the denoised text segment according to the data type to which the denoised text segment belongs to obtain a segmentation result.
[0082] Optionally, the index corresponding to the text segment further includes a second index, and the large model knowledge retrieval device 500 further includes: A third determining module is used to determine whether the second index enhancement function is enabled; A generation module, configured to generate questions based on the denoised text segments, wherein the questions are used to represent questions that can be asked based on the denoised text segments; The second construction module is used to construct the second index based on the question and store the second index in the index library.
[0083] Optionally, the large model knowledge retrieval device 500 further includes: The third acquisition module is used to acquire knowledge documents; A second segmentation module is used to segment the knowledge document to obtain a plurality of initial text blocks of the knowledge document; A traversal module, configured to traverse the multiple initial text blocks in sequence according to their positions in the knowledge document until all the initial text blocks are traversed; The interception module is used to intercept a sub-text segment of the initial text block that does not exceed the preset character length as a text segment, starting from the first character of the initial text block when the character length of the traversed initial text block is greater than the preset character length, and use the remaining part after intercepting the sub-text segment as a new initial text block.
[0084] Optionally, the large model knowledge retrieval device 500 further includes: The merging module is configured to, when the character length of the traversed initial text block is less than the preset character length, merge the other initial text blocks downward until any one of the following preset stop merging conditions is met, wherein the result of the current merging is used as a text segment, and the preset stop merging conditions include: The initial text block is obtained based on the segmentation rule of the user-defined delimiter, and the next initial text block of the currently traversed initial text block contains the user-defined delimiter; or The initial text block is obtained based on the segmentation rule of the layout, and the next initial text block of the currently traversed initial text block is an initial text block of a preset type; or, The character length of a result of merging the currently traversed initial text block and the next initial text block of the initial text block exceeds the preset character length.
[0085] Optionally, the retrieval module 502 includes: A first determination submodule is configured to determine a matching degree between the target question and each index in the index library according to the target question; A second determining submodule is used to determine the index corresponding to the matching degree of the first preset number; The deduplication submodule is used to deduplicate the index based on the text segment corresponding to the index to obtain a target index that matches the target question.
[0086] Optionally, the recall module 503 includes: A first recall submodule, configured to recall, based on the target index, a first text segment corresponding to the target index from all the text segments; A third determining submodule, configured to determine whether a third index enhancement function is enabled; a second recall submodule, configured to recall a second text segment from all the text segments, wherein the second text segment and the first text segment are adjacent to each other in the corresponding knowledge document; The fourth determining submodule is configured to determine the first text segment and the second text segment as target text segments.
[0087] Optionally, the large model knowledge retrieval device 500 further includes: The fourth determination module is configured to determine the hit count of the text segment, wherein the hit count is the number of times the text segment is determined as the target text segment, and the hit count is used to analyze the value of the text segment.
[0088] The implementation of each module in the large model knowledge retrieval device 500 can refer to the above-mentioned related embodiments, and this embodiment will not be described in detail here.
[0089] The embodiment of the present disclosure also provides a computer-readable medium having a computer program stored thereon, which implements the steps of the above-mentioned large model knowledge retrieval method when executed by a processing device.
[0090] The embodiment of the present disclosure also provides a computer program product, including a computer program, which implements the steps of the above-mentioned large model knowledge retrieval method when executed by a processor.
[0091] The present disclosure also provides an electronic device, including: a storage device having a computer program stored thereon; A processing device is used to execute the computer program in the storage device to implement the steps of the above-mentioned large model knowledge retrieval method.
[0092] Reference below Figure 6 , which shows a schematic structural diagram of an electronic device 600 suitable for implementing an embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (such as in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0093] like Figure 6 As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 602 or programs loaded from a storage device 608 into a random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of electronic device 600. Processing device 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to bus 604.
[0094] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0095] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
[0096] It should be noted that the computer-readable medium described above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. Computer-readable storage media may include, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or components, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such a propagated data signal may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wire, optical cable, RF (radio frequency), or any suitable combination thereof.
[0097] In some embodiments, electronic devices can communicate using any currently known or later developed network protocol, such as HTTP (HyperText Transfer Protocol), and can interconnect with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or later developed network.
[0098] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0099] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device is enabled to: obtain a target question; according to the target question, retrieve a target index matching the target question in the index library, wherein the index library includes multiple indexes, each index uniquely corresponds to a text segment, and the text segment is obtained by segmenting the corresponding knowledge document. The index corresponding to the text segment includes a first index, which is used to describe the segmentation result obtained by segmenting the corresponding text segment; based on the target index, recall the target text segment from all the text segments; determine the target text segment as the target context of the target question, wherein the target context is used by the large model to generate a target response to the target question.
[0100] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0101] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0102] The modules described in the embodiments of the present disclosure may be implemented in software or hardware. In some cases, the name of a module does not necessarily limit the module itself. For example, the first acquisition module may also be described as a "module for acquiring a target problem."
[0103] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0104] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A 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 machine-readable storage media may include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fibers, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0105] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of the present disclosure is not limited to technical solutions formed by specific combinations of the aforementioned technical features. It also encompasses other technical solutions formed by any combination of the aforementioned technical features or their equivalents, without departing from the scope of the above disclosure. For example, a technical solution formed by replacing the aforementioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.
[0106] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0107] Although the subject matter has been described using language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims. Regarding the apparatus in the above-described embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments related to the method and will not be elaborated upon here.
Claims
1. A large model knowledge retrieval method, characterized in that: include: Get the target question; According to the target question, a target index matching the target question is retrieved from an index library, wherein the index library includes a plurality of indexes, each index uniquely corresponding to a text segment, the text segment being obtained by segmenting the corresponding knowledge document, and the index corresponding to the text segment including a first index, the first index being used to describe a segmentation result obtained by segmenting the corresponding text segment; Recalling a target text segment from all the text segments based on the target index; The target text segment is determined as a target context for the target question, wherein the target context is used by the large model to generate a target answer to the target question.
2. The method according to claim 1, characterized in that The method further comprises: Obtaining the text segment; Denoising the text segment to obtain denoised text segment; Make sure the first index enhancement function is turned on; Segmenting the denoised text to obtain segmentation results; Based on the segmentation result, the first index is constructed and stored in the index library.
3. The method according to claim 2, characterized in that The segmenting of the denoised text to obtain a segmentation result includes: The denoised text segments are segmented according to the data type to which the denoised text segments belong to, to obtain segmentation results.
4. The method according to claim 2, characterized in that The index corresponding to the text segment further includes a second index, and the method further includes: Make sure the second index enhancement function is turned on; generating questions based on the denoised text segments, wherein the questions are used to represent questions that can be asked based on the denoised text segments; Based on the question, the second index is constructed and stored in the index library.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Acquisition of knowledge documents; Segmenting the knowledge document to obtain a plurality of initial text blocks of the knowledge document; Traversing the multiple initial text blocks in sequence according to their positions in the knowledge document until all the initial text blocks are traversed; In the case that the character length of the traversed initial text block is greater than the preset character length, taking the first character of the initial text block as the starting position, a sub-text segment of the initial text block that does not exceed the preset character length is cut off as a text segment, and the remaining part after cutting off the sub-text segment is used as a new initial text block.
6. The method according to claim 5, characterized in that The method further comprises: If the character length of the traversed initial text block is less than the preset character length, other initial text blocks are merged downward until any one of the following preset stop merging conditions is met, wherein the current merging result is used as a text segment, and the preset stop merging conditions include: The initial text block is obtained based on the segmentation rule of the user-defined delimiter, and the next initial text block of the currently traversed initial text block contains the user-defined delimiter; or The initial text block is obtained based on the segmentation rule of the layout, and the next initial text block of the currently traversed initial text block is an initial text block of a preset type; or, The character length of a result of merging the currently traversed initial text block and the next initial text block of the initial text block exceeds the preset character length.
7. The method according to claim 1, characterized in that The step of searching an index library for a target index that matches the target question according to the target question includes: Determining the matching degree between the target question and each index in the index library; Determine the index corresponding to the matching degree of the first preset number of items; Based on the text segment corresponding to the index, the index is deduplicated to obtain a target index that matches the target question.
8. The method according to claim 1, characterized in that The step of recalling a target text segment from all the text segments based on the target index includes: Based on the target index, recalling a first text segment corresponding to the target index from all the text segments; Make sure the third index enhancement function is turned on; Recalling a second text segment from all the text segments, wherein the second text segment and the first text segment are adjacent to each other in the corresponding knowledge document; The first text segment and the second text segment are determined as target text segments.
9. The method according to claim 1, characterized in that The method further comprises: The number of hits of the text segment is determined, wherein the number of hits is the number of times the text segment is determined as the target text segment, and the number of hits is used to analyze the value of the text segment.
10. A large model knowledge retrieval device, characterized in that: include: The first acquisition module is used to obtain the target question; A retrieval module is configured to retrieve a target index matching the target question in an index library according to the target question, wherein the index library includes a plurality of indexes, each index uniquely corresponding to a text segment, the text segment being obtained by segmenting the corresponding knowledge document, and the index corresponding to the text segment including a first index, the first index being used to describe a segmentation result obtained by segmenting the corresponding text segment; a recall module, configured to recall a target text segment from all the text segments based on the target index; A first determination module is configured to determine the target text segment as a target context for the target question, wherein the target context is used by the large model to generate a target response to the target question.
11. A computer-readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processing device, the steps of the method according to any one of claims 1 to 9 are implemented.
12. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 9.
13. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Question answering method, question answering system and computer readable storage medium
CN117520488A
Information retrieval method and device, electronic equipment and storage medium
CN118394916A
Question and answer method and device, equipment and medium
CN118445395A
Method for improving recall rate of large model retrieval enhancement system based on knowledge density
CN119106142A
Knowledge retrieval-oriented government affair document enhanced generation method, electronic equipment and medium
CN119416776A