A method and system for enterprise knowledge question and answer on rules and regulations

By building a database of rules and regulations and training language models, dismantling problems and matching similar documents, we solve the problem of accurate processing of laws, regulations and rules in enterprise knowledge management, improve the accuracy and efficiency of information processing, and enhance the system's robustness. Stickiness and coverage ability.

CN118410878BActive Publication Date: 2024-09-03CHANGJIANG SECURITIES
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202410891716.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-04
Publication Date
2024-09-03
Estimated Expiration
2044-07-04

AI Technical Summary

Technical Problem

In enterprise knowledge management, traditional methods are difficult to accurately process and trace laws, regulations and internal rules and regulations, leading to problems of inaccurate search and incomplete information coverage.

Method used

Build a rules and regulations database, and use this database to train large and small language models, break down questions, use the small model to obtain answers, perform similar document matching and recall if there is no answer, and use the large model to summarize the answers.

Benefits of technology

It improves the accuracy and efficiency of problem solving, optimizes resource utilization, enhances the robustness and generalization ability of the system, quickly generates question and answer pairs, and improves the speed of knowledge accumulation and legal and regulatory coverage of small models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118410878B
    Figure CN118410878B
Patent Text Reader

Abstract

The present invention provides an enterprise knowledge question-answering method and system for rules and regulations, step S1: construct a rules and regulations database, and train a large language model and a small language model through a rules and regulations knowledge base; step S2: receive questions raised by the front end, determine whether the questions are related to the enterprise rules and regulations, and if so, enter step S3; step S3: decompose the questions into several single-target questions; step S4: input several single-target questions into the trained small language model, and return the answers corresponding to the questions to the front end for display; when the small language model cannot find the answer, similar document matching and recall are performed in the rules and regulations database to obtain the corresponding knowledge block; step S5: input the knowledge block into the large language model for summary, and return to the front end for display after generating the answer. The collaborative work of the small model and the large model optimizes resource utilization, and enhances the robustness of the system while ensuring accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language data processing application technology, and in particular to an enterprise knowledge question-answering method and system for rules and regulations. Background Art

[0002] At present, the application and understanding of laws and regulations in society are becoming more and more profound, and people can obtain relevant regulatory content through various channels. When doing corporate knowledge management, laws and regulations and internal rules and regulations are the most important basis, and each department faces a large number of rules and regulations. In highly knowledge-intensive operating scenarios such as investment banks, the professional knowledge required for each business type (such as: equity business, bond business, financial advisory business, etc.) and each business link (such as: project undertaking, securities underwriting, internal control management, etc.) varies greatly, and most of this knowledge is composed of internal and external business rules and regulations. At the same time, investment banks have high requirements for the accuracy of knowledge, and key regulatory information must be traced back to the original text.

[0003] The traditional method is to enter all the rules and regulations into the search engine and search by keywords. It has high requirements for the input keywords and the description of the problem, and it is easy to fail to search or search inaccurately. The existing general large model has strong intention understanding ability, but lacks knowledge of laws and regulations in specific fields, and cannot provide professional answers and traceability.

[0004] A common method is to achieve professional question-answering through large-model retrieval enhancement. The retrieval enhancement mode is to match the user's question with the existing knowledge base by vector, and interact the matched knowledge fragments with the large model to obtain professional answers. Its accuracy depends on the matching degree of the limited-length text content input into the large model. The core is the accuracy of matching the user's question with the rules and regulations. The key technical point is how to accurately split and encode the existing rules and regulations.

[0005] Another way is to rely on local small models to accumulate questions that users may ask one by one. Since the knowledge that small models can obtain is limited, there may be situations where they cannot answer. The core of its successful operation is also the extraction of items in the existing system and the manual generation of question and answer pairs. Therefore, there are problems such as slow accumulation and incomplete coverage of laws and regulations.

[0006] Therefore, there is an urgent need in the market for a method and system for solving the above problems. Summary of the invention

[0007] In order to solve the above technical problems, the present invention provides an enterprise knowledge question-answering method for rules and regulations, comprising the following steps:

[0008] Step S1: construct a rules and regulations database, and train the language large model and the language small model through the rules and regulations database;

[0009] Step S2: receiving the question raised by the front end, determining whether the question is related to the enterprise rules and regulations, and if so, proceeding to step S3;

[0010] Step S3: decomposing the problem into several single-objective problems;

[0011] Step S4: inputting a number of the single-target questions into the trained language model, and returning the answers corresponding to the questions to the front end for display; when the language model cannot find the answer, matching and recalling similar documents in the regulations database to obtain the corresponding knowledge block;

