Geographical information intelligent question answering method and device based on knowledge graph prompt enhancement

By introducing a collaborative question-answering system that combines geographic knowledge graphs and structured databases, the accuracy and interpretability issues of traditional intelligent question-answering systems in the geographic information field are solved, achieving high-precision and traceable natural language interaction for geographic information.

CN122132501APending Publication Date: 2026-06-02SHANDONG PROVINCIAL LAND SURVEYING & MAPPING INST

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANDONG PROVINCIAL LAND SURVEYING & MAPPING INST
Filing Date
2026-02-10
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Traditional intelligent question-answering systems suffer from cognitive biases, logical gaps, outdated knowledge, and insufficient computational reasoning capabilities when dealing with the geographic information field. This results in answers that deviate from the facts or are vague, making it difficult to meet the accuracy, timeliness, and interpretability requirements of professional fields.

Method used

We adopt a knowledge graph-based intelligent question-answering method for geographic information. By identifying geographic entities and quantified elements through semantic parsing, and combining geographic knowledge graphs and structured databases, we construct a dual-track collaborative question-answering system to achieve high-precision, highly interpretable, and traceable natural language interaction for geographic information.

Benefits of technology

It achieves high-precision geographic information question answering, provides logically coherent answers and traceable data sources, enhances credibility and interpretability in professional fields, and balances the flexibility of precise queries with open question answering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122132501A_ABST
    Figure CN122132501A_ABST
Patent Text Reader

Abstract

This invention provides a method and device for intelligent question answering of geographic information based on knowledge graph-based prompt enhancement. The method includes: semantically parsing a natural language question to identify geographic entities and extracting quantitative elements, thereby determining whether it is a statistical question that can trigger a structured query; retrieving a local subgraph from a geographic knowledge graph based on the geographic entity and converting it into a knowledge prompt in natural language form; if it is a statistical question, executing a first processing path: querying a structured geographic statistics database based on the quantitative elements to obtain target data, and integrating it with the knowledge prompt as the first input information; otherwise, executing a second processing path, using the knowledge prompt as the second input information; and inputting the question and corresponding input information into a pre-trained language model to generate an answer. Based on this method, an intelligent question answering device for geographic information is also proposed. This invention improves the accuracy, interpretability, and traceability of geographic question answering through a dual-track collaborative mechanism combining knowledge graph-based prompt enhancement and dynamic data retrieval.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the interdisciplinary field of artificial intelligence and geographic information technology, and specifically relates to a method and device for intelligent question answering of geographic information based on knowledge graph-enhanced prompts. Background Technology

[0002] With the rapid development of Natural Language Processing (NLP) and Large Language Modeling (LLM) technologies, intelligent question answering systems have been widely used in fields such as general knowledge question answering, educational tutoring, and information retrieval. However, in the field of geographic information, traditional intelligent question answering systems still have significant limitations.

[0003] Geographical problems are typically highly structured and domain-specific, involving multidimensional spatiotemporal semantics, complex administrative hierarchical relationships, and specific quantitative indicators such as regional area, river length, and population size. These characteristics cause general-purpose language models to exhibit significant cognitive biases and logical gaps when dealing with geographical problems. Second, geographical problems often involve multi-level entities, temporal constraints, and spatial attributes. General-purpose language models mainly rely on statistical semantic relationship learning and lack the ability to deeply model geographical knowledge systems, spatial hierarchies, and semantic dependencies. When faced with complex geographical entity relationships or descriptions of temporal changes, the models are prone to entity ambiguity, relationship confusion, or spatial cognitive errors, leading to answers that deviate from the facts or are vague in expression. Third, answers to geographical problems often require reliance on authoritative statistical databases or geographical knowledge bases (such as administrative division databases, natural resource statistics databases, and Geographic Information System (GIS) data). However, the training corpora for general-purpose language models are mostly derived from internet text, whose internal knowledge updates are lagging and whose sources are uncertain, making it difficult to guarantee timeliness and accuracy. Fourth, existing language models lack the ability to handle computational reasoning tasks (such as area summation and administrative unit statistics). Even if a model can generate values ​​that closely approximate reality, it often fails to explain the data source, computational logic, or reasoning basis. This characteristic of "correct results but opaque processes" severely limits the application of models in scenarios with high requirements for interpretability and traceability, such as geographical decision-making, scientific research analysis, and government statistics.

[0004] In summary, while traditional intelligent question-answering technologies have made breakthroughs in natural language understanding and generation, they still lack effective systematic support when facing data-driven, knowledge-constrained, and reasoning-based tasks in the geographic domain. Geographic information question answering not only requires models to understand natural language but also to have the ability to access knowledge graphs, statistical databases, and perform reasoning based on domain rules. Current technologies urgently need a hybrid intelligent question-answering technology that integrates authoritative geographic data, structured domain knowledge, and the generation capabilities of large language models to address the shortcomings in accuracy, timeliness, and interpretability in geographic information question answering. Summary of the Invention

