Document analysis method and device, equipment and storage medium
By extracting user intentions and searching keywords, and slicing data on complex documents such as fund announcements, the problem of lack of customized analysis methods in the existing technology is solved, and efficient analysis of complex documents and accurate answers to complex analysis problems are achieved.
Patent Information
- Application Number
- CN202411619050.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-03-18
AI Technical Summary
The existing technology lacks customized analysis methods when analyzing complex documents such as fund announcements, making it difficult to answer complex analysis problems.
By obtaining user input information and document to be parsed, extracting user intentions and searching keywords, and performing data slices to generate document parsing answers. Specific steps include information extraction, data slicing and analytical answer generation.
It realizes customized analysis of complex documents, can accurately answer complex analysis problems, and improves the efficiency and accuracy of document analysis.
Smart Images

Figure CN119647450A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data analysis technology, and in particular to a document parsing method, device, equipment and storage medium. Background Art
[0002] At present, there are many defects when using traditional file parsing and question-answering devices based on large language models for content parsing, information extraction and analysis of some documents. For example, when parsing fund announcement documents, there are a large number of proper nouns, numerical data, and complex indicator systems in fund announcements. These general analysis tools lack customized analysis methods and it is difficult to complete the answers to complex analysis problems. Summary of the invention
[0003] The main purpose of this application is to provide a document parsing method, device, equipment and storage medium, aiming to solve problems that arise in document parsing, such as the lack of customized analysis methods.
[0004] To achieve the above objectives, the present application proposes a document parsing method, which includes:
[0005] Get user input information and the document to be parsed;
[0006] Extracting information from the user input information to determine the user intent and search keywords corresponding to the user input information;
[0007] Slicing the document to be parsed to obtain a plurality of first document content blocks;
[0008] A document parsing answer is generated based on the user intention, each of the first document content blocks, and the search keyword.
[0009] In one embodiment, extracting information from the user input information to determine the user intent and search keywords corresponding to the user input information includes:
[0010] Obtaining a preset question and answer prompt template, and integrating the user input information and the preset question and answer prompt template to generate an intent recognition prompt;
[0011] Inputting the intention recognition prompt into a user intention recognition model to obtain the user intention output by the user intention recognition model;
[0012] Keyword extraction is performed on the user intention to determine search keywords.
[0013] In one embodiment, the data slicing of the document to be parsed to obtain a plurality of first document content blocks includes:
[0014] Identifying non-critical content in the document to be parsed;
[0015] Based on the non-critical content, performing data preprocessing on the document to be parsed;
[0016] Based on the chapter information of the document to be parsed after data preprocessing, data slicing is performed on the document to be parsed to obtain a plurality of first document content blocks.
[0017] In one embodiment, generating a document parsing answer based on the user intention, each of the first document content blocks, and the search keyword includes:
[0018] Determining first content integration information corresponding to each of the first document content blocks;
[0019] Based on the search keyword and each of the first content integration information, determining a plurality of second content integration information and content block rankings corresponding to the user intention;
[0020] A document parsing answer is generated based on the user intention, each of the second content integration information, and the content block ranking.
[0021] In one embodiment, determining the first content integration information corresponding to each of the first document content blocks includes:
[0022] Inputting each of the first document content blocks and a preset description generation prompt into a key content generation model, and obtaining content description information and content keywords corresponding to each of the first document content blocks output by the key content generation model;
[0023] For any of the first document content blocks, the first document content block is associated and combined with the content description information and content keywords corresponding to the first document content block to generate first content integration information.
[0024] In one embodiment, the determining, based on the search keyword and each of the first content integration information, a plurality of second content integration information and a content block ranking corresponding to the user intention includes:
[0025] Obtain several preset search algorithms;
[0026] For any of the preset search algorithms: searching the search keyword and each of the first content integration information according to the preset search algorithm to obtain a plurality of second content integration information and a search score;
[0027] The second content integration information and the search scores corresponding to the preset search algorithms are integrated and reordered to determine the content block order.
[0028] In one embodiment, generating a document parsing answer based on the user intention, each second content integration information, and the content block ranking includes:
[0029] Based on the content block sorting, embedding each of the second content integration information into a document parsing generation model;
[0030] Determine a parsing task type corresponding to the user intention, and integrate the user intention with a task question and answer template corresponding to the parsing task type to obtain a file parsing prompt;
[0031] The file parsing prompt is input into the document parsing generation model to obtain a document parsing answer output by the document parsing generation model.
[0032] In addition, to achieve the above-mentioned purpose, the present application also proposes a document parsing device, which includes:
[0033] The acquisition module is used to obtain user input information and the document to be parsed;
[0034] An extraction module, used to extract information from the user input information and determine the user intent and search keywords corresponding to the user input information;
[0035] A slicing module, used for slicing the data of the document to be parsed to obtain a plurality of first document content blocks;
[0036] A parsing module is used to generate a document parsing answer based on the user intention, each of the first document content blocks and the search keywords.
[0037] In addition, to achieve the above-mentioned purpose, the present application also proposes a document parsing device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the document parsing method described above.
[0038] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the document parsing method described above are implemented.
[0039] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the document parsing method described above are implemented.
[0040] The present application provides a document parsing method, apparatus, device and storage medium. The document parsing method obtains user input information and a document to be parsed, and then extracts information from the user input information, determines the user intent and search keywords corresponding to the user input information, and then performs data slicing on the document to be parsed to obtain a plurality of first document content blocks, and then generates a document parsing answer based on the user intent, each of the first document content blocks and the search keywords, thereby being able to perform customized document parsing on documents with a large number of proper nouns, numerical data and complex indicator systems, and thus completing the solution to complex analysis problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0042] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0043] Figure 1 A flowchart of the first embodiment of the document parsing method of the present application is provided;
[0044] Figure 2 An example diagram of the document slicing process provided for the document parsing method of this application;
[0045] Figure 3 An example diagram of the task classification process provided for the document parsing method of this application;
[0046] Figure 4 A brief flowchart of the document parsing method provided for this application;
[0047] Figure 5 This is a schematic diagram of the module structure of the document parsing device according to an embodiment of the present application;
[0048] Figure 6 Schematic diagram of the device structure of the hardware operating environment involved in the document parsing method in the embodiment of the present application.
[0049] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0050] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0051] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0052] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a big data service platform, a fund announcement parsing system, etc. The following takes the fund announcement parsing system as an example to illustrate this embodiment and the following embodiments.
[0053] Based on this, the present application embodiment provides a document parsing method, referring to Figure 1 , Figure 1 A flowchart of the first embodiment of the document parsing method of the present application is provided.
[0054] In this embodiment, the document parsing method includes steps S11 to S14:
[0055] Step S11, obtaining user input information and the document to be parsed;
[0056] It should be noted that the user input information refers to the questions asked by the user to the system, the queries or instructions that the user wants to issue, such as the data of a specific indicator or the summary of a part of a fund announcement, which is not limited here.
[0057] It should be further explained that the document to be parsed refers to a document that needs to be analyzed and processed by the system, including PDF, Word documents or files in other formats, which contain text information that needs to be parsed and analyzed, such as fund announcements, annual reports, quarterly reports, etc. in the financial field. These documents usually contain complex information such as financial data, market analysis, and portfolio details.
[0058] Specifically, a document, such as a PDF file, is read from a preset acquisition source (such as a database or a file system), which includes format verification and content extraction of the file to ensure the integrity of the information.
[0059] Step S12, extracting information from the user input information to determine the user intent and search keywords corresponding to the user input information;
[0060] It should be noted that the user intent refers to the real user needs represented by the user input information, so as to correctly identify whether the user wants to query specific data, obtain a summary of a certain part, perform comparative analysis or other types of requests. The search keyword refers to the keyword or phrase used to retrieve relevant information in the document to be parsed, which helps to locate relevant content in the document to answer the user's question.
[0061] Specifically, a preset question and answer prompt template is obtained, and the user input information and the preset question and answer prompt template are integrated to generate an intention recognition prompt, and then the intention recognition prompt is input into a user intention recognition model to obtain the user intention output by the user intention recognition model, thereby performing keyword extraction on the user intention and determining the search keyword.
[0062] Step S13, slicing the document to be parsed to obtain a plurality of first document content blocks;
[0063] It should be noted that the first document content block refers to a number of document fragments obtained after data slicing of the document to be parsed, and each first document content block corresponds to a chapter, paragraph or specific part in the document.
[0064] Specifically, the non-critical content in the document to be parsed is identified, and then based on the non-critical content, data preprocessing is performed on the document to be parsed, thereby data slicing is performed on the document to be parsed based on the chapter information of the document to be parsed after data preprocessing to obtain a plurality of first document content blocks.
[0065] Step S14: Generate a document parsing answer based on the user intention, each of the first document content blocks and the search keywords.
[0066] It should be noted that the document parsing answer refers to the final answer to the user input information generated based on information such as user intent, search keywords and document content blocks. The document parsing answer is generated based on the user input information, so the form and content of the document parsing answer are not limited here and vary according to the actual user input information.
[0067] Specifically, the first content integration information corresponding to each of the first document content blocks is determined, and then based on the search keywords and each of the first content integration information, a number of second content integration information and content block rankings corresponding to the user intention are determined, thereby generating a document parsing answer based on the user intention, each of the second content integration information and the content block rankings.
[0068] This embodiment obtains user input information and a document to be parsed, and then extracts information from the user input information, determines the user intent and search keywords corresponding to the user input information, and then performs data slicing on the document to be parsed to obtain a number of first document content blocks, and then generates a document parsing answer based on the user intent, each of the first document content blocks and the search keywords, thereby being able to perform customized document parsing on documents with a large number of proper nouns, numerical data and complex indicator systems, and thus complete the solution to complex analysis problems.
[0069] In a feasible implementation manner, extracting information from the user input information and determining the user intent and search keywords corresponding to the user input information include:
[0070] Step S21, obtaining a preset question and answer prompt template, and integrating the user input information and the preset question and answer prompt template to generate an intention recognition prompt;
[0071] It should be noted that the preset Q&A prompt template refers to a series of standardized Q&A templates pre-defined by the system, which are used to guide users to ask questions and help the system understand the user's query intention, and usually contain specific question structures, keywords or question types, so that the system can recognize and process user input. For example, the template may include questions asking about specific financial indicators in a fund announcement, or instructions requesting a summary of a certain part of the announcement.
[0072] It should be further explained that the intent recognition prompt refers to a prompt generated by combining the information input by the user and the preset question and answer prompt template, which is used to stimulate the user intent recognition model so that it can more accurately recognize the user's query intent. The intent recognition prompt contains the user's real demand question and related structured information in the template, thereby helping the model to better understand the context of the question and specific needs.
[0073] Understandably, in order to solve the problem that the user input information does not contain query keywords but uses pronouns, which leads to the inability of both traditional retrieval methods and retrieval systems based on vector similarity matching to accurately retrieve and have a low recall rate, for example, some query expressions may not contain keywords suitable for retrieval, or the query may contain ambiguous expressions. Please refer to Table 1, which is an example of user input that cannot be directly used for retrieval. If the user input information is directly used for retrieval, no suitable data will be matched during the retrieval process, resulting in inaccurate retrieval and a low recall rate. Therefore, the user input information is rewritten through the user intention recognition model to determine whether the prompt word intention (that is, the real demand contained in the user input information) needs to be retrieved and extract the keywords used for retrieval, especially the judgment of demonstrative pronouns, so as to obtain relatively pure and reliable retrieval keywords.
[0074] Table 1
[0075]
[0076] Specifically, a preset question and answer prompt template is obtained. In one embodiment, the preset question and answer prompt template is "The following is a question that requires the help of external documents. The question may contain honorifics, demonstrative pronouns and other rhetoric. Please optimize the expression of the question to help the retrieval system retrieve relevant documents as much as possible. Please output the core keywords to be retrieved, and do not include a line break at the end of the output. If the question does not require the help of external documents, please return to the original question. The following are several examples:
[0077] Example 1: User input: Please help me find the fifth part of this report;
[0078] Thinking process: The intention is to query the content of the report, and the keyword to be searched is "Part 5";
[0079] Output: Part 5;
[0080] Example 2: User input information: "Dream of Red Mansions" is one of the representative works of Chinese classical novels, written by Cao Xueqin, a writer in the Qing Dynasty. The book has 120 chapters, with Jia Baoyu, Lin Daiyu, Xue Baochai and other characters as the main line, depicting the rise and fall of a large family and reflecting the various drawbacks and contradictions of feudal society. Please summarize the views on liquidity in this report for me.
[0081] Thinking process: 1) The first sentence about Dream of the Red Chamber is a distraction and has nothing to do with the real query "Views on liquidity in the report". 2) The core keyword suitable for retrieval: "liquidity"
[0082] Output: Liquidity;
[0083] Example 3: Input question: The weather is really nice today;
[0084] Thinking process: 1) This request has nothing to do with external documents. 2) Return to the original question;
[0085] Output: "It's a nice day today."
[0086] Furthermore, the user input information and the preset question and answer prompt template are integrated to generate an intent recognition prompt, that is, the user input information is integrated into the preset question and answer prompt template to generate subsequent model input questions.
[0087] Step S22, inputting the intention recognition prompt into a user intention recognition model to obtain the user intention output by the user intention recognition model;
[0088] It should be noted that the user intent recognition model is used to analyze the user's query intent. The model receives the intent recognition prompt as input, analyzes the text content in the prompt, and outputs the recognition result of the user's intent. This model may be trained based on a large amount of annotated data to recognize different query types, such as information queries, data analysis requests, report generation, etc. The output of the user intent recognition model can be a classification label indicating which intent category the user's query belongs to, or a more detailed structured representation, such as a specific query topic or question type.
[0089] Step S23: extract keywords from the user's intention and determine search keywords.
[0090] Specifically, based on the identified user intent, the content of the user input is further analyzed, and natural language processing techniques such as word segmentation, part-of-speech tagging, dependency syntax analysis, etc. are used to extract the keywords most relevant to the user intent, and then each of the keywords is used as a search keyword to retrieve and locate relevant information in the document to be parsed.
[0091] This embodiment obtains a preset question and answer prompt template, integrates the user input information and the preset question and answer prompt template, generates an intention recognition prompt, and then inputs the intention recognition prompt into a user intention recognition model to obtain the user intention output by the user intention recognition model, thereby performing keyword extraction on the user intention, determining the search keywords, and thus more accurately understanding the user's query intention, and facilitating more precise extraction of search keywords, thereby improving the relevance and accuracy of subsequent information retrieval, and at the same time generating customized answers based on the user intention, thereby promoting personalized services.
[0092] In a feasible implementation manner, the data slicing of the document to be parsed to obtain a plurality of first document content blocks includes:
[0093] Step S31, identifying non-critical content in the document to be parsed;
[0094] It should be noted that the non-critical content refers to the content in the document to be parsed that is not directly relevant or important for the specific analysis purpose or information extraction task, including headers and footers, footnotes and endnotes, line spacing, column spacing and irrelevant pictures, etc. It can be set according to actual conditions and is not restricted here.
[0095] Step S32, performing data preprocessing on the document to be parsed based on the non-critical content;
[0096] Specifically, in the data preprocessing step, the document to be parsed is cleaned up in depth through a specific parser, and non-critical content in the document is identified and stripped, thereby eliminating potential interference factors while maintaining the semantic integrity of the original text. In addition to removing irrelevant elements such as headers, footers, footnotes and page numbers, it also includes eliminating format inconsistencies, removing unnecessary line spacing, column spacing and images, etc., thereby significantly improving the purity of the data and creating a noise-free input environment for subsequent precise parsing and efficient analysis, thereby ensuring the smoothness of the entire process and the reliability of the results.
[0097] In one embodiment, considering that the original document data mostly exists in the form of PDF files, PDF files are very friendly to human reading at the display level, but there are several difficulties in machine processing and text mining. In particular, when the content contains a large amount of table data, directly parsing PDF may cause a large amount of data structure loss or confusion. In order to solve this problem, a PDF to MARKDOWN tool can be selected as the core processing tool, because MARKDOWN is a lightweight markup language, which can retain the structural information of the table to the greatest extent for documents containing a large number of tables.
[0098] Step S33: based on the chapter information of the document to be parsed after data preprocessing, data slicing is performed on the document to be parsed to obtain a plurality of first document content blocks.
[0099] It should be noted that the chapter information refers to the structured information in the document used to organize and divide the content, usually including chapter titles, such as "Introduction", "Methods", "Results", "Discussion", etc.; sub-chapter titles, such as "Data Collection" and "Data Analysis" under "Methods", etc.; paragraph and section numbers; table of contents and index; chapter summaries or summaries, etc.
[0100] Specifically, in one embodiment, the data slicing operation is further implemented for the converted MARKDOWN file, so as to refine and organize the large blocks of data for subsequent data retrieval and utilization. The document to be parsed in the MARKDOWN file is divided into several first document content blocks according to the chapter information, and each first document content block is attached with the original PDF file title of its source, so as to facilitate the accurate retrieval of knowledge points in a specific chapter, and help maintain the logical association between knowledge points, and provide richer and more detailed context information for the subsequent process. Figure 2 , Figure 2 An example diagram of the document slicing process provided for the document parsing method of this application.
[0101] In the process of paragraph recognition and segmentation, a specific set of regular rules can be used to identify paragraph titles by analyzing the text structure to ensure the accuracy of paragraph division and provide a clear segmentation basis for information extraction.
[0102] This embodiment identifies the non-key content in the document to be parsed, and then performs data preprocessing on the document to be parsed based on the non-key content, and then performs data slicing on the document to be parsed based on the chapter information of the document to be parsed after data preprocessing, and obtains a number of first document content blocks, thereby structuring the complex document information, thereby efficiently and accurately parsing the document content, and then improving the efficiency, accuracy and precision of the information acquisition process, so as to improve the model's ability to understand information in subsequent processing, thereby quickly obtaining key information and improving the efficiency and accuracy of document parsing answer generation. In addition, dividing the document into small blocks can optimize storage, facilitate rapid retrieval of information in specific chapters or paragraphs, and improve the readability of the document.
[0103] In a feasible implementation manner, generating a document parsing answer based on the user intention, each of the first document content blocks, and the search keyword includes:
[0104] Step S41, determining first content integration information corresponding to each of the first document content blocks;
[0105] It should be noted that the first content integration information refers to the integrated information obtained by integrating the first document content block with the content description information output by the key content generation model and the content keywords.
[0106] Specifically, each of the first document content blocks and a preset description generation prompt are input into a key content generation model to obtain content description information and content keywords corresponding to each of the first document content blocks output by the key content generation model. Then, for any of the first document content blocks, the first document content block is associated and combined with the content description information and content keywords corresponding to the first document content block to generate first content integration information.
[0107] Step S42, determining a plurality of second content integration information and content block rankings corresponding to the user intention based on the search keyword and each of the first content integration information;
[0108] It should be noted that the second content integration information refers to the information obtained by further screening and integration based on the first content integration information according to the user's intention and search keywords. Such information more accurately matches the user's needs.
[0109] It should be further explained that the content block sorting refers to the order obtained by sorting all the second content integration information according to user intent and search keywords, so as to determine which content blocks are the most important and relevant, thereby improving the pertinence of answers and user satisfaction.
[0110] Specifically, several preset retrieval algorithms are obtained, and then for any of the preset retrieval algorithms: the retrieval keywords and each of the first content integration information are retrieved according to the preset retrieval algorithm to obtain several pieces of second content integration information and retrieval scores, thereby integrating and reordering each of the second content integration information and each of the retrieval scores corresponding to each of the preset retrieval algorithms to determine the content block order.
[0111] Step S43: Generate a document parsing answer based on the user intention, each piece of second content integration information, and the content block ranking.
[0112] Specifically, based on the sorting of the content blocks, each second content integration information is embedded into the document parsing generation model, and then the parsing task type corresponding to the user intention is determined, and the user intention is integrated with the task question and answer template corresponding to the parsing task type to obtain a file parsing prompt, and then the file parsing prompt is input into the document parsing generation model to obtain a document parsing answer output by the document parsing generation model.
[0113] This embodiment determines the first content integration information corresponding to each of the first document content blocks, and then determines a number of second content integration information corresponding to the user intention and the content block sorting based on the search keywords and each of the first content integration information, thereby generating a document parsing answer based on the user intention, each of the second content integration information and the content block sorting, and then through the sorting of the content blocks, the most relevant information can be located more quickly, thereby optimizing information retrieval efficiency, improving retrieval accuracy and precision, and then improving the relevance and accuracy of answer generation, thereby achieving customized document parsing and completing the solution of complex analysis problems.
[0114] In a feasible implementation manner, the determining the first content integration information corresponding to each of the first document content blocks includes:
[0115] Step S51, inputting each of the first document content blocks and a preset description generation prompt into a key content generation model, and obtaining content description information and content keywords corresponding to each of the first document content blocks output by the key content generation model;
[0116] It should be noted that the preset description generation prompt refers to a pre-designed template or instruction used to guide or stimulate the key content generation model to generate a specific type of output. In one embodiment, the preset description generation prompt can be set to "Please analyze the following content, generate corresponding descriptions and keywords, and extract a concise and representative summary based on the theme and importance of the content to help users quickly grasp the key information. Please output in Json format.
[0117] The content is as follows:
[0118] Title: {title}
[0119] Content: {content}
[0120] The Json format is as follows:
[0121] Output: <{"title":"XXX","keywords":"XXX","abstract":"XXX"}>", where {title} is used to fill in the title corresponding to the first document content block, and {content} is used to fill in the content corresponding to the first document content block.
[0122] It should be further explained that the key content generation model can be trained based on large-scale language data to understand and generate abstracts, summaries or other types of descriptive text related to the input text, thereby identifying the key information in the text and generating concise and accurate content descriptions and keywords accordingly.
[0123] Furthermore, the content description information refers to a concise summary or explanation of the document content block output by the key content generation model to provide an overview of the document content and help quickly understand the main idea and key points of the document. The content keywords refer to the most important words or phrases extracted from the first document content block by the key content generation model to represent the core theme and concept of the document content, which facilitates the retrieval and classification of documents.
[0124] Step S52: for any of the first document content blocks, the first document content block is associated and combined with the content description information and content keywords corresponding to the first document content block to generate first content integration information.
[0125] Specifically, for any of the first document content blocks, the content description information and the content keywords are integrated into meta information, and are associated and combined with the first document content block to match and generate a content-meta information pair, thereby facilitating subsequent data storage and retrieval and improving data availability. In addition, the integrated first content integration information will be stored in a database in a preset format (such as a vector, etc.) to support efficient query and subsequent analysis, and provide a flexible data access method for subsequent steps.
[0126] In this embodiment, each of the first document content blocks and a preset description generation prompt is input into a key content generation model to obtain content description information and content keywords corresponding to each of the first document content blocks output by the key content generation model, and then for any of the first document content blocks, the first document content block is associated and combined with the content description information and content keywords corresponding to the first document content block to generate first content integration information, thereby facilitating subsequent data storage and retrieval in an integrated form, improving data availability, and facilitating rapid acquisition of key information in subsequent processing, thereby improving the ability to understand information and optimizing the decision-making process.
[0127] In a feasible implementation manner, the determining, based on the search keyword and each of the first content integration information, a plurality of second content integration information and content block rankings corresponding to the user intention includes:
[0128] Step S61, obtaining several preset search algorithms;
[0129] It should be noted that the preset retrieval algorithm refers to a series of pre-set retrieval algorithms used to retrieve information related to user queries from a document collection, including but not limited to BM25 (Best Matching 25) algorithm, vector similarity retrieval, keyword matching-based algorithm, TF-IDF (Term Frequency-Inverse Document Frequency) algorithm, etc. By combining the use of multiple retrieval algorithms, it is effective to address the problems of inaccurate retrieval of full-text or partial chapters and low recall, so as to improve the accuracy and coverage of the retrieval.
[0130] Step S62, for any of the preset search algorithms: searching the search keyword and each of the first content integration information according to the preset search algorithm to obtain a plurality of second content integration information and a search score;
[0131] It should be noted that the retrieval score refers to a quantitative score given by the retrieval algorithm based on the relevance between the document and the user query, reflecting the degree of match between the document and the query. The higher the score, the greater the relevance between the document and the query. The calculation method of the retrieval score depends on the retrieval algorithm used and is not limited here.
[0132] In one embodiment, a hybrid retrieval method based on the BM25 algorithm and vector similarity matching is adopted. Specifically, during the retrieval process, specific metadata content (i.e., content description information and content keywords) and the document body content are retrieved using the BM25 algorithm and the vector similarity matching algorithm respectively, to obtain a number of first content integration information and scores, wherein the scores obtained by different retrieval algorithms can be weighted, so as to select the TOP_K documents with the highest scores as the second content integration information and the final retrieval score.
[0133] It can be understood that since the metadata stores the chapter title, paragraph description and keywords, both the sparse retrieval method based on text (Lexical) and the dense retrieval method based on embedding vectors can effectively retrieve the target document, thereby improving the recall rate of the retrieval results.
[0134] Step S63 , integrating and reordering the second content integration information and the search scores corresponding to the preset search algorithms to determine the content block order.
[0135] Specifically, each of the second content integration information and each of the search scores corresponding to each of the preset search algorithms are integrated, such as context fusion and deduplication in the second content integration information.
[0136] Furthermore, since the context retrieved by hybrid multi-algorithm fusion is achieved, but multiple retrieval algorithms may retrieve context that is not highly relevant to the question, the fused context is reordered using reranking technology, and the TOP_K important second content integration information is screened out. Putting the second content integration information with the highest relevance at the front can effectively improve the accuracy of answer generation.
[0137] This embodiment obtains several preset retrieval algorithms, and then for any of the preset retrieval algorithms: the retrieval keywords and each of the first content integration information are retrieved according to the preset retrieval algorithm to obtain several pieces of second content integration information and retrieval scores, thereby integrating and reordering the second content integration information and each of the retrieval scores corresponding to each of the preset retrieval algorithms to determine the sorting of content blocks, and then through multiple retrieval algorithms, information can be mixed and retrieved from different angles, effectively addressing the problem of inaccurate retrieval of the full text or partial chapters of the query document and low recall, thereby enhancing the reliability of the retrieval results, and at the same time, by using multiple retrieval algorithms in parallel, the retrieval time is shortened, relevant information is quickly found from a large amount of data, and the retrieval efficiency is improved. In addition, the retrieval algorithm used can be flexibly selected and adjusted according to different retrieval scenarios and needs, thereby realizing customized document parsing.
[0138] In a feasible implementation manner, generating a document parsing answer based on the user intention, each second content integration information, and the content block ranking includes:
[0139] Step S71, based on the content block sorting, embedding each second content integration information into a document parsing generation model;
[0140] It should be noted that the document parsing generation model is used to parse the document content and generate corresponding answers to understand the user's query intention, extract key information in the document, and combine this information to generate accurate and coherent conversational answers. It can be trained based on a large amount of document and query data to identify different question types and generate appropriate answers, and there is no limitation here.
[0141] Specifically, according to the sorting of the content blocks, each of the second content integration information is sorted and integrated and then embedded into the document parsing generation model, thereby ensuring that the most relevant content blocks are processed by the model first, and the generated answers are more likely to directly solve the user's queries, thereby improving the response speed, while more accurately capturing and understanding the core information of the document.
[0142] Step S72, determining the parsing task type corresponding to the user intention, and integrating the user intention with the task question and answer template corresponding to the parsing task type to obtain a file parsing prompt;
[0143] It should be noted that the parsing task type refers to a specific type of parsing task identified by the system based on the intent and content of the user's query. For example, parsing task types include fact query, data extraction, trend analysis, comparative analysis, content extraction, core indicator statistical analysis, analysis report generation, etc., which helps the system select the correct processing flow and algorithm to generate the most appropriate answer.
[0144] It should be further explained that the task question and answer template refers to a preset question and answer template, which is used to guide the document parsing generation model to generate a specific type of answer. The document parsing prompt refers to the input used to stimulate the document parsing generation model to generate an answer, so as to guide the model how to combine the document content and user intent to construct an answer.
[0145] Specifically, the user intent recognition can be converted into a classification task by constructing a classification prompt project, and then the type of parsing task corresponding to the user intent can be determined. For example, the classification prompt can be "You are a fund announcement analysis intent recognition system. Your main task is to understand user questions and divide user questions into four categories: fund announcement content extraction, core indicator statistical analysis, fund analysis report generation and other questions. When receiving a user's question, you need to use your analytical ability to directly give the user's intent category.
[0146] User intent; {question} (used to fill in user intent)", and then input the classification prompt into the classification model for output, determine the parsing task type corresponding to the user intent, if the user intent cannot be divided into the subtask of the existing type, then the original question will be input into the document parsing generation model, relying on the base capability of the document parsing generation model for a comprehensive answer. Then the user intent is integrated with the task question and answer template corresponding to the parsing task type to obtain a file parsing prompt.
[0147] In one embodiment, if the parsing task type is a content extraction task, the corresponding task question and answer template may be "You are a fund announcement information query system. You can search the knowledge base and answer users' questions. Your main task is to understand and answer users' questions. When you receive a user's question, you need to use your search ability to find information related to the question in the knowledge base. After that, you take these relevant information and the user's question as input, and return structured information in Json format, as well as the most relevant original paragraph.
[0148] Knowledge base (the knowledge base is represented in list form): {knowledge} (used to fill the second document content block or other knowledge base after fusion and reordering, etc.)
[0149] Question: {question} (used to fill in user intent)", and then integrate the user intent with the task question and answer template corresponding to the parsing task type to obtain a complete file parsing prompt.
[0150] Step S73, inputting the file parsing prompt into the document parsing generation model to obtain a document parsing answer output by the document parsing generation model.
[0151] Specifically, the file parsing prompt is input into the document parsing generation model to obtain the document parsing answer output by the document parsing generation model.
[0152] In one embodiment, if the parsing task type is a content extraction task, the Json format is specified to extract structured information, and the relevant paragraphs of the original document are located to extract content; if the parsing task type is a core indicator statistical analysis task, then based on the content extraction capability, simple calculation and correlation comparison of indicator data are performed, and indicator calculation tools can be defined in the form of Function Call, including basic calculation tools such as difference calculation, ratio calculation, growth rate calculation, standard deviation calculation, and fund indicator calculation tools such as concentration of heavily-weighted stocks and excess yield, and then the function function description document and the above tools are input into the big model together, and the big model completes function selection, parameter extraction, and statistical analysis, etc.; if the parsing task type is a fund analysis report generation task, then based on the information extraction and indicator calculation capabilities, fund announcement analysis text and statistical charts are generated for simple fund analysis needs, and drawing tools are defined in the form of Function Call, including the drawing of line charts and pie charts, so as to generate a fund analysis report, which can be referred to Figure 3 , Figure 3 An example flow chart of task classification provided for the document parsing method of this application. In this process, the system uses the preset PromptTemplate and Function Call functions to guide the large language model to generate accurate answers, thereby improving the efficiency and accuracy of document parsing.
[0153] This embodiment embeds each second content integration information into the document parsing generation model based on the sorting of the content blocks, thereby determining the parsing task type corresponding to the user intention, and integrating the user intention with the task question and answer template corresponding to the parsing task type to obtain a file parsing prompt, thereby inputting the file parsing prompt into the document parsing generation model to obtain a document parsing answer output by the document parsing generation model, thereby adapting to different user intentions and parsing tasks and providing customized answers, thereby enhancing the flexibility and adaptability of the system and improving the relevance and accuracy of the answers.
[0154] For example, to help understand the implementation process of the document parsing method, please refer to Figure 4 , Figure 4 A simplified flowchart of the document parsing method provided for this application.
[0155] It should be noted that the examples in the figure are only used to understand the present application and do not constitute a limitation on the document parsing method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0156] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0157] This application also provides a document parsing device, please refer to Figure 5 , the document parsing device comprises:
[0158] The acquisition module 51 is used to acquire user input information and the document to be parsed;
[0159] An extraction module 52, configured to extract information from the user input information and determine the user intent and search keywords corresponding to the user input information;
[0160] A slicing module 53, used for slicing the data of the document to be parsed to obtain a plurality of first document content blocks;
[0161] The parsing module 54 is used to generate a document parsing answer based on the user intention, each of the first document content blocks and the search keywords.
[0162] The document parsing device is also used for:
[0163] Obtaining a preset question and answer prompt template, and integrating the user input information and the preset question and answer prompt template to generate an intent recognition prompt;
[0164] Inputting the intention recognition prompt into a user intention recognition model to obtain the user intention output by the user intention recognition model;
[0165] Keyword extraction is performed on the user intention to determine search keywords.
[0166] The document parsing device is also used for:
[0167] Identifying non-critical content in the document to be parsed;
[0168] Based on the non-critical content, performing data preprocessing on the document to be parsed;
[0169] Based on the chapter information of the document to be parsed after data preprocessing, data slicing is performed on the document to be parsed to obtain a plurality of first document content blocks.
[0170] The document parsing device is also used for:
[0171] Determining first content integration information corresponding to each of the first document content blocks;
[0172] Based on the search keyword and each of the first content integration information, determining a plurality of second content integration information and content block rankings corresponding to the user intention;
[0173] A document parsing answer is generated based on the user intention, each of the second content integration information, and the content block ranking.
[0174] The document parsing device is also used for:
[0175] Inputting each of the first document content blocks and a preset description generation prompt into a key content generation model, and obtaining content description information and content keywords corresponding to each of the first document content blocks output by the key content generation model;
[0176] For any of the first document content blocks, the first document content block is associated and combined with the content description information and content keywords corresponding to the first document content block to generate first content integration information.
[0177] The document parsing device is also used for:
[0178] Obtain several preset search algorithms;
[0179] For any of the preset search algorithms: searching the search keyword and each of the first content integration information according to the preset search algorithm to obtain a plurality of second content integration information and a search score;
[0180] The second content integration information and the search scores corresponding to the preset search algorithms are integrated and reordered to determine the content block order.
[0181] The document parsing device is also used for:
[0182] Based on the content block sorting, embedding each of the second content integration information into a document parsing generation model;
[0183] Determine a parsing task type corresponding to the user intention, and integrate the user intention with a task question and answer template corresponding to the parsing task type to obtain a file parsing prompt;
[0184] The file parsing prompt is input into the document parsing generation model to obtain a document parsing answer output by the document parsing generation model.
[0185] The document parsing device provided by the present application adopts the document parsing method in the above embodiment, and can solve the technical problems in the background technology. Compared with the prior art, the beneficial effects of the document parsing device provided by the present application are the same as the beneficial effects of the document parsing method provided by the above embodiment, and other technical features in the document parsing device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0186] The present application provides a document parsing device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the document parsing method in the above-mentioned embodiment one.
[0187] Reference below Figure 6 , which shows a schematic diagram of the structure of a document parsing device suitable for implementing the embodiment of the present application. The document parsing device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The document parsing device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0188] like Figure 6As shown, the document parsing device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the document parsing device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the document parsing device to communicate with other devices wirelessly or by wire to exchange data. Although the document parsing device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0189] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a 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 a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0190] The document parsing device provided by the present application adopts the document parsing method in the above embodiment, which can solve the technical problems in the background technology. Compared with the prior art, the beneficial effects of the document parsing device provided by the present application are the same as the beneficial effects of the document parsing method provided by the above embodiment, and other technical features in the document parsing device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0191] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0192] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0193] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the document parsing method in the above-mentioned embodiment.
[0194] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with 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), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0195] The computer-readable storage medium may be included in the document parsing device; or may exist independently without being assembled into the document parsing device.
[0196] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the document parsing device, the document parsing device:
[0197] Get user input information and the document to be parsed;
[0198] Extracting information from the user input information to determine the user intent and search keywords corresponding to the user input information;
[0199] Slicing the document to be parsed to obtain a plurality of first document content blocks;
[0200] A document parsing answer is generated based on the user intention, each of the first document content blocks, and the search keyword.
[0201] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including 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 separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through 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).
[0202] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the 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 square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square 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 square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0203] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0204] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned document parsing method, and can solve the technical problems in the background technology. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the document parsing method provided in the above-mentioned embodiment, and will not be repeated here.
[0205] An embodiment of the present application provides a computer program product, including a computer program, which implements the steps of the document parsing method as described above when executed by a processor.
[0206] The computer program product provided in this application can solve the technical problems in the background technology. Compared with the prior art, the beneficial effects of the computer program product provided in the embodiment of this application are the same as the beneficial effects of the document parsing method provided in the above embodiment, which will not be repeated here.
[0207] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A document parsing method, characterized in that: include: Get user input information and the document to be parsed; Extracting information from the user input information to determine the user intent and search keywords corresponding to the user input information; Slicing the document to be parsed to obtain a plurality of first document content blocks; A document parsing answer is generated based on the user intention, each of the first document content blocks, and the search keyword.
2. The document parsing method according to claim 1, characterized in that: The extracting information from the user input information and determining the user intention and search keywords corresponding to the user input information includes: Obtaining a preset question and answer prompt template, and integrating the user input information and the preset question and answer prompt template to generate an intent recognition prompt; Inputting the intention recognition prompt into a user intention recognition model to obtain the user intention output by the user intention recognition model; Keyword extraction is performed on the user intention to determine search keywords.
3. The document parsing method according to claim 1, characterized in that: The step of slicing the document to be parsed to obtain a plurality of first document content blocks includes: Identifying non-critical content in the document to be parsed; Based on the non-critical content, performing data preprocessing on the document to be parsed; Based on the chapter information of the document to be parsed after data preprocessing, data slicing is performed on the document to be parsed to obtain a plurality of first document content blocks.
4. The document parsing method according to claim 1, characterized in that: The generating a document parsing answer based on the user intention, each of the first document content blocks and the search keyword includes: Determining first content integration information corresponding to each of the first document content blocks; Based on the search keyword and each of the first content integration information, determining a plurality of second content integration information and content block rankings corresponding to the user intention; A document parsing answer is generated based on the user intention, each of the second content integration information, and the content block ranking.
5. The document parsing method according to claim 4, characterized in that: The determining the first content integration information corresponding to each of the first document content blocks includes: Inputting each of the first document content blocks and a preset description generation prompt into a key content generation model, and obtaining content description information and content keywords corresponding to each of the first document content blocks output by the key content generation model; For any of the first document content blocks, the first document content block is associated and combined with the content description information and content keywords corresponding to the first document content block to generate first content integration information.
6. The document parsing method according to claim 4, characterized in that: The determining, based on the search keyword and each of the first content integration information, a plurality of second content integration information and content block rankings corresponding to the user intention includes: Obtain several preset retrieval algorithms; For any of the preset search algorithms: searching the search keyword and each of the first content integration information according to the preset search algorithm to obtain a plurality of second content integration information and a search score; The second content integration information and the search scores corresponding to the preset search algorithms are integrated and reordered to determine the content block order.
7. The document parsing method according to claim 4, characterized in that: The generating a document parsing answer based on the user intention, each of the second content integration information and the content block sorting includes: Based on the content block sorting, embedding each of the second content integration information into a document parsing generation model; Determine a parsing task type corresponding to the user intention, and integrate the user intention with a task question and answer template corresponding to the parsing task type to obtain a file parsing prompt; The file parsing prompt is input into the document parsing generation model to obtain a document parsing answer output by the document parsing generation model.
8. A document parsing device, characterized in that: include: The acquisition module is used to obtain user input information and the document to be parsed; An extraction module, used to extract information from the user input information and determine the user intent and search keywords corresponding to the user input information; A slicing module, used for slicing the data of the document to be parsed to obtain a plurality of first document content blocks; A parsing module is used to generate a document parsing answer based on the user intention, each of the first document content blocks and the search keywords.
9. A document parsing device, characterized in that: The document parsing device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the document parsing method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the document parsing method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Search question-answering system and method based on large model and electronic equipment
CN117708274A
Government affair intelligent response device and method based on intention recognition and large language model
CN118035419A
Database-based retrieval enhancement and question and answer method and system
CN118364087A
Large language model commodity recommendation method based on slice tag retrieval and electronic equipment
CN118365409A
Aviation knowledge question answering method and device, computer equipment and storage medium
CN118779419A
Cited By
File access method and device, equipment and storage medium
CN121075029A