[0012] Step S5: input the knowledge block into the language model for summarization, and return the answer to the front end for display after the answer is generated.

[0013] Preferably, the method for constructing a regulations database comprises the following steps:

[0014] Step S11: Identify the rules and regulations document, generate text information and encode it;

[0015] Step S12: segmenting the text information, using the segmented text to fill in the summary prompt word template and then inputting it into the language model to generate summary information and encode it;

[0016] Step S13: determine the structural directory type of the document, select the corresponding prompt word template, extract the entry information of the text and encode it;

[0017] Step S14: splitting, parsing and encoding the entry information in step S13 to generate sentence encoding information;

[0018] Step S15: Segment the entry information in step S13, count the keywords and word frequencies in the entry, and generate segmentation information for splitting, parsing and encoding;

[0019] Step S16: the text information, summary information, item information, sentence encoding information and word segmentation information are associated with each other through the set file ID and item ID and then stored in the database.

[0020] Preferably, the method for generating text entry information in step S13 includes: splitting the rules and regulations file into multiple sub-files according to the optimal token input number of the generative large model, each sub-file consisting of several pages, and then inputting the generative large model to generate entry information.

[0021] Preferably, after the splitting, if it is not the first request, the content of the split is forward compatible with the set forward compatible token length and input into the generative large model for parsing.

[0022] Preferably, step S13 also includes a matching check on the generated entry information: matching the entry information with the text information one by one, and when the first and last n characters are completely matched and the middle text similarity is above a set threshold, the match is successful; when the match is unsuccessful, the forward-compatible token length is adjusted to re-parse the corresponding page of the entry.

[0023] Preferably, step S13 further includes checking the coverage of the generated entry information. When the coverage of the current page does not reach a set threshold, the forward-compatible token length of the current page is adjusted for re-parsing.

[0024] Preferably, the method for adjusting the forward compatible token length comprises: obtaining the last entry of the last parsing, matching the last entry with the parsed text of the last time; when the match is successful, setting the length of all texts after matching the entry as the forward compatible token length; when the match is unsuccessful, calculating the average length of the entries of the most recent 10 entries, traversing forward based on the average length of the entries, stopping when encountering a period or the end of a paragraph, adding the average length of the entries to the traversal length, and then obtaining the forward compatible token length; when the number of re-parsing is greater than a set first parsing threshold, while adjusting the forward compatible token length, the text before the first successfully parsed entry in the next page is added to the current page as backward compatible text for parsing, and the entries that have been successfully parsed on the current page are eliminated; when the number of re-parsing is greater than a set second parsing threshold, one page is forward compatible and one page is backward compatible, and no entries are eliminated, and the temperature parameter of the generative large model is increased, and the topk parameter is increased;

[0025] In step S2, the problem is judged by using the intention recognition small model. When the output score of the intention recognition small model is not less than the set threshold, the problem is related to the enterprise rules and regulations.

[0026] Preferably, the method for matching and recalling similar documents to obtain corresponding knowledge blocks in step S4 includes the following steps:

[0027] Step S41: obtaining a plurality of target rules and regulations documents by matching the summary information in the rules and regulations database with the single target question;

[0028] Step S42: Calculate the similarity between all knowledge blocks in the regulations database corresponding to the target regulations document and the single target question, and obtain the first a knowledge blocks with the highest similarity values ​​as the first knowledge block. The calculation method of a is to sort in reverse order by similarity, and stop when the similarity is below 0.8 or the cumulative knowledge block length exceeds the maximum token input of the language model × 0.6. If the value of a is less than or equal to the set threshold, proceed to step S43, otherwise proceed to step S44;

[0029] Step S43: split all knowledge blocks in the regulations database corresponding to the target regulations document into sentences; perform similarity matching between the sentences and the single target question, obtain the first n similarity sentences and add and sum them according to the knowledge blocks, and then divide by the number of knowledge block sentences after logarithmization to obtain the similarity of the current knowledge block, perform reverse sorting on the similarities of all knowledge blocks and take the first b as the second knowledge block, where b is calculated as follows: stop when the similarity is below the set threshold or the cumulative length of the knowledge blocks including the first knowledge block exceeds the maximum token input of the language large model × 0.6;

[0030] Step S44: extract keywords of the single-target problem, compare all the extracted keywords with the keywords of all the original knowledge blocks in the regulations database corresponding to the target regulations document, find the keywords common to both, add the weight values ​​corresponding to the common keywords to obtain the similarity value between the keywords and the original text of the current knowledge block, sort the similarities of all knowledge blocks in reverse order and take the first c as the third knowledge block, and calculate c as follows: stop when the cumulative knowledge block length exceeds the model maximum token input × 0.2;

