This invention relates to the field of large
language model technology and discloses a
large model contextual semantic retrieval method based on knowledge graphs, including the following steps: entity and intent extraction, vectorized
knowledge retrieval, KG subgraph query construction, multi-source
database SQL transformation and context acquisition, and final prompt construction and
knowledge question answering. This invention constructs a deep alignment representation of structured and
natural language, transforming the discrete structure representation of the
knowledge graph into a continuous vector representation through a
graph embedding model, achieving unification with the vector representation
system of the large
language model. Simultaneously, it vectorizes the entities and intents of the user query and performs
similarity matching, realizing semantic soft alignment between KG triples and
natural language queries. This enables the large
language model to perceive the topological structure and semantic constraints of the
knowledge graph, reducing reliance on statistical associations and significantly reducing factual errors.