Logic knowledge construction method and device based on large language model and logic programming, electronic equipment and storage medium

By combining large language models and logic programming, it achieves efficient conversion from unstructured knowledge to standard logic rules, solving the problems of low automation and logical consistency in existing technologies, and supporting dynamic updates and multi-domain adaptability of knowledge bases.

CN121166932APending Publication Date: 2025-12-19ZHEJIANG LINGHU EXHIBITION TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510619310.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-14
Publication Date
2025-12-19

AI Technical Summary

Technical Problem

Existing technologies struggle to efficiently transform unstructured or semi-structured knowledge into formal logical rules that machines can understand and reason about, and suffer from problems such as high labor costs, low automation levels, and difficulty in ensuring logical consistency.

Method used

By combining the natural language understanding capabilities of large language models with the rigor of logical programming, a machine-reasonable logical knowledge base is generated and stored through semantic parsing, normalization, and consistency verification. This includes entity recognition, predicate logic structure detection, syntax transformation, metadata addition, and conflict resolution.

Benefits of technology

It achieves efficient conversion from unstructured knowledge to standard logical representation, reduces manual costs, ensures logical consistency and dynamic updating capability of the knowledge base, and is applicable to multiple professional fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121166932A_ABST
    Figure CN121166932A_ABST
Patent Text Reader

Abstract

The invention discloses a logic knowledge construction method and device based on a large language model and logic programming, electronic equipment and a storage medium, and belongs to the field of artificial intelligence knowledge engineering. According to the method, automatic conversion from multi-source heterogeneous knowledge to machine reasonable logic knowledge is realized through combination of semantic understanding capability of a large language model and standardized processing of logic programming. The method specifically comprises the steps of obtaining unstructured / semi-structured original knowledge data, performing entity relationship recognition and predicate logic detection by utilizing a large language model to generate a preliminary logic expression, performing grammar normalization processing to form standard logic facts and rules, and constructing a consistent logic knowledge base through a conflict detection and resolution mechanism. According to the method, a mixed conversion framework of natural language and formalized logic is innovatively provided, and the maintainability and expandability of the knowledge base are remarkably improved by introducing timestamp metadata, a rule dependence graph and an incremental updating mechanism. The technology provides structured logic support for subsequent large model reasoning, and can be widely applied to intelligent questions and answers, decision support and other scenes requiring precise logic reasoning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence and knowledge engineering technology. Specifically, it relates to a method, apparatus, electronic device, and storage medium for constructing logical knowledge based on large language models and logical programming. It is particularly suitable for transforming unstructured or semi-structured knowledge into formal logical rules and facts that can be reasoned by machines, providing structured knowledge support for knowledge-driven large model reasoning. Background Technology

[0002] In the field of artificial intelligence, transforming unstructured or semi-structured raw knowledge data into machine-understandable and reasonable representations has always been a key challenge. Currently, there are two main approaches to knowledge base processing and use based on large language models: the first is to directly input the knowledge base content as context into the model for question answering. This approach is limited by the length of the model's context window, making it difficult to handle large-scale knowledge bases, and it suffers from knowledge truncation and insufficient accuracy. The second approach is to vectorize the knowledge base and then use Retrieval Augmentation (RAG) technology for question answering. However, this approach has limited effectiveness when dealing with complex logical relationships and it is difficult to guarantee the rigor of the reasoning process.

[0003] While traditional knowledge engineering methods can construct precise logical knowledge bases, they rely entirely on human experts to write rules and facts, which is not only inefficient but also difficult to adapt to the needs of large-scale, multi-domain knowledge processing. In particular, when dealing with unstructured text data, a significant amount of manpower is required for knowledge extraction and logical encoding, severely limiting the efficiency of knowledge base updates and the scope of application.