[0031] Step S45: Integrate and remove duplicates of the first knowledge block, the second knowledge block and the third knowledge block to obtain a final knowledge block.

[0032] The present invention also provides an enterprise knowledge question-answering system for rules and regulations, which is applicable to the above-mentioned enterprise knowledge question-answering method for rules and regulations, and includes a rules and regulations database generation module, an intention recognition module, a question splitting module and a question-answering module;

[0033] The rules and regulations database generation module is used to generate a database including text information, summary information, item information, sentence coding information and word segmentation information according to the rules and regulations document;

[0034] The intention recognition module is used to identify the questions raised by the front end and determine whether they are questions related to corporate knowledge about rules and regulations;

[0035] The question splitting module is used to split the question raised by the front end into several single-objective questions and input them into the question-answering module;

[0036] The question-answering module includes a small language model and a large language model trained according to the rules and regulations database, which is used to input several single-target questions into several small language models to return corresponding answers; when the small language model cannot find the answer, similar document matching and recall are performed in the rules and regulations database to obtain the corresponding knowledge block; the knowledge block is input into the large language model for summary to generate an answer.

[0037] The beneficial effects of the present invention include at least: providing an effective data processing and knowledge question-answering method for enterprise rules and regulations with many documents and large amounts of information. The present invention divides complex problems into multiple single-objective problems, first uses a small language model to process the simple part, and then recalls relevant knowledge blocks through similar document matching for unsolvable problems, and then inputs them into the large model for processing. This method improves the accuracy and efficiency of problem solving.

[0038] The collaborative work of small and large models optimizes resource utilization and enhances the robustness of the system by gradually solving single-objective problems and processing associations. In addition, the document matching and knowledge block recall process contribute to the accumulation and dynamic optimization of the knowledge base, improve the system's ability to handle similar problems, have strong generalization capabilities, and can handle various complex formats of regulations.

[0039] At the same time, the above solution solves the problem that when a large model is used alone, the large model lacks professional knowledge; when a small model is used alone, there are problems that the small model cannot answer.

[0040] In addition, the present invention also improves the knowledge accumulation speed of the small model and enhances the legal and regulatory coverage capability of the small model by quickly generating question-answer pairs. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 A schematic diagram of a method flow chart of an embodiment of the present invention;

[0042] Figure 2 A schematic diagram of the system structure of an embodiment of the present invention;

[0043] Figure 3 This is a schematic diagram of adjusting the forward compatibility length in Example 4. DETAILED DESCRIPTION

[0044] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the protection scope of the present invention.

[0045] Example 1

[0046] like Figure 1 As shown, an embodiment of the present invention provides an enterprise knowledge question-answering method for rules and regulations, comprising the following steps:

[0047] Step S1: Build a database of rules and regulations, and train the large language model and the small language model through the database of rules and regulations.

[0048] Specifically, in this embodiment, the rules and regulations database includes the rules and regulations file name, summary, items, sentences and corresponding codes and the segmentation words corresponding to the items.

[0049] By adopting the rules and regulations database and training the large language model and the small language model through the rules and regulations database, we can obtain a small language model with high efficiency and a large language model that can handle complex problems.

[0050] Step S2: Receive questions raised by the front end and determine whether the questions are related to corporate rules and regulations. If so, proceed to step S3.

[0051] Specifically, in this embodiment, the intention recognition model is called to perform intention recognition to determine whether the question is related to corporate rules and regulations. If the output score of the model is below the set threshold, it means that the question is not related to corporate rules and regulations, and "Please re-enter the question related to corporate rules and regulations" is returned to the front end. If the output score of the model is not less than the set threshold, it means that the question is real knowledge related to corporate rules and regulations.

[0052] Step S3: Decompose the problem into several single-objective problems.

[0053] Step S4: Input several single-target questions into the trained language model, and return the answers corresponding to the questions to the front end for display; when the language model cannot find the answer, similar documents are matched and recalled in the regulations database to obtain the corresponding knowledge block.

[0054] Specifically, in the specific operation of this embodiment, the question is first processed by embedding to obtain the question embedding, and the question embedding is input into the small language model to obtain the classification answer and its corresponding discrimination probability. If the probability is greater than 0.95, it means that the small language model can find the answer to the corresponding question, and the matching answer is returned as output to the front end for display; if there is no corresponding answer, the obtained question embedding is matched and recalled with the existing rules and regulations in the rules and regulations database, and after obtaining the corresponding knowledge block, it is transmitted to the large language model for processing.