[0005] To address the aforementioned technical challenges, this invention proposes a method and device for intelligent question answering of geographic information based on knowledge graph-based prompts. By introducing a geographic knowledge graph-based prompt enhancement mechanism and a structured data dynamic retrieval mechanism, a dual-track collaborative intelligent question answering system is constructed, thereby achieving high-precision, highly interpretable, and traceable natural language interaction of geographic information.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: Firstly, this invention proposes an intelligent question-answering method for geographic information based on knowledge graph-enhanced prompts, comprising the following steps: Semantic parsing is performed on the natural language questions input by users to identify geographic entities and extract quantitative features; based on geographic entities and quantitative features, it is determined whether the natural language question is a statistical question that can trigger a structured query. Based on the geographic entities, relevant local subgraphs are retrieved from the pre-constructed geographic knowledge graph, and the local subgraphs are converted into knowledge prompts in the form of natural language text. If the natural language question is determined to be a statistical question that can trigger a structured query, then the first processing path is executed; otherwise, the second processing path is executed. The first processing path generates a query instruction based on quantitative elements to access the corresponding structured geostatistical database and obtain the target data, and then integrates the target data with knowledge prompts to form the first input information. The second processing path directly uses the knowledge prompts as the second input information. The natural language question, along with either the first or second input information, is input into a pre-trained language model, which then drives the language model to generate the answer text. Output the answer text and associate it with the data source identifier or knowledge identifier information on which the answer text was generated.

[0007] Secondly, the present invention proposes a geographic information intelligent question answering device based on knowledge graph-enhanced prompts, comprising at least one processor and a memory, wherein the memory stores a computer program, and the computer program, when executed by the at least one processor, implements the geographic information intelligent question answering method based on knowledge graph-enhanced prompts.

[0008] The effects described in the invention are merely those of the embodiments, and not all the effects of the invention. One of the above technical solutions has the following advantages or beneficial effects: This invention proposes a method and device for intelligent question answering of geographic information based on knowledge graph-enhanced prompts. The method includes the following steps: semantic parsing of a user-input natural language question to identify geographic entities and extract quantitative elements; determining whether the natural language question is a statistical question that can trigger a structured query based on the geographic entities and quantitative elements; retrieving relevant local subgraphs from a pre-constructed geographic knowledge graph based on the geographic entities, and converting the local subgraphs into knowledge prompts in natural language text form; if the natural language question is determined to be a statistical question that can trigger a structured query, then executing a first processing path; otherwise, executing a second processing path; the first processing path is to generate a query instruction based on the quantitative elements to access the corresponding structured geographic statistical database and obtain target data, and then integrate the target data with the knowledge prompts to form first input information; the second processing path is to directly use the knowledge prompts as second input information; inputting the natural language question, along with the first or second input information, into a pre-trained language model to drive the language model to generate answer text; outputting the answer text and associating it with the data source identifier or knowledge identifier information on which the answer text is based. Based on this method, this invention also proposes an intelligent question answering device for geographic information based on knowledge graph-enhanced prompts. This invention constructs a dual-track collaborative intelligent question-and-answer system by introducing a geographic knowledge graph-based prompting enhancement mechanism and a structured data dynamic retrieval mechanism, thereby achieving high-precision, highly interpretable, and traceable natural language interaction of geographic information.

[0009] This invention uses a knowledge graph-based suggestion enhancement mechanism to inject explicit knowledge such as spatial relationships, hierarchical affiliations, and attribute associations between geographical entities into the language model generation process, so that the generated answers not only contain facts, but also provide causal explanations and background descriptions that conform to geographical logic.

[0010] When outputting the answer, this invention simultaneously outputs the data source identifier (such as a database query snapshot) or knowledge source identifier (such as a knowledge graph triple ID), realizing full traceability and verifiability of the answer, and greatly improving the credibility of its application in professional fields.

[0011] By designing a collaborative mechanism between the first processing path (precise query) and the second processing path (knowledge reasoning), as well as strategies such as confidence tolerance and information retrieval compensation, this invention enables the system to properly handle various geographical issues, balancing the rigor of precise queries with the flexibility of open-ended question answering. Attached Figure Description

[0012] Figure 1 This is a flowchart of the intelligent question-answering method for geographic information based on knowledge graph-enhanced prompts proposed in Embodiment 1 of the present invention; Figure 2 This is a diagram of the dedicated model architecture proposed in Embodiment 1 of the present invention; Figure 3 This is a visualization of the universal model interface for a wide range of fields proposed in Embodiment 1 of the present invention; Figure 4 This is a visualization of the dedicated model interface optimized for the geographic domain proposed in Embodiment 1 of the present invention; Figure 5 This is a schematic diagram of the intelligent question-answering device for geographic information based on knowledge graph-based prompts, as proposed in Embodiment 2 of the present invention. Detailed Implementation

[0013] To clearly illustrate the technical features of this solution, the invention will be described in detail below through specific embodiments and in conjunction with the accompanying drawings. The following disclosure provides many different embodiments or examples for implementing different structures of the invention. To simplify the disclosure of the invention, components and arrangements of specific examples are described below. Furthermore, reference numerals and / or letters may be repeated in different examples. This repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed. It should be noted that the components illustrated in the drawings are not necessarily drawn to scale. Descriptions of well-known components, processing techniques, and processes are omitted in this invention to avoid unnecessarily limiting the invention.

[0014] Example 1 Embodiment 1 of this invention proposes a geographic information intelligent question answering method based on knowledge graph prompt enhancement. By introducing a geographic knowledge graph prompt enhancement mechanism and a statistical database dynamic calling mechanism, and through the collaboration of natural language understanding, knowledge retrieval, structured query and result generation, a high-precision question answering process from question input to authoritative data output is realized.