[0004] In recent years, large language models have demonstrated powerful capabilities in natural language understanding, providing new ideas for automated knowledge acquisition. However, relying solely on large language models has significant limitations: first, the logical expressions generated by the models often do not conform to the syntax of standard logic programming languages; second, the lack of a systematic conflict detection mechanism makes it difficult to guarantee logical consistency with existing knowledge bases; and finally, it cannot effectively handle the dynamic update requirements of knowledge bases.

[0005] Therefore, there is an urgent need for an innovative method that can organically integrate the semantic understanding capabilities of large language models with the rigor of logical programming, achieving the automated conversion from unstructured knowledge to reasonable logical rules. This method needs to address three core issues: how to ensure that the logical expressions output by the large language model conform to standard syntax; how to establish an effective conflict detection and resolution mechanism; and how to support incremental updates and maintenance of the knowledge base. These are precisely the technical problems that this invention aims to solve. Summary of the Invention

[0006] The purpose of this invention is to provide a method, apparatus, electronic device, and storage medium for constructing logical knowledge based on a large language model and logical programming, aiming to solve the technical problems in the existing knowledge base construction process, such as high labor costs, low automation, and difficulty in ensuring logical consistency, and to achieve efficient conversion from unstructured or semi-structured knowledge to standardized logical representation.

[0007] To achieve the above objectives, the first aspect of this invention provides a method for constructing logical knowledge based on a large language model and logical programming, comprising: Obtain raw knowledge base data, which includes unstructured text and / or semi-structured data; The original knowledge base data is semantically parsed using a large language model to generate a preliminary set of logical expressions. The initial logical expression is standardized based on the syntax rules of the logic programming language to form standard logical facts and rules; The standard logical facts and rules are validated for consistency, and logical conflicts are eliminated before being stored to form a logical knowledge base.

[0008] Optionally, the semantic parsing includes: Identify entities and their attribute relationships in the input text; Detect the implicit predicate logic structure; Generate intermediate expressions that conform to first-order logic or descriptive logic.

[0009] Optionally, the normalization process includes: Convert natural language expressions into predicate logic that conforms to the format of Prolog or other logic programming systems; Add timestamps and credibility metadata; Establish a mapping relationship with the domain ontology.

[0010] Optionally, the consistency check includes: Detect logical conflicts between facts and rules; Verify the completeness of the rules; Apply conflict resolution strategies, including prioritization or manual intervention.

[0011] Optionally, the method further includes: Construct a rule dependency graph; Implement an incremental knowledge update mechanism; Provides a visual editing interface for manual correction.

[0012] A second aspect of the present invention provides a knowledge construction apparatus based on a large language model and logic programming, comprising: The data acquisition module is configured to receive multi-source heterogeneous knowledge data; The semantic understanding module integrates a large language model to achieve the conversion from natural language to logic; The logic normalization module is configured to execute the above methods; The knowledge storage module uses a database or logic programming environment storage system.

[0013] Optionally, the device further includes: The quality assessment unit calculates the confidence score of knowledge elements; Version management unit, supporting time-series backtracking of knowledge base; The interface service unit provides a data interaction channel with other inference systems.

[0014] A third aspect of the present invention provides an electronic device, comprising: processor; Memory, which stores computer programs; When the computer program is executed by the processor, the method described above is implemented.

[0015] A fourth aspect of the present invention provides a computer-readable storage medium storing computer instructions that, when executed, cause a computer to perform the method described above.

[0016] Compared with the prior art, the present invention has the following beneficial effects.

[0017] First, this invention innovatively combines the natural language understanding capabilities of a large language model with the formal representation of logical programming, ensuring both efficient knowledge extraction and the standardization and consistency of logical expression. By designing a specialized semantic parsing algorithm, it achieves accurate conversion from unstructured text to logical predicates, significantly reducing the manual cost of knowledge base construction.

[0018] Secondly, the standardization and consistency verification mechanisms proposed in this invention effectively solve the problems of non-standard logical expressions and knowledge conflicts in the output of large language models. In particular, by introducing timestamps and credibility metadata, as well as constructing rule dependency graphs, a systematic solution for managing complex knowledge is provided.