[0055] Step S5: Input the knowledge block into the language model for summary, and return it to the front end for display after the answer is generated.

[0056] Specifically, the knowledge block and the disassembled question are filled into a preset prompt word template, a corresponding prompt is generated, the language model is called to generate, the output result of the language model is parsed, the language model's summary of the question and the original text cited are obtained, and the original text cited is reversely mapped with the knowledge block in the knowledge base, including the system name, chapter, item, and original text of the system, and returned to the front end for display. In this embodiment, when transmitted to the language model, the prompt word template requires the model to output the summarized answer and the original text of the knowledge block cited by the answer.

[0057] Example 2

[0058] Since the object of the present invention is corporate rules and regulations, there must be no omissions or missing items, and there should be a correlation between different items; and the rules and regulations promulgated by different institutions vary greatly in content and format. Traditional text information processing mainly extracts key information such as directories, summaries, tables, and pictures from relatively standardized documents such as annual reports or research reports. The current commonly used method is to use keywords for positioning and then use rules to extract key information. Natural language technology is used for enhancement in some scenarios. However, the traditional method of extracting rules and regulations is limited by the quality and coverage of rule templates, and the scalability is not strong. The framework of the detection and recognition model is single and cannot meet the needs of various rules and regulations with different forms.

[0059] Therefore, this embodiment further improves the method of constructing the rules and regulations database in step S1, which includes the following steps.

[0060] Step S11: Identify the rules and regulations document, generate text information and encode it.

[0061] Specifically, a request to extract rules and regulations is accepted, and the extraction request contains documents and recognition patterns. Rules and regulations documents usually include two categories: PDF format and Word format. Word format is generally the original published document. The system document is subjected to target detection through the preset version analysis model to obtain the target detection result. The PDF file is subjected to target detection. If the PDF document is protected or has a screenshot, the external preset OCR interface is called to identify and process the document through the external OCR interface, and the data returned by the external OCR interface is accepted.

[0062] Then, according to the detection results, the corresponding parsing module is called to parse the rules and regulations file and obtain the page layout. According to the parsed page layout, the character information of each page in the system file is obtained in sequence. According to the detection template, the redundant information of the page, such as the header, footer, template and other data, is cleaned to generate the full text structured information of the rules and regulations, that is, the text information.

[0063] Step S12: segmenting the text information, using the segmented text to fill in the summary prompt word template and then inputting it into the language model to generate summary information and encode it.

[0064] Specifically, the plain text information generated in the previous step is segmented according to 60% of the maximum token length accepted by the large model, and filled into the pre-set summary generation prompt word template, generating the corresponding prompt, calling the large model for generation, parsing the output of the generative large model, and obtaining the summary of the text information. In the summary generation prompt word template, the language large model is required to extract the content of the summary at a scale of 1:10.

[0065] Step S13: Determine the structural directory type of the document, select the corresponding prompt word template, extract the entry information of the text and encode it.

[0066] Specifically, the format type of the rules and regulations document is detected using the big model to determine the structure directory type of the document. The generative big model type and corresponding parameters, as well as the corresponding prompt word template, are selected based on the detection results.

[0067] The generative big model is called to parse this paragraph of rules and regulations, and the prompt words require and return them in the form of entries of first-level chapters, second-level chapters, and table of contents. The specific format is as follows [<first-level chapter, second-level chapter, entry>]. To ensure the stability of the generative big model, this embodiment sets the temperature parameter to 0 when it is requested for the first time.

[0068] Accept the return result of the generative large language model and try to convert the returned result into a list of regulation items in JSON list format. If the parsing fails, directly discard the generated result. Repeat the above steps for parsing until all items are generated.

[0069] Step S14: The entry information in step S13 is split, parsed and encoded sentence by sentence to generate sentence encoding information.

[0070] Specifically, the obtained entry information is decomposed sentence by sentence to obtain all the sentences corresponding to a single entry. Then the sentence is input into the small model to obtain the embedding corresponding to each sentence in the entry, and the sentence encoding information is obtained in the format of <file id, file name, entry id, original sentence, sentence embedding>.

[0071] Step S15: Segment the entry information in step S13, count the keywords and word frequencies in the entry, generate segmentation information and encode it.

[0072] Specifically, the word segmentation model is called on the obtained entry information to segment the entry, obtain the word segmentation result of the entry, and count the keywords and word frequencies of the entry.

