Input text processing method and device, equipment, storage medium and program product
By extracting reference named entities from the input text in a generative language model and querying related text statements in a knowledge base, the problem of semantic ambiguity in the input text is solved, and more accurate natural language processing is achieved.
Patent Information
- Application Number
- CN202410529056.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-28
- Publication Date
- 2025-10-31
AI Technical Summary
The semantic ambiguity of user-written input text leads to equally semantically ambiguous output from generative language models, affecting the accuracy of natural language processing.
By extracting reference named entities from the input text and querying related reference text statements in the knowledge base, and combining the input text and reference text statements for natural language processing, more comprehensive relevant knowledge can be obtained, thereby improving the accuracy of natural language processing.
By using textual aids associated with the input text, generative language models can more accurately understand the semantics of the input text, generate more targeted outputs, and improve the accuracy of natural language processing.
Smart Images

Figure CN120873153A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of AI technology, and in particular to an input text processing method, apparatus, device, storage medium, and program product. Background Technology
[0002] With the continuous development of artificial intelligence technology, the application of machine learning models is becoming more and more widespread.
[0003] In related technologies, in natural language processing scenarios, users can input a sentence into an input interface, and the generative language model will use the input text as a prompt to perform natural language processing and output the generated results.
[0004] However, user-written input text is usually quite concise, which leads to semantic ambiguity in the input text. Consequently, the output of generative language models is also semantically ambiguous, affecting the accuracy of natural language processing. Summary of the Invention
[0005] This application provides an input text processing method, apparatus, device, storage medium, and program product, which can improve the accuracy of natural language processing based on input text. The technical solution is as follows:
[0006] On the one hand, an input text processing method is provided, the method comprising:
[0007] Extract reference named entities from input text based on natural language processing;
[0008] The knowledge base is used to query reference text statements associated with the reference named entity; the knowledge base contains the association between named entities and text statements; the text statements are used to describe the relevant knowledge of the associated named entity.
[0009] The natural language processing is performed on the input text and the reference text statement to obtain the natural language processing result of the input text.
[0010] On the other hand, an input text processing apparatus is provided, the apparatus comprising:
[0011] The entity extraction module is used to extract reference named entities from input text based on natural language processing.
[0012] The statement query module is used to query reference text statements associated with the reference named entity in the knowledge base; the knowledge base contains the association relationship between named entities and text statements; the text statements are used to describe the relevant knowledge of the associated named entity;
[0013] The processing module is used to perform natural language processing on the input text and the reference text statement to obtain the natural language processing result of the input text.
[0014] In another aspect, a computer device is provided, the computer device comprising a processor and a memory, the memory storing at least one instruction, at least one program, code set or instruction set, the at least one instruction, the at least one program, the code set or instruction set being loaded and executed by the processor to implement the input text processing method as described above.
[0015] In another aspect, a computer-readable storage medium is provided, wherein at least one instruction, at least one program, code set, or instruction set is stored therein, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the input text processing method described above.
[0016] In another aspect, a computer program product is provided, comprising a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the input text processing methods provided in the various optional implementations described above.
[0017] The technical solution provided in this application may include the following beneficial effects:
[0018] In scenarios where input text is processed using natural language processing (NLP), this application assists in the NLP processing of the input text by using text statements associated with named entities in the input text. Since these text statements describe relevant knowledge within the input text, when NLP is performed on both the text statements and the input text simultaneously, the NLP model can understand more comprehensive relevant knowledge about the input text. This allows the model to more accurately understand the semantics of the input text, and consequently, the output results generated by the model can be more targeted, thereby improving the accuracy of NLP.
[0019] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0020] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0021] Figure 1 This is a system configuration diagram of a computer system according to one embodiment of this application;
[0022] Figure 2 This is a schematic diagram of the input text processing process according to one embodiment of this application;
[0023] Figure 3 This is a flowchart of an input text processing method provided in one embodiment of this application;
[0024] Figure 4 This is a schematic diagram of the structure of an interconnected network according to an embodiment of this application;
[0025] Figure 5 This is a flowchart of an input text processing method provided in one embodiment of this application;
[0026] Figure 6 This is a flowchart of an input text processing method provided in one embodiment of this application;
[0027] Figure 7 This is a flowchart of an input text processing method provided in one embodiment of this application;
[0028] Figure 8 This is a framework diagram of the extension of named entities involved in the embodiments of this application;
[0029] Figure 9 This is a flowchart of an input text processing method provided in one embodiment of this application;
[0030] Figure 10 This is a flowchart of an input text processing method provided in one embodiment of this application;
[0031] Figure 11 This is a system framework diagram for input text processing according to an exemplary embodiment of this application;
[0032] Figure 12 This is a flowchart of an input text processing method provided in one embodiment of this application;
[0033] Figures 13 to 15 This is a flowchart of a knowledge base organization framework provided in one embodiment of this application;
[0034] Figure 16 This is a flowchart of an input text processing method provided in one embodiment of this application;
[0035] Figure 17 This is a block diagram of an input text processing apparatus provided in an exemplary embodiment of this application;
[0036] Figure 18 This is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application. Detailed Implementation
[0037] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0038] This application proposes an input text processing scheme that improves the accuracy of natural language processing. For ease of understanding, some concepts involved in this application are explained below.
[0039] 1) Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.
[0040] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, pre-trained model technology, operating / interactive systems, and mechatronics. Among these, pre-trained models, also known as large-scale models or foundational models, can be widely applied to downstream tasks across various AI fields after fine-tuning. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0041] 2) Machine Learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence; its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and instruction-based learning. Pre-trained models are the latest development in deep learning, integrating the above techniques.
[0042] 3) Natural Language Processing (NLP) is an important field within computer science and artificial intelligence. It studies the theories and methods for enabling effective communication between humans and computers using natural language. NLP deals with natural language, the language people use in daily life, and is closely related to linguistics; it also involves computer science and mathematics. Pre-trained models, a crucial technique for model training in artificial intelligence, evolved from large language models in NLP. After fine-tuning, large language models can be widely applied to downstream tasks. NLP techniques typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs.
[0043] 4) Pre-trained Model (PTM), also known as a foundational model or large model, refers to a deep neural network (DNN) with a large number of parameters. It is trained on massive amounts of unlabeled data. Leveraging the function approximation capabilities of the large-parameter DNN, the PTM extracts common features from the data. Through fine-tuning, parameter-efficient fine-tuning (PEFT), and prompt-tuning techniques, it is suitable for downstream tasks. Therefore, pre-trained models can achieve ideal results in scenarios with few or zero samples. Based on the data modalities they process, PTM (Programmable Modules) can be categorized into language models (such as Language Model Embedding (ELMO), Bidirectional Encoder Representations from Transformers (BERT), Generative Pre-Trained (GPT), etc.), visual models (such as win-transformer, Vision Transformer (ViT), Vision Mixture Of Experts (V-MOE), etc.), speech models (such as VALL-E), and multimodal models (such as Visual BERT (ViBERT), Contrastive Language-Image Pre-Training (CLIP), Flamingo, Gato), etc. Multimodal models refer to models that establish feature representations for two or more data modalities. Pre-trained models are important tools for outputting Artificial Intelligence Generated Content (AIGC) and can also serve as a general interface connecting multiple task-specific models.
[0044] 5) Large Language Model (MLM) is an artificial intelligence technique that automatically learns language patterns and generates natural language sentences and paragraphs in the field of natural language processing. MLM uses unsupervised or semi-supervised learning on massive corpora, employing deep learning techniques to process and learn by encoding each word, phrase, and sentence as a numerical variable, and then training and optimizing the model based on the existing corpus. Currently, MLM has been applied to various natural language processing problems.
[0045] 6) Knowledge Base, in this application, refers to a system or tool for storing and managing knowledge. It can be a structured information repository used to collect, organize, store, and retrieve knowledge.
[0046] 7) A prompt is a form of input in the field of pre-trained large models, used to instruct an AI model what action it should take or what output it should produce when performing a task. A prompt is a natural language input, similar to a command or instruction, letting the AI model know what it needs to do. That is, in an interactive system based on a generative language model, the user inputs a prompt, and the system responds accordingly based on the user's input.
[0047] The solutions provided in this application involve artificial intelligence machine learning models and large-scale generative language models, as described in the following embodiments.
[0048] It should be noted that this application may display prompt interfaces, pop-ups, or output voice prompts before and during the collection of user-related data (such as user input text, user accounts, etc.). These prompt interfaces, pop-ups, or voice prompts are used to inform the user that their relevant data is being collected. This ensures that the application only begins the steps related to collecting user-related data after receiving confirmation from the user regarding the prompt interface or pop-up; otherwise (i.e., without receiving confirmation from the user), the steps to collect user-related data end, meaning no user-related data is collected. In other words, all user data collected in this application is collected with the user's consent and authorization, and the collection, use, and processing of relevant user data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.
[0049] Figure 1 This is a system configuration diagram of a computer system according to one embodiment of this application. Figure 1 As shown, the system includes a requester device 120 and a servicer device 130 for input text processing.
[0050] The requesting device 120 can be a personal computer device such as a desktop computer, a laptop computer, or a personal workstation.
[0051] The service provider equipment 130 can be a single server, several servers, a virtualization platform, or a cloud computing service center.
[0052] The requesting device 120 and the serving device 130 can be connected via a communication network. Optionally, this communication network can be a wired network or a wireless network.
[0053] Optionally, the aforementioned wireless or wired networks use standard communication technologies and / or protocols. The network is typically the Internet, but can also be any network, including but not limited to Local Area Networks (LANs), Metropolitan Area Networks (MANs), Wide Area Networks (WANs), mobile, wired or wireless networks, private networks, or any combination of virtual private networks. In some embodiments, technologies and / or formats, including Hyper Text Markup Language (HTML), Extensible Markup Language (XML), etc., are used to represent data exchanged over the network. Furthermore, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Networks (VPNs), and Internet Protocol Security (IPsec) can be used to encrypt all or some links. In other embodiments, custom and / or dedicated data communication technologies can be used to replace or supplement the aforementioned data communication technologies.
[0054] exist Figure 1 In the system shown, the requesting device 120 can provide the input text to be processed to the service device 130, and the service device 130 will send the generated output to the requesting device 120.
[0055] For example, please refer to Figure 2 This illustrates a flowchart of input text processing according to an embodiment of this application. Figure 2As shown, the requesting device 120 sends input text 120a to the serving device 130. Before performing natural language processing on the input text 120a, the serving device 130 first performs semantic enhancement on it. Specifically, the serving device 130 extracts a reference named entity 120b from the input text 120a and queries the knowledge base 130a for a reference text statement 130b associated with the reference named entity 120b. This reference text statement 130b is used to semantically enhance the input text 120a. During natural language processing, the serving device 130 performs natural language processing on both the reference text statement 130b and the input text 120a to obtain the natural language processing result of the input text. Afterward, the serving device 130 sends the natural language processing result of the input text to the requesting device 120.
[0056] Figure 3 This is a flowchart of an input text processing method provided in one embodiment of this application. The input text processing method can be executed by a computer device, for example, the computer device described above. Figure 1 The service provider device 130 shown, or the aforementioned computer device, can also be other computer devices, such as a server, or a personal computer, etc. The aforementioned input text processing method may include the following steps:
[0057] Step 310: Extract reference named entities from the input text based on natural language processing.
[0058] The aforementioned input text refers to the text input to or to be input into a generative language model (such as a large language model) for natural language processing.
[0059] The input text can be entered by the user through an input interface displayed on the computer device. For example, when the computer device is a user terminal, the input text can be text entered by the user through an input interface displayed on that user terminal.
[0060] Alternatively, the aforementioned input text can also be entered by the user through an input interface on a device other than the computer device, and then sent to the computer device by that device. For example, when the computer device is a server and the other device is a user terminal, the user can enter the aforementioned input text through an input interface displayed on the user terminal, and the user terminal will then send the input text to the server.
[0061] Alternatively, the input text mentioned above can also be text automatically generated by the application when performing application tasks. For example, when the application needs to call a generative language model to perform a certain task, it can generate the input text mentioned above.
[0062] The aforementioned reference named entity can be a named entity contained in the input text. Alternatively, the aforementioned reference named entity can also be a named entity that is not contained in the input text but is semantically related to the input text.
[0063] Step 320: Query the reference text statements associated with the reference named entity in the knowledge base; the knowledge base contains the association between named entities and text statements; the text statements are used to describe the relevant knowledge of the associated named entities.
[0064] An entity is an objectively existing and distinguishable thing. An entity can be a specific person, event, or object, or it can be a concept. A named entity is an entity identified by its name. Simply put, if we can know what specific thing it is just by hearing its name, then that thing is a named entity.
[0065] Named entities have entity types, which are concepts defined by humans based on requirements. Common entity types include person names, place names, organization names, time periods, product names, domain terms, and so on.
[0066] In this embodiment of the application, the knowledge base is a pre-built and stored information system / information base / database. The knowledge base contains various pre-collected text statements, and each text statement is a statement used to describe the relevant knowledge of the associated named entities.
[0067] Each of the above text statements can be associated with one or more named entities, and correspondingly, each named entity can be associated with one or more text statements.
[0068] The relationship between the named entities and the text statements mentioned above can also be called the correspondence between named entities and text statements.
[0069] In this embodiment of the application, after the computer device extracts the reference named entity from the input text, it can query the knowledge base for text statements that are related to the reference named entity, and use them as the aforementioned reference text statements.
[0070] Step 330: Perform natural language processing on the input text and the reference text statement to obtain the natural language processing result of the input text.
[0071] In this embodiment of the application, the computer device can input the reference text statement and the input text together into the generative language model, and the generative language model can perform natural language processing to obtain the natural language processing result of the input text. In the process of performing natural language processing on the reference text statement and the input text, the generative language model can extract not only the semantics of the input text, but also the semantics of the related knowledge of the named entities in the input text, so as to guide the generative language model to perform natural language processing on the input text through the related knowledge of the named entities.
[0072] Specifically, in the embodiments of this application, when the generative language model performs natural language processing on the input text and the reference text statement, it can refer to the semantics of the reference text statement to perform natural language processing on the input text. This allows for more targeted natural language processing on the input text by combining the semantics of the reference text statement.
[0073] In summary, the solution presented in this application, when processing input text through natural language processing, assists in the natural language processing of the input text by using text statements associated with named entities in the input text. Since these text statements describe relevant knowledge within the input text, when performing natural language processing on both the text statements and the input text simultaneously, the natural language processing model can understand more comprehensive relevant knowledge about the input text. This allows the model to more accurately understand the semantics of the input text, and consequently, the output results generated by the model are more targeted, thereby improving the accuracy of natural language processing.
[0074] In one possible implementation, if the number of reference text statements n is greater than the number threshold m, where n > m ≥ 1 and n and m are integers, then the computer device can select m reference text statements from the n reference text statements, and then perform natural language processing on the selected m reference text statements and the input text to obtain the natural language processing result of the input text.
[0075] If the number of reference text statements is large, it may cause the subsequent natural language processing process to be too long, resulting in a decrease in the efficiency of natural language processing. In this embodiment, the number of reference text statements participating in the subsequent natural language processing can be limited to ensure the efficiency of natural language processing.
[0076] When a computer device selects m reference text statements from n reference text statements, it can obtain the m text statements with the highest semantic relevance to the input text from the n reference text statements as the aforementioned m reference text statements. For example, the computer device can calculate the semantic relevance between the n reference text statements and the input text (such as the similarity between the feature vectors of the reference text statements and the input text (e.g., cosine value, etc.)), and sort the n reference text statements in descending order of semantic relevance to the input text, selecting the m text statements that are ranked first as the aforementioned m reference text statements.
[0077] Alternatively, the computer device described above can randomly select m reference text statements from n reference text statements.
[0078] Based on the above Figure 3 In one possible implementation of the embodiment shown, the knowledge base can be represented by a network of associations between named entities and text statements. For example, the knowledge base contains an association network, which includes one or more text statements corresponding to a first topic, and one or more named entities associated with the text statements.
[0079] In this embodiment, the knowledge base may contain one or more association networks, each corresponding to a topic. Specifically, an association network contains one or more text statements whose content corresponds to the same topic, and each text statement is associated with one or more named entities. The named entities associated with a text statement may be semantically related to that text statement.
[0080] Through the solution shown in the above embodiments of this application, the knowledge base can be divided into corresponding association networks according to the topics, which can simplify the composition structure of the knowledge base. Specifically, when updating the knowledge base, association networks can be added or removed in the knowledge base by topic, thereby ensuring the flexibility of updating or expanding the knowledge base.
[0081] For example, taking the aforementioned text statement as an example, which includes the named entities within that text statement as well as other named entities with the same semantics as the named entities within that text statement, please refer to [reference needed]. Figure 4 This illustrates a schematic diagram of the structure of an interconnected network according to an embodiment of this application. Figure 4 As shown, taking the first topic "riboflavin" as an example, this first topic corresponds to three text statements, which are as follows:
[0082] Text statement 401: Riboflavin Also called Vitamin B2 It is one of the water-soluble B vitamins.
[0083] Text statement 402: Riboflavin It is essential for biochemical processes that use food as an energy source and can be converted into reactive phosphorylated metabolites. Flavin mononucleotide and Flavin adenine dinucleotide .
[0084] Text statement 403: Flavin mononucleotide and Flavin adenine dinucleotide These are all important coenzymes for tissue respiration; their deficiency can lead to… Riboflavin The deficiency causes a series of clinical symptoms.
[0085] Among them, text statements 401, 402, and Chinese text statement 403 all contain the named entity "riboflavin". Text statement 401 also contains the named entity "vitamin B2", which has the synonym "vitamin B2 powder". Text statements 402 and 403 also contain the named entities "flavin mononucleotide" and "flavin adenine dinucleotide". Therefore, in the association network corresponding to the first topic "riboflavin", text statements 401, 402, and Chinese text statement 403 are included. The named entities "vitamin B2", "vitamin B2 powder", and "riboflavin" are associated with text statements 401, 402, and 403, respectively. The named entities "flavin mononucleotide" and "flavin adenine dinucleotide" are associated with text statements 402 and 403, respectively.
[0086] The one or more text statements corresponding to the first topic can be obtained in advance by the computer device responsible for building the knowledge base. For example, the computer device can obtain a piece or more of the text corpus corresponding to the first topic collected in advance by the developers, and then process the piece or more of the text corpus corresponding to the first topic into blocks to obtain the one or more text statements corresponding to the first topic.
[0087] For example, for each of the above text corpora, the computer device can divide the text corpora according to the period as the dividing point, and obtain one or more text sentences corresponding to the topic to which the above text corpora belong.
[0088] Optionally, in the process of dividing the text corpus according to the period as the dividing point, the resulting text sentences may lack a subject. In this embodiment of the application, the computer device can divide the above text corpus according to the period as the dividing point to obtain one or more candidate text sentences, and then add a subject to the candidate text sentences that lack a subject to obtain one or more text sentences.
[0089] The process of segmenting the text corpus and adding subjects to candidate text sentences can be implemented using a generative language model. For example, a computer device can generate a prompt containing the aforementioned text corpus. This prompt instructs the generative language model to segment the text corpus using periods as dividing points and to add subjects to the resulting text sentences. The computer device then inputs this prompt into the generative language model, which outputs the resulting text sentences after segmenting the text corpus and adding subjects.
[0090] Based on the solutions shown in the above embodiments, please refer to Figure 5 The diagram illustrates a flowchart of an input text processing method provided in one embodiment of this application. Prior to step 310 above, the knowledge base construction step may include steps 301 to 303.
[0091] Step 301: Obtain the first candidate named entity. The first candidate named entity is a named entity that belongs to both the first text statement and the knowledge graph corresponding to the first topic. The knowledge graph contains the relationships between the named entities in the knowledge domain to which the first topic belongs. The first text statement is one of one or more text statements corresponding to the first topic.
[0092] A knowledge graph is a network structure knowledge base used to represent and store knowledge. It is a semantic-based representation method that uses a network structure to represent the relationships and attributes between entities. A knowledge graph typically consists of a set of entities and relationships (also called entity-relation pairs). For example, an entity-relation pair can be represented as <head entity, association, tail entity>, indicating that there is an "association" between the "head entity" and the "tail entity".
[0093] The aforementioned relationships can be of various types. For example, they can include synonymous relationships (meaning that the "head entity" and the "tail entity" are synonymous), superior relationships (meaning that the "tail entity" is superior to the "head entity"), subordinate relationships (meaning that the "tail entity" is subordinate to the "head entity"), corresponding part relationships (meaning that the "head entity" is the part corresponding to the "tail entity"), etc. This application embodiment does not limit the types of the aforementioned relationships.
[0094] The knowledge graph corresponding to the first topic mentioned above can refer to the knowledge graph of the knowledge domain to which the first topic belongs; for example, when the first topic is a topic in the medical field, the knowledge graph corresponding to the first topic can be a knowledge graph in the medical field; or, for example, when the first topic is a topic in the digital electronics field, the knowledge graph corresponding to the first topic can be a knowledge graph in the digital electronics field, and so on.
[0095] The knowledge graph corresponding to the first topic can be pre-set by the developers and connected to the computer device responsible for building the knowledge base. For example, the developers pre-set knowledge graphs for each knowledge domain. When building the knowledge base, the computer device responsible for building the knowledge base can determine the knowledge graph corresponding to the first topic from multiple pre-set knowledge graphs when building the association network corresponding to the first topic. The knowledge domain corresponding to the first topic can be set or specified by the developers.
[0096] In the embodiments of this application, during the process of constructing the knowledge base, for any one of the one or more text statements corresponding to the first topic (i.e., the first text statement mentioned above), the computer device responsible for constructing the knowledge base can first determine the named entity existing in the knowledge graph corresponding to the first topic from the first text statement as the first candidate named entity.
[0097] For example, a computer device can first extract named entities from the first text statement, thereby extracting each candidate named entity in the first text statement. For each candidate named entity, the computer device responsible for building the knowledge base can compare the candidate named entity with the named entities contained in the knowledge graph corresponding to the first topic. If a candidate named entity is consistent with a named entity in the knowledge graph corresponding to the first topic, then the candidate named entity is considered to exist in the knowledge graph corresponding to the first topic, and the candidate named entity can be identified as a first candidate named entity. For the aforementioned first text statement, multiple first candidate named entities can be identified.
[0098] When the aforementioned computer device extracts candidate named entities from the first text statement, it can do so with the help of a generative language model. For example, the computer device generates a prompt containing the first text statement, which instructs the generative language model to extract named entities from the first text statement. Then, the prompt is input into the generative language model, which outputs the candidate named entities from the first text statement.
[0099] Alternatively, the aforementioned computer device may also perform word segmentation on the first text statement, and obtain one or more words obtained from the word segmentation as the aforementioned candidate named entities.
[0100] Step 302: In the knowledge graph corresponding to the first topic, query the second candidate named entity that has a synonymous relationship with the first candidate named entity.
[0101] In this embodiment of the application, the computer device responsible for building the knowledge base can further determine, from the knowledge graph corresponding to the first topic, a named entity that has a synonymous relationship with the first candidate named entity and does not exist in the first text statement, as the second candidate named entity.
[0102] For example, a computer device can query the knowledge graph corresponding to the first topic, and find the entity relationship pairs that contain the first candidate named entity. For entity relationship pairs that have synonymous relationships, if the other named entity in the entity relationship pair does not exist in the first text statement, then the named entity is obtained as the second candidate named entity.
[0103] For example, the first text statement above is Figure 4 Text statement 401 in the text contains the named entity " Riboflavin "and" Vitamin B2 The knowledge graph contains " Vitamin B2 The two corresponding entity relation pairs with synonymous associations are: < Vitamin B2 Synonyms Vitamin B2 powder > and, < Vitamin B2 Synonyms, riboflavin, where, for the first candidate named entity " Vitamin B2 Its synonym named entity in the knowledge graph is " Vitamin B2 powder "and "riboflavin", of which " Vitamin B2 powder If it does not exist in the first text statement, then the computer device can... Vitamin B2 powder If "riboflavin" is identified as the second candidate named entity, and "riboflavin" exists in the first text statement, then the computer device will not identify "riboflavin" as the second candidate named entity (the named entity "riboflavin" itself can be the first candidate named entity).
[0104] Step 303: Add the first candidate named entity and the second candidate named entity as synonymous named entities associated with the first text statement in the association network.
[0105] In other words, in the embodiments of this application, a synonymous named entity of a text statement refers to the named entity contained in the text statement, and at least one of other named entities that have the same semantics as the named entity contained in the text statement.
[0106] In this embodiment of the application, after the computer device performs the above step 301 and obtains the first candidate named entity, it can add the obtained first candidate named entity as a synonym named entity associated with the first text statement in the association network corresponding to the first topic; subsequently, after performing step 302, if the second candidate named entity is successfully obtained, it can further add the obtained second candidate named entity as a synonym named entity associated with the first text statement in the association network corresponding to the first topic.
[0107] Alternatively, after executing steps 301 and 302 above, the computer device may add the first candidate named entity and the second candidate named entity together as synonymous named entities associated with the first text statement in the association network corresponding to the first topic.
[0108] Optionally, if the computer device does not query the knowledge graph corresponding to the first topic for a second candidate named entity that has a synonymous relationship with the first candidate named entity, the computer device may add the first candidate named entity as a synonymous named entity associated with the first text statement in the association network corresponding to the first topic.
[0109] Through the solution shown in the above embodiments of this application, the computer device responsible for building the knowledge base can determine the named entities and their synonyms contained in the text statement based on the knowledge graph of the knowledge domain corresponding to the first topic. As synonymous named entities associated with the text statement, the accuracy of the association between the named entities and the text statement can be guaranteed, ensuring that sufficiently accurate reference text statements can be queried through the knowledge base in the future, thereby improving the accuracy of subsequent natural language processing.
[0110] Based on the scheme shown in the above embodiments, in one possible implementation, the knowledge base construction step further includes: in response to the second text statement being a statement containing a title, and the title not belonging to the knowledge graph corresponding to the first topic, adding the title as a title named entity associated with the second text statement in the association network corresponding to the first topic; wherein the second text statement is one of one or more text statements corresponding to the first topic.
[0111] Optionally, the second text statement mentioned above can be a semi-structured statement, where the headings exist in the form of structured data. A semi-structured statement refers to a text statement that contains a portion of structured data. Structured data refers to data with a fixed format and rules, typically presented in the form of tables, tree structures, or relational models. Structured data usually has clearly defined data types and fields, allowing for data modeling and data analysis operations.
[0112] For example, suppose a text statement is: "Submucosal tumor of the duodenum [CLS] Etiology [SEP] The pathogenesis is abnormal proliferation of submucosal tissue and muscle layer, mostly caused by congenital factors." In this text statement, the first named entity includes not only "submucosal tumor of the duodenum" and "abnormal proliferation of submucosal tissue and muscle layer" within the text statement, but also the title "Etiology." Then, a computer device can associate the title "Etiology" as a title named entity with the text statement.
[0113] For semi-structured statements, the titles and core semantics of the text statements are usually strongly correlated. For example, in the text statement above, the title "etiology" is strongly correlated with the core semantics "pathogenesis". In this regard, in the solution shown in the embodiment of this application, when a semi-structured text statement contains a title, the computer device responsible for building the knowledge base will also determine the title as the title named entity of the text statement. In this way, when the reference named entity contained in the subsequent input text is the title of the text statement, the text statement strongly related to the reference named entity can be retrieved as a reference text statement through the reference named entity. This can ensure that a sufficiently accurate reference text statement can be retrieved through the knowledge base, thereby improving the accuracy of subsequent natural language processing.
[0114] Based on the solutions shown in the above embodiments, in one possible implementation, the above-mentioned association network further includes one or more extended named entities associated with the first text statement;
[0115] The extended named entity does not belong to the associated first text statement, and the synonymous named entity associated with the extended named entity and the first text statement are semantically different named entities with an association relationship in the knowledge graph.
[0116] In other words, an extended named entity of a text statement is a named entity obtained by expanding the synonym named entity of the text statement according to the association relationship between named entities in the knowledge graph.
[0117] The aforementioned extended named entity and the synonymous named entity associated with the first text statement have an association relationship in the knowledge graph. This can mean that the extended named entity and the synonymous named entity have a direct association relationship in the knowledge graph. For example, the extended named entity and the synonymous named entity have a synonym association relationship, a hierarchical association relationship, a corresponding part association relationship, etc. in the knowledge graph.
[0118] Alternatively, the aforementioned extended named entity and the synonymous named entity associated with the first text statement may have an association relationship in the knowledge graph. This could also mean that the extended named entity and the synonymous named entity have an indirect association relationship in the knowledge graph. For example, the extended named entity and the synonymous named entity may not have a direct association relationship such as a synonymous association, a hierarchical association, or a corresponding part association relationship in the knowledge graph. However, in the aforementioned knowledge graph, there exists an association path that starts from the extended named entity, goes through various direct association relationships, and reaches the synonymous named entity.
[0119] In one exemplary embodiment, in the aforementioned association network, the first text statement can be directly associated with the synonymous named entity / title named entity (e.g., the first text statement has a link relationship with the synonymous named entity / title named entity), and the aforementioned extended named entity can be indirectly associated with the first named entity (e.g., the extended named entity has a link relationship with the synonymous named entity), thus indirectly associating the extended named entity with the first text statement.
[0120] In another exemplary embodiment, the extended named entity and the first text statement can also be directly associated, that is, the extended named entity and the first text statement can also have a link relationship.
[0121] In the embodiments of this application, the number of text statements that can be obtained in a knowledge domain is usually limited. Therefore, the named entities and their synonyms (corresponding to the above-mentioned synonym named entities) contained in the text statements are difficult to cover all or most of the named entities in the knowledge graph of the knowledge domain. In the subsequent natural language processing, the input text may contain reference named entities that do not belong to any text statement or are not synonyms of the named entities contained in any text statement, but belong to the corresponding knowledge domain.
[0122] To maximize the probability of finding the corresponding reference text statement through the reference named entity, in this embodiment, for the association network in the knowledge base, the first text statement, in addition to being associated with synonym named entities and title named entities, can also be associated with one or more extended named entities. These extended named entities are not part of the associated first text statement, nor are they synonyms of the named entities in the associated first text statement; rather, they are semantically related to the synonym named entities associated with the first text statement. Thus, when subsequently querying the knowledge base through the reference named entity, even if the reference named entity is not part of any text statement, nor is it a synonym of any named entity contained in any text statement, there is still a chance to find a reference text statement that is semantically related to the reference named entity. This increases the probability of finding the reference text statement through the knowledge base, thereby improving the accuracy of subsequent natural language processing.
[0123] Based on the scheme shown in the above embodiments, in one possible implementation, one or more extended named entities include at least one of a first extended entity and a second extended entity;
[0124] The first extended entity mentioned above is a subordinate named entity of a single synonym named entity;
[0125] The aforementioned second extended entity is semantically related to multiple synonymous named entities, and among the multiple synonymous named entities is a synonymous named entity associated with the first text statement.
[0126] In this embodiment of the application, for a first text statement, if a synonymous named entity corresponding to the first text statement has a subordinate named entity, the subordinate named entity usually has a strong semantic relationship with the first text statement. Therefore, the subordinate named entity can be used as an extended named entity of the first text statement.
[0127] In the embodiments of this application, among the synonymous named entities corresponding to the above one or more text statements, if multiple synonymous named entities are semantically related to a named entity at the same time, and the named entity is not a synonymous named entity of the above one or more text statements, then the named entity will usually also have a strong semantic relationship with the text statements associated with the above multiple synonymous named entities. Therefore, the named entity can be used as an extended named entity of the text statements associated with the above multiple synonymous named entities.
[0128] In this embodiment, the subordinate named entities of the synonymous named entities of the first text statement, as well as the named entities that are simultaneously associated with multiple synonymous named entities, can be used as extended named entities of the first text statement. In the knowledge base, text statements can be associated with named entities that have strong semantic relevance. In this way, when querying the knowledge base through reference named entities, even if the reference named entity does not belong to any text statement or is not a synonym of the named entity contained in any text statement, reference text statements with strong semantic relevance to the reference named entity can still be found. This improves the accuracy of reference text statements retrieved through the knowledge base, and thus improves the accuracy of subsequent natural language processing.
[0129] Optionally, one or more of the above extended named entities may also include a third extended entity; the third extended entity is the parent named entity of a single synonymous named entity associated with the first text statement.
[0130] Whether the aforementioned knowledge base contains a third extended entity, or whether the third extended entity contained in the aforementioned knowledge base is available, can be preset by the developers; or whether the third extended entity contained in the aforementioned knowledge base is available can also be preset by the user.
[0131] Based on the solutions shown in the above embodiments, please refer to Figure 6 The diagram illustrates a flowchart of an input text processing method provided in one embodiment of this application. In the case where one or more extended named entities include a first extended entity, the knowledge base construction step may further include steps 304 and 305.
[0132] Step 304: Query the knowledge graph corresponding to the first topic, and find the named entities that have a subordinate relationship with the synonymous named entities associated with the first text statement.
[0133] The knowledge graph can contain multiple named entity pairs, each named entity pair containing two named entities and the association between the two named entities. In this embodiment, for each synonym named entity associated with the first text statement, the computer device can query the named entity pair in the knowledge graph that corresponds to the hierarchical relationship of the named entity pair to which the synonym named entity is located, and obtain the hierarchical named entity that belongs to the synonym named entity as the hierarchical named entity of the synonym named entity.
[0134] Step 305: Add the retrieved named entity as the first extended entity associated with the first text statement in the association network.
[0135] For example, the computer equipment responsible for building the knowledge base can link the lower-level named entities retrieved above to the corresponding higher-level synonymous named entities in the association network, so as to establish an indirect association between the lower-level named entities and the first text statement.
[0136] Alternatively, the computer device responsible for building the knowledge base can directly link the aforementioned subordinate named entities to the first text statement to establish a direct association between the subordinate named entity and the first text statement.
[0137] In the embodiments of this application, the knowledge graph contains named entity pairs with hierarchical relationships. With the help of the knowledge graph, on the one hand, it is convenient and quick to determine the named entity with a hierarchical relationship with the synonym named entity as the first extended entity. On the other hand, it can also ensure the accuracy of the determined first extended entity.
[0138] Based on the solutions shown in the above embodiments, please refer to Figure 7The diagram illustrates a flowchart of an input text processing method provided in one embodiment of this application. In the case where one or more extended named entities include a second extended entity, the knowledge base construction steps may further include steps 306 and 307.
[0139] Step 306: For two synonymous named entities associated with one or more text statements corresponding to the first topic, query whether there is a connection path between the two synonymous named entities in the knowledge graph; at least one of the two synonymous named entities is associated with the first text statement; the connection path is a path that starts from one named entity and reaches another named entity through the connection relationship between the named entities.
[0140] In this embodiment of the application, a knowledge graph can be regarded as a graph structure data. In the knowledge graph, each named entity can be regarded as a node in the graph structure data. The relationship between two named entities can be regarded as the two named entities being connected by an edge in the graph structure data. Since a named entity may have relationships with multiple different named entities at the same time, in the above-mentioned graph structure data, starting from a named entity A, it is possible to reach another named entity B that does not have a direct relationship with named entity A through the edges between adjacent named entities. The path formed by other named entities traversed from named entity A to named entity B can be regarded as the above-mentioned relationship path.
[0141] For example, knowledge graphs contain " Vitamin B2 The two corresponding entity relation pairs with synonym relationships are: < Vitamin B2 Synonyms Vitamin B2 powder > and, < Vitamin B2 Synonyms, riboflavin >, then the above named entity " Life Vitamin B2 "In graph-structured data, simultaneously with the named entity 'riboflavin' and the named entity..." Vitamin B2 powder The elements connected by an edge start from the named entity "riboflavin" and pass through the named entity "...". Vitamin B2 ", can reach the named entity " Vitamin B2 pink In other words, the above graph structure data contains entries from the named entity "riboflavin" to the named entity "..." Vitamin B2 powder The associated path of "".
[0142] Optionally, in this embodiment of the application, when a computer device queries the association path between two synonymous named entities in a knowledge graph, it can start from one of the two synonymous named entities and use a search algorithm, such as depth-first search (DFS) or breadth-first search (BFS), to traverse the other named entities associated with that synonymous named entity layer by layer until the other named entity of the two synonymous named entities is found, or until the termination condition is met (such as the number of traversed levels reaching a threshold). For example, suppose we want to query the association path between two synonymous named entities (named entity 1 and named entity 2). The computer device starts with named entity 1 and first performs a first-level traversal, which means traversing the first-level named entities in the knowledge graph that have a direct association with named entity 1. If the first-level named entities do not contain named entity 2, then a second-level traversal is performed, which means traversing the second-level named entities in the knowledge graph that have a direct association with the first-level named entities. If the second-level named entities do not contain named entity 2, then a third-level traversal is performed, and so on, until named entity 2 is traversed, or the traversal level reaches a level threshold. If named entity 2 is traversed, then the path composed of named entity 1, named entity 2, and all the named entities traversed during the traversal from named entity 1 to named entity 2 is determined as the aforementioned association path.
[0143] Step 307: If two synonymous named entities have a related path in the knowledge graph, add the named entity that exists in the related path of the two synonymous named entities in the knowledge graph and does not belong to the first text statement as the second extended entity associated with the first text statement in the association network.
[0144] In this embodiment of the application, if two synonymous named entities have an association path in the knowledge graph, it can be considered that the two synonymous named entities, as well as other named entities on the association path between the two synonymous named entities, have a certain semantic relevance. In this case, the other named entities on the association path between the two synonymous named entities can be regarded as the second extended entity of the text statement associated with the two synonymous named entities.
[0145] In this embodiment of the application, named entity pairs with direct relationships in the knowledge graph can be inferred from the graph structure formed by the direct relationships between the named entities in the knowledge graph. Named entities that are directly or indirectly related to multiple synonymous named entities can be deduced as the second extended entities of the text statements associated with these multiple synonymous named entities. On the one hand, it is convenient and quick to determine the named entities that have semantic relevance to multiple synonymous named entities as the second extended entities. On the other hand, it can also ensure the accuracy of the determined second extended entities.
[0146] For example, based on the above Figure 6 and Figure 7 Please refer to the proposed solution. Figure 8 This illustrates a framework diagram of the extended named entities involved in embodiments of this application. Figure 8 As shown, the knowledge graph 810 contains several named entities, including named entities A to E. The knowledge base association network 820 contains text statement 1 and text statement 2. Named entity A is a named entity contained in text statement 1 (corresponding to the above synonymous named entity), and named entity D is a named entity contained in text statement 2.
[0147] On the one hand, in the aforementioned knowledge graph 810, there is a hierarchical relationship between named entity E and named entity A, and named entity E is a subordinate named entity of named entity A. Therefore, the computer device can link named entity E to named entity A in the association network 820, thereby adding named entity E as the first extended entity of text statement 1.
[0148] On the other hand, for the aforementioned named entities A and D, the computer device can traverse the knowledge graph 810 to obtain the association path between named entity A and named entity D. This association path sequentially contains named entity B and named entity C. The computer device can link named entity B to named entity A and named entity C respectively in the association network 820, and link named entity C to named entity D, thereby adding named entity B and named entity C as the second extended entities of text statement 1 and text statement 2.
[0149] In one possible implementation, in step 307 above, the computer device may further add the named entity that exists in the association path of the two synonymous named entities in the knowledge graph and does not belong to the first text statement as a second extended entity associated with the first text statement in the association network when the length of the association path is less than the length threshold.
[0150] In this embodiment of the application, if the length of the association path between two synonymous named entities in the knowledge graph is too long (greater than the length threshold), the semantic relevance between the two synonymous named entities may be relatively low. At this time, the semantic relevance between the other named entities on the association path between the two synonymous named entities in the knowledge graph and the two synonymous named entities may also be relatively low.
[0151] In this embodiment, after determining the association path between two synonymous named entities in the knowledge graph, the computer device can determine whether the length of the association path is less than a length threshold. If it is, it indicates that the semantic relevance between the two synonymous named entities is high enough, and other named entities on the association path can be added as second extended entities of the text statement associated with the two synonymous named entities. Otherwise, the computer device may not add other named entities on the association path as second extended entities of the text statement associated with the two synonymous named entities. The above scheme can ensure that there is sufficient semantic relevance between the text statement and the associated named entity in the association network of the knowledge base, thereby improving the accuracy of subsequent natural language processing.
[0152] In one possible implementation, in step 307 above, the computer device may further, when two synonymous named entities have a connection path in the knowledge graph, identify the synonymous named entity that is closest to the intermediate named entity among the two synonymous named entities on the connection path, and add the intermediate named entity as a second extended entity of the text statement associated with the closest synonymous named entity. For example, in the above embodiment, when the synonymous named entity that is closest to the intermediate named entity among the two synonymous named entities is a synonymous named entity associated with the first text statement, the computer device may add the intermediate named entity as a second extended entity associated with the first text statement.
[0153] In this embodiment, the distances between other named entities in the association path of two synonymous named entities and the two synonymous named entities may vary. The closer the two named entities are in the knowledge graph, the higher the semantic relevance between them. Conversely, the farther apart the two named entities are in the knowledge graph, the lower the semantic relevance between them. If an intermediate named entity in the above association path is added as the second extended entity of the text statement associated with the more distant synonymous named entities, the semantic relevance between the second extended entity and the text statement may also be relatively low.
[0154] In this embodiment, after determining the association path between two synonymous named entities in the knowledge graph, the computer device can add each intermediate named entity in the association path as a second extended entity of the text statement associated with the closer synonymous named entity. For example, in the above... Figure 8 In the text, if the distance between named entity B and named entity A is less than the distance between named entity B and named entity D, then named entity B can be added as the second extended entity of text statement 1. Similarly, if the distance between named entity C and named entity A is greater than the distance between named entity C and named entity D, then named entity C can be added as the second extended entity of text statement 2. This scheme can ensure that there is sufficient semantic relevance between text statements and associated second extended entities in the knowledge base's association network, thereby improving the accuracy of subsequent natural language processing.
[0155] In one possible implementation, in step 307 above, the computer device may further determine the distance between an intermediate named entity and each of the two synonymous named entities if there is an association path between the two synonymous named entities on the association path, in addition to the two synonymous named entities. If the distance between the intermediate named entity and either of the two synonymous named entities is less than a distance threshold, then the intermediate named entity is added as a second extended entity of the text statement associated with the synonymous named entity.
[0156] For example, in the above embodiment, when the distance between the synonymous named entity associated with the first text statement and the intermediate named entity is less than a distance threshold, the computer device can add the intermediate named entity as a second extended entity associated with the first text statement.
[0157] In this embodiment of the application, after the computer device determines the association path between two synonymous named entities in the knowledge graph, for each intermediate named entity in the association path, the intermediate named entity can be added as a second extended entity of the text statement associated with the synonymous named entity whose distance is less than a distance threshold. For example, in the above... Figure 8 In this example, assuming a distance threshold of 2, named entity B has a distance of 1 (less than 2) from named entity A and a distance of 2 (not less than 2) from named entity D. In this case, named entity B can be added as the second extended entity of text statement 1. Similarly, named entity C has a distance of 1 (less than 2) from named entity D and a distance of 2 (not less than 2) from named entity A. In this case, named entity C can be added as the second extended entity of text statement 2. The above scheme can ensure that there is sufficient semantic relevance between text statements and associated second extended entities in the knowledge base's association network, thereby improving the accuracy of subsequent natural language processing.
[0158] Based on the solutions shown in the above embodiments, please refer to Figure 9 This illustrates a flowchart of an input text processing method provided in one embodiment of this application. Step 330 can be replaced by steps 330a and 330b.
[0159] Step 330a: Generate a first prompt statement with reference text statements as background knowledge and input text as task description.
[0160] For example, the first prompt statement above could be "Given the 'reference text statement,' please process the 'input text' and return the result."
[0161] Step 330b: Input the first prompt statement into the first generative language model and obtain the natural language processing result output by the first generative language model.
[0162] In this embodiment of the application, the computer device can use reference text statements as background knowledge to generate a prompt for performing natural language processing on the input text. This enables the first generative language model to accurately use the reference text statements as background knowledge and process the input text in a targeted manner. In this way, while making full use of the semantic information of the reference text statements, the semantic information of the reference text statements is avoided from interfering with the natural language processing task of the input text, thereby improving the accuracy of natural language processing of the input text.
[0163] Based on the solutions shown in the above embodiments, please refer to Figure 10 The diagram illustrates a flowchart of an input text processing method provided in one embodiment of this application. Steps 312 and 314 may be included prior to step 320 described above.
[0164] Step 312: Obtain the knowledge domain to which the input text belongs.
[0165] In this embodiment of the application, after the computer device obtains the input text, it can first obtain the knowledge domain to which the input text belongs, so that it can subsequently query the corresponding reference text statements in a targeted manner.
[0166] In one possible implementation, obtaining the knowledge domain to which the input text belongs includes:
[0167] A second prompt statement containing the input text is generated. The second prompt statement is used to instruct the second generative language model to identify the knowledge domain to which the input text belongs. The second prompt statement is then input into the second generative language model to obtain the knowledge domain to which the input text belongs, as output by the second generative language model.
[0168] In this embodiment of the application, the computer device can process the input text using a generative language model to determine the knowledge domain to which the input text belongs, thereby simplifying the complexity of determining the knowledge domain and improving the efficiency of knowledge domain acquisition.
[0169] Step 314: Query the knowledge base corresponding to the knowledge domain to which the input text belongs.
[0170] The same named entity can involve multiple knowledge domains, and the semantics of the named entity are usually different in different knowledge domains. For example, the semantics of the named entity "apple" are completely different in the digital electronics domain and the fruit domain. If "apple" is used as a reference named entity and the corresponding reference text statement is queried directly without distinguishing the knowledge domain, multiple reference text statements in different domains may be found. Among the multiple reference text statements in different domains, the reference text statement in the wrong domain will interfere with the generative language model's natural language processing of the input text in the subsequent natural language processing process.
[0171] To address the aforementioned issues, in this embodiment of the application, developers can pre-set multiple knowledge bases corresponding to different knowledge domains. After the computer device obtains the knowledge domain to which the input text belongs, it can first determine the knowledge base corresponding to the knowledge domain to which the input text belongs. Subsequently, it can query the reference text statements associated with the reference text statements in the knowledge base, thereby ensuring the semantic relevance between the reference text statements and the input text, and thus ensuring the effectiveness of the subsequent generative language model in natural language processing of the input text.
[0172] Based on the solutions shown in the above embodiments, please refer to Figure 11 This illustrates a system framework diagram for input text processing according to an exemplary embodiment of this application. Figure 11 As shown, the system framework includes a knowledge base construction part and an input text processing part.
[0173] The knowledge base construction is performed by the computer equipment responsible for building the knowledge base (knowledge base construction equipment), which can be a personal computer or a server; the knowledge base construction part is as follows:
[0174] S1101, the knowledge base construction device acquires the text corpus of the first topic.
[0175] S1102, the knowledge base construction device divides the text corpus into multiple text statements using periods as dividing points, and adds these multiple text statements to the association network corresponding to the first topic.
[0176] S1103, the knowledge base construction device determines named entities 1 and 7 contained in the text statement from the knowledge graph corresponding to the first topic, as well as the synonym named entity 2 of named entity 1. For semi-structured text statements, the device also sets the title in the semi-structured text statement as named entity 3 (named entity 1, named entity 7, and named entity 2 correspond to the above synonym named entities, and named entity 3 corresponds to the above title named entity). The device also adds the association relationship between named entity 1, named entity 7, named entity 2, and named entity 3 and the text statement in the above association network.
[0177] S1104, for any of the named entities among named entity 1, named entity 2, and named entity 7, the knowledge base construction device further searches for the corresponding subordinate named entity in the knowledge graph to obtain named entity 4 (corresponding to the first extended entity mentioned above), and links named entity 4 to the superior named entity in the association network (e.g., ...). Figure 11 Named entity 4 is added to the association network by adding the association between named entity 4 and the text statement.
[0178] S1105, for any two of the named entities (e.g., named entity 1, named entity 2, and named entity 7) mentioned above, Figure 11 The knowledge base building device also searches for the association path between these two named entities (named entities 2 and 7) in the knowledge graph, and links named entities 5 and 6 in the association path to named entities 2 and 7, thereby adding the association relationship between named entities 5 and 6 in the association network.
[0179] The input text processing is performed by a computer device (text processing device) responsible for processing the input text. Once the knowledge base is built, it can be deployed to this text processing device. This text processing device can be a personal computer or a server; the text processing device and the knowledge base building device can be two different computer devices, or they can be the same computer device. The knowledge base building process is as follows:
[0180] S1106, The text processing device receives input text edited by the user.
[0181] S1107, The text processing device extracts a reference named entity from the input text, for example, the reference named entity can be named entity 1.
[0182] S1108, the text processing device queries the knowledge base for the reference text statement associated with the named entity 1, such as text statement 1.
[0183] S1109, the text processing device generates a prompt statement containing the text statement 1 and the input text. For example, the prompt statement could be "Given 'text statement 1', please process the 'input text' and return the result".
[0184] S1110, the text processing device inputs the prompt statement into the generative language model (such as a large language model LLM) and obtains the natural language processing result output by the generative language model.
[0185] The above Figure 3 The solutions shown in the embodiments can be applied to multiple scenarios, such as intelligent question answering, AI content generation, etc. The following will briefly introduce two application scenarios of the embodiments of this application:
[0186] Application Scenario 1: Intelligent Question Answering
[0187] When the above solution is applied to intelligent question-answering scenarios, computer devices can perform intelligent question-answering processing on the input text to generate the corresponding answer text.
[0188] For example, in application scenario one, the input text can be a question text; natural language processing can be used to generate an answer text from the question text.
[0189] For example, please refer to Figure 12 , Figure 12 This is a flowchart of an input text processing method provided in one embodiment of this application. The input text processing method may include the following steps:
[0190] Step 1201: Extract reference named entities from the question text based on natural language processing.
[0191] Step 1202: Query the reference text statements associated with the reference named entity in the knowledge base; the knowledge base contains the association between named entities and text statements; the text statements are used to describe the relevant knowledge of the associated named entities.
[0192] Step 1203: Perform natural language processing on the question text and the reference text to obtain the answer text to the question text.
[0193] In one possible implementation, step 1203 above includes: generating a first prompt statement with reference text statement as background knowledge and question text as task description; inputting the first prompt statement into a first generative language model to obtain the answer text output by the first generative language model.
[0194] In one possible implementation, before step 1202, the method further includes: obtaining the knowledge domain to which the question text belongs; and querying the knowledge base corresponding to the knowledge domain to which the question text belongs.
[0195] In one possible implementation, the steps of obtaining the knowledge domain to which the question text belongs may include: generating a second prompt statement containing the question text, the second prompt statement being used to instruct a second generative language model to identify the knowledge domain to which the question text belongs; inputting the second prompt statement into the second generative language model to obtain the knowledge domain to which the question text belongs, as output by the second generative language model.
[0196] Taking the aforementioned intelligent question-answering scenario in the medical field as an example, with the development of large language model technology, more and more question-answering systems are being replaced by large language models. Unlike general domain question answering, medical question answering is characterized by knowledge dependence. In practical applications, medical question answering usually requires more auxiliary knowledge input to achieve better question-answering results. Therefore, a well-organized medical knowledge base is crucial. The dependence on certain medical knowledge in medical question answering is characterized by a long tail, strong colloquialism, and clear hierarchy. Specifically, medical knowledge exhibits a long-tail distribution in the knowledge base (or in the real world), meaning that some high-frequency knowledge is repeatedly mentioned or expressed while some knowledge is rarely mentioned; medical knowledge is highly colloquial in question-answering scenarios, for example, "acute upper respiratory tract infection" is often referred to as "cold" in colloquial speech; due to its clear hierarchical characteristics, medical knowledge can be organized according to a certain hierarchical structure, such as by respiratory diseases, digestive diseases, and infant medications. To address the shortcomings (or characteristics) of these three medical knowledge areas, the embodiments described above in this application provide a multi-layered organization and application scheme for a knowledge base in medical large-scale language model question answering. This scheme allows for targeted modification of the knowledge base relied upon by medical question answering in a specific scenario, enabling it to better cooperate with the large-scale medical model and achieve more accurate responses. The knowledge base organization scheme shown in this application consists of three main steps: segmentation, reorganization, and expansion. Ultimately, the specified knowledge base is reorganized, and in the large-scale model question answering process, the most relevant knowledge is quickly retrieved and input into the large-scale model's prompt, achieving better question answering results.
[0197] Specifically, the three main characteristics of medical knowledge base organization in large-scale question answering models in the medical field can be summarized as follows:
[0198] 1) The distribution of medical knowledge bases exhibits a significant long-tail effect: Taking the International Classification of Diseases (ICD) 10 knowledge base as an example, it defines as many as 46,000 standard disease names, of which "swelling" is associated with 111 diseases, "typhoid fever" with 176, and "tuberculosis" with 326. It can be seen that the number of entities corresponding to different disease knowledge varies greatly, and consequently, the corresponding medical knowledge often exhibits significant differences in magnitude. When the frequency of some medical knowledge is much greater than that of other medical knowledge, the distribution of this knowledge base is a long-tail distribution.
[0199] 2) Medical knowledge bases struggle to handle the prevalence of colloquial language in medical question-and-answer sessions: In real-world medical question-and-answer scenarios, users often describe their clinical symptoms in a descriptive way, such as having a cold or stomachache for several days. Such colloquial expressions often cannot be directly mapped to the definitions of "acute upper respiratory tract infection" or "abdominal pain" in the knowledge base, leading to errors in how large models respond to these questions. Therefore, identifying and associating colloquial, non-standard medical entity expressions with the knowledge base is crucial. However, while model-based medical entity normalization or linking algorithms are flexible, they suffer from error propagation issues. Augmentation based on synonym relationships in knowledge graphs is safer and more conducive to secondary human verification and error correction.
[0200] 3) Poor adaptability of medical knowledge bases to multi-level medical knowledge: Taking ICD-10 as an example, there are 326 standard disease names related to "pulmonary tuberculosis," while there are 1751 standard disease names related to "tuberculosis." However, it should be noted that "pulmonary tuberculosis" is a subordinate term of "tuberculosis" in medical terms, meaning that 1751 encompasses all 326. Furthermore, medical knowledge graphs often contain broader higher-level concepts. For example, entities related to "pulmonary tuberculosis" and "tuberculosis" can be categorized under "infectious and parasitic diseases," while other categories include "circulatory system diseases," "eye and accessory organ diseases," and "genitourinary system diseases." Therefore, it can be seen that such hierarchical medical information can help better organize the knowledge base, thereby achieving better knowledge retrieval with higher relevance.
[0201] The application of artificial intelligence technology in the medical field is becoming increasingly widespread, especially the application of large language models. Large language models can help doctors quickly obtain information and make decisions, improving medical efficiency and quality. For example, large language models can assist doctors in tasks such as disease-aided diagnosis and treatment planning; they can also help patients obtain accurate medical information and guidance, reducing unnecessary examination and treatment costs. Large language models can also provide hospitals with intelligent customer service, enabling 24-hour online medical services and improving the quality and efficiency of hospital services. Simultaneously, large language models can provide patients with personalized health consultations and suggestions, helping them better manage their health. The knowledge base organization and application scheme for large medical models provided in this application can help question-and-answer systems quickly retrieve corresponding knowledge in practical applications, achieving better question-and-answer results. Furthermore, the technical solutions provided in this application are specifically optimized to address the characteristics of long-tail knowledge distribution, severe colloquialism, and distinct hierarchical medical knowledge in medical question-and-answer scenarios, which improves the practical application effect of the technical solutions provided in this application and broadens the scope of practical applications.
[0202] Please refer to Figures 13 to 15 It illustrates a flowchart of a knowledge base organization framework provided in one embodiment of this application. Figures 13 to 15 The knowledge base organization framework is illustrated, comprising three main stages: medical data segmentation based on a large model, medical data reorganization, and medical data mapping extension based on a knowledge graph. This scheme also includes a large model application stage after the knowledge base organization is completed. The technical details of these four parts are described below.
[0203] 1) Medical data segmentation based on large models
[0204] Knowledge bases for large-scale model question-answering retrieval can be broadly categorized into two types: knowledge-based and question-answering-based. This application uses knowledge-based medical data organization as an example for illustration.
[0205] Knowledge-based data mostly consists of explanations or descriptions of a specific medical entity, for example, in... Figures 13 to 18 In the text, A_1 and A_2 are relatively traditional, unstructured encyclopedic descriptions, while A_3 is a semi-structured content, which contains subheadings to indicate the attributes of some content (etiology, clinical manifestations). This application can process both of these content formats.
[0206] 1.1 Processing of unstructured content:
[0207] For unstructured content, this application can leverage the reading comprehension capabilities of a large model to segment multi-paragraph / sentence content into several data blocks, each consisting of a single sentence (i.e., the aforementioned text statement). The specific segmentation prompt is as follows:
[0208] Please divide the following content into several data blocks, each consisting of a sentence, using periods as the unit. If a data block contains an omitted subject or uses a pronoun as the subject, please supplement the subject with medical entity words: \n<unstructured text>
[0209] For example, for A_1, the input to the large model is:
[0210] "Please divide the following content into several data blocks, each consisting of a sentence, using periods. If a data block contains an omitted subject or uses a pronoun as the subject, please supplement the subject with a medical entity term:\nRiboflavin, also known as vitamin B2, is one of the water-soluble B vitamins. It is essential for biochemical processes that use food as an energy source and can be converted into the active phosphorylated metabolites flavin mononucleotide and flavin adenine dinucleotide. Both are important coenzymes for tissue respiration, and a deficiency can lead to riboflavin deficiency, causing a series of clinical symptoms."
[0211] We can obtain the splitting results of A_1 as B_1_1, B_1_2, and B_1_3.
[0212] B_1_1: Riboflavin Also called Vitamin B2, It is one of the water-soluble B vitamins.
[0213] B_1_2: Riboflavin It is essential for biochemical processes that use food as an energy source and can be converted into reactive phosphorylated metabolites. Flavin mononucleotide and Flavin adenine dinucleotide .
[0214] B_1_3: Flavin mononucleotide and Flavin adenine dinucleotide These are all important coenzymes for tissue respiration; their deficiency can lead to… Riboflavin The deficiency causes a series of clinical symptoms.
[0215] The underlined parts mentioned above are the medical entity subjects supplemented by the large model through reading comprehension.
[0216] For example, for A_2, the input to the large model is:
[0217] "Please divide the following content into several data blocks, each consisting of a sentence, using periods. If a data block contains an omitted subject or uses a pronoun as the subject, please supplement the subject with a medical entity word:\nHypertension is extremely common in clinical practice. It can be divided into two categories: primary hypertension and secondary hypertension. Renal hypertension is one of the most common types of secondary hypertension. In the absence of obvious edema or urine tests, patients are easily misdiagnosed as having primary hypertension. The treatment and prognosis of renal hypertension and primary hypertension differ greatly, so it is necessary to carefully differentiate between the two. How to distinguish between renal hypertension and primary hypertension? This requires careful examination and history taking to clarify the causal relationship and the order of onset. Renal hypertension can be divided into renal parenchymal hypertension and renovascular hypertension. Among them, renal parenchymal hypertension is difficult to differentiate from primary hypertension when the medical history is atypical. In this case, a renal biopsy is necessary to confirm the diagnosis."
[0218] The possible splits of A_2 are B_2_1, B_2_2, B_2_3, B_2_4, B_2_5, B_2_6, and B_2_7.
[0219] B21: Hypertension is extremely common in clinical practice.
[0220] B_2_2: Hypertension can be divided into two categories: primary hypertension and secondary hypertension.
[0221] B_2_3: Renal hypertension is one of the most common secondary hypertension. In the absence of obvious edema or without urine tests, patients may easily mistake it for primary hypertension.
[0222] B_2_4: The treatment and prognosis of renal hypertension and essential hypertension are very different, so it is necessary to carefully differentiate between the two.
[0223] B_2_5: How to differentiate between renal hypertension and essential hypertension? This requires a careful examination and history taking to clarify the causal relationship and the order of onset.
[0224] B_2_6: Renal hypertension can be divided into renal parenchymal hypertension and renovascular hypertension.
[0225] B_2_7: Among them, renal parenchymal hypertension is difficult to differentiate from essential hypertension when the medical history is atypical. In this case, a renal biopsy is required to make a definitive diagnosis.
[0226] 1.2 Semi-structured content processing:
[0227] Semi-structured content, due to its inherent structural characteristics, can be segmented without the aid of a large language model. This means that the subheadings of each data point can be used as attributes / relationships of the medical entity, while the content under each subheading can be used as the actual attribute values or tail entities. For example, A_3:
[0228] Submucosal tumors of the duodenum refer to non-epithelial mesenchymal tumors originating from the duodenal wall, including stromal tumors, lipomas, fibromas, hemangiomas, leiomyomas, and cysts. These diseases are generally asymptomatic, but if the lesion erodes and ulcerates, pain and bleeding may occur; some may become malignant. [CLS] Etiology [SEP] The pathogenesis involves abnormal proliferation of the submucosal tissue and muscle layer, mostly due to congenital factors. [CLS] Clinical manifestations [SEP] are nonspecific, varying depending on the tumor's location, size, integrity, presence of complications, and metastasis. Generally, there are no symptoms; however, if the lesion erodes and ulcerates, pain and bleeding may occur; some may become malignant, exhibiting characteristics such as infiltration of adjacent tissues and organs or hematogenous metastasis.
[0229] In this structured format, "Etiology" and "Clinical Manifestations" are attributes / relationships, followed by descriptions of the actual etiology and clinical manifestations. Therefore, this structured content can be processed as follows: B_3_1, B_3_3, B_3_4.
[0230] B_3_1: Submucosal tumors of the duodenum refer to non-epithelial mesenchymal tumors originating from the duodenal wall, including stromal tumors, lipomas, fibromas, hemangiomas, leiomyomas, and cysts. These diseases generally have no noticeable symptoms, but if the lesion erodes or ulcerates, symptoms such as pain and bleeding may occur, and some may become malignant.
[0231] B_3_3: Submucosal tumors of the duodenum [CLS] Etiology [SEP] Pathogenesis is abnormal proliferation of submucosal tissue and muscle layer, mostly caused by congenital factors.
[0232] B_3_4: Submucosal tumors of the duodenum [CLS] Clinical manifestations [SEP] are nonspecific, varying depending on the tumor's location, size, integrity, presence of complications, and metastasis. Generally, there are no subjective symptoms. If the lesion erodes or ulcerates, pain and bleeding may occur. Some may undergo malignant transformation, exhibiting characteristics such as infiltration of adjacent tissues and organs or hematogenous metastasis.
[0233] The parts marked in red are automatically supplemented medical entities. Note that B_3_1 here can also be regarded as unstructured content, so the technical solution for unstructured data can be reused for secondary processing to obtain B_3_1 and B_3_2.
[0234] B_3_1: Submucosal tumors of the duodenum refer to non-epithelial mesenchymal tumors originating from the duodenal wall, including stromal tumors, lipomas, fibromas, hemangiomas, leiomyomas, and cysts.
[0235] B_3_2: Submucosal tumors of the duodenum generally do not have any subjective symptoms, but if the lesion erodes and ulcerates, symptoms such as pain and bleeding may occur, and some may become malignant.
[0236] Similarly, the parts marked in red are the medical entity subjects supplemented by the large model through reading comprehension.
[0237] 2) Medical data restructuring
[0238] After medical data is segmented, it can be obtained into several smaller data blocks, such as Figures 13 to 15 As shown, medical data A_1, A_2, and A_3 are segmented into B_1_1 / B_1_2 / B_1_3, B_2_1 / B_2_2 / B_2_3 / B_2_4 / B_2_5 / B_2_6 / B_2_7, and B_3_1 / B_3_2 / B_3_3 / B_3_4, respectively. The sum of these data blocks is denoted as B. The next step is to extract / scan these data blocks for medical entities or medical relational terms, and then reassemble the obtained entity terms with the data blocks into a network structure.
[0239] The reorganization phase requires a structurally stable medical knowledge graph G as its foundation, which includes knowledge triples in the form of <head entity, relation, tail entity>, where each entity e belongs to the entity set E. Based on this entity set, medical entities are extracted from the data blocks, specifically as follows:
[0240]
[0241] That is, for each data block, all entities are traversed, and if an entity exists within that data block, it is added to the set. Here, the set of all entities in the knowledge graph G is denoted as E, and each entity traversed is denoted as e. The above formula means that when an entity e (obtained through traversing E) appears in the string of a data block, e is recorded in the set corresponding to that data block (this set records all entities appearing in the text of that data block).
[0242] Note that nested entities due to hierarchical relationships often occur in medical entities, such as "secondary hypertension" and "senile secondary hypertension," or "hypertension" and "stage 3 hypertension." Therefore, E_B requires a further post-processing step:
[0243]
[0244] Here, len(e) represents the length of entity e. That is, if there is both a longer medical entity and a shorter medical entity, and their position information in the data block is an inclusion relationship (i.e., the longer entity contains the shorter entity), then only the longer entity is retained and the shorter entity is deleted.
[0245] Taking B_1_1 / B_1_2 / B_1_3 as an example, after extracting entities from the medical knowledge graph, we can obtain four entities: "vitamin B2", "riboflavin", "flavin nucleotide", and "flavin adenine dinucleotide". By linking these four entities to their corresponding data blocks, we can obtain... Figure 13 The (reorganized) network structure is shown below. For semi-structured content, due to the special meaning of its subheadings, we can also associate these subheadings as "entity" terms (actually relational terms) with the data blocks. These relational terms will significantly improve the data block retrieval performance in subsequent applications.
[0246] In the scheme shown in this embodiment, the reorganization stage relies on entity definitions in the medical knowledge graph. The relatively limited and controllable range of entity words helps in the management and verification of data blocks and facilitates subsequent expert annotation / verification. If there are few associated entity words in practical applications, this can be addressed by expanding the scope of the knowledge graph or introducing more knowledge.
[0247] 3) Knowledge Graph-Based Medical Data Mapping Extension
[0248] Following step 2), a network structure W is obtained that associates entities with data blocks, where each entity is directly associated with an entity in the knowledge graph G. Next, this application expands W using the medical knowledge originally defined in G to obtain W', thereby improving the knowledge base's ability to recognize long-tail entity words and hypernym / hyponym entity words. Specifically, long-tail entity words are expanded using <synonym> relationships, and hypernym / hyponym entity words are expanded using <hyponym><hyponym> relationships.
[0249] Synonyms: with Figure 13 For example, in G, a triple <vitamin B2, synonym, vitamin B2 powder> is defined. Therefore, "vitamin B2 powder" can be linked to the data block linked to "vitamin B2", thus solving the problem of not being able to retrieve the relevant data block when the user inputs "vitamin B2 powder". A similar example can be seen. Figure 14 <Hypertension, synonym, hypertension> <Hypertension, synonym, hypertension syndrome>.
[0250] Hypernym / Subnym: For entity words with obvious hierarchical characteristics, this application expands the solution by introducing a <hypernym> <subnym> relationship, in order to... Figure 14For example, in G, a triple <senile secondary hypertension, superior, secondary hypertension> is defined. Therefore, "senile secondary hypertension" can be unidirectionally linked to "secondary hypertension". When a user inputs a question related to "senile secondary hypertension", this entity can be retrieved first, and then linked to "secondary hypertension" defined in the knowledge base via a unidirectional arrow. This solves the problem of poor knowledge base retrieval performance caused by hierarchical information. Optionally, both the <superior> and <inferior> relationships are unidirectional links, and in the technical solution of this application, the identified inferior entity is allowed to obtain the associated knowledge base content of the superior entity (e.g., Figure 14 (as shown); Optionally, the identified higher-level entities are not allowed to access the associated knowledge base content of the lower-level entities (e.g., the knowledge content of diabetes cannot be indexed to stage 3 diabetes), or the identified higher-level entities are allowed to access the associated knowledge base content of the lower-level entities.
[0251] Reasoning: The built-in network structure of the knowledge graph facilitates simple reasoning. For example, in G, there are triples defined as <duodenal wall, superior, duodenum> and <duodenum, corresponding location, duodenal bleeding>. In W, there is an entity term "bleeding." It can be inferred that this bleeding likely refers to "duodenal bleeding," and therefore, "duodenal bleeding" can be linked to "bleeding" to expand the entity term. Optionally, this reasoning link can be annotated and verified by medical experts.
[0252] The reasoning primarily employs path traversal methods from graph networks. This can be understood as follows: when three entities a, b, and d exist in W, if the graph G defines a->b / b->c / c->d, then entity c can also be included in the retrieved entity set W'. Specifically, this can be achieved by using depth-first search (DFS) or breadth-first search (BFS) algorithms to traverse layer by layer until the target node c is reached.
[0253] By using the three different extensions mentioned above (synonym, hierarchical, and inference), W can be extended to obtain W', which contains more entities and theoretically has better recognition and retrieval effects for long-tail entities and entities of different granularities (i.e., hierarchical entities).
[0254] 4) Examples of Knowledge Base Applications
[0255] by Figures 13 to 15Taking the three knowledge base records shown as an example, after being modified by the organization method of this application, for the user input M (e.g., "Could duodenal bleeding during a hospital checkup be a sign of a tumor?"), after the knowledge graph entity extraction involved in step 2), the entity words "duodenal bleeding" and "tumor" are extracted from M; the data blocks B_3_2 and B_3_4 associated with the knowledge base are retrieved through the entity word e; these two data blocks are input into the large model with the following prompt structure to obtain the response:
[0256] "You are a doctor, and you know B32 and B34. How should you respond to a user who asks, 'Could duodenal bleeding during a hospital checkup be a sign of a tumor?'"
[0257] To verify the feasibility of the technical solution in this application, the above example problem is addressed:
[0258] 1) Inputting directly into the medical question-and-answer model without retrieval enhancement;
[0259] The prompt you enter can be as follows:
[0260] "As a doctor, how should you respond to a user's question, 'Could duodenal bleeding during a hospital checkup be a sign of a tumor?'"
[0261] The results are as follows:
[0262] "First of all, I am not a doctor and cannot give you a professional answer. However, I can provide you with some basic information about duodenal bleeding and tumors."
[0263] Duodenal bleeding can be caused by a variety of factors, such as peptic ulcers, inflammation, vascular abnormalities, and tumors. While tumors can indeed be a cause of duodenal bleeding, not all duodenal bleeding is caused by tumors.
[0264] If you are concerned that you may have a tumor, it is recommended that you see a doctor promptly for a thorough examination. Your doctor will diagnose your condition based on your symptoms, signs, and examination results, and develop an appropriate treatment plan. Please do not ignore any discomfort due to worry; seeking medical attention promptly is the wise choice.
[0265] 2) After retrieval enhancement, the data is then input into a large-scale medical question-and-answer model;
[0266] The prompt you enter can be as follows:
[0267] "You are a doctor. It is known that submucosal tumors of the duodenum generally have no noticeable symptoms, but if the lesion erodes and ulcerates, symptoms such as pain and bleeding may occur. Some may become malignant. Furthermore, the clinical manifestations of submucosal tumors of the duodenum [CLS] [SEP] are nonspecific, varying depending on the tumor's location, size, integrity, presence of complications, and metastasis. Generally, there are no noticeable symptoms, but if the lesion erodes and ulcerates, pain and bleeding may occur; some may become malignant, exhibiting characteristics such as infiltration of adjacent tissues and organs or hematogenous metastasis. How should I respond to the user's question, 'Could duodenal bleeding during a hospital checkup indicate a tumor?'"
[0268] The following response can be obtained.
[0269] "First of all, I am not a doctor and cannot give you a professional answer. However, I can provide you with some basic information about duodenal bleeding and tumors."
[0270] Submucosal tumors of the duodenum may not cause any noticeable symptoms, but if the lesion erodes and ulcerates, symptoms such as pain and bleeding may occur. Some submucosal tumors of the duodenum may become malignant. Therefore, if you experience symptoms such as duodenal bleeding, it may be due to a tumor.
[0271] However, duodenal bleeding can be caused by a variety of reasons, such as peptic ulcers, inflammation, vascular abnormalities, and tumors. Therefore, duodenal bleeding alone cannot determine whether you have a tumor. It is recommended that you seek medical attention promptly for a thorough examination. Your doctor will diagnose your condition based on your symptoms, signs, and examination results and develop an appropriate treatment plan.
[0272] As can be seen from the above, without retrieval enhancement, the large model's response is more ambiguous, and due to the lack of medical knowledge support, the generated second paragraph may contain errors. After the knowledge base retrieval enhancement provided by the technical solution of this application, the large model's response is relatively more professional and provides a more direct answer to the user's questions. Furthermore, retrieval enhancement differs from full parameter fine-tuning / efficient parameter fine-tuning of the large model; it does not change the large model's original response preferences, meaning that content that aligns with human preferences, such as "suggest seeking medical treatment," will not be affected by the technical solution of this application.
[0273] The beneficial effects of the technical solution in this application may include:
[0274] 1) This technical solution has better scalability and more controllable expansion costs. For long-tail knowledge and colloquial expressions, this technical solution can expand the number of entities in the knowledge graph while keeping the knowledge base unchanged, and map these long-tail / colloquial expression entities to existing entities to achieve knowledge base coverage of long-tail knowledge / colloquial knowledge.
[0275] 2) This technical solution has greater flexibility. For hierarchical medical knowledge, this application provides configurable items to enable or disable the superior entity reasoning according to the specific needs of the downstream question-and-answer scenario (i.e., whether to allow the indexing of the relevant data block of "secondary hypertension" in the knowledge base when the user asks "senile secondary hypertension").
[0276] Application Scenario 2: AI Content Generation
[0277] When the above solution is applied to AI content generation scenarios, computer devices can generate AI content corresponding to the input text by performing AI content generation processing on the input text, such as AI images.
[0278] For example, in application scenario two, the input text can be an AI content description text; natural language processing can be used to generate AI content from the AI content description text.
[0279] For example, please refer to Figure 16 , Figure 16 This is a flowchart of an input text processing method provided in one embodiment of this application. The input text processing method may include the following steps:
[0280] Step 1601: Extract reference named entities from AI content description text based on natural language processing.
[0281] Step 1602: Query the reference text statements associated with the reference named entity in the knowledge base; the knowledge base contains the association between named entities and text statements; the text statements are used to describe the relevant knowledge of the associated named entities.
[0282] Step 1603: Perform natural language processing on the AI content description text and the reference text statement to obtain the AI content of the AI content description text.
[0283] In one possible implementation, step 1603 above includes: generating a first prompt statement with reference text statement as background knowledge and AI content description text as task description; inputting the first prompt statement into a first generative language model to obtain the AI content output by the first generative language model.
[0284] In one possible implementation, prior to step 1602, the method further includes: obtaining the knowledge domain to which the AI content description text belongs; and querying the knowledge base corresponding to the knowledge domain to which the AI content description text belongs.
[0285] In one possible implementation, the steps of obtaining the knowledge domain to which the AI content description text belongs may include: generating a second prompt statement containing the AI content description text, the second prompt statement being used to instruct a second generative language model to identify the knowledge domain to which the AI content description text belongs; inputting the second prompt statement into the second generative language model to obtain the knowledge domain to which the AI content description text belongs, as output by the second generative language model.
[0286] The above is merely one embodiment of this application and should not be considered as a limitation thereof. Those skilled in the art will understand that various modifications and variations can be made to the embodiments to adapt to different application requirements. Therefore, the scope of this application should be defined by the claims appended to the claims.
[0287] Please refer to Figure 17 This diagram illustrates a block diagram of an input text processing apparatus provided in an exemplary embodiment of this application. The input text processing apparatus can be implemented as all or part of a computer device in hardware or a combination of hardware and software to perform all or part of the steps described in the various method embodiments above. Figure 17 As shown, the input text processing device includes:
[0288] Entity extraction module 1701 is used to extract reference named entities from input text based on natural language processing;
[0289] The statement query module 1702 is used to query reference text statements associated with the reference named entity in the knowledge base; the knowledge base contains the association relationship between named entities and text statements; the text statements are used to describe the relevant knowledge of the associated named entity;
[0290] The processing module 1703 is used to perform natural language processing on the input text and the reference text statement to obtain the natural language processing result of the input text.
[0291] In one possible implementation, the knowledge base is characterized by an association network between the named entities and the text statements; the association network includes one or more text statements corresponding to the first topic, and one or more named entities associated with the text statements.
[0292] In one possible implementation, the steps for constructing the knowledge base are as follows:
[0293] Obtain a first candidate named entity, which is a named entity that belongs to both the first text statement and the knowledge graph corresponding to the first topic; the first text statement is one of one or more text statements corresponding to the first topic; the knowledge graph contains the association relationships between various named entities in the knowledge domain to which the first topic belongs;
[0294] In the knowledge graph corresponding to the first topic, query the second candidate named entity that has a synonymous relationship with the first candidate named entity;
[0295] The first candidate named entity and the second candidate named entity are added as synonymous named entities associated with the first text statement in the association network.
[0296] In one possible implementation, the construction steps of the knowledge base further include:
[0297] In response to the second text statement being a statement containing a title, and the title not belonging to the knowledge graph corresponding to the first topic, the title is added as a title named entity associated with the second text statement in the association network; the second text statement is one of one or more text statements corresponding to the first topic.
[0298] In one possible implementation, the association network further includes one or more extended named entities associated with the first text statement; the extended named entities do not belong to the first text statement, and the extended named entities and the synonym named entities are semantically different but related in the knowledge graph.
[0299] In one possible implementation, the one or more extended named entities include at least one of a first extended entity and a second extended entity; the first extended entity is a subordinate named entity of a single synonym named entity; the second extended entity is semantically related to multiple synonym named entities, and the multiple synonym named entities include the synonym named entity associated with the first text statement.
[0300] In one possible implementation, if the first extended entity is included in one or more of the extended named entities, the knowledge base construction step further includes: querying the knowledge graph corresponding to the first topic for named entities that have a subordinate relationship with the synonym named entity associated with the first text statement; and adding the queried named entities as the first extended entity associated with the first text statement in the association network.
[0301] In one possible implementation, if the second extended entity is included in one or more of the extended named entities, the knowledge base construction step further includes:
[0302] For two of the synonymous named entities associated with one or more text statements corresponding to the first topic, query whether there is an association path between the two synonymous named entities in the knowledge graph; at least one of the two synonymous named entities is associated with the first text statement; the association path is a path that starts from one named entity and reaches another named entity through the association relationship between the named entities.
[0303] If the two synonymous named entities have the associated path in the knowledge graph, the named entity that exists in the associated path of the two synonymous named entities in the knowledge graph and does not belong to the first text statement is added as the second extended entity associated with the first text statement in the association network.
[0304] In one possible implementation, the processing module 1703 is used to generate a first prompt statement with the reference text statement as background knowledge and the input text as a task description; input the first prompt statement into a first generative language model to obtain the natural language processing result output by the first generative language model.
[0305] In one possible implementation, the device further includes:
[0306] The domain acquisition module is used to acquire the knowledge domain to which the input text belongs before the statement query module 1702 queries the knowledge base for the reference text statement associated with the reference named entity;
[0307] The knowledge base query module is used to query the knowledge base corresponding to the knowledge domain to which the input text belongs.
[0308] In one possible implementation, the domain acquisition module is used to generate a second prompt statement containing the input text, the second prompt statement being used to instruct a second generative language model to identify the knowledge domain to which the input text belongs; the second prompt statement is input into the second generative language model to obtain the knowledge domain to which the input text belongs, as output by the second generative language model.
[0309] Please refer to Figure 18 , Figure 18This is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application. The computer device 1800 includes a Central Processing Unit (CPU) 1801, a system memory 1804 including Random Access Memory (RAM) 1802 and Read-Only Memory (ROM) 1803, and a system bus 1805 connecting the system memory 1804 and the CPU 1801. The computer device 1800 also includes a Basic Input / Output System (I / O System) 1806 to facilitate the transfer of information between various devices within the computer, and a mass storage device 1807 for storing the operating system 1813, application programs 1814, and other program modules 1810.
[0310] The basic input / output system 1806 includes a display 1808 for displaying information and an input device 1809 for user input, such as a mouse or keyboard. Both the display 1808 and the input device 1809 are connected to the central processing unit 1801 via an input / output controller 1810 connected to the system bus 1805. The basic input / output system 1806 may also include the input / output controller 1810 for receiving and processing input from multiple other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1810 also provides output to a display screen, printer, or other types of output devices.
[0311] The mass storage device 1807 is connected to the central processing unit 1801 via a mass storage controller (not shown) connected to the system bus 1805. The mass storage device 1807 and its associated computer-readable media provide non-volatile storage for the computer device 1800. That is, the mass storage device 1807 may include computer-readable media (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.
[0312] Without loss of generality, the computer-readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media include RAM (Random Access Memory), ROM (Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory or other solid-state storage technologies, CD-ROM, DVD (Digital Video Disc) or other optical storage, magnetic tape cassettes, magnetic tape, disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that the computer storage media are not limited to the above-mentioned types. The system memory 1804 and mass storage device 1807 described above can be collectively referred to as memory.
[0313] Computer device 1800 can be connected to the Internet or other network devices via network interface unit 1811 connected to the system bus 1805.
[0314] The memory also includes one or more programs stored in the memory, and the central processing unit 1801 executes the one or more programs to implement all or part of the steps in the methods shown in the above embodiments of this application.
[0315] In an exemplary embodiment, a chip is also provided, the chip including programmable logic circuitry and / or program instructions, which, when the chip is run on a computer device, are used to implement all or part of the steps of the methods shown in the above embodiments of this application.
[0316] In an exemplary embodiment, a computer program product is also provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions to implement all or part of the steps of the methods shown in the above embodiments of this application.
[0317] In an exemplary embodiment, a computer-readable storage medium is also provided, which stores a computer program that is loaded and executed by a processor to implement all or part of the steps of the methods shown in the above embodiments of this application.
[0318] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0319] Those skilled in the art will recognize that the functions described in the embodiments of this application in one or more of the above examples can be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transfer of a computer program from one place to another. Storage media can be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0320] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for processing input text, characterized in that, The method includes: Extract reference named entities from input text based on natural language processing; The knowledge base is used to query reference text statements associated with the reference named entity; the knowledge base contains the association between named entities and text statements; the text statements are used to describe the relevant knowledge of the associated named entity. The natural language processing is performed on the input text and the reference text statement to obtain the natural language processing result of the input text.
2. The method according to claim 1, characterized in that, The knowledge base is represented by a network of associations between the named entities and the text statements; the network of associations includes one or more text statements corresponding to the first topic, and one or more named entities associated with the text statements.
3. The method according to claim 2, characterized in that, The steps for constructing the knowledge base are as follows: Obtain a first candidate named entity, which is a named entity that belongs to both the first text statement and the knowledge graph corresponding to the first topic; the first text statement is one of one or more text statements corresponding to the first topic; the knowledge graph contains the association relationships between various named entities in the knowledge domain to which the first topic belongs; In the knowledge graph corresponding to the first topic, query the second candidate named entity that has a synonymous relationship with the first candidate named entity; The first candidate named entity and the second candidate named entity are added as synonymous named entities associated with the first text statement in the association network.
4. The method according to claim 3, characterized in that, The steps for constructing the knowledge base also include: In response to the second text statement being a statement containing a title, and the title not belonging to the knowledge graph corresponding to the first topic, the title is added as a title named entity associated with the second text statement in the association network; the second text statement is one of one or more text statements corresponding to the first topic.
5. The method according to claim 3, characterized in that, The association network also includes one or more extended named entities associated with the first text statement; The extended named entity does not belong to the first text statement, and the extended named entity and the synonym named entity are semantically different but related named entities in the knowledge graph.
6. The method according to claim 5, characterized in that, The one or more extended named entities include at least one of the first extended entity and the second extended entity; The first extended entity is a subordinate named entity of the single synonym named entity; The second extended entity is semantically related to multiple synonymous named entities, and the multiple synonymous named entities include the synonymous named entity associated with the first text statement.
7. The method according to claim 6, characterized in that, If the first extended entity is included in one or more of the extended named entities, the knowledge base construction step further includes: Query the knowledge graph corresponding to the first topic, and find the named entities that have a subordinate relationship with the synonym named entities associated with the first text statement. The queried named entity is added to the association network as the first extended entity associated with the first text statement.
8. The method according to claim 6, characterized in that, If one or more of the extended named entities include the second extended entity, the knowledge base construction steps further include: For two of the synonymous named entities associated with one or more text statements corresponding to the first topic, query whether there is an association path between the two synonymous named entities in the knowledge graph; at least one of the two synonymous named entities is associated with the first text statement; the association path is a path that starts from one named entity and reaches another named entity through the association relationship between the named entities. If the two synonymous named entities have the associated path in the knowledge graph, the named entity that exists in the associated path of the two synonymous named entities in the knowledge graph and does not belong to the first text statement is added as the second extended entity associated with the first text statement in the association network.
9. The method according to any one of claims 1 to 8, characterized in that, The step of performing natural language processing on the input text and the reference text statement to obtain the natural language processing result of the input text includes: Generate a first prompt statement that uses the reference text statement as background knowledge and the input text as a task description; The first prompt statement is input into the first generative language model to obtain the natural language processing result output by the first generative language model.
10. The method according to any one of claims 1 to 8, characterized in that, Before querying the reference text statement associated with the reference named entity in the knowledge base, the method further includes: Obtain the knowledge domain to which the input text belongs; Query the knowledge base corresponding to the knowledge domain to which the input text belongs.
11. The method according to claim 10, characterized in that, The step of obtaining the knowledge domain to which the input text belongs includes: Generate a second prompt statement containing the input text, the second prompt statement being used to instruct the second generative language model to identify the knowledge domain to which the input text belongs; The second prompt statement is input into the second generative language model to obtain the knowledge domain to which the input text belongs, as output by the second generative language model.
12. An input text processing device, characterized in that, The device includes: The entity extraction module is used to extract reference named entities from input text based on natural language processing. The statement query module is used to query reference text statements associated with the reference named entity in the knowledge base; the knowledge base contains the association relationship between named entities and text statements; the text statements are used to describe the relevant knowledge of the associated named entity; The processing module is used to perform natural language processing on the input text and the reference text statement to obtain the natural language processing result of the input text.
13. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing instructions which are executed by the processor to implement the input text processing method as described in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, The storage medium stores instructions that are executed by a processor of a computer device to implement the input text processing method as described in any one of claims 1 to 11.
15. A computer program product, characterized in that, The computer program product includes computer instructions stored in a computer-readable storage medium; the computer instructions are read and executed by a processor of a computer device to implement the input text processing method as described in any one of claims 1 to 11.