[0019] Furthermore, the incremental knowledge update mechanism designed in this invention supports the dynamic maintenance and expansion of the knowledge base, meeting the needs of continuous knowledge evolution in practical applications. Combined with a visual editing interface, it achieves an organic integration of expert knowledge and automated extraction, further improving the quality and usability of the knowledge base.

[0020] Finally, the logical knowledge construction method proposed in this invention is not only applicable to a single domain, but can also be extended to multiple professional domains through mapping relationships with domain ontology, demonstrating broad adaptability and versatility. The constructed logical knowledge base can be directly used in subsequent logical reasoning systems, providing a solid foundation for logical enhancement of large models. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0022] Figure 1 This is a schematic diagram of the conceptual process provided by the present invention.

[0023] Figure 2 This is a schematic diagram of the logical knowledge construction method provided by the present invention.

[0024] Figure 3 This is a schematic diagram of the logical knowledge construction device provided by the present invention.

[0025] Figure 4 This is a schematic diagram of the electronic device and storage medium provided by the present invention. Detailed Implementation

[0026] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0027] This invention provides a method, apparatus, electronic device, and storage medium for constructing logical knowledge based on a large language model and logic programming. The core idea is to utilize the powerful natural language understanding capabilities of a large language model to initially analyze raw knowledge, extract potential logical structures, and then leverage the rigor of logic programming to standardize, verify, and store these structures, ultimately forming a consistent and machine-reasonable logical knowledge base.

[0028] Example 1: Logical knowledge construction method.

[0029] This embodiment describes in detail the specific steps of a logical knowledge construction method based on a large language model and logical programming. Referring to claims 1 to 5, the method flow may include the following stages.

[0030] Phase 1: Raw Knowledge Base Data Acquisition and Preprocessing. This phase aims to collect raw data for constructing the logical knowledge base. Data sources can be diverse, including unstructured text data such as technical reports, news articles, web page content, user comments, and medical records; and semi-structured data such as Wikipedia information boxes, JSON files, XML documents, and database tables. The data acquisition module (corresponding to the data acquisition module in claim 6) is responsible for accessing this data from one or more sources. Before inputting it into the large language model, some preprocessing may be required, such as text cleaning (removing irrelevant characters and HTML tags), segmentation (dividing long texts into blocks suitable for LLM processing), and format conversion.

[0031] Phase Two: Semantic Analysis Based on Large Language Models. This phase utilizes large language models (such as pre-trained models based on the Transformer architecture, like the GPT series, BERT series, or models specifically designed for information extraction) to perform deep semantic understanding on the acquired raw data, generating preliminary logical expressions. The semantic analysis in this phase generally includes the following processes.

[0032] Entity and Relationship Recognition: Large language models are used to identify key entities mentioned in text or data (such as names of people, places, organizations, products, concepts, etc.) and their attributes and relationships (such as “belong to,” “located in,” “cause,” “own,” etc.).

[0033] Predicate logic structure detection: The large language model not only identifies explicit relations, but also detects implicit logical relations through contextual understanding, such as conditional relations (if...then...), causal relations, implication relations, universal quantification (all...are...), or existential quantification (there exists...that makes...), etc.

[0034] Preliminary logical expression generation: The large language model generates logical expressions based on entity and relation information and predicate logic structure information. Logical expressions can be intermediate representations of logical programming or logical programming statements. Intermediate representations of logical programming may approximate logical expressions in natural language (e.g., "Fact: A is a component of B", "Rule: If X satisfies condition C, then X has attribute P"). Logical programming statements may be closer to formal logical structures, such as preliminary first-order logic (FOL) predicate expressions or descriptive logic (DL) axioms. For example, for the input text "All birds can fly", the large language model may generate a preliminary expression similar to ∀x (Bird(x) → CanFly(x)). This step is completed by the semantic understanding module (corresponding to the semantic understanding module in claim 6).