[0015] This invention employs a dual-track collaborative approach to achieve an intelligent question-answering method for geographic information based on knowledge graph-enhanced prompts. The vertical model used is a dedicated model optimized for the geographic domain. Figure 2 This is a diagram of the dedicated model architecture proposed in Embodiment 1 of the present invention. The architecture forms a complete question-answering closed loop consisting of semantic understanding, knowledge retrieval, data querying, and natural language generation. The processing flow is as follows: natural language input → semantic parsing → question type determination → data query or knowledge graph retrieval → model generation → result interpretation and tracing. This system possesses the dual-track collaborative characteristics of a general-purpose model and a dedicated model, ensuring the accuracy, professionalism, and verifiability of the answers while maintaining openness and flexibility.

[0016] The dedicated model of this invention uses a lightweight inference framework such as llama.cpp, employs an offline quantization deployment strategy and a local knowledge enhancement mechanism, and achieves high-performance inference in a low-resource, offline environment.

[0017] This embodiment takes the "Shandong Province Geographic Information Intelligent Question Answering System" as an example to explain in detail the specific implementation process of the method described in this invention. The system as a whole adopts a dual-track fusion architecture of general model and special model, and introduces a geographic knowledge graph prompt enhancement mechanism.

[0018] Figure 1 This is a flowchart of the intelligent question-answering method for geographic information based on knowledge graph-enhanced prompts proposed in Embodiment 1 of the present invention; In step S1, the natural language question input by the user is semantically parsed to identify geographic entities and extract quantitative elements; A lightweight Transformer encoder is used to model the semantics of the problem and generate a problem vector. The system extracts elements such as time, administrative division, geographical entities, and indicator terms using the Named Entity Recognition (NER) model. The recognition results are represented in BIO encoding, forming a feature sequence. BIO is an encoding format used for sequence labeling, marking the start, interior, and exterior of entities.

[0019] The feature sequence is as follows: ; in, Represents the problem vector. ; Represents a time entity. Indicates an administrative division entity. Represents geographic entities; Terms indicating statistical indicators; This represents a semantic extraction model; This represents the set of model parameters.

[0020] The system's built-in geographic dictionary can help disambiguate, such as resolving "Yangtze River Basin Area" as the entity "Yangtze River" and the indicator "Area", rather than incorrectly identifying them as two parallel entities.

[0021] To prevent ambiguity or mismatch, this invention introduces a confidence calculation mechanism to calculate the overall confidence score of the semantic parsing performed; the overall confidence score... The calculation formula is:

[0022] in, This indicates the number of semantic components identified through semantic parsing; An index representing semantic components; Indicates the first The weight coefficients corresponding to each semantic component; This represents the first identified natural language problem after semantic parsing. The accuracy score of each semantic component.

[0023] If the confidence level is lower than the set threshold, the system will automatically prompt the user to confirm or re-identify, thereby improving the stability of the parsing.

[0024] In step S2, it is determined whether the natural language question is a statistical question that can trigger a structured query based on the geographic entity and quantitative elements; In this step, the parsed results are matched against standard problem patterns in the template library. The templates use logical rule expressions: T1: (Year) + (Administrative Division) + (Entity) + (Indicator).

[0025] When the matching function exceeds a preset threshold, the system determines that the problem is a statistical problem that can trigger a structured query and generates a standardized SQL query statement; if the matching fails, it will switch to a robustness enhancement mechanism within a processing path.

[0026] For general model paths, the system automatically determines the type of input question using a question classifier. The classification process combines features such as semantic vector similarity, named entity recognition (NER), part-of-speech tagging (POS), and dependency syntax structure. The classification function is defined as: ; in, Represents the problem classification function; Represents entity description Semantic vector representation obtained through a semantic encoding model; This indicates the named entity recognition result; This indicates the part-of-speech tagging results; Indicates dependency syntax structure; when The system determines that the question does not possess the characteristics of a structured query and automatically switches to the second processing path. To set a threshold.

[0027] In step S3, based on the geographic entity, relevant local subgraphs are retrieved from the pre-constructed geographic knowledge graph, and the local subgraphs are converted into knowledge prompts in the form of natural language text. The geographical knowledge graph is constructed using the "Entity-Relation-Attribute (ERA)" triple as its basic unit, covering multiple levels of elements in Shandong Province, including natural geography, administrative divisions, socio-economic factors, and ecological environment. Its data primarily comes from the following four sources: Authoritative geographic database: including structured geographic data from Shandong Provincial Department of Natural Resources, Department of Ecology and Environment, Bureau of Statistics, Meteorological Bureau, and other departments; Public geographic knowledge resources: Integrating data sources such as the National Geographic Information Public Service Platform, Baidu Encyclopedia, and OpenStreetMap; Specialized domain knowledge base: Includes literature from professional fields such as agriculture, marine, ecological protection, and urban planning in Shandong Province; Manual semantic annotation and ontology supplementation: A "geographic ontology" was established with expert participation, defining semantic relationships between geographic entities such as superiority, affiliation, adjacency, inclusion, and flow. The resulting Shandong geographic knowledge graph contains approximately 200,000 entity nodes, 600,000 relation edges, and 1.5 million attribute fields. This constitutes the core semantic network for system knowledge enhancement, as shown in Table 1 (main table of entity relationships), Table 2 (extended table of entity relationships), Table 3 (road entity table), Table 4 (site and other geographic entity table), and Table 5 (pipeline and pipeline entity table).