[0073] Step S16: Map the text information, summary information, item information, sentence coding information and word segmentation information to the corresponding coding, and store them in the database after associating them with the set file ID and item ID.

[0074] Specifically, the generated summary is stored in the summary database in the format of <file id, summary id, file name, summary>, the generated entry is stored in the entry database in the format of <file id, file name, first-level chapter, second-level chapter, entry id, entry, page number>, the generated sentence and the corresponding code are stored in the sentence database in the format of <file id, file name, entry id, sentence original text, sentence embedding>, and the generated word segmentation is stored in the format of <file id, file name, first-level chapter, second-level chapter, entry id, keyword, word frequency>.

[0075] Example 3

[0076] In order to further improve the accuracy and completeness of the extraction of rules and regulations, this embodiment further improves the extraction of knowledge blocks, namely, entry information, as follows.

[0077] When the number of tokens input to a large generative model is too large, that is, when it exceeds the model's understanding ability, the model's understanding ability will decrease and the output stability will also decrease rapidly. For example, for large commercial models (Wenxinyiyan, chatGPT), the length is controlled within 2000 tokens, and for local models (QWen), the parsing length is controlled within 600 bytes.

[0078] Therefore, this embodiment splits the rules and regulations file into multiple files and then inputs them into the model for parsing. Since splitting the rules and regulations file only according to the number of tokens will make it difficult to understand the context, this embodiment splits the rules and regulations file into multiple sub-files according to the optimal number of tokens input to the generative large model, and each sub-file consists of several pages. For example, when the optimal number of tokens is 600, if the total number of tokens on the first and second pages exceeds 600, then during this split, it is only split into files consisting of the first page.

[0079] Furthermore, in order to ensure the consistency of parsing of the rules and regulations document, this embodiment, when it is not the first request, inputs the generative big model for parsing the content of the previous split according to the set forward-compatible token length. In this way, by including part of the content of the previous parsing in this parsing, it can be ensured that the big model can fully understand the intention and contextual relationship of the two parsings, and the parsing consistency is guaranteed.

[0080] After the entry information is generated, this embodiment performs a matching check on the entry information to ensure the accuracy of the analysis: the entry information is matched with the text information one by one. When the first and last n characters are completely matched and the intermediate text similarity is above the set threshold, the match is successful. When the match is unsuccessful, the forward compatible token length is adjusted to re-parse the corresponding page of the entry. In order to ensure the integrity of the analysis, this embodiment also performs a coverage check on the generated entry information. The coverage is expressed as the sum of the length of the regulation entry per page / the length of the current document.

[0081] When the coverage of the current page number does not reach the set threshold, the forward compatible token length of the current page number is adjusted for re-parse. Specifically, the spliced ​​text is added with a prompt word, and the temperature parameter is increased to 0.5 to increase the diversity of the generated results. The large model is called to re-parse the text for chapter entries to obtain a newly parsed chapter entry list. The new parsed result is compared with the original parsed list, and after removing duplicate data, the newly parsed entry is obtained, and the new entry is inserted into the parsed result list.

[0082] In this embodiment, the forward compatible token length is first adjusted: the last entry of the last parsing is obtained, and the last entry is matched with the last parsed text; when the match is successful, the length of all texts after the matching entry is set to the forward compatible token length. Specifically, Figure 3 In the case shown, the content of the last 20th item parsed in the previous analysis is taken as the forward-compatible length and put into the current page for merging and parsing; when the match fails, the average length of the last 10 items is calculated, and based on the average length of the items, the document is traversed forward, and the forward-compatible token length is obtained by adding the average length of the items to the traversal length. The document is traversed until the input length is met.

[0083] When the similarity and coverage requirements cannot be met after multiple adjustments, that is, the number of adjustments is greater than the set first parsing threshold, the forward-compatible token length is adjusted and the text before the first successfully parsed entry on the next page is added to the current page as backward-compatible text for parsing, and the entries that have been successfully parsed on the current page are removed.

[0084] When adding backward compatible text multiple times, that is, the number of adjustments is greater than the set second analysis number threshold, if the similarity requirements and coverage requirements still cannot be met, then directly forward compatible with one page and backward compatible with one page, and no longer remove entries, increase the temperature parameter of the generative large model, and increase the topk parameter.

[0085] Finally, the generated entry information may be missing some chapter information. This embodiment splices all the chapter entry information in order, inputs the spliced ​​text into the language model, and allows the language model to complete the missing chapter information and generate a new chapter entry list.

[0086] Example 4