[0035] Phase Three: Logic Normalization Processing. This phase aims to transform the preliminary logical expressions generated by LLM, which may not fully conform to standards or contain ambiguities, into standard logical facts and rules that strictly conform to the syntax of a specific logic programming language. This phase mainly includes the following parts.

[0036] Syntax Conversion: Using predefined mapping rules or templates, preliminary logical expressions are converted into the standard syntax of the target logic programming language (such as Prolog, Datalog, Answer Set Programming, etc.). For example, ∀x (Bird(x) → CanFly(x)) is converted to the Prolog rule can_fly(X) :- bird(X), and "fact: Tweety is a bird" is converted to the Prolog fact bird(tweety).

[0037] Metadata Addition: Adding metadata to each generated logical fact or rule is crucial for knowledge management. Metadata information includes timestamps, credibility / confidence scores, etc. Timestamps record the generation or last verification time of knowledge entries, used to handle knowledge timeliness, implement version control, and enable incremental updates. Credibility / confidence scores assign a credibility score to each knowledge entry, used for conflict resolution and uncertainty reasoning. This score can be calculated by the quality assessment unit (corresponding to claim 7).

[0038] Phase Four: Consistency Verification Phase. This phase ensures that the newly generated logical facts and rules maintain logical consistency with the existing content in the knowledge base. Conflict detection can be performed using a logic programming engine (such as the Prolog interpreter) or a dedicated logic inference engine. This phase mainly includes the following processing steps.

[0039] Step 1: Fact and fact conflict detection: For example, both location(paris, france) and location(paris, usa) exist simultaneously.

[0040] Step 2: Fact and rule conflict detection: For example, there exists a fact can_fly(penguin) and a rule cannot_fly(X) :- penguin(X).

[0041] Step 3: Rule conflict detection: For example, rule 1 derives p(a), and rule 2 derives not_p(a).

[0042] Step 4: Conflict Resolution: Apply preset strategies to handle conflicts automatically or manually. For example, automated conflict resolution can determine which conflict items need to be retained or removed based on source authority, timestamp, and credibility score. Manual conflict resolution can mark conflicts that are difficult to resolve automatically and present them to domain experts for judgment and correction through a visual editing interface (corresponding to claim 5).

[0043] Step 5: Reject or Modify: Directly reject the introduction of conflicting new knowledge, or try to modify the conflicting knowledge to reach an agreement.

[0044] Phase Five: Storage Update Phase. After verification and conflict resolution, the confirmed standard logical facts and rules are stored in the logical knowledge base. This knowledge base can be based on a file system (such as storing Prolog code files), a relational database, a graph database, or directly stored in the in-memory database of the logic programming environment. This is the responsibility of the knowledge storage module (corresponding to the knowledge storage module in claim 6).

[0045] Example 2: Logical knowledge construction device.

[0046] This embodiment describes an apparatus for implementing the above-described method (corresponding to claims 6 and 7). This apparatus can be a standalone software system or integrated into a larger intelligent data processing platform. Its main components include the following modules.

[0047] Module 1: Data Acquisition Module: Responsible for connecting to different data sources (file system, database, API interface, etc.) to acquire unstructured or semi-structured data.

[0048] Module 2: Semantic Understanding Module: The core of this module integrates one or more large language models. It receives preprocessed data, performs semantic parsing tasks, and outputs preliminary logical expressions. It may include sub-units such as Prompt management and model call interfaces.

[0049] Module 3: Logic Normalization Module: Implements the logic to convert LLM output into a standard logic format, mainly including syntax converter, metadata appender, ontology mapper (optional), and other logic.

[0050] Module 4: Consistency Verification Module: Embedded logic reasoning engine, responsible for executing conflict detection and applying resolution strategies.

[0051] Module 5: Knowledge Storage Module: Manages the storage and retrieval of the logical knowledge base. Logic programming environments such as SWI-Prolog and Flora-2 can be used, or the logical representation can be stored in an optimized database.