[0028] Table 1: Main Table of Entity Relationships in Knowledge Graph

[0029] Table 2: Knowledge Graph Entity Relationship Expansion Table

[0030] Table 3: Road Entity List

[0031] Table 4: Sites and Other Geographic Entities

[0032] Table 5: Pipeline and Pipeline Entity List

[0033] The knowledge graph adopts a hierarchical structure design, divided into the following five levels from macro to micro: Administrative division level: describes the hierarchical structure and subordinate relationships of Shandong Province, its prefecture-level cities, and counties; for example: Shandong Province → subordinate to → Jinan City, Qingdao City, Yantai City, Weifang City, etc. The physical geography layer includes natural elements such as mountains, rivers, lakes, and plains; for example, Mount Tai is located in Tai'an City; the Yellow River flows through Dongying City. Ecology and Resources Layer: Includes information on the distribution of natural resources such as forests, wetlands, minerals, and marine resources; Socioeconomic layer: Represents human geographical features such as industrial distribution, transportation network, and urban functional areas; Statistical attribute layer: Attach quantifiable indicators to each entity node, such as area, altitude, population density, etc.

[0034] The layers are connected by relation types (such as "belongs to", "adjacent", "flows through", "contains"), constructing a computable semantic network structure. This multi-layered relational structure provides stable knowledge support for model reasoning, enabling it not only to answer "what" but also to explain "why".

[0035] During intelligent question answering, the system automatically retrieves relevant local subgraphs from the knowledge graph based on the geographic entity of the input question and converts them into natural language prompts, injecting them into the input context of the language model. This process can be divided into three stages: First, entity location and relation retrieval When inputting questions Parsed as an entity Then, the system performs a depth-first search (DFS) on the knowledge graph to extract a set of relation triples directly related to the entity: ; in, Representation and entity The set of related relational triples; This represents the query entity parsed from the question; Indicates the type of relation in a knowledge graph; Indicates other entities related to the queried entity; For the entire knowledge graph; For example, when the question is "Which cities in Shandong does the Yellow River flow through?", the system will extract: Yellow River → flows through → Dongying City; Yellow River → flows through → Binzhou City; Yellow River → flows through → Jinan City.

[0036] Second, semantic prompt generation The retrieved relation triples are transformed into readable prompts and added to the model input in natural language format. For example, the prompt message is generated as: "The Yellow River flows through Dongying City, Binzhou City, and Jinan City in Shandong Province." This is then concatenated with the user question to form the final model input: Prompt + User Question → Language Model Input Sequence.

[0037] Third, generating constraints and fact verification. During the language model generation phase, the prompts are used as factual constraints in attention calculations, thus prioritizing knowledge graph information in the output process. If the generated result differs from the prompts, the system performs a semantic check based on similarity to ensure the accuracy of the answer. This mechanism integrates explicit knowledge with implicit semantics, shifting the model from probabilistic generation to knowledge-driven generation.

[0038] In step S4, is the natural language question determined to be a statistical question that can trigger a structured query? If so, proceed to step S5; otherwise, proceed to step S6. This step is the path decision-making stage, where the execution path is selected based on the judgment result of step S2.

[0039] In step S5, the first processing path is executed: the first processing path is to generate query instructions based on quantitative elements to access the corresponding structured geostatistical database and obtain target data, and then integrate the target data with knowledge prompts to form the first input information; This step corresponds to the subsequent processing flow of the dedicated model, including data query, semantic fusion, and compensation mechanism.

[0040] When backend statistical data is dynamically utilized, the system accesses the geostatistical database and automatically retrieves authoritative data for the corresponding entity once the query meets the structured query criteria. The backend database covers administrative division information, geographic features, and their statistical indicators, and currently supports three main query indicators: Numerical indicators (such as the number of place names, the number of administrative units, etc.); Area-related indicators (such as regional area, forest coverage area, etc.); Length-related indicators (such as river length, total highway mileage, etc.).

[0041] During model analysis and natural language generation, the system can efficiently return authoritative results through a unified data interface and standardized query protocol, providing a solid data foundation for the language model generation stage.

[0042] During semantic fusion, the model incorporates the question context. Knowledge graph information and database return values Unified encoding as implicit vector representation: ; in, This represents the fused implicit vector representation; This represents the Sigmoid activation function; The weight matrix representing the problem context vector; The weight matrix representing the information vectors in a knowledge graph; The weight matrix represents the vector of values ​​returned by the database. This represents the bias term of the fusion layer.

[0043] The fusion layer uses a gating mechanism to dynamically adjust the weights of the three elements, ensuring that the generated sentences conform to linguistic rules and contain accurate geographical facts.

[0044] The output stage employs an autoregressive language generation model, generating words one by one according to a conditional probability distribution: ; in, This represents the probability of generating the current word given the historical output and the fused hidden state; Indicates the word generated at the current time step; This represents all words generated at the previous time step; Indicates the weights of the output layer; Indicates the bias of the output layer; This indicates the hidden state at the current time step.

[0045] To avoid numerical errors, the model calls the numerical protection module during the output process to ensure that the statistical values ​​maintain the same format and accuracy as the database.

[0046] The generated answer includes not only the direct result but also the time span, data source, and trend. For example: "According to the 2023 Shandong Provincial Natural Resources Bulletin, the forest area is 1.782 million hectares, an increase of approximately 1.2% compared to the previous year." This generation mechanism ensures that the output conforms to natural expression while possessing the standardization and interpretability of statistical reports. If the user selects the visualization mode, the system can further generate a line graph of area changes or map annotations, achieving multimodal output of the results.

