CN117743558B - Knowledge processing and knowledge question-answering method, device and medium based on large model - Google Patents

Knowledge processing and knowledge question-answering method, device and medium based on large model Download PDF

Info

Publication number
CN117743558B
CN117743558B CN202410185839.0A CN202410185839A CN117743558B CN 117743558 B CN117743558 B CN 117743558B CN 202410185839 A CN202410185839 A CN 202410185839A CN 117743558 B CN117743558 B CN 117743558B
Authority
CN
China
Prior art keywords
target
question
knowledge
answer
level
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202410185839.0A
Other languages
Chinese (zh)
Other versions
CN117743558A (en
Inventor
邓邱伟
张旭
付振宇
刘朝振
王淼
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qingdao Haier Technology Co Ltd
Qingdao Haier Intelligent Home Appliance Technology Co Ltd
Haier Uplus Intelligent Technology Beijing Co Ltd
Original Assignee
Qingdao Haier Technology Co Ltd
Qingdao Haier Intelligent Home Appliance Technology Co Ltd
Haier Uplus Intelligent Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Qingdao Haier Technology Co Ltd, Qingdao Haier Intelligent Home Appliance Technology Co Ltd, Haier Uplus Intelligent Technology Beijing Co Ltd filed Critical Qingdao Haier Technology Co Ltd
Priority to CN202410185839.0A priority Critical patent/CN117743558B/en
Publication of CN117743558A publication Critical patent/CN117743558A/en
Application granted granted Critical
Publication of CN117743558B publication Critical patent/CN117743558B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a knowledge processing and knowledge question answering method, device and medium based on a large model, and relates to the field of artificial intelligence, wherein the method comprises the following steps: acquiring a target picture file corresponding to a target document; analyzing the target picture file to obtain an analysis result, wherein the analysis is used for indicating the extraction of the elements of each picture in the target picture file; acquiring knowledge segments nested in a hierarchy according to the level corresponding to the title and the text content in the analysis result, wherein each title corresponds to one level, the next-level title is a sub-title of the previous-level title, and the knowledge segment corresponding to each title comprises the text content corresponding to the title and the knowledge segment of the next-level title; and generating a question-answer database according to the knowledge segments nested in the hierarchy, so that answers are acquired according to the question-answer database when knowledge questions and answers are obtained. The method realizes high reliability and expansibility of knowledge processing, thereby improving the quality of answer content and enhancing user experience.

Description

Knowledge processing and knowledge question-answering method, device and medium based on large model
Technical Field
The application relates to the field of artificial intelligence, in particular to a knowledge processing and knowledge question-answering method, device and medium based on a large model.
Background
PDF (Portable Document Format) is a general electronic document format, and is widely used because of its cross-platform property and structural stability. In reality, a large amount of data content exists in a PDF form, and along with the continuous development of artificial intelligence, intelligent question-answering application based on PDF documents is gradually rising in the fields of customer service and information retrieval.
However, the existing PDF document question-answering system cannot analyze PDF in a refined manner, and therefore analysis accuracy is limited, and only a few simple documents can be processed. Aiming at the question of the user, the questions with incomplete answer content and incoherence before and after the word sequence exist. The questions can lead to poor question and answer effects, thereby affecting user experience.
Disclosure of Invention
In order to solve the problems, the application provides a knowledge processing and knowledge question answering method, device and medium based on a large model.
In a first aspect, the present application provides a knowledge processing method based on a large model, including:
Obtaining a target picture file corresponding to a target document, wherein the target document represents a document in a non-editable format to be analyzed, and the target picture file represents a file formed after the target document is converted into a picture format;
analyzing the target picture file to obtain an analysis result, wherein the analysis is used for indicating the extraction of elements of each picture in the target picture file, and the elements comprise a title and text content;
acquiring hierarchical nested knowledge segments according to the level corresponding to the title and the text content in the analysis result, wherein each title corresponds to one level, the next-level title is a sub-title of the previous-level title, and each knowledge segment corresponding to the title comprises the text content corresponding to the title and the knowledge segment of the next-level title;
Generating a question-answer database according to the knowledge segments nested in the hierarchy, so that answers are obtained according to the question-answer database when knowledge questions and answers;
The question-answer database comprises a question-answer knowledge base, a text database and a vector database, wherein the question-answer knowledge base comprises question-answer contents corresponding to each knowledge segment and target levels corresponding to the question-answer contents, the question-answer contents are acquired through a large model, the text database is used for storing a plurality of sub-text databases, different sub-text databases store knowledge segments of different nesting levels, the vector database is used for storing a plurality of sub-vector databases, and different sub-vector databases are used for storing vector data of knowledge segments of different nesting levels.
In one possible implementation manner, the generating a question-answer database according to the knowledge segments nested in the hierarchy, so that the answer is obtained according to the question-answer database when knowledge questions and answers, includes:
acquiring at least two groups of question-answer contents corresponding to each title through a large model according to each knowledge fragment, and acquiring a question-answer knowledge base according to the question-answer contents and target levels corresponding to the question-answer contents, wherein each group of question-answer contents comprises a question and a corresponding answer;
According to the hierarchical nested relation of each knowledge segment, sequentially acquiring text contents of each level from low level to high level, and splicing the text contents according to the order from low level to high level to obtain target text contents;
Storing the target text content according to a corresponding target level to obtain the text database;
and carrying out vectorization processing on the target text content to obtain vector data corresponding to the knowledge segments, and storing the vector data according to a target level corresponding to the target text content to obtain the vector database.
In one possible implementation manner, the obtaining the target picture file corresponding to the target document includes:
Acquiring an initial picture file corresponding to the target document according to the target document, wherein the content corresponding to each picture in the initial picture file is the same as the content corresponding to each page in the target document;
Judging whether the pictures in the initial picture file are required to be paged according to a preset paging rule, wherein the paging rule is used for indicating a preset single page size or typesetting structure;
If yes, acquiring a target picture to be paged and a corresponding paging boundary in the initial picture file, performing paging processing on the target picture, and acquiring the target picture file according to the target picture after the paging processing and the rest pictures except the target picture in the initial picture file;
if not, the initial picture file is the target picture file.
In a possible implementation manner, the determining, according to a preset paging rule, whether to need to page the picture in the initial picture file includes:
Acquiring size information corresponding to each picture of the initial picture file;
judging whether a target picture with the height-width ratio and/or the area larger than the corresponding preset size exists in the initial picture file or not according to the size information;
if yes, indicating that paging is required for the pictures in the initial picture file; if not, the picture in the initial picture file does not need to be paged.
In a possible implementation manner, the determining, according to a preset paging rule, whether to need to page the picture in the initial picture file includes:
traversing the line spacing in each picture of the initial picture file, wherein the line spacing is used for indicating the distance between each line element in each picture;
judging whether target pictures with line spacing larger than preset spacing exist in the initial picture file;
if yes, indicating that paging is required for the pictures in the initial picture file; if not, the picture in the initial picture file does not need to be paged.
In one possible implementation manner, the obtaining a knowledge segment nested in a hierarchy according to the level corresponding to the topic and the text content in the parsing result includes:
acquiring a hierarchical structure of the title according to the level corresponding to the title in the analysis result;
and distributing the text content to corresponding levels according to the belonged titles to obtain level nested knowledge segments.
In one possible implementation manner, the obtaining the hierarchical structure of the title according to the level corresponding to the title in the parsing result includes:
According to the level corresponding to the title in the analysis result, placing each title in a corresponding level so that each title corresponds to one node;
for titles of different levels, respectively associating the nodes of each title with the nodes of the corresponding previous-level and next-level titles, so that the nodes of each title contain references pointing to the previous-level and next-level nodes;
and after the node association of each title is completed, acquiring the hierarchical structure of the title.
In one possible implementation manner, the assigning the text content to the corresponding hierarchy according to the title to which the text content belongs, to obtain the knowledge segment nested in the hierarchy, includes:
acquiring position information of the text content, wherein the position information is used for indicating the position of the text content in a picture;
Regarding each text content, taking a title nearest to the text content as a title to which the text content belongs in the text content according to the position information;
and distributing the text content to nodes corresponding to the titles according to the titles to obtain the hierarchical nested knowledge segments.
In a second aspect, the present application provides a knowledge question-answering method based on a large model, the method comprising:
Acquiring a target question input by a user terminal, wherein the target question is in a text format;
Judging whether a corresponding target answer exists in a question-answer knowledge base of the question-answer database according to the target questions and the question-answer database, wherein the question-answer database is obtained by the method according to any one of the first aspect, the question-answer database comprises a question-answer knowledge base, a text database and a vector database, the question-answer knowledge base comprises question-answer contents corresponding to each knowledge segment obtained through a large model and target levels corresponding to the question-answer contents, the text database is used for storing a plurality of sub-text databases, different sub-text databases are used for storing knowledge segments of different nesting levels, the vector database is used for storing a plurality of sub-vector databases, and different sub-vector databases are used for storing vector data of knowledge segments of different nesting levels;
If yes, returning the target answer to the user side;
If not, acquiring a target level of the target problem according to the question-answer knowledge base, respectively acquiring a first knowledge segment and a second knowledge segment similar to the target problem from a sub-text database and a sub-vector database associated with the target level, acquiring a target answer through a large model according to the first knowledge segment and/or the second knowledge segment, and returning to the user terminal, wherein the association comprises at least one of a present level, an upper level or a lower level corresponding to the target level.
In one possible implementation manner, the determining whether the corresponding target answer exists in the question-answer knowledge base of the question-answer database includes:
acquiring a target keyword in the target problem, wherein the target keyword is used for indicating words corresponding to preset parts of speech in the target problem, and the preset parts of speech comprises at least one of nouns, verbs or adjectives;
according to the occurrence times of each target keyword in the historical query data of the user side, acquiring the weight corresponding to each target keyword, wherein the higher the occurrence times are, the higher the corresponding weight is;
Acquiring a first matching degree corresponding to each question in the question-answer knowledge base according to the target keywords and the corresponding weights, wherein the first matching degree is used for indicating the sum of the occurrence times of each target keyword in a single question and the weighted value of the corresponding weight;
If a target matching problem with the first matching degree being greater than or equal to a first preset threshold exists, the answer corresponding to the target matching problem with the highest matching degree is a target answer;
If no target matching problem with the first matching degree being greater than or equal to a first preset threshold value exists, the fact that no corresponding target answer exists in the question-answer knowledge base is indicated.
In one possible implementation manner, the obtaining the target level of the target problem according to the question-answering knowledge base, and obtaining a first knowledge segment and a second knowledge segment similar to the target problem from a sub-text database and a sub-vector database associated with the target level, and obtaining a target answer through a large model according to the first knowledge segment and/or the second knowledge segment, includes:
acquiring the candidate problem with the highest first matching degree from the question-answer knowledge base, and acquiring a target level corresponding to the question-answer content to which the candidate problem belongs, wherein the target level is the level corresponding to the target problem;
Acquiring a sub-text database associated with the target level;
According to the target keywords and the corresponding weights, first knowledge segments with second matching degrees larger than or equal to a second preset threshold value are obtained from the sub-text database, wherein the second matching degrees are used for indicating the sum of the occurrence times of each target keyword in a single knowledge segment and the weighted value of the corresponding weight;
Carrying out vectorization processing on the target problem, obtaining corresponding target vector data, and obtaining a sub-vector database associated with the target level;
According to the target vector data, obtaining a second knowledge segment corresponding to vector data with a third matching degree greater than or equal to a third preset threshold value from the sub-vector database, wherein the third matching degree is used for indicating a value obtained by vector similarity calculation of the target vector data and vector data corresponding to a single knowledge segment;
and generating the target answer through the large model according to the first knowledge piece and/or the second knowledge piece.
In a third aspect, the present application provides a knowledge processing apparatus based on a large model, comprising:
The first acquisition module is used for acquiring a target picture file corresponding to a target document, wherein the target document represents a document in a non-editable format to be analyzed, and the target picture file represents a file formed after the target document is converted into a picture format;
The analysis module is used for analyzing the target picture file to obtain an analysis result, wherein the analysis is used for indicating the extraction of elements of each picture in the target picture file, and the elements comprise a title and text content;
The first processing module is used for obtaining knowledge segments nested in a hierarchy according to the level corresponding to the title and the text content in the analysis result, wherein each title corresponds to one level, the next-level title is a sub-title of the previous-level title, and the knowledge segment corresponding to each title comprises the text content corresponding to the title and the knowledge segment of the next-level title;
The first processing module is further used for generating a question-answer database according to the knowledge segments nested in the hierarchy, so that answers are obtained according to the question-answer database when knowledge questions and answers are obtained;
The question-answer database comprises a question-answer knowledge base, a text database and a vector database, wherein the question-answer knowledge base comprises question-answer contents corresponding to each knowledge segment and target levels corresponding to the question-answer contents, the question-answer contents are acquired through a large model, the text database is used for storing a plurality of sub-text databases, different sub-text databases store knowledge segments of different nesting levels, the vector database is used for storing a plurality of sub-vector databases, and different sub-vector databases are used for storing vector data of knowledge segments of different nesting levels.
In a fourth aspect, the present application provides a knowledge question-answering apparatus based on a large model, including:
the second acquisition module is used for acquiring a target problem input by the user side, wherein the target problem is in a text format;
The second processing module is configured to determine whether a corresponding target answer exists in a question-answer knowledge base of the question-answer database according to the target question and the question-answer database, where the question-answer database is obtained by the method according to any one of the first aspects, the question-answer database includes a question-answer knowledge base, a text database, and a vector database, the question-answer knowledge base includes a question-answer content and a target level corresponding to the question-answer content, which are acquired through a large model, each knowledge segment, the text database is used for storing a plurality of sub-text databases, different sub-text databases store knowledge segments of different nesting levels, and the vector database is used for storing a plurality of sub-vector databases, and different sub-vector databases are used for storing vector data of knowledge segments of different nesting levels;
If yes, returning the target answer to the user side;
If not, acquiring a target level of the target problem according to the question-answer knowledge base, respectively acquiring a first knowledge segment and a second knowledge segment similar to the target problem from a sub-text database and a sub-vector database associated with the target level, acquiring a target answer through a large model according to the first knowledge segment and/or the second knowledge segment, and returning to the user terminal, wherein the association comprises at least one of a present level, an upper level or a lower level corresponding to the target level.
In a fifth aspect, the present application provides a computer readable storage medium comprising a stored program, wherein the program when run performs the method of any one of the first and second aspects.
In a sixth aspect, the present application provides an electronic device comprising a memory having a computer program stored therein and a processor arranged to perform the method as described in the first and second aspects by means of the computer program.
According to the knowledge processing and knowledge question answering method, device and medium based on the large model, provided by the application, the picture file corresponding to the target document is obtained, and the picture file is analyzed to obtain the title in the picture, the text, the embedded picture or the elements such as the table. And acquiring a hierarchical nested knowledge fragment according to the corresponding level of the title and the text content, and acquiring a corresponding question-answer database according to the hierarchical nested knowledge fragment, so that answers are acquired according to the question-answer database when knowledge questions and answers. The method can realize the refined question and answer and the generalized question and answer by generating knowledge segments with different granularities. And provides a plurality of databases for knowledge questions and answers to support a diversified way of directly matching answers or generating answers based on a language big model. The high reliability and expansibility of knowledge processing are realized, so that the quality of answer content is improved, and the user experience is enhanced.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the embodiments of the application or the technical solutions of the prior art, the drawings which are used in the description of the embodiments or the prior art will be briefly described, and it will be obvious to a person skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1A is a schematic diagram of a business flow for applying the knowledge processing method according to an embodiment of the present application;
FIG. 1B is a schematic diagram of a business process for applying the knowledge question-answering method according to an embodiment of the present application;
FIG. 2 is a flowchart I of a knowledge processing method based on a large model according to an embodiment of the present application;
FIG. 3 is a second flowchart of a knowledge processing method based on a large model according to an embodiment of the present application;
FIG. 4 is a flowchart III of a knowledge processing method based on a large model according to an embodiment of the present application;
FIG. 5 is a flowchart I of a knowledge question-answering method based on a large model according to an embodiment of the present application;
FIG. 6 is a diagram of a knowledge processing apparatus based on a large model according to an embodiment of the present invention;
FIG. 7 is a knowledge question-answering device diagram based on a big model according to an embodiment of the present invention;
fig. 8 is a hardware schematic diagram of an electronic device according to an embodiment of the invention.
Detailed Description
In order that those skilled in the art will better understand the present application, a technical solution in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description of the present application and the above-described drawings are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the application described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Aiming at the problems in the prior art, the application provides a knowledge processing method and a knowledge question-answering method based on a large model, which are characterized in that a target picture file corresponding to a target document is obtained, and the target picture file is analyzed to extract the title and the text content of each picture in the target picture file. And acquiring the knowledge segments nested in the hierarchy according to the level corresponding to the title and the text content. And generating a question-answer database based on the knowledge segments nested in the hierarchy, so that answers are acquired according to the question-answer database when knowledge questions and answers are obtained. The question-answer database comprises a question-answer knowledge base, a text database and a vector database, wherein the question-answer knowledge base comprises question-answer contents corresponding to each knowledge segment and target levels corresponding to the question-answer contents, which are acquired through a large model, the text database is used for storing a plurality of sub-text databases, different sub-text databases are used for storing knowledge segments of different nesting levels, the vector database is used for storing a plurality of sub-vector databases, and different sub-vector databases are used for storing vector data of knowledge segments of different nesting levels.
Further, by acquiring the target questions input by the user side, matching corresponding target answers from the question-answer knowledge base in the question-answer database. If the matching is successful, returning a target answer to the user side; if the matching is unsuccessful, respectively acquiring a first knowledge segment and a second knowledge segment similar to the target problem from a sub-text database and a sub-vector database associated with the target level where the target problem is located, and acquiring an answer through a large model.
The application provides a complete and full-link method for supporting question and answer of non-editable format type documents, which comprises document analysis, knowledge segment generation with different granularity, further knowledge processing on the knowledge segment based on a large model and an intelligent question and answer strategy. The method realizes high reliability, availability and expansibility of each link related to the document question and answer. And the document is subjected to refined analysis, so that the accuracy of content identification is improved. Knowledge segments with different granularities support question and answer requirements with different depths, knowledge segments are obtained from a database of an associated level according to user questions, answers are generated based on a large model, the efficiency of question and answer processing is improved, the completeness and the readability of the answers are improved, and user experience is enhanced.
Fig. 1A is a schematic diagram of a business flow for applying the knowledge processing method according to an embodiment of the present application. As shown in fig. 1A, the target document is converted into a corresponding picture file, and whether there is a picture to be paged is further determined for the picture file. Specifically, the target document may have a problem that a single page format is too large, so that the one-to-one converted picture file includes multiple pages of content, and in order to clearly identify elements in the target document, the pictures corresponding to the pages with the too large formats are paged. After the paging processing is finished or when the paging is not needed, the elements in the pictures are further analyzed, and the elements in each picture are identified, wherein the elements comprise titles, text, embedded pictures or tables and other text contents. And obtaining a hierarchical structure corresponding to the title according to the grade and the text content corresponding to the title, and distributing elements except the title to corresponding hierarchies according to the title to which the elements belong to obtain the hierarchically nested knowledge fragments. And acquiring a question-answer database according to the knowledge segments. Specifically, each knowledge segment is stored into a corresponding sub-text database in the text database according to the nesting level; after vectorizing each knowledge segment, storing the knowledge segments into a corresponding sub-vector database in a vector database according to a nesting level; and generating a plurality of question-answer pairs corresponding to each title, namely a plurality of groups of questions and answers based on the language big model, and storing the questions and answers to obtain a knowledge question-answer library.
Fig. 1B is a schematic diagram of a business flow for applying the knowledge question-answering method according to an embodiment of the present application. As shown in fig. 1B, according to the target question input by the user terminal, matching is first performed from the question-answer knowledge base, and whether the target answer can be matched is confirmed. If the target answers can be matched, outputting matched target answers in a question-answer knowledge base; if the knowledge segments cannot be matched, retrieving knowledge segments related to the target problem from related sub-text databases in the text database and related sub-vector databases in the vector database through text retrieval or vectorization retrieval. And generating a corresponding target answer through the large model and the recalled knowledge piece. And returning the target answer acquired in the mode to the user side.
The following describes the technical scheme of the present application and how the technical scheme of the present application solves the above technical problems by adopting specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 2 is a flowchart of a knowledge processing method based on a large model according to an embodiment of the present application. As shown in fig. 2, the method includes:
s201, acquiring a target picture file corresponding to a target document.
The target document represents a document in a non-editable format to be analyzed, and the target picture file represents a file formed after the target document is converted into a picture format.
In this step, in order to facilitate parsing, the target document needs to be uniformly processed into a file in a picture format. Typically, the conversion of the target document into a file in a picture format is a one-to-one conversion process, i.e., one picture in a corresponding picture file for each page in the target document. However, in other cases, the layout of the target document may be larger, and a corresponding picture includes multiple pages of content. In order to realize the subsequent accurate analysis of the target document, the pictures can be further subjected to paging processing, and the contents in the pictures are paged. The following examples will explain this part in detail.
Alternatively, the document in the non-editable format may be a document in a PDF or other type of format, and may also include documents in other formats.
S202, analyzing the target picture file to obtain an analysis result.
The parsing is used for indicating extraction of elements of each picture in the target picture file, the elements comprise a title and text content, and the text content comprises at least one of text, embedded pictures or tables.
In this step, the elements in each picture may be parsed using a correlation detection model or algorithm to identify the different elements therein. The correlation model and algorithm can be trained to learn the characteristics of the different elements and locate and classify in the image. For the identified title, the ranking may be based on information such as position in the page, size of the word size, etc. In general, titles may be divided into different levels of primary, secondary, tertiary, etc. to reflect their hierarchical relationship in the document structure. For different elements, targeted extraction and processing can be performed, for example, for embedded pictures, the content of the embedded pictures can be extracted and stored as independent image files; for table elements, the structure and data of the table may be extracted; for paragraph text elements, the text content of a paragraph may be extracted.
S203, acquiring a knowledge segment nested in a hierarchy according to the level corresponding to the topic and the text content in the analysis result.
Each title corresponds to one level, the next level title is a sub-title of the previous level title, and the knowledge piece corresponding to each title comprises text content corresponding to the title and the knowledge piece of the next level title.
In the step, according to the analysis result, each extracted text content is associated with the corresponding title to form a hierarchical nested knowledge segment. For example, a tree structure or other data structure may be used to represent the relationship between titles and content, such a structured organization being advantageous for subsequent knowledge retrieval and use.
It should be noted that, in the knowledge segments nested in the hierarchy, the knowledge segment corresponding to each title actually includes the text content corresponding to the title and the knowledge segment of the next-level title. The knowledge segments with the structure can meet the requirements of different granularity questions and answers. For example, for the question related to the title of higher level, i.e. the question depth of the user is shallower, the knowledge segment corresponding to the title can be processed in a generalized way through a language big model at this time to adapt to the answer of the generalized question. If the user further deepens the depth of the question, the user performs refinement processing through the language big model based on knowledge segments of relevant lower-level titles, and a finer answer is generated.
S204, generating a question-answer database according to the knowledge segments nested in the layers, so that answers are obtained according to the question-answer database when knowledge questions and answers are obtained.
The question-answer database comprises a question-answer knowledge base, a text database and a vector database, wherein the question-answer knowledge base comprises question-answer content corresponding to each knowledge segment obtained through a large model and a target level corresponding to the question-answer content, the text database is used for storing a plurality of sub-text databases, different sub-text databases store knowledge segments of different nested levels, the vector database is used for storing a plurality of sub-vector databases, different sub-vector databases are used for storing vector data of knowledge segments of different nested levels, so that when a target answer corresponding to the target question does not exist in the question-answer knowledge base, a first knowledge segment and a second knowledge segment similar to the target question are respectively obtained from the sub-text database and the sub-vector database associated with the target level, and answers are obtained through the large model according to the first knowledge segment and/or the second knowledge segment, and the association comprises at least one of the current level, the upper level or the lower level corresponding to the target level.
It should be noted that, the above embodiment may be used to process one target document, or may process multiple target documents at the same time. But each processed target document is independent of the process of obtaining hierarchically nested knowledge pieces. Meanwhile, the question-answer database includes relevant data of the target documents, and can be updated when new target documents are processed; in other embodiments, each target document or each type of target document may be stored in correspondence with a sub-question-and-answer database, i.e., a related data sub-module corresponding to each target document or each type of target document in the question-and-answer database.
Illustratively, the generating a question-answer database according to the hierarchically nested knowledge segments, so that the answer is obtained according to the question-answer database when knowledge questions and answers, includes:
acquiring at least two groups of question-answer contents corresponding to each title through a large model according to each knowledge segment, and acquiring a question-answer knowledge base according to the question-answer contents, wherein each group of question-answer contents comprises a question and a corresponding answer;
According to the hierarchical nested relation of each knowledge segment, sequentially acquiring text contents of each level from low level to high level, and splicing the text contents according to the order from low level to high level to obtain target text contents;
Storing the target text content according to a corresponding target level to obtain the text database;
and carrying out vectorization processing on the target text content to obtain vector data corresponding to the knowledge segments, and storing the vector data according to a target level corresponding to the target text content to obtain the vector database.
It should be noted that, since each knowledge segment nested in the hierarchy includes the text content of the corresponding title and the knowledge segment of the next-level title, when each knowledge segment is stored, the text content of each level extending under the title needs to be obtained in advance, and then is spliced, and the target text content obtained by splicing is the corresponding content of the knowledge segment. And storing and processing the target text content in a corresponding level to obtain a text database or a vector database. Alternatively, when storing the target text content, the corresponding titles may be stored in association at the same time, or stored as a part of the target text content. Vectorizing the knowledge segments may be performed by a Embedding model or other similar vectorizing model. Vector data is stored into a vector database after vectorization processing is performed through the model.
Alternatively, the large model may be a generative class model of natural language processing, text generation, and understanding to provide intelligent, natural user interactions and responses for the system, such as GPT (GENERATIVE PRE-trained Transformer), and the like.
According to the knowledge processing method based on the large model, the picture file corresponding to the target document is acquired, and the picture file is analyzed to obtain the title in the picture, the text, the embedded picture or the elements such as the table. And acquiring a hierarchical nested knowledge fragment according to the corresponding level of the title and the text content, and acquiring a corresponding question-answer database according to the hierarchical nested knowledge fragment, so that answers are acquired according to the question-answer database when knowledge questions and answers. The method can realize the refined question and answer and the generalized question and answer by generating knowledge segments with different granularities. And provides a plurality of databases for knowledge questions and answers to support a diversified way of directly matching answers or generating answers based on a language big model. The high reliability and expansibility of knowledge processing are realized, so that the quality of answer content is improved, and the user experience is enhanced.
Fig. 3 is a second flowchart of a knowledge processing method based on a large model according to an embodiment of the present application. As shown in fig. 3, the present embodiment describes in detail a target picture file corresponding to an acquisition target document on the basis of the embodiment of fig. 2. The method comprises the following steps:
s301, acquiring an initial picture file corresponding to the target document according to the target document, wherein the content corresponding to each picture in the initial picture file is the same as the content corresponding to each page in the target document.
In this step, in converting the picture format of the target document, the target document may be converted by using an image processing library (for example, a file library in Python) or a tool (for example, IMAGEMAGICK), for example. Or by calling a corresponding API or command line tool to convert each page in the target document into a picture. Each picture should correspond to a page in the target document and the content should be the same as the content of the corresponding page in the target document.
S302, judging whether the pictures in the initial picture file need to be paged according to a preset paging rule, wherein the paging rule is used for indicating a preset single page size or typesetting structure.
In this step, in some target documents, there may be a case where a single page layout is excessively large, resulting in that each page in the target document may actually contain a plurality of pages of content. Correspondingly, when the initial picture file is converted, the condition that one picture corresponds to a plurality of pages of content exists, so that errors are likely to occur when elements in the picture are analyzed, and element extraction is inaccurate. Therefore, for the pictures actually containing multiple pages of content, the pictures with oversized formats need to be paged so as to extract the elements in the pictures more accurately. For such oversized versions of the picture, there are typically features in common, such as a larger picture size than normal, or a pronounced paging feature in the layout structure, such as a larger line spacing, etc. According to the actual situation, based on the shared characteristics, the initial picture file can be checked to determine whether to page or not, and the page boundaries. Alternatively, the initial picture file may be processed through a computer vision model, such as the Yolo series, or the like.
Exemplary, the determining, according to a preset paging rule, whether to page the picture in the initial picture file includes:
Acquiring size information corresponding to each picture of the initial picture file;
judging whether a target picture with the height-width ratio and/or the area larger than the corresponding preset size exists in the initial picture file or not according to the size information;
if yes, indicating that paging is required for the pictures in the initial picture file; if not, the picture in the initial picture file does not need to be paged.
Exemplary, the determining, according to a preset paging rule, whether to page the picture in the initial picture file includes:
traversing the line spacing in each picture of the initial picture file, wherein the line spacing is used for indicating the distance between each line element in each picture;
judging whether target pictures with line spacing larger than preset spacing exist in the initial picture file;
if yes, indicating that paging is required for the pictures in the initial picture file; if not, the picture in the initial picture file does not need to be paged.
Alternatively, for the preset of the paging rule, the above example exemplifies that the paging judgment is made with the size (aspect ratio) or the line spacing as the rule standard. The two rules can be used alone or in combination. In addition, other paging rules can be set in a targeted manner according to the specific situation of the current target document, and the method is not limited.
And S303, if yes, acquiring a target picture to be paged and a corresponding paging boundary in the initial picture file, performing paging processing on the target picture, and acquiring the target picture file according to the target picture after the paging processing and the rest pictures except the target picture in the initial picture file.
S304, if not, the initial picture file is the target picture file.
It should be noted that, for the pictures to be paged, when judging whether to page, the paging boundary information can be returned based on the preset paging rule, so that the processes of synchronous judgment and paging processing can be realized. If the target picture to be paged does not exist in the initial picture file, the initial picture file is the target picture file, and no additional processing is needed.
According to the knowledge processing method based on the large model, a corresponding initial picture file is obtained according to the target document, whether the initial picture file needs to be paged or not is judged according to a preset paging rule, and corresponding paging processing is carried out. The method can realize that the picture with larger format and more impurity content is paged, avoid the problem of inaccurate element identification caused by directly analyzing the complex layout, and is beneficial to improving the accuracy of subsequent element analysis.
Fig. 4 is a flowchart III of a knowledge processing method based on a large model according to an embodiment of the present application. As shown in fig. 4, the present embodiment describes in detail the acquisition of knowledge pieces of hierarchical nesting. The method comprises the following steps:
s401, acquiring a target picture file corresponding to a target document, analyzing the target picture file, and acquiring an analysis result.
In this step, the foregoing embodiments have been described with respect to the step of obtaining the target picture file corresponding to the target document, and the step of analyzing the target picture file is the same as S202, which is not described herein.
S402, acquiring a hierarchical structure of the title according to the level corresponding to the title in the analysis result.
Exemplary, the obtaining, according to the level corresponding to the title in the parsing result, the hierarchical structure of the title includes:
According to the level corresponding to the title in the analysis result, placing each title in a corresponding level so that each title corresponds to one node;
for titles of different levels, respectively associating the nodes of each title with the nodes of the corresponding previous-level and next-level titles, so that the nodes of each title contain references pointing to the previous-level and next-level nodes;
and after the node association of each title is completed, acquiring the hierarchical structure of the title.
The analysis result of the target picture file also includes level information corresponding to the title. Based on this level information, a node is created for each title, which is placed in the corresponding hierarchy according to its level, e.g., a primary title placed in the highest hierarchy, a secondary title placed under the primary title, and so on. Further, the association between nodes is established such that the nodes of each title contain references to the nodes of the previous and next level, which may be implemented by a linked list structure or other data structures, for example. It should be understood that each title may correspond to only one parent title, but may correspond to multiple sub-titles, and correspondingly, there may be multiple titles at the same level. When the association is completed, a hierarchical structure of the entire title is obtained.
S403, distributing the text content to corresponding levels according to the belonged titles to obtain level nested knowledge segments.
In this step, the corresponding title may be confirmed by the location information of the text content, but may be understood by other alternative means, for example, by confirming text similarity, semantic relationship analysis, or using a pre-trained language model, without limitation. The text content is distributed to the corresponding hierarchy according to the title, and specifically, to the corresponding title in the corresponding hierarchy.
Optionally, after confirming the text content corresponding to the title, different text content elements in the same title may be further associated, for example, a picture is associated with a text description of an adjacent interpretation picture, a table is associated with a text description of an adjacent interpretation table, etc., so that the content is more comprehensive and rich when generating an answer.
Illustratively, the assigning the text content to the corresponding hierarchy according to the belonging title, to obtain the knowledge segments nested in the hierarchy, includes:
acquiring position information of the text content, wherein the position information is used for indicating the position of the text content in a picture;
Regarding each text content, taking a title nearest to the text content as a title to which the text content belongs in the text content according to the position information;
and distributing the text content to nodes corresponding to the titles according to the titles to obtain the hierarchical nested knowledge segments.
According to the knowledge processing method based on the large model, the analysis result of the target picture file corresponding to the target document is obtained, each title is set to be one node according to the extracted title corresponding level, so that the hierarchical structure of the title is obtained, and the text content corresponding to the title is distributed to the corresponding hierarchy. The method realizes the structuring treatment of the document content to obtain knowledge segments with different granularities, thereby supporting knowledge question-answering with different dimensions and better organizing and understanding the document content.
Fig. 5 is a flowchart of a knowledge question-answering method based on a big model according to an embodiment of the present application. As shown in fig. 4, the method includes:
s501, acquiring a target question input by a user terminal, wherein the target question is in a text format.
In this step, a user-provided target question may be received by interacting with the user's interface or application program, the question being presented in a text format. The user may present the target question in natural language form, based on which the target question is processed and analyzed to understand and answer.
S502, judging whether a corresponding target answer exists in a question-answer knowledge base of the question-answer database according to the target question and the question-answer database.
The question-answer database is obtained through the method in the embodiment, and comprises a question-answer knowledge base, a text database and a vector database, wherein the question-answer knowledge base comprises question-answer contents corresponding to each knowledge segment obtained through a large model and target levels corresponding to the question-answer contents, the text database is used for storing a plurality of sub-text databases, different sub-text databases are used for storing knowledge segments of different nesting levels, the vector database is used for storing a plurality of sub-vector databases, and different sub-vector databases are used for storing vector data of knowledge segments of different nesting levels.
Illustratively, obtaining a target keyword in the target question, where the target keyword is used to indicate a word corresponding to a preset part of speech in the target question, and the preset part of speech includes at least one of nouns, verbs or adjectives;
according to the occurrence times of each target keyword in the historical query data of the user side, acquiring the weight corresponding to each target keyword, wherein the higher the occurrence times are, the higher the corresponding weight is;
Acquiring a first matching degree corresponding to each question in the question-answer knowledge base according to the target keywords and the corresponding weights, wherein the first matching degree is used for indicating the sum of the occurrence times of each target keyword in a single question and the weighted value of the corresponding weight;
If a target matching problem with the first matching degree being greater than or equal to a first preset threshold exists, the answer corresponding to the target matching problem with the highest matching degree is a target answer;
If no target matching problem with the first matching degree being greater than or equal to a first preset threshold value exists, the fact that no corresponding target answer exists in the question-answer knowledge base is indicated.
Specifically, the target keyword is extracted by extracting a word or phrase with important meaning from the target question queried by the user, and the part of speech of the keyword to be extracted can be preset to identify the keyword, for example, the noun usually contains key information and can be used as one of the target keywords. Further, in order to obtain the question in the question-answer knowledge base most relevant to the target question queried by the user, the question in the question-answer knowledge base can be screened by setting a weight for the target keyword, and according to historical query data of the user, the more times the target keyword in the current target question is queried in the history, the more attention the user pays to the content relevant to the target keyword is described, so that the weight of the target keyword can be correspondingly increased.
It should be noted that, in addition to the above-mentioned way of matching the target answer by the keyword, a phrase matching way may be also used, that is, the target question of the user and the question in the question-answer knowledge base are extracted to obtain a phrase, so as to calculate the matching degree between them; or by means of semantic matching, namely converting the target questions of the user and the questions in the question-answer knowledge base into semantic representations, and calculating semantic similarity or correlation between the target questions and the questions in the question-answer knowledge base.
And S503, if yes, returning the target answer to the user side.
S504, if not, acquiring a target level of the target problem according to the question-answer knowledge base, respectively acquiring a first knowledge segment and a second knowledge segment similar to the target problem from a sub-text database and a sub-vector database associated with the target level, acquiring a target answer through a large model according to the first knowledge segment and/or the second knowledge segment, and returning to the user terminal.
Wherein the association includes at least one of a present hierarchy, an upper hierarchy, or a lower hierarchy corresponding to the target hierarchy.
It should be noted that, because each question-answer content in the question-answer knowledge base is generated based on the corresponding knowledge segment, when each question-answer content is stored, a target level to which the corresponding knowledge segment belongs is correspondingly stored, and the target level is a nested level to which the corresponding knowledge segment belongs. Each level is provided with a corresponding sub-text database and a sub-vector database, after the target level to which the target problem belongs is confirmed, the sub-text database and the sub-vector database associated with the target level are matched with a first knowledge segment and a second knowledge segment similar to the target problem, so that a target answer is obtained through a large model and returned to the user side. The sub-text databases and sub-vector databases associated with the target hierarchy include, but are not limited to, sub-text databases and sub-vector databases corresponding to the present hierarchy, superior or inferior, and may be preferentially found in the sub-text databases and sub-vector databases corresponding to the present hierarchy in performing the operation of finding similar knowledge segments. If the similar knowledge segments are not found in the knowledge segments, the knowledge segments can be sequentially found in the sub-text databases and the sub-vector databases corresponding to adjacent levels, and the query scope can be reduced by the method, so that the time consumption of querying the knowledge segments is reduced, and the resource consumption is reduced. It should be understood that the purpose of searching knowledge segments in the sub-text database and the sub-vector database is that different query methods may obtain different results, and this difference may make the obtained information more comprehensive and the coverage wider. In practical use, one query mode can be used alone or in combination.
The obtaining, according to the question-answering knowledge base, a target level where the target question is located, and obtaining, from a sub-text database and a sub-vector database associated with the target level, a first knowledge segment and a second knowledge segment similar to the target question, and obtaining, according to the first knowledge segment and/or the second knowledge segment, a target answer through a large model, includes:
acquiring the candidate problem with the highest first matching degree from the question-answer knowledge base, and acquiring a target level corresponding to the question-answer content to which the candidate problem belongs, wherein the target level is the level corresponding to the target problem;
Acquiring a sub-text database associated with the target level;
According to the target keywords and the corresponding weights, first knowledge segments with second matching degrees larger than or equal to a second preset threshold value are obtained from the sub-text database, wherein the second matching degrees are used for indicating the sum of the occurrence times of each target keyword in a single knowledge segment and the weighted value of the corresponding weight;
Carrying out vectorization processing on the target problem, obtaining corresponding target vector data, and obtaining a sub-vector database associated with the target level;
According to the target vector data, obtaining a second knowledge segment corresponding to vector data with a third matching degree greater than or equal to a third preset threshold value from the sub-vector database, wherein the third matching degree is used for indicating a value obtained by vector similarity calculation of the target vector data and vector data corresponding to a single knowledge segment;
and generating the target answer through the large model according to the first knowledge piece and/or the second knowledge piece.
It should be noted that, according to the actual situation, the obtained first knowledge segment and the second knowledge segment may be used as materials for generating the answer at the same time, and input into the large model for processing, where the processing of the repeated parts of the two types of knowledge segments may involve a process of combining the two types of knowledge segments, so as to generate the target answer of the same context of the target question. In addition, the most similar object problem can be selected from the first knowledge segment and the second knowledge segment and input into the large model for processing. And are not limited herein.
According to the knowledge question-answering method based on the large model, the target questions input by the user side are obtained, the corresponding target answers are matched from the question-answering knowledge base of the question-answering database based on the pre-generated question-answering database, if the corresponding target answers are not matched, knowledge segments related to the target questions are further obtained, and the target answers are generated through the large model. The method realizes diversified intelligent question-answering modes, improves the question-answering processing efficiency, improves the completeness and the readability of answers, and enhances the user experience.
Fig. 6 is a diagram of a knowledge processing apparatus based on a large model according to an embodiment of the present invention. As shown in fig. 6, the apparatus 60 includes: the device comprises a first acquisition module 601, an analysis module 602 and a first processing module 603.
The first obtaining module 601 is configured to obtain a target picture file corresponding to a target document, where the target document represents a document in a non-editable format to be parsed, and the target picture file represents a file formed after the target document is converted into a picture format;
The parsing module 602 is configured to parse the target picture file to obtain a parsing result, where the parsing is configured to instruct extraction of an element of each picture in the target picture file, the element includes a title and text content, and the text content includes at least one of a text, an embedded picture, or a table;
a first processing module 603, configured to obtain, according to the level corresponding to the title and the text content in the parsing result, a knowledge segment nested in a hierarchy, where each title corresponds to a level, a next-level title is a sub-title of a previous-level title, and each knowledge segment corresponding to the title includes the text content corresponding to the title and a knowledge segment of the next-level title;
The first processing module 603 is further configured to generate a question-answer database according to the knowledge segments nested in the hierarchy, so that an answer is obtained according to the question-answer database when a knowledge question is answered;
The question-answer database comprises a question-answer knowledge base, a text database and a vector database, wherein the question-answer knowledge base comprises a question-answer content corresponding to each knowledge segment obtained through a large model and a target level corresponding to the question-answer content, the text database is used for storing a plurality of sub-text databases, different sub-text databases store knowledge segments of different nested levels, the vector database is used for storing a plurality of sub-vector databases, different sub-vector databases are used for storing vector data of knowledge segments of different nested levels, so that when a target answer corresponding to a target question does not exist in the question-answer knowledge base, a first knowledge segment and a second knowledge segment similar to the target question are respectively obtained from the sub-text database and the sub-vector database associated with the target level, and answers are obtained through the large model according to the first knowledge segment and/or the second knowledge segment, and the association comprises at least one of the level, the upper level or lower level corresponding to the target question.
Fig. 7 is a knowledge question-answering device diagram based on a big model according to an embodiment of the present invention. As shown in fig. 7, the apparatus 70 includes: the second acquisition module 701 and the second processing module 702.
A second obtaining module 701, configured to obtain a target question input by a user, where the target question is in a text format;
A second processing module 702, configured to determine, according to the target question and the question-answer database, whether a question-answer knowledge base of the question-answer database includes a question-answer knowledge base, a text database, and a vector database, where the question-answer knowledge base includes a question-answer content and a target level corresponding to the question-answer content that are acquired through a large model, the text database is used to store a plurality of sub-text databases, different sub-text databases store knowledge segments of different nesting levels, and the vector database is used to store a plurality of sub-vector databases, different sub-vector databases are used to store vector data of knowledge segments of different nesting levels;
If yes, returning the target answer to the user side;
if not, the target level of the target problem is obtained according to the question-answering knowledge base, wherein the question-answering knowledge base further comprises a target level corresponding to each question-answering content, a first knowledge fragment and a second knowledge fragment similar to the target problem are respectively obtained from a sub-text database and a sub-vector database associated with the target level, a target answer is obtained through a large model according to the first knowledge fragment and/or the second knowledge fragment, and the target answer is returned to the user side, and the association comprises at least one of the present level, the upper level or the lower level corresponding to the target level.
Fig. 8 is a hardware schematic diagram of an electronic device according to an embodiment of the invention. As shown in fig. 8, the electronic device 80 provided in this embodiment includes: at least one processor 801 and a memory 802. The electronic device 80 further comprises a communication component 803. The processor 801, the memory 802, and the communication section 803 are connected via a bus 804.
In a specific implementation, at least one processor 801 executes the computer program stored in the memory 802, so that the at least one processor 801 performs the above method.
The specific implementation process of the processor 801 may refer to the above-mentioned method embodiment, and its implementation principle and technical effects are similar, and this embodiment will not be described herein again.
In the embodiment shown in fig. 8, it should be understood that the Processor may be a central processing unit (english: central Processing Unit, abbreviated as CPU), other general purpose processors, digital signal Processor (english: DIGITAL SIGNAL Processor, abbreviated as DSP), application-specific integrated Circuit (english: application SPECIFIC INTEGRATED Circuit, abbreviated as ASIC), and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor for execution, or in a combination of hardware and software modules in a processor for execution.
The Memory may include high-speed Memory (Random Access Memory, RAM) or may further include Non-volatile Memory (NVM), such as at least one disk Memory.
The bus may be an industry standard architecture (Industry Standard Architecture, ISA) bus, an external device interconnect (PERIPHERAL COMPONENT, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, the buses in the drawings of the present application are not limited to only one bus or to one type of bus.
The application also provides a computer-readable storage medium, characterized in that the computer-readable storage medium comprises a stored program, wherein the program when run performs the method as described above.
The above-described readable storage medium may be implemented by any type or combination of volatile or non-volatile memory devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk. A readable storage medium can be any available medium that can be accessed by a general purpose or special purpose computer.
An exemplary readable storage medium is coupled to the processor such the processor can read information from, and write information to, the readable storage medium. In the alternative, the readable storage medium may be integral to the processor. The processor and the readable storage medium may reside in an Application SPECIFIC INTEGRATED Circuits (ASIC). The processor and the readable storage medium may reside as discrete components in the case of a computer system.
It should be noted that, for simplicity of description, the foregoing method embodiments are all described as a series of acts, but it should be understood by those skilled in the art that the present application is not limited by the order of acts described, as some steps may be performed in other orders or concurrently in accordance with the present application. Further, those skilled in the art will also appreciate that the embodiments described in the specification are alternative embodiments, and that the acts and modules referred to are not necessarily required for the present application.
It should be further noted that, although the steps in the flowchart are sequentially shown as indicated by arrows, the steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least a portion of the steps in the flowcharts may include a plurality of sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, the order in which the sub-steps or stages are performed is not necessarily sequential, and may be performed in turn or alternately with at least a portion of the sub-steps or stages of other steps or other steps.
It will be appreciated that the device embodiments described above are merely illustrative and that the device of the application may be implemented in other ways. For example, the division of the units/modules in the above embodiments is merely a logic function division, and there may be another division manner in actual implementation. For example, multiple units, modules, or components may be combined, or may be integrated into another system, or some features may be omitted or not performed.
In addition, each functional unit/module in each embodiment of the present application may be integrated into one unit/module, or each unit/module may exist alone physically, or two or more units/modules may be integrated together, unless otherwise specified. The integrated units/modules described above may be implemented either in hardware or in software program modules.
The integrated units/modules may be stored in a computer readable memory if implemented in the form of software program modules and sold or used as a stand-alone product. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in whole or in part in the form of a software product stored in a memory, comprising several instructions for causing a computer device (which may be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method of the various embodiments of the present application. And the aforementioned memory includes: a usb disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and for parts of one embodiment that are not described in detail, reference may be made to related descriptions of other embodiments. The technical features of the foregoing embodiments may be arbitrarily combined, and for brevity, all of the possible combinations of the technical features of the foregoing embodiments are not described, however, all of the combinations of the technical features should be considered as being within the scope of the disclosure.
Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains.
The foregoing is merely a preferred embodiment of the present application and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present application, which are intended to be comprehended within the scope of the present application.

Claims (13)

1. A knowledge processing method based on a large model, comprising:
Obtaining a target picture file corresponding to a target document, wherein the target document represents a document in a non-editable format to be analyzed, and the target picture file represents a file formed after the target document is converted into a picture format;
Analyzing the target picture file to obtain an analysis result, wherein the analysis is used for indicating the extraction of elements of each picture in the target picture file, the elements comprise a title and text content, and the text content comprises at least one of a text, an embedded picture or a table;
acquiring hierarchical nested knowledge segments according to the level corresponding to the title and the text content in the analysis result, wherein each title corresponds to one level, the next-level title is a sub-title of the previous-level title, and each knowledge segment corresponding to the title comprises the text content corresponding to the title and the knowledge segment of the next-level title;
Generating a question-answer database according to the knowledge segments nested in the hierarchy, so that answers are obtained according to the question-answer database when knowledge questions and answers;
The question-answer database comprises a question-answer knowledge base, a text database and a vector database, wherein the question-answer knowledge base comprises a question-answer content corresponding to each knowledge segment obtained through a large model and a target level corresponding to the question-answer content, the text database is used for storing a plurality of sub-text databases, different sub-text databases store knowledge segments of different nested levels, the vector database is used for storing a plurality of sub-vector databases, different sub-vector databases are used for storing vector data of knowledge segments of different nested levels, so that when a target answer corresponding to a target question does not exist in the question-answer knowledge base, a first knowledge segment and a second knowledge segment similar to the target question are respectively obtained from the sub-text database and the sub-vector database associated with the target level, and answers are obtained through the large model according to the first knowledge segment and/or the second knowledge segment, and the association comprises at least one of the current level, the upper level or the lower level corresponding to the target level;
The generating a question-answer database according to the hierarchically nested knowledge segments, so that answers are obtained according to the question-answer database when knowledge questions and answers, comprises the following steps:
acquiring at least two groups of question-answer contents corresponding to each title through a large model according to each knowledge segment, and acquiring a question-answer knowledge base according to the question-answer contents, wherein each group of question-answer contents comprises a question and a corresponding answer;
According to the hierarchical nested relation of each knowledge segment, sequentially acquiring text contents of each level from low level to high level, and splicing the text contents according to the order from low level to high level to obtain target text contents;
Storing the target text content according to a corresponding target level to obtain the text database;
and carrying out vectorization processing on the target text content to obtain vector data corresponding to the knowledge segments, and storing the vector data according to a target level corresponding to the target text content to obtain the vector database.
2. The method according to claim 1, wherein the obtaining the target picture file corresponding to the target document includes:
Acquiring an initial picture file corresponding to the target document according to the target document, wherein the content corresponding to each picture in the initial picture file is the same as the content corresponding to each page in the target document;
Judging whether the pictures in the initial picture file are required to be paged according to a preset paging rule, wherein the paging rule is used for indicating a preset single page size or typesetting structure;
If yes, acquiring a target picture to be paged and a corresponding paging boundary in the initial picture file, performing paging processing on the target picture, and acquiring the target picture file according to the target picture after the paging processing and the rest pictures except the target picture in the initial picture file;
if not, the initial picture file is the target picture file.
3. The method of claim 2, wherein the determining whether the pictures in the initial picture file need to be paged according to a preset paging rule comprises:
Acquiring size information corresponding to each picture of the initial picture file;
judging whether a target picture with the height-width ratio and/or the area larger than the corresponding preset size exists in the initial picture file or not according to the size information;
if yes, indicating that paging is required for the pictures in the initial picture file; if not, the picture in the initial picture file does not need to be paged.
4. The method of claim 2, wherein the determining whether the pictures in the initial picture file need to be paged according to a preset paging rule comprises:
traversing the line spacing in each picture of the initial picture file, wherein the line spacing is used for indicating the distance between each line element in each picture;
judging whether target pictures with line spacing larger than preset spacing exist in the initial picture file;
if yes, indicating that paging is required for the pictures in the initial picture file; if not, the picture in the initial picture file does not need to be paged.
5. The method according to claim 1, wherein the obtaining a hierarchically nested knowledge segment according to the level corresponding to the topic and the text content in the parsing result includes:
acquiring a hierarchical structure of the title according to the level corresponding to the title in the analysis result;
and distributing the text content to corresponding levels according to the belonged titles to obtain level nested knowledge segments.
6. The method according to claim 5, wherein the obtaining the hierarchical structure of the title according to the level corresponding to the title in the analysis result includes:
According to the level corresponding to the title in the analysis result, placing each title in a corresponding level so that each title corresponds to one node;
for titles of different levels, respectively associating the nodes of each title with the nodes of the corresponding previous-level and next-level titles, so that the nodes of each title contain references pointing to the previous-level and next-level nodes;
and after the node association of each title is completed, acquiring the hierarchical structure of the title.
7. The method according to claim 6, wherein the assigning the text content to the corresponding hierarchy according to the belonging title, to obtain the hierarchically nested knowledge segments, comprises:
acquiring position information of the text content, wherein the position information is used for indicating the position of the text content in a picture;
Regarding each text content, taking a title nearest to the text content as a title to which the text content belongs in the text content according to the position information;
and distributing the text content to nodes corresponding to the titles according to the titles to obtain the hierarchical nested knowledge segments.
8. A knowledge question-answering method based on a large model, the method comprising:
Acquiring a target question input by a user terminal, wherein the target question is in a text format;
Judging whether a corresponding target answer exists in a question-answer knowledge base of the question-answer database according to the target questions and the question-answer database, wherein the question-answer database is obtained by the method of any one of claims 1 to 7, the question-answer database comprises a question-answer knowledge base, a text database and a vector database, the question-answer knowledge base comprises question-answer contents corresponding to each knowledge segment and target levels corresponding to the question-answer contents obtained through a large model, the text database is used for storing a plurality of sub-text databases, different sub-text databases are used for storing knowledge segments of different nesting levels, the vector database is used for storing a plurality of sub-vector databases, and different sub-vector databases are used for storing vector data of knowledge segments of different nesting levels;
If yes, returning the target answer to the user side;
if not, the target level of the target problem is obtained according to the question-answering knowledge base, wherein the question-answering knowledge base further comprises a target level corresponding to each question-answering content, a first knowledge fragment and a second knowledge fragment similar to the target problem are respectively obtained from a sub-text database and a sub-vector database associated with the target level, a target answer is obtained through a large model according to the first knowledge fragment and/or the second knowledge fragment, and the target answer is returned to the user side, and the association comprises at least one of the present level, the upper level or the lower level corresponding to the target level.
9. The method of claim 8, wherein the determining whether the corresponding target answer exists in the question-answer knowledge base of the question-answer database comprises:
acquiring a target keyword in the target problem, wherein the target keyword is used for indicating words corresponding to preset parts of speech in the target problem, and the preset parts of speech comprises at least one of nouns, verbs or adjectives;
according to the occurrence times of each target keyword in the historical query data of the user side, acquiring the weight corresponding to each target keyword, wherein the higher the occurrence times are, the higher the corresponding weight is;
Acquiring a first matching degree corresponding to each question in the question-answer knowledge base according to the target keywords and the corresponding weights, wherein the first matching degree is used for indicating the sum of the occurrence times of each target keyword in a single question and the weighted value of the corresponding weight;
If a target matching problem with the first matching degree being greater than or equal to a first preset threshold exists, the answer corresponding to the target matching problem with the highest matching degree is a target answer;
If no target matching problem with the first matching degree being greater than or equal to a first preset threshold value exists, the fact that no corresponding target answer exists in the question-answer knowledge base is indicated.
10. The method according to claim 9, wherein the obtaining the target level of the target question according to the question-answer knowledge base, and obtaining a first knowledge segment and a second knowledge segment similar to the target question from a sub-text database and a sub-vector database associated with the target level, and obtaining a target answer according to the first knowledge segment and/or the second knowledge segment through a large model, respectively, includes:
acquiring the candidate problem with the highest first matching degree from the question-answer knowledge base, and acquiring a target level corresponding to the question-answer content to which the candidate problem belongs, wherein the target level is the level corresponding to the target problem;
Acquiring a sub-text database associated with the target level;
According to the target keywords and the corresponding weights, first knowledge segments with second matching degrees larger than or equal to a second preset threshold value are obtained from the sub-text database, wherein the second matching degrees are used for indicating the sum of the occurrence times of each target keyword in a single knowledge segment and the weighted value of the corresponding weight;
Carrying out vectorization processing on the target problem, obtaining corresponding target vector data, and obtaining a sub-vector database associated with the target level;
According to the target vector data, obtaining a second knowledge segment corresponding to vector data with a third matching degree greater than or equal to a third preset threshold value from the sub-vector database, wherein the third matching degree is used for indicating a value obtained by vector similarity calculation of the target vector data and vector data corresponding to a single knowledge segment;
and generating the target answer through a large model according to the first knowledge piece and/or the second knowledge piece.
11. A knowledge processing apparatus based on a large model, comprising:
The first acquisition module is used for acquiring a target picture file corresponding to a target document, wherein the target document represents a document in a non-editable format to be analyzed, and the target picture file represents a file formed after the target document is converted into a picture format;
the analysis module is used for analyzing the target picture file to obtain an analysis result, wherein the analysis is used for indicating the extraction of elements of each picture in the target picture file, the elements comprise a title and text content, and the text content comprises at least one of a text, an embedded picture or a table;
The first processing module is used for obtaining knowledge segments nested in a hierarchy according to the level corresponding to the title and the text content in the analysis result, wherein each title corresponds to one level, the next-level title is a sub-title of the previous-level title, and the knowledge segment corresponding to each title comprises the text content corresponding to the title and the knowledge segment of the next-level title;
The first processing module is further used for generating a question-answer database according to the knowledge segments nested in the hierarchy, so that answers are obtained according to the question-answer database when knowledge questions and answers are obtained;
The question-answer database comprises a question-answer knowledge base, a text database and a vector database, wherein the question-answer knowledge base comprises a question-answer content corresponding to each knowledge segment obtained through a large model and a target level corresponding to the question-answer content, the text database is used for storing a plurality of sub-text databases, different sub-text databases store knowledge segments of different nested levels, the vector database is used for storing a plurality of sub-vector databases, different sub-vector databases are used for storing vector data of knowledge segments of different nested levels, so that when a target answer corresponding to a target question does not exist in the question-answer knowledge base, a first knowledge segment and a second knowledge segment similar to the target question are respectively obtained from the sub-text database and the sub-vector database associated with the target level, and answers are obtained through the large model according to the first knowledge segment and/or the second knowledge segment, and the association comprises at least one of the level, the upper level or lower level corresponding to the target question;
The first processing module is specifically configured to:
acquiring at least two groups of question-answer contents corresponding to each title through a large model according to each knowledge segment, and acquiring a question-answer knowledge base according to the question-answer contents, wherein each group of question-answer contents comprises a question and a corresponding answer;
According to the hierarchical nested relation of each knowledge segment, sequentially acquiring text contents of each level from low level to high level, and splicing the text contents according to the order from low level to high level to obtain target text contents;
Storing the target text content according to a corresponding target level to obtain the text database;
and carrying out vectorization processing on the target text content to obtain vector data corresponding to the knowledge segments, and storing the vector data according to a target level corresponding to the target text content to obtain the vector database.
12. A knowledge question-answering device based on a large model, comprising:
the second acquisition module is used for acquiring a target problem input by the user side, wherein the target problem is in a text format;
The second processing module is used for judging whether a corresponding target answer exists in a question-answer knowledge base of the question-answer database according to the target questions and the question-answer database, the question-answer database is obtained through the method of any one of claims 1 to 8, the question-answer database comprises a question-answer knowledge base, a text database and a vector database, the question-answer knowledge base comprises a question-answer content and a target level corresponding to the question-answer content, which are acquired through a large model, each knowledge segment corresponds to the question-answer content, the text database is used for storing a plurality of sub-text databases, knowledge segments of different nesting levels are stored in different sub-text databases, the vector database is used for storing a plurality of sub-vector databases, and the different sub-vector databases are used for storing vector data of knowledge segments of different nesting levels;
If yes, returning the target answer to the user side;
if not, the target level of the target problem is obtained according to the question-answering knowledge base, wherein the question-answering knowledge base further comprises a target level corresponding to each question-answering content, a first knowledge fragment and a second knowledge fragment similar to the target problem are respectively obtained from a sub-text database and a sub-vector database associated with the target level, a target answer is obtained through a large model according to the first knowledge fragment and/or the second knowledge fragment, and the target answer is returned to the user side, and the association comprises at least one of the present level, the upper level or the lower level corresponding to the target level.
13. A computer readable storage medium, characterized in that the computer readable storage medium comprises a stored program, wherein the program when run performs the method of any one of claims 1 to 10.
CN202410185839.0A 2024-02-20 2024-02-20 Knowledge processing and knowledge question-answering method, device and medium based on large model Active CN117743558B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410185839.0A CN117743558B (en) 2024-02-20 2024-02-20 Knowledge processing and knowledge question-answering method, device and medium based on large model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410185839.0A CN117743558B (en) 2024-02-20 2024-02-20 Knowledge processing and knowledge question-answering method, device and medium based on large model

Publications (2)

Publication Number Publication Date
CN117743558A CN117743558A (en) 2024-03-22
CN117743558B true CN117743558B (en) 2024-05-24

Family

ID=90261251

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410185839.0A Active CN117743558B (en) 2024-02-20 2024-02-20 Knowledge processing and knowledge question-answering method, device and medium based on large model

Country Status (1)

Country Link
CN (1) CN117743558B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021196520A1 (en) * 2020-03-30 2021-10-07 西安交通大学 Tax field-oriented knowledge map construction method and system
WO2022095385A1 (en) * 2020-11-06 2022-05-12 平安科技(深圳)有限公司 Document knowledge extraction method and apparatus, and computer device and readable storage medium
CN115374781A (en) * 2022-08-25 2022-11-22 上海浦东发展银行股份有限公司 Text data information mining method, device and equipment
CN115794995A (en) * 2022-11-29 2023-03-14 科大讯飞股份有限公司 Target answer obtaining method and related device, electronic equipment and storage medium
CN116090560A (en) * 2023-04-06 2023-05-09 北京大学深圳研究生院 Knowledge graph establishment method, device and system based on teaching materials
CN117520515A (en) * 2023-11-24 2024-02-06 信雅达科技股份有限公司 Bank field question and answer method, system and device based on local knowledge base

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021196520A1 (en) * 2020-03-30 2021-10-07 西安交通大学 Tax field-oriented knowledge map construction method and system
WO2022095385A1 (en) * 2020-11-06 2022-05-12 平安科技(深圳)有限公司 Document knowledge extraction method and apparatus, and computer device and readable storage medium
CN115374781A (en) * 2022-08-25 2022-11-22 上海浦东发展银行股份有限公司 Text data information mining method, device and equipment
CN115794995A (en) * 2022-11-29 2023-03-14 科大讯飞股份有限公司 Target answer obtaining method and related device, electronic equipment and storage medium
CN116090560A (en) * 2023-04-06 2023-05-09 北京大学深圳研究生院 Knowledge graph establishment method, device and system based on teaching materials
CN117520515A (en) * 2023-11-24 2024-02-06 信雅达科技股份有限公司 Bank field question and answer method, system and device based on local knowledge base

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于层级类别信息的标题自动分类研究;葛文镇;刘柏嵩;王洋洋;赵福青;;计算机应用研究;20150929(07);全文 *

Also Published As

Publication number Publication date
CN117743558A (en) 2024-03-22

Similar Documents

Publication Publication Date Title
US10860654B2 (en) System and method for generating an answer based on clustering and sentence similarity
TWI536181B (en) Language identification in multilingual text
CN110929038B (en) Knowledge graph-based entity linking method, device, equipment and storage medium
US10922346B2 (en) Generating a summary based on readability
CN114756733A (en) Similar document searching method and device, electronic equipment and storage medium
CN111931041A (en) Label recommendation method and device, electronic equipment and storage medium
CN112070550A (en) Keyword determination method, device and equipment based on search platform and storage medium
CN115794995A (en) Target answer obtaining method and related device, electronic equipment and storage medium
US11468346B2 (en) Identifying sequence headings in a document
CN117668180A (en) Document question-answering method, document question-answering device, and readable storage medium
CN114547257A (en) Class matching method and device, computer equipment and storage medium
CN114328983A (en) Document fragmenting method, data retrieval device and electronic equipment
WO2020041413A1 (en) Sibling search queries
CN117972048A (en) Question and answer processing method and device
CN112765976A (en) Text similarity calculation method, device and equipment and storage medium
CN117195875A (en) Data processing method, terminal and storage medium
CN117743558B (en) Knowledge processing and knowledge question-answering method, device and medium based on large model
CN112487181A (en) Keyword determination method and related equipment
CN113553410B (en) Long document processing method, processing device, electronic equipment and storage medium
WO2014170965A1 (en) Document processing method, document processing device, and document processing program
CN110968691B (en) Judicial hotspot determination method and device
CN114021541A (en) Presentation generation method, device, equipment and storage medium
CN114067343A (en) Data set construction method, model training method and corresponding device
CN113254800A (en) Information recommendation method and device, electronic equipment and storage medium
JP2011150603A (en) Category theme phrase extracting device, hierarchical tag attaching device, method, and program, and computer-readable recording medium

Legal Events

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