[0052] Other optional modules include: a quality assessment unit for calculating and attaching credibility scores to logical fact knowledge entries; a version management unit that uses metadata such as timestamps to support historical version queries and rollbacks of the logical knowledge base; an interface service unit that provides APIs or other interfaces to allow external systems (such as downstream large model inference applications) to access the logical knowledge base; and a visualization and editing unit that provides a user interface.

[0053] Example 3: Electronic device and storage medium.

[0054] The method of the present invention can be implemented on a general-purpose electronic device (corresponding to claim 8). This electronic device typically includes at least one processor, memory, and communication bus.

[0055] The memory stores computer programs (instructions). When the processor executes these computer programs, the logical knowledge construction method described in any of the foregoing embodiments is implemented. The electronic device can be a server, workstation, personal computer, virtual machine or container on a cloud computing platform, etc.

[0056] The present invention also provides a computer-readable storage medium (corresponding to claim 9) having computer instructions stored thereon. When these instructions are executed by a computer (or the processor of the aforementioned electronic device), the computer performs the logical knowledge construction method described in any of the foregoing embodiments. The storage medium can be non-volatile, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), or it can be volatile, such as random access memory (RAM). It can be local storage or network storage.

[0057] In summary, by combining the advantages of large language models and logic programming, this invention provides an automated, efficient, and logically consistent method and system for constructing logical knowledge, laying a solid knowledge foundation for knowledge-driven artificial intelligence applications, especially in scenarios requiring precise logical reasoning.

[0058] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for constructing logical knowledge based on a large language model and logical programming, characterized in that, Comprising: Obtaining raw knowledge base data, including unstructured text and / or semi-structured data; Performing semantic parsing on the raw knowledge base data through a large language model to generate a preliminary set of logical expressions; Standardizing the preliminary logical expressions based on the syntax rules of a logic programming language to form standard logical facts and rules; Performing consistency checking on the standard logical facts and rules to eliminate logical conflicts and store the resulting logical knowledge base.

2. The method of claim 1, wherein, The semantic parsing includes: Identifying entities and their attribute relationships in the input text; Detecting implicit predicate logic structures; Generating intermediate expressions conforming to first-order logic or description logic.

3. The method of claim 1, wherein, The standardization process includes: Converting natural language expressions into predicate logic conforming to Prolog or other logical programming system formats; Adding timestamp and credibility metadata; Establishing mapping relationships with domain ontologies.

4. The method of claim 1, wherein, The consistency checking includes: Detecting logical conflicts between facts and rules; Verifying the completeness of rules; Applying conflict resolution strategies, including priority sorting or manual intervention.

5. The method according to any one of claims 1 to 4, characterized in that, Also including: Building a rule dependency graph; Implementing an incremental knowledge update mechanism; Providing a visual editing interface for manual correction. 6.A logic knowledge construction apparatus based on a large language model and logic programming, characterized by, Comprising: A data acquisition module configured to receive multi-source heterogeneous knowledge data; A semantic understanding module integrating a large language model to realize natural language to logic conversion; A logic standardization module configured to perform the method of any one of claims 1-5; A knowledge storage module using a database or a logical programming environment storage system.

7. The apparatus of claim 6, wherein, Also including: A quality assessment unit to calculate the confidence score of knowledge elements; A version management unit to support time sequence backtracking of the knowledge base; An interface service unit to provide data interaction channels with other reasoning systems.

8. An electronic device, comprising: Comprising: A processor; A memory storing a computer program; When the computer program is executed by the processor, the method of any one of claims 1-5 is implemented.

9. A computer-readable storage medium, characterized in that, Storing computer instructions that, when executed, cause the computer to perform the method of any one of claims 1-5.

Citation Information

Cited By

  • Formula analysis method based on multi-stage knowledge base constraint and heuristic logic

    CN121885016A