[0047] The information retrieval compensation mechanism is used to maintain system robustness when there are no results in the database or the question does not conform to structured rules. This mechanism is based on a multi-stage reasoning strategy involving semantic retrieval, graph reasoning, and model generation.

[0048] During semantic detection, the semantic similarity between the input question and entity descriptions in the knowledge graph is first calculated. The calculation process is as follows: ; in, Indicate the problem and entity description The semantic similarity value between them; Represents the natural language question text input by the user; Descriptive text representing entity nodes in a knowledge graph; Indicate the problem Semantic vector representation obtained through a semantic encoding model; Represents entity description Semantic vector representation obtained through a semantic encoding model; Representing vectors The Euclidean norm.

[0049] If the similarity exceeds the threshold, the previous one will be selected. The most relevant knowledge fragments constitute a set of knowledge hints. .

[0050] Graph-based reasoning expands entities and inherits attributes based on relational edges in the knowledge graph. For example, when the question is "length of the Yi River," the system can reason along the "flows through --- belongs to --- tributary" relational chain to locate the "Huai River system," and then combine this with higher-level data to estimate the proportion. This type of reasoning uses a heuristic weight propagation algorithm, namely: ; in, Representing entities with neighboring nodes Semantic association weights; Representing entities with neighboring nodes semantic similarity; Representing entities The set of neighboring nodes; exp represents the exponential function.

[0051] The final dedicated model will The reasoning results are input into the generator, which outputs an explanatory answer in natural language. For example: "The database does not provide data on the length of the Yi River. Based on the relationship between the tributaries of the Huai River and the proportion of the basin, the total length of the Yi River is estimated to be approximately 574 kilometers." This design enables the system to still have adaptive reasoning capabilities even when data is missing, achieving an intelligent transition from "data-driven question answering" to "knowledge-driven question answering."

[0052] In step S6, the second processing path is executed; the second processing path is to directly use the knowledge hints as the second input information. The general-purpose model is a crucial component of the Shandong Geographic Information Intelligent Question Answering System, primarily used to handle natural language questions lacking clearly defined structured features. Compared to dedicated models, the general-purpose model does not rely on databases or statistical indicators; instead, it leverages the language model's own semantic understanding, knowledge reasoning, and generation capabilities to provide natural language answers to open-ended, explanatory, and descriptive questions. The general-purpose model plays a vital role in the overall system: when dedicated models fail to resolve questions or the database fails to return results, the general-purpose model performs fallback reasoning and semantic generation tasks, thus ensuring the system's integrity and usability.

[0053] In the general model path, the system directly uses the knowledge hints generated in step S3 as the second input information to the language model for reasoning generation. The general model adopts the 7B quantization model of the llama.cpp architecture, and achieves multi-layer attention focusing through the optimized Transformer structure.

[0054] In the semantic understanding stage, the input question is mapped into a high-dimensional semantic representation vector, and the model captures the dependencies between keywords through a multi-head attention mechanism. This mechanism enables the model to identify spatial entities (such as "Shandong Peninsula" and "Central Shandong Hills"), temporal constraints (such as "2023"), and semantic associations (such as "climate", "landform", and "resource distribution") in the question, and to perform causal reasoning based on inherent linguistic knowledge.

[0055] At the knowledge reasoning layer, the system embeds prompts from a geographical knowledge graph, enabling the model to reference explicit geographical knowledge structures, such as administrative divisions and natural geographical relationships, when answering questions. This mechanism effectively compensates for the limitations of the model's own knowledge coverage, making the generated answers more logical and domain-relevant.

[0056] The general model employs a dynamic knowledge injection mechanism to improve the factual consistency of the answers. When a specific geographic entity is detected in the question, the system extracts relevant local subgraphs (such as spatial affiliation, watershed relationships, and climate types) from the Shandong Province geographic knowledge graph and injects them into the model input as prompts. For example: Note: Shandong Peninsula belongs to Shandong Province; Shandong Province faces the Bohai Sea and the Yellow Sea. Question: Why are the coastal areas of the Shandong Peninsula rich in wind resources? This knowledge-based prompting makes the model-generated answers semantically constrained by facts, thereby reducing fictional content and improving the consistency of the answers.

[0057] Furthermore, the system incorporates a context fusion strategy for multi-turn question answering. The model utilizes a sliding window mechanism to encode the most recent question-answer pairs and calculate their semantic similarity to the current input, ensuring contextual continuity. For example, when a user asks consecutive questions such as "What is the highest mountain in Shandong?" and "What is its altitude?", the system can accurately identify that it refers to Mount Tai and generate a coherent answer.

[0058] During the answer generation phase, the general model integrates multi-source information by combining semantic context, knowledge hints, and system control parameters. The general generation probability can be expressed as: ; in, This represents the probability of generating a complete sequence of answers given the context and hints. Indicates the semantic context of the current problem; This indicates the content of the knowledge prompt; Represents a sequence of answers; Indicates the word generated at the current time step; This represents all words generated at the previous time step; This invention employs the Beam Search decoding algorithm to generate candidate answers and introduces a semantic consistency scoring function to filter the output quality. Furthermore, temperature parameters and repetition penalty coefficients are set to balance linguistic diversity and factual accuracy, avoiding the generation of repetitive or logically contradictory statements. In engineering implementation, to improve response speed, the general model adopts a multi-threaded asynchronous inference mechanism, keeping the average response time within 1.2 seconds, thus meeting the real-time interactive requirements of the Shandong Geographic Information Question Answering System.