[0087] In the process of matching and recalling similar documents to obtain corresponding knowledge blocks, in order to more accurately locate the knowledge blocks, this embodiment further improves the matching of similar documents as follows.

[0088] Step S41: The language model calculates the similarity between the question embedding and the summary embedding of the original rules and regulations file in the rules and regulations database one by one, and obtains the original rules and regulations files corresponding to the first a summary embeddings with the highest similarity values. The calculation method of a is to sort in reverse order by similarity, and stop when the similarity is below 0.6, and the maximum value of a is set to 20.

[0089] The purpose of this step is to first perform summary matching, retrieve layer by layer, quickly lock in possible target documents through summary matching, and remove irrelevant documents.

[0090] Step S42: The rules and regulations file obtained in step S41 corresponds to all knowledge block embeddings in the rules and regulations database, and the similarity of all knowledge block embeddings and question embeddings is calculated to obtain the top b knowledge block embeddings with the highest similarity values. If the value of b is less than or equal to 2, proceed to step S43, otherwise proceed to S44. The calculation method of b is to sort in reverse order by similarity, and stop when the similarity is less than 0.8 or the cumulative knowledge block length exceeds the model maximum token input × 0.6.

[0091] Step S43: Obtain all the knowledge blocks and the sentences and sentence embeddings after the knowledge blocks are split in the rules and regulations database corresponding to the rules and regulations file obtained in step S41, calculate the similarity of all sentence embeddings and question embeddings one by one to obtain the similarity of a single sentence, obtain the top 100 similarity sentences and accumulate and sum them according to the knowledge blocks, and then divide by the number of knowledge block sentences after taking the log to obtain the similarity of the current knowledge block. The similarities of all knowledge blocks are sorted in reverse order to obtain the first c, and c is calculated as follows: stop when the similarity is below 0.8 or the cumulative knowledge block length exceeds the model's maximum token input × 0.6. The accumulated knowledge blocks in this step include the knowledge blocks obtained in step S42.

[0092] Step S44: First, input the original question into the keyword extraction model to extract the keywords of the question. Compare all the extracted keywords with the keywords of the original text of each knowledge block in the rules and regulations database to find the common keywords between the two, and add the weight values ​​corresponding to the common keywords to get the similarity value between the keywords and the original text of the current knowledge block. Reverse the similarities of all knowledge blocks and stop when the cumulative length of the knowledge block exceeds the maximum token input of the model × 0.2. At the same time, the knowledge blocks obtained in steps S43 and S44 are integrated with the knowledge blocks obtained in this step to remove duplicates, and finally all related knowledge blocks are obtained.

[0093] Example 5

[0094] After the solution of Example 1 is used to generate the answer to the question, this embodiment can further fill the rules and regulations knowledge base with rules and regulations knowledge blocks, so that the small language model and the large language model can master more knowledge. Specifically, the following steps are included:

[0095] 1) Combine the matched and recalled knowledge blocks according to the rule that the maximum length does not exceed 2000 to obtain a large knowledge block.

[0096] 2) Extraction of knowledge question and answer pairs: fill the obtained large knowledge block into the pre-set prompt word template, generate the corresponding prompt word prompt, call the language large model for generation, parse the output result of the generative large model, and output it in a fixed json_list format such as "{"Question 1:", "Answer 1:"}, {"Question 2:", "Answer 2:"}, {"Question 3:", "Answer 3:"}......." output format.

[0097] 3) Knowledge ambiguity optimization: The question-answer pairs extracted above are compared and analyzed with the existing question-answer pairs in the regulations and rules database.

[0098] 31) Bind the question-answer pairs extracted in the above steps to the original file, and determine whether the current file is a new or updated version of an existing file based on the document title and summary information.

[0099] 32) If the document is an updated version of an existing document, the question and answer pairs in the rules and regulations database corresponding to the existing document shall be updated one by one and the version information shall be marked.

[0100] 33) If the file is a new one, it is necessary to check whether each question and answer pair has similar questions and answers in the rules and regulations database.

[0101] 331) Call the search model in the regulations database to compare each question and answer pair to obtain similar or repeated existing question and answer pairs.

[0102] 332) Call the coding model to vectorize the question, and calculate the similarity between the vectorized code and the vector code of the existing questions in the database. If the calculated similarity is 95% or above, the answer in the extracted question and answer pair can be selected as the latest answer and updated to the rules and regulations database; if no similar question can be found, the question and answer pair will be added to the rules and regulations database as new content.

[0103] 4) Question statement expansion: To match the needs of operators, for the question and answer pairs obtained in 3), a preset number of question statement expansions are performed on each question.