[0059] Figure 3 This is a visualization of the interface of the general-purpose model proposed in Embodiment 1 of this invention, applicable to a wide range of fields. To enhance system transparency, the general-purpose model outputs the reasoning basis and knowledge references simultaneously when generating answers. For example: "According to the climate zoning and coastline characteristics of Shandong Province, coastal areas are affected by both monsoons and the thermal differences between land and sea, thus possessing abundant wind resources." The system records the reasoning chain and knowledge sources in a JSON structure in the backend, facilitating subsequent visualization and knowledge verification. Simultaneously, the general-purpose model supports an explicit "source description" output function, suitable for answer tracing requirements in scientific research or policy application scenarios.

[0060] In practical applications, the llama.cpp architecture 7B quantization model adopted by the general model exhibits high operational efficiency in resource-constrained deployment environments, but its reasoning ability and knowledge coverage are somewhat limited. On the one hand, due to the limited number of parameters and weak semantic expression ability of the general model, it is prone to insufficient reasoning when dealing with geographical problems involving multi-layered causal logic. For example, for the question "Why is the hilly area of ​​central Shandong suitable for fruit tree planting?", the general model can identify the correlation between terrain features and agricultural activities, but lacks in-depth reasoning when explaining "soil drainage and light conditions". On the other hand, the problems of simplified generated content and factual lag are obvious. Due to the limitations of the general model's capacity and offline quantization deployment, some recent administrative division adjustments (such as Laiwu merging into Jinan) or the latest policy data cannot be updated in a timely manner, resulting in answers that may be generated based on old information. Despite the above limitations, the general model is still an indispensable component of the system. On the one hand, it fills the gaps in open question-answering tasks that dedicated models cannot cover; on the other hand, its low power consumption and local deployment characteristics ensure the controllability and security of the system on the Shandong provincial platform.

[0061] In step S7, the natural language question, together with the first input information or the second input information, is input into the pre-trained language model to drive the language model to generate the answer text; In environments with limited computing power, deploying large-scale language models using the original FP32 architecture will significantly increase memory usage and inference time. FP32 refers to 32-bit floating-point numbers. This invention employs a hybrid precision quantization strategy from llama.cpp, using layered INT4 and INT8 quantization to compress the model's weight matrix to approximately one-quarter of its original size. INT4 and INT8 are two integer quantization precision formats, referring to the use of 4-bit or 8-bit integers to represent model parameters or activation values. This invention uses INT4 for high compression of low-sensitivity layers or channels (such as some fully connected layers), and uses INT8 to retain more precision for high-sensitivity layers or channels (such as the output of attention layers). This achieves an optimal balance between overall compression ratio (model size) and task precision (model performance), resulting in higher compression efficiency and more controllable precision loss.

[0062] The quantization process uses a channel-by-channel scaling method, and its core formula is as follows: ; in, Indicates the first Each channel quantized weight submatrix; Represents the original weight submatrix; Indicates the first Quantization scaling factor for each channel; Represents the floor function; Indicates the channel index.

[0063] During inference, the dedicated model employs quantization matrix multiplication and dequantization recovery mechanisms, combined with SIMD (Single Instruction Multiple Data) parallel optimization in llama.cpp, achieving an average inference latency of less than 120ms / sentence in a single-machine CPU environment.

[0064] Furthermore, the offline deployment employs an isolated sandbox and an irreversible data caching structure to ensure that the interaction between the model and the geographic database is limited to local calls, eliminating the risk of data leakage. In terms of engineering implementation, the quantized model weights are loaded using mmap (memory-mapped file) to further improve startup efficiency and resource reuse, enabling the system to run efficiently on ordinary terminal devices.

[0065] When the language model generates answer text, its attention mechanism is enhanced by the aforementioned knowledge cues; this enhancement is achieved by introducing a knowledge attention head, the attention weight of which is calculated using the following formula: ; in, This represents the query weight matrix derived from the current decoding state of the language model; This represents the key matrix derived from the entity and relation embedding vectors in the aforementioned knowledge hints; This represents the value matrix derived from the entity and relation embedding vectors in the aforementioned knowledge prompts; This represents the dimension of the key vector.

[0066] By introducing explicit knowledge embedding, the model not only relies on the statistical co-occurrence relationships between word vectors during the generation process, but also actively references the logical structure between entities and relationships. For example, for the question "Why are coastal areas of Shandong rich in wind resources?", the model will automatically focus on knowledge nodes such as "coastline length", "monsoon climate" and "land-sea thermal differences", thereby generating an explanatory answer with geographical logic.

[0067] In step S8, the answer text is output, and the data source identifier or knowledge identifier information on which the answer text is based is associated with the output. Figure 4 This is a visualization of the dedicated model interface optimized for the geographic domain proposed in Embodiment 1 of the present invention; The system outputs the answer text and associates it with the data source identifier or knowledge identifier information on which the answer was based. The data source identifier includes at least one of the following: database name, query time, and query statement hash value; the knowledge identifier information includes the unique identifier of the knowledge graph triple on which it is based.

[0068] If the question involves statistical changes or spatial distribution, the system calls the geographic visualization module to generate charts or maps and provides source information in the results. This workflow achieves a unified closed loop of natural language understanding, knowledge retrieval, model generation, and result verification, enabling the question-answering system to have both data support and interpretive intelligence.

[0069] The geographic information intelligent question answering method based on knowledge graph-enhanced prompts proposed in Embodiment 1 of this invention integrates explicit knowledge such as spatial relationships, administrative levels, and attribute associations between geographic entities into the language model generation process through knowledge graph prompt injection. This not only enhances the model's semantic parsing ability for complex geographic problems but also enables it to generate answers with logical coherence and causal explanation, achieving a leap from simple "data retrieval" to "knowledge reasoning".

[0070] The geographic information intelligent question-answering method based on knowledge graph-enhanced prompts proposed in Embodiment 1 of this invention provides clear data source identification and knowledge reference paths while outputting answers, ensuring that every factual statement can be traced back to authoritative databases or structured knowledge graphs. This mechanism not only enhances users' trust in the system's output but also provides reliable and transparent support for the application of geographic information in serious scenarios such as scientific research, planning, and decision-making.

[0071] The geographic information intelligent question answering method based on knowledge graph-enhanced prompts proposed in Embodiment 1 of this invention, through dual-path collaborative design and information retrieval compensation mechanism, can adaptively handle statistical queries and open-domain interpretation questions, ensuring accuracy while also considering the flexibility and completeness of the answers. Even in cases of missing data or unconventional query conditions, the system can still generate valuable reference answers through knowledge reasoning, demonstrating good fault tolerance and scenario adaptability.

[0072] The geographic information intelligent question-answering method based on knowledge graph-enhanced prompts proposed in Embodiment 1 of this invention upgrades traditional geographic information systems based on keyword retrieval or fixed templates into intelligent question-answering platforms that support natural language interaction, possess domain knowledge understanding, and multi-source data fusion capabilities. This not only lowers the barrier to entry for using professional geographic information but also provides strong technical support for its widespread and in-depth application in public services, government decision-making, scientific research, education, and other fields.

[0073] The geographic information intelligent question answering method based on knowledge graph prompt enhancement proposed in Embodiment 1 of this invention, with its proposed knowledge graph prompt enhancement and dual-model collaborative architecture, is not only applicable to the geographic information field, but its methodology and implementation path can also provide a reference for the construction of intelligent question answering systems in other vertical fields (such as law, finance, and healthcare), demonstrating broad technical promotion value and application prospects.

[0074] Example 2 Embodiment 2 of the present invention also proposes a geographic information intelligent question-answering device based on knowledge graph-enhanced prompts, comprising: Memory, used to store computer programs; When a processor executes the computer program, the method steps are as follows: In step S1, the natural language question input by the user is semantically parsed to identify geographic entities and extract quantitative elements; In step S2, it is determined whether the natural language question is a statistical question that can trigger a structured query based on the geographic entity and quantitative elements; In step S3, based on the geographic entity, relevant local subgraphs are retrieved from the pre-constructed geographic knowledge graph, and the local subgraphs are converted into knowledge prompts in the form of natural language text. In step S4, is the natural language question determined to be a statistical question that can trigger a structured query? If so, proceed to step S5; otherwise, proceed to step S6. In step S5, the first processing path is executed: the first processing path is to generate query instructions based on quantitative elements to access the corresponding structured geostatistical database and obtain target data, and then integrate the target data with knowledge prompts to form the first input information; In step S6, the second processing path is executed; the second processing path is to directly use the knowledge hints as the second input information. In step S7, the natural language question, together with the first input information or the second input information, is input into the pre-trained language model to drive the language model to generate the answer text; In step S8, the answer text is output, and the data source identifier or knowledge identifier information on which the answer text is based is associated with the output.

[0075] The geographic information intelligent question-answering device based on knowledge graph-enhanced prompts proposed in Embodiment 2 of this invention effectively overcomes the problems of factual errors and insufficient timeliness faced by general language models in the geographic field by introducing a dual-track mechanism of knowledge graph-enhanced prompts and dynamic retrieval of structured data. For structured geographic questions involving statistical indicators, administrative divisions, and natural resources, it can directly access authoritative databases to obtain accurate data, fundamentally avoiding the risk of model-generated content not matching the facts, and significantly improving the reliability and professionalism of the answers.

[0076] It should be noted that the present invention also provides an electronic device, including: a communication interface capable of interacting with other devices such as network devices; and a processor connected to the communication interface to enable information interaction with other devices, used to execute the knowledge graph-based enhanced geographic information intelligent question-answering method provided by one or more of the above technical solutions when running a computer program, wherein the computer program is stored in a memory. Of course, in practical applications, the various components in the electronic device are coupled together through a bus system. It is understood that the bus system is used to realize the connection and communication between these components. In addition to a data bus, the bus system also includes a power bus, a control bus, and a status signal bus. The memory in the embodiments of this application is used to store various types of data to support the operation of the electronic device. Examples of this data include any computer program used to operate on the electronic device. It is understood that the memory can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic random access memory, flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache.By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM). The memories described in the embodiments of this application are intended to include, but are not limited to, these and any other suitable types of memory. The methods disclosed in the embodiments of this application can be applied to or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by integrated logic circuits in the processor hardware or by instructions in software form. The processor can be a general-purpose processor, a DSP (Digital Signal Processing, i.e., a chip capable of implementing digital signal processing technology), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software modules can be located in a storage medium, which is located in memory. The processor reads the program from the memory and, in conjunction with its hardware, completes the steps of the aforementioned method. When the processor executes the program, it implements the corresponding processes in the various methods of the embodiments of this application; for simplicity, these will not be elaborated further here.

[0077] The description of the relevant parts of the knowledge graph-based intelligent question answering device for geographic information with enhanced prompts provided in Embodiment 2 of this application can be found in the detailed description of the corresponding parts of the knowledge graph-based intelligent question answering method for geographic information with enhanced prompts provided in Embodiment 1 of this application, and will not be repeated here.

[0078] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that the elements inherent in a process, method, article, or apparatus that includes a list of elements are included. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. Additionally, portions of the technical solutions provided in the embodiments of this application that are consistent with the implementation principles of corresponding technical solutions in the prior art have not been described in detail to avoid excessive elaboration.

[0079] While specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art can make other modifications or variations based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.

Claims

1. A geographic information intelligent question answering method based on knowledge graph-enhanced prompts, characterized in that, Includes the following steps: Semantic parsing is performed on the natural language questions input by users to identify geographic entities and extract quantitative features; based on geographic entities and quantitative features, it is determined whether the natural language question is a statistical question that can trigger a structured query. Based on the geographic entities, relevant local subgraphs are retrieved from the pre-constructed geographic knowledge graph, and the local subgraphs are converted into knowledge prompts in the form of natural language text. If the natural language question is determined to be a statistical question that can trigger a structured query, then the first processing path is executed; otherwise, the second processing path is executed. The first processing path is to generate query instructions based on quantitative elements, access the corresponding structured geostatistical database and obtain target data, and then integrate the target data with knowledge prompts to form the first input information; The second processing path is to directly use the knowledge hints as the second input information; The natural language question, along with either the first or second input information, is input into a pre-trained language model, which then drives the language model to generate the answer text. Output the answer text and associate it with the data source identifier or knowledge identifier information on which the answer text was generated.

2. The method according to claim 1, characterized in that, Determining whether a natural language question is a statistical question that can trigger a structured query based on geographic entities and quantitative elements involves: calculating the overall confidence score of the semantic parsing performed; the overall confidence score... The calculation formula is: in, This indicates the number of semantic components identified through semantic parsing; An index representing semantic components; Indicates the first The weight coefficients corresponding to each semantic component; This represents the first identified natural language problem after semantic parsing. The accuracy score of each semantic component; When the confidence level When the value falls below a preset threshold, a fault tolerance mechanism for the semantic parsing results is triggered.

3. The method according to claim 1, characterized in that, To determine whether a natural language question is a statistical question that can trigger a structured query, the specific steps are as follows: The extracted geographic entities and quantitative elements are matched with a preset structured query template. If the match is successful, it is determined to be a statistical problem that can trigger a structured query; otherwise, it is determined to be a statistical problem that cannot trigger a structured query. The structured query template includes time, spatiotemporal constraints, geographic entities, and statistical indicators.

4. The method according to claim 1, characterized in that, When executing the second processing path, if the knowledge hints are insufficient to directly support the generation of an answer, a reasoning process based on a knowledge graph is initiated. The reasoning process based on the knowledge graph includes: calculating the semantic similarity between the natural language question and the entity description in the knowledge graph, and performing logical reasoning based on the relational paths in the knowledge graph to expand the knowledge hints.

5. The method according to claim 4, characterized in that, The semantic similarity The calculation process is as follows: ; in, Indicate the problem and entity description The semantic similarity value between them; Represents the natural language question text input by the user; Descriptive text representing entity nodes in a knowledge graph; Indicate the problem Semantic vector representation obtained through a semantic encoding model; Represents entity description Semantic vector representation obtained through a semantic encoding model; Representing vectors The Euclidean norm.

6. The method according to claim 1, characterized in that, When generating answer text, the language model's attention mechanism is enhanced by the knowledge prompts; this enhancement is achieved by introducing a knowledge attention head, the attention weight of which is calculated using the following formula: ; in, This represents the query weight matrix derived from the current decoding state of the language model; This represents the key matrix derived from the entity and relation embedding vectors in the aforementioned knowledge hints; This represents the value matrix derived from the entity and relation embedding vectors in the aforementioned knowledge prompts; This represents the dimension of the key vector.

7. The method according to claim 1, characterized in that, In the first processing path, query instructions are generated based on quantitative elements. Specifically, the extracted time, administrative division, geographical entities and statistical indicator elements are mapped into standardized structured query statements.

8. The method according to claim 7, characterized in that, The first processing path also includes an information retrieval compensation step: when the target data is not obtained by accessing the structured geostatistical database, compensatory knowledge is generated by combining the semantic retrieval and the reasoning results of the knowledge graph and input into the language model.

9. The method according to claim 1, characterized in that, The data source identifier includes at least one of the name of the structured geostatistical database, the query time, and the query statement hash value; the knowledge identifier information includes the unique identifier of the knowledge graph triple on which it is based.

10. A geographic information intelligent question-answering device based on knowledge graph-enhanced prompts, comprising at least one processor and a memory, wherein the memory stores a computer program, characterized in that, When the computer program is executed by the at least one processor, it implements the geographic information intelligent question answering method based on knowledge graph prompt enhancement as described in any one of claims 1 to 9.