[0104] 41) Set prompt words based on specific business scenarios, such as requiring more authoritative language internally and more colloquial questions externally. Prompt words can be set by operators themselves or selected based on preset options.

[0105] 42) Supplement the prompt template according to the prompt words and preset number information in the previous step, call the large model to ask questions, and parse the output results of the generative large model in a fixed format such as "{{{Similar question 1}}}, {{{Similar question 2}}}, {{{Similar question 3}}}....." and return them in a streaming manner.

[0106] 43) For similar questions generated in the previous step, operators can choose to accept or reject them based on whether the requirements and quantity are met.

[0107] 431) If accepted, it may be added to the rules and regulations database;

[0108] 432) If you do not accept it, you can edit it again. You can directly modify some words, modify part of the question, or choose another generative model to regenerate it until it is accepted and stored.

[0109] 5) Scenario-based language polishing: To match the needs of operations staff, for the question and answer pairs obtained in 3), make scenario-based adjustments to each answer according to different scenarios such as customer and internal.

[0110] 51) First, match the appropriate scene, prompt words, and model.

[0111] 511) For the answers extracted from 2), first select the scenario, such as internal or external, to customers or operational sales personnel, to leaders or other colleagues.

[0112] 512) Operators can choose the default or customized settings based on their needs, and choose appropriate large model prompt words, such as "Please rephrase in a more tactful way", "The answer is more authoritative", etc.

[0113] 513) Select a recommended generative model or select your own model.

[0114] 52) According to the above selected scenarios, prompt words, and models, the prompt template is supplemented, the big model is called to ask questions, and the output results of the parsed generative big model are returned in a stream in a fixed format such as "{"Answer 1:", "Polished Answer 1:"}, {"Answer 2:", "Polished Answer 2:"}, {"Answer 3:", "Polished Answer 3:"}.......". The operator can choose to accept the polished answer or modify it again to request single or batch generation.

[0115] 6) Question and answer pair storage: The original question and answer pair obtained in 3), the question expansion obtained in 4), and the polished answer obtained in 5) are stored in the rules and regulations database in the format of <question, answer, file name, question expansion, polished answer>.

[0116] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. Only the preferred embodiments of the present invention are expressed. The description is more specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. As long as there is no contradiction in the combination of these technical features, they should be considered as the scope recorded in this specification.

[0117] It should be noted that, for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these modifications and improvements all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. A corporate knowledge question-answering method for rules and regulations, characterized by: The following steps are involved: Step S1: construct a rules and regulations database, and train the language large model and the language small model through the rules and regulations database; Step S2: receiving the question raised by the front end, determining whether the question is related to the enterprise rules and regulations, and if so, proceeding to step S3; Step S3: decomposing the problem into several single-objective problems; Step S4: inputting a number of the single-target questions into the trained language model, and returning the answers corresponding to the questions to the front end for display; when the language model cannot find the answer, matching and recalling similar documents in the regulations database to obtain the corresponding knowledge block; Step S5: input the knowledge block into the language model for summarization, and return the answer to the front end for display after the answer is generated; The method of constructing a rules and regulations database includes the following steps: Step S11: Identify the rules and regulations document, generate text information and encode it; Step S12: segmenting the text information, using the segmented text to fill in the summary prompt word template and then inputting it into the language model to generate summary information and encode it; Step S13: determine the structural directory type of the document, select the corresponding prompt word template, extract the entry information of the text and encode it; Step S14: splitting, parsing and encoding the entry information in step S13 sentence by sentence to generate sentence encoding information; Step S15: Segment the entry information in step S13, count the keywords and word frequencies in the entry, generate segmentation information and encode it; Step S16: Map the information obtained from step S11 to step S15 and the corresponding code, and store them in the database after associating them with the set file ID and entry ID; The method for generating text entry information in step S13 includes: splitting the rules and regulations file into multiple sub-files according to the optimal token input number of the generative big model, each sub-file consists of a number of pages, and then inputting the generative big model to generate entry information; after splitting, if it is not the first request, inputting the content of the previous split into the generative big model for parsing according to the set forward compatible token length to be forward compatible; Step S13 also includes checking the matching degree of the generated entry information: matching the entry information with the text information one by one, and when the first and last n characters are completely matched and the intermediate text similarity is above a set threshold, the match is successful; when the match is unsuccessful, the forward-compatible token length is adjusted to reparse the entry corresponding page; Step S13 also includes checking the coverage of the generated entry information. When the coverage of the current page does not reach a set threshold, the forward-compatible token length of the current page is adjusted for re-parsing. In step S13, the method for adjusting the forward-compatible token length includes: obtaining the last entry of the last parsing, matching the last entry with the last parsed text; when the match is successful, setting the length of all texts after matching the entry as the forward-compatible token length; when the match is unsuccessful, calculating the average length of the entries of the most recent 10 entries, traversing forward based on the average length of the entries, stopping when encountering a period or the end of a paragraph, adding the average length of the entries to the traversal length, and then obtaining the forward-compatible token length; when the number of re-parsing is greater than the set first parsing number threshold, while adjusting the forward-compatible token length, the text before the first successfully parsed entry on the next page is added to the current page as backward-compatible text for parsing, and the entries that have been successfully parsed on the current page are eliminated; when the number of re-parsing is greater than the set second parsing number threshold, one page is forward compatible and one page is backward compatible, and no entries are eliminated, and the temperature parameter of the generative large model is increased, and the topk parameter is increased.

2. The enterprise knowledge question-answering method for rules and regulations according to claim 1, characterized in that: In step S2, the problem is judged by using the intention recognition small model. When the output score of the intention recognition small model is not less than the set threshold, the problem is related to the enterprise rules and regulations.

3. The enterprise knowledge question-answering method for rules and regulations according to claim 1 is characterized by: The method for matching and recalling similar documents to obtain corresponding knowledge blocks in step S4 includes the following steps: Step S41: obtaining a plurality of target rules and regulations documents by matching the summary information in the rules and regulations database with the single target question; Step S42: Calculate the similarity between all knowledge blocks in the regulations database corresponding to the target regulations document and the single target question, and obtain the first a knowledge blocks with the highest similarity values ​​as the first knowledge block. The calculation method of a is to sort in reverse order by similarity, and stop when the similarity is below 0.8 or the cumulative knowledge block length exceeds the maximum token input of the language model × 0.

6. If the value of a is less than or equal to the set threshold, proceed to step S43, otherwise proceed to step S44; Step S43: split all knowledge blocks in the regulations database corresponding to the target regulations document into sentences; perform similarity matching between the sentences and the single target question, obtain the first n similarity sentences and add and sum them according to the knowledge blocks, and then divide by the number of knowledge block sentences after logarithmization to obtain the similarity of the current knowledge block, perform reverse sorting on the similarities of all knowledge blocks and take the first b as the second knowledge block, where b is calculated as follows: stop when the similarity is below the set threshold or the cumulative length of the knowledge blocks including the first knowledge block exceeds the maximum token input of the language large model × 0.6; Step S44: extract keywords of the single-target problem, compare all the extracted keywords with the keywords of all the original knowledge blocks in the regulations database corresponding to the target regulations document, find the keywords common to both, add the weight values ​​corresponding to the common keywords to obtain the similarity value between the keywords and the original text of the current knowledge block, sort the similarities of all knowledge blocks in reverse order and take the first c as the third knowledge block, and calculate c as follows: stop when the cumulative knowledge block length exceeds the model maximum token input × 0.2; Step S45: Integrate and remove duplicates of the first knowledge block, the second knowledge block and the third knowledge block to obtain a final knowledge block.

4. An enterprise knowledge question-answering system for rules and regulations, applicable to the enterprise knowledge question-answering method for rules and regulations as claimed in any one of claims 1 to 3, characterized in that: It includes rules and regulations database generation module, intention recognition module, question splitting module and question-answering module; The rules and regulations database generation module is used to generate a database including text information, summary information, item information, sentence coding information and word segmentation information according to the rules and regulations document; The intention recognition module is used to identify the questions raised by the front end and determine whether they are questions related to corporate knowledge about rules and regulations; The question splitting module is used to split the question raised by the front end into several single-objective questions and input them into the question-answering module; The question-answering module includes a small language model and a large language model trained according to the rules and regulations database, which is used to input several single-target questions into several small language models to return corresponding answers; when the small language model cannot find the answer, similar document matching and recall are performed in the rules and regulations database to obtain the corresponding knowledge block; the knowledge block is input into the large language model for summary to generate an answer.

Citation Information

Patent Citations

  • Hypertension question-answering method and system based on deep learning

    CN116737911A

  • Knowledge base construction method and question and answer dialogue method and system based on generative large language model

    CN117056471A

  • Knowledge question and answer method, device and equipment and storage medium

    CN117171306A

  • Agricultural knowledge question and answer method and device, storage medium and equipment

    CN117708294A

  • Knowledge base retrieval method based on text compression and related equipment

    CN117763084A