A geoscience operator organization and question-answer retrieval method and device based on a large language model and a knowledge graph
By combining large language models and knowledge graphs, a geoscience operator knowledge graph is constructed, which solves the professional knowledge needs of ordinary users when selecting geoscience operators, realizes a fast and accurate operator selection and decision-making process, and improves the response accuracy of the question answering system.
Patent Information
- Application Number
- CN202510310433.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2045-03-17
AI Technical Summary
When using traditional open-source tools to select geoscience operators, users need to have in-depth geoscience expertise, which leads to low efficiency and significant difficulties. In particular, when faced with a large number of geoscience operators with similar functions and complex parameters, ordinary users find it difficult to quickly select the appropriate operator.
We employ a geoscience operator organization and question-answering retrieval method based on a large language model and knowledge graph. By acquiring user question segments, we use a large language model combined with a vector database and a geoscience operator knowledge graph to generate query statements and output natural language responses, simplifying the user selection process.
It reduces the requirements for professional knowledge and operational experience, enabling users to quickly and accurately locate and select the most suitable combination of operators, thereby improving the accuracy of knowledge graph queries and the response accuracy of question-answering systems.
Smart Images

Figure CN120234390B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of intelligent question answering, and in particular to a geoscience operator organization and question-answer retrieval method and device based on a large language model and a knowledge graph. BACKGROUND
[0002] A geographic information system (GIS) provides numerous geoscience operators for spatial analysis and geoscience calculation. With the continuous development of GIS technology, especially the richness of open source tools, the types of geoscience operators are increasing, and the functions and parameters of each operator are not the same.
[0003] The current open source tools can only provide simple semantic similarity retrieval, which leads to the fact that users must fully understand the functions, application scenarios, and mutual relationships of each operator when selecting an operator. Therefore, users need to have strong professional knowledge to filter out suitable operators. However, not all users have in-depth geoscience professional knowledge and rich spatial analysis experience, so even though the open source tools provide some convenience, there are still great difficulties and high cognitive burdens when weakly professional users select numerous geoscience operators with similar functions and complex parameters. At this time, users need to learn the specific use method of the open source tools on the one hand, and spend a lot of time on filtering suitable operators on the other hand, that is, there is a low use efficiency problem.
[0004] Therefore, there is an urgent need for a geoscience operator organization and question-answer retrieval method and device based on a large language model and a knowledge graph. SUMMARY
[0005] The present application provides a geoscience operator organization and question-answer retrieval method and device based on a large language model and a knowledge graph, which solves the problem that general users still have great difficulties and high cognitive burdens when selecting numerous geoscience operators with similar functions and complex parameters using traditional open source tools, that is, there is a low use efficiency problem.
[0006] In a first aspect of the present application, a geoscience operator organization and question-answer retrieval method based on a large language model and a knowledge graph is provided, the method comprising: in response to a user's question and answer operation, acquiring a question sentence input by the user; inputting the question sentence into the large language model to output an entity corresponding to the question sentence; inputting the question sentence and the entity into the large language model, and the large language model generates at least one query sentence corresponding to the question sentence by combining a vector database; constructing a geoscience operator knowledge graph, and outputting a query result corresponding to the query sentence through the large language model combined with the geoscience operator knowledge graph; inputting the question sentence and the query result into the large language model, and outputting a natural language reply result corresponding to the question sentence.
[0007] Optionally, the question segment and the entity are input into a large language model, and the large language model generates at least one query sentence corresponding to the question segment by combining a vector database, specifically including: performing semantic disambiguation on the entity through the vector database, the vector database being used to store vectorized name information, the vectorized name information including vectorized geoscience operator name information and vectorized geoscience algorithm name information; inputting the question segment and the entity after semantic disambiguation into the large language model, and the large language model generates at least one query sentence corresponding to the question segment by combining the vector database.
[0008] Optionally, before performing semantic disambiguation on the entity through the vector database, the vector database needs to be constructed, specifically including: establishing a target loss function and constructing a text vectorization model through the target loss function; inputting the geoscience operator name information and the geoscience algorithm name information into the text vectorization model, and outputting the vectorized geoscience operator name information and the vectorized geoscience algorithm name information; storing the vectorized operator name information and the vectorized geoscience algorithm name information as the quantized name information in the vector database.
[0009] Optionally, the semantic disambiguation on the entity through the vector database specifically includes: vectorizing the entity through the vectorization model, and calculating the similarity value between the vectorized entity and a target vector using cosine similarity, the target vector being any one of the quantized operator name information; determining whether the similarity value is greater than or equal to a preset similarity value; if the preset similarity value is greater than or equal to the preset similarity value, the name corresponding to the target vector is used as the name corresponding to the vectorized entity for semantic disambiguation.
[0010] Optionally, a three-layer architecture ontology model is constructed, the three-layer architecture ontology model being composed of an algorithm layer, an operator layer and an instance information layer; according to the data corresponding to the operator layer, attribute information corresponding to the nodes of the algorithm layer is output through the large language model, and the association relationship between the operator layer and the algorithm layer is output through the large language model; according to the three-layer architecture ontology model, the attribute information and the association relationship, a geoscience operator knowledge graph is constructed.
[0011] Optionally, according to the data corresponding to the operator layer, attribute information corresponding to the nodes of the algorithm layer is output through the large language model, specifically including: guiding the large language model to summarize and classify the operator data corresponding to the data of the operator layer through the construction of a prompt project, and outputting the attribute information corresponding to the nodes of the algorithm layer through the large language model.
[0012] Optionally, the prompt project is constructed, specifically including: obtaining globally and constructing a first prompt parameter according to the following formula:
[0013]
[0014] wherein, θ* is a first prompt parameter, d i is the i-th operator layer corresponding data, t i is the attribute information corresponding to the algorithm layer related node associated with the i-th operator layer corresponding data, is a training data set, and θ is a candidate prompt parameter, is the output generated under the action of the i-th operator layer corresponding data and the candidate prompt parameter, represents an adaptation function, ε is a generalization ability evaluation weight factor, and N is the total number of prompt samples used in the generalization ability evaluation process, represents a generalization ability evaluation function, θ j represents the j-th candidate prompt parameter used in the ability evaluation process, d j represents the j-th operator layer corresponding data used in the ability evaluation process, t j represents the attribute information corresponding to the algorithm layer related node corresponding to the j-th candidate prompt parameter; through gradient optimization, and according to the following formula, a second prompt parameter is constructed:
[0015]
[0016] wherein θ ** is a second prompt parameter, and η is a learning rate, is a gradient operator, is an expected value of a reward function, is a reward function, which is used to evaluate the matching degree between the algorithm layer attribute information and the real target attribute information t; a prompt engineering is constructed according to the second prompt parameter.
[0017] In a second aspect of the present application, a geoscience operator organization and question and answer retrieval device based on a large language model and a knowledge graph is provided. The device comprises an acquisition module and a processing module, wherein,
[0018] The acquisition module is configured to acquire a question segment input by a user in response to a question and answer operation of the user; input the question segment into a large language model to output an entity corresponding to the question segment; and input the question segment and the entity into the large language model, and the large language model generates at least one query statement corresponding to the question segment by combining a vector database.
[0019] The processing module is configured to construct a geoscience operator knowledge graph, and output a query result corresponding to the query statement by combining the geoscience operator knowledge graph through the large language model; and input the question segment and the query result into the large language model, and output a natural language reply result corresponding to the question segment.
[0020] In a third aspect of the present application, an electronic device is provided, comprising a processor, a memory, a user interface and a network interface, the memory is configured to store instructions, the user interface and the network interface are configured to communicate with other devices, and the processor is configured to execute the instructions stored in the memory to enable the electronic device to perform the method of any one of the above.
[0021] In a fourth aspect of the present application, a computer-readable storage medium is provided, which stores a computer program, and the computer program is configured to enable a processor to perform the method of any one of the above.
[0022] The one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:
[0023] 1. Obtain a question segment of user input; input the question segment into a large language model to output an entity corresponding to the question segment; input the question segment and the entity into the large language model, and the large language model generates at least one query statement corresponding to the question segment by combining a vector database; construct a geoscience operator knowledge graph, and output a query result corresponding to the query statement through the large language model combined with the geoscience operator knowledge graph; input the question segment and the query result into the large language model, and output a natural language reply result corresponding to the question segment, thereby simplifying the selection and decision-making process of a user with weak professional knowledge when facing a large number of geoscience operators and complex parameters, reducing the user's requirement for professional knowledge and operation experience, and enabling the user to quickly and accurately locate and select the most suitable operator combination for their own task requirements.
[0024] 2. The vectorization model is used to vectorize the entity, and the cosine similarity is used to calculate the similarity value between the vectorized entity and the target vector, and it is judged whether the similarity value is greater than or equal to a preset similarity value, and if the preset similarity value is greater than or equal to the preset similarity value, the name corresponding to the target vector is taken as the name corresponding to the vectorized entity for semantic disambiguation, thereby realizing high-precision semantic disambiguation of the entity in the user question, significantly reducing the mis-matching problem caused by semantic ambiguity in the entity matching process, and effectively improving the accuracy of knowledge graph query and the response accuracy of the question and answer system.
[0025] 3. A three-layer architecture ontology model is constructed by an algorithm layer, an operator layer and an instance information layer, and according to the data corresponding to the operator layer, the large language model is used to output attribute information corresponding to the nodes of the algorithm layer, and the large language model is used to output the association relationship between the operator layer and the algorithm layer; according to the three-layer architecture ontology model, the attribute information and the association relationship, the geoscience operator knowledge graph is constructed, thereby realizing clear hierarchical division and systematic organization among algorithms, operators and instance information, and significantly improving the structural and logical properties of the geoscience operator knowledge graph. BRIEF DESCRIPTION OF DRAWINGS
[0026] Figure 1 FIG. 1 is a flow diagram of a geoscience operator organization and question-answer retrieval method based on a large language model and a knowledge graph according to an embodiment of the present application;
[0027] Figure 2 FIG. 2 is a three-layer architecture ontology model diagram according to an embodiment of the present application;
[0028] Figure 3 FIG. 3 is a large language model API calling method diagram according to an embodiment of the present application;
[0029] Figure 4 FIG. 4 is a prompt engineering overall architecture diagram according to an embodiment of the present application;
[0030] Figure 5 FIG. 5 is a question-answer process diagram according to an embodiment of the present application;
[0031] Figure 6 FIG. 6 is a module diagram of a geoscience operator organization and question-answer retrieval device based on a large language model and a knowledge graph according to an embodiment of the present application;
[0032] Figure 7 FIG. 7 is a structural diagram of an electronic device according to an embodiment of the present application.
[0033] FIG. 8 is a structural diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0034] In order to enable a person skilled in the art to better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be clearly and completely described below in conjunction with the drawings in the embodiments of the present specification. Obviously, the described embodiments are only some of the embodiments of the present application, not all embodiments.
[0035] The terms used in the following embodiments of the present application are only for the purpose of describing the specific embodiments, and are not intended to be limiting to the present application. As used in the specification of the present application, the singular expression "one", "a", "said", "the above", "the", and "this" are intended to also include the plural expression, unless there is clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application means and includes any or all possible combinations of one or more listed items.
[0036] Hereinafter, the terms "first", "second" are only used for descriptive purposes and cannot be understood as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise specified.
[0037] In order for those skilled in the art to better understand the technical solutions of the present application, the present application will be further described in detail below with reference to the accompanying drawings.
[0038] Please refer to Figure 1 which shows a flowchart of a geoscience operator organization and question and answer retrieval method based on a large language model and a knowledge graph provided by the embodiments of the present application. The flowchart mainly includes the following steps: S101 to S104.
[0039] Step S101, in response to the user's question and answer operation, acquiring the user input question sentence.
[0040] Specifically, when the user performs a question and answer retrieval operation related to a geoscience operator, the user input question sentence is acquired. The user's question and answer sentence usually includes expressions related to geoscience algorithms, operators, software tools, parameter settings, execution history or specific instances, for example, the user may ask specific questions such as "What are the parameter settings required for spatial interpolation of land surface temperature data using Kriging interpolation method" or "How to use the raster clipping operator in QGIS software" and the like.
[0041] Step S102, inputting the question sentence into the large language model to output the entity corresponding to the question sentence.
[0042] Specifically, the user input question sentence is analyzed by the large language model, and the corresponding entity is output. The large language model includes but is not limited to: Qwen, ChatGPT, GPT-4, LLaMA, ChatGLM, ERNIE Bot, Pangu, and Xinghuo Cognition Large Model. The entity extraction adopts the method of prompt engineering, and the prompt words include input, role, task and constraint condition, wherein the role is set as an expert in the GIS field, so that the large language model focuses on the extraction of GIS-related entities, the task is to extract GIS-related entities from user question input, and the constraint condition ensures that the large language model only generates entities without outputting the analysis process.
[0043] Step S103, inputting the question sentence and the entity into the large language model, and the large language model generates at least one query sentence corresponding to the question sentence by combining the vector database.
[0044] Specifically, the large language model generates one or more query statements according to the user question, entities, and the geoscience operator knowledge graph structure and background knowledge. The background knowledge of the geoscience operator knowledge graph includes the labels and attribute relationships between knowledge picture nodes. If at least one query statement cannot be generated, the large language model is further triggered to perform a query statement optimization strategy, specifically including but not limited to: adjusting the query entity range, restructuring the query path, modifying the query statement syntax structure, or expanding the context semantics of the query, to again attempt to generate an effective query statement, while setting a predefined query retry number threshold. When the query optimization number reaches the retry number threshold and an effective query statement is still not successfully generated, the system terminates this query process and no longer attempts to generate a query statement, and feeds back corresponding prompt information to the user. The user can re-input the question segment according to the prompt or end the question and answer retrieval operation.
[0045] Step S104, constructing a geoscience operator knowledge graph, and outputting a query result corresponding to the query statement through a large language model combined with the geoscience operator knowledge graph.
[0046] Specifically, the query statement is executed in the geoscience operator knowledge graph in turn, and the structured knowledge obtained by the query is stored as a result. If the query fails or returns an empty result, the large language model optimizes the query statement and reattempts the query, with a maximum retry number set to a predefined threshold. When the threshold is reached and an effective result is still not successfully obtained, the query processing is terminated and no further attempts are made.
[0047] In one possible implementation, step S103 further includes: performing semantic disambiguation on the entities through a vector database, the vector database being used to store vectorized name information, the vectorized name information including vectorized geoscience operator name information and vectorized geoscience algorithm name information; and inputting the question segment and the entities after semantic disambiguation into the large language model, the large language model generating at least one query statement corresponding to the question segment by combining the vector database.
[0048] Specifically, spelling errors in entities involved in a user's question can cause query failures. To reduce such issues, semantic disambiguation of entities can be performed using a vector database, and the query can be obtained from the disambiguated entities. The vector database stores vectorized name information, including vectorized geoscientific operator names and vectorized geoscientific algorithm names. First, the entity names are fine-tuned using a text vectorization model. By constructing training data containing positive samples of similar entity pairs and negative samples of dissimilar entity pairs, the model can better capture the semantic relationships between entities within the domain, enhancing its ability to identify spelling errors, synonyms, and domain-specific naming differences. During training, a contrastive loss function is used. This loss function optimizes the vector distance between similar entities, bringing semantically similar entities closer together and pushing semantically unrelated entities further apart, thus ensuring that the model learns more accurate and consistent entity vector representations. The target loss function is established using the following formula, and the text vectorization model is constructed using the target loss function.
[0049]
[0050] Where L is the target loss function, M is the number of samples, and w d (y m ) represents the dynamic weight term, y m For, and w d (y m )=α+β·∣d m -μ∣, α and β are hyperparameters of the control weights, d m For the sample label, when d m =1 indicates a positive sample, when d m = 0 indicates a negative sample, μ represents the average Euclidean distance between the feature vectors of all samples in a batch used for training, and φ(d) m ) 2 Nonlinear distance mapping, and φ(d) m ) = log(1+d m ), ψ(d m () represents the non-linear penalty for negative samples. γ is a hyperparameter controlling the decay rate, τ is an improved margin threshold, τ=τ0+δ·Var(d), where τ0 is the initial threshold, δ is the adjustment coefficient, and Var(d) represents the variance of the distance between all sample pairs within the current batch used for training. To counteract the regularization term, KL() is the Kullback-Leibler divergence, ρ is the regularization weight, and a m b is the vectorized representation of the first entity text in the m-th sample pair. m In the m-th sample pair, the other one is different from a.m a m : vector representation of the text "Kriging interpolation algorithm"; b m : vector representation of the text "Kriging method in spatial interpolation". For another example, another sample pair can be negative samples: a m : vector representation of the text "raster clipping"; b m : vector representation of the text "vector buffer analysis". Therefore, a m ,b m are high-dimensional vector representations of entity texts processed by the text vectorization model, which are used to calculate distances (such as Euclidean distance) or divergences (such as KL divergence) to evaluate the semantic similarity between two text entities, so as to help the model distinguish positive and negative samples. Then, the geoscience operator name information and the geoscience algorithm name information are input into the text vectorization model, and the quantized geoscience operator name information and the vectorized geoscience algorithm name information are output. The vectorized operator name information and the vectorized geoscience algorithm name information are stored in the vector database as quantized name information, and the vector database can be a Weaviate vector database.
[0051] Finally, the vector database performs semantic disambiguation on entities, and the specific process is as follows: the vectorization model is used to vectorize the entities, and the cosine similarity is used to calculate the similarity value between the vectorized entities and the target vector, and the target vector is any vector in the quantized operator name information; the calculation formula of the cosine similarity is:
[0052]
[0053] wherein, cosine similarity is the similarity value between the vectorized entity and the target vector, a m ·b m represents the dot product of vectors a m and b m , and the calculation method is to multiply the corresponding dimension elements and sum them up:
[0054]
[0055] wherein, K represents the number of dimensions, a m,k is a m in the kth dimension, b m,k is b m in the kth dimension. ‖a m ‖ and ‖b m ‖ represent the modulus of vectors a m and b m , respectively, and the calculation method is the square root of the sum of squares of each dimension element:
[0056]
[0057] determining whether the similarity value is greater than or equal to a preset similarity value; if the preset similarity value is greater than or equal to the preset similarity value, taking the name corresponding to the target vector as the name corresponding to the vectorized entity for semantic disambiguation, if there are multiple target vectors satisfying the preset similarity threshold, taking the name corresponding to the target vector with the maximum similarity value in the multiple target vectors as the final name corresponding to the vectorized entity, to realize high-precision semantic disambiguation, avoid ambiguity and confusion caused by multiple candidate entities, further ensure the accuracy and stability of the entity recognition and knowledge graph query in the question and answer system, and improve the reliability of the question and answer response result. For example, one of the entities extracted in the question sentence is buffers, and after disambiguation, it is buffer, which is easier to query successfully. If the similarity value is less than the preset similarity value, further semantic analysis of the entity is performed through the large language model, and the candidate target vector of the entity is re-determined according to the context semantics; if the re-determined candidate target vector still does not reach the preset similarity value, the corresponding prompt information is fed back to the user to guide the user to express or supplement the necessary context information more clearly. Thus, the error matching caused by the fuzzy entity in the semantic disambiguation process is effectively avoided.
[0058] In a possible implementation, the step S104 further includes: constructing a three-layer architecture ontology model, the three-layer architecture ontology model being composed of an algorithm layer, an operator layer, and an instance information layer; outputting attribute information corresponding to nodes in the algorithm layer by the large language model according to data corresponding to the operator layer, and outputting an association relationship between the operator layer and the algorithm layer by the large language model; and constructing the geoscience operator knowledge graph according to the three-layer architecture ontology model, the attribute information, and the association relationship.
[0059] Specifically, the specific steps of constructing the geoscience operator knowledge graph are described with reference to steps S11 to S13.
[0060] In step S11, a three-layer architecture ontology model is constructed, the three-layer architecture ontology model being composed of an algorithm layer, an operator layer, and an instance information layer.
[0061] Specifically, please refer to Figure 2The application provides a three-layer architecture ontology model, and the algorithm layer of the three-layer architecture ontology model provides systematic and structured description for geographic processing algorithms. The algorithm is used for abstracting and defining general geographic processing tasks, and has high conceptuality and generality. In order to obtain information related to the operator in the operator layer, the application takes the official user manual or help document of the open source geoscience software as a data source, extracts the operator information based on the operator layer of the ontology model, and the information includes the name, description, input and output parameters and data types of the operator. In the implementation process, for the semi-structured expression of the operator information, the network crawler technology is used for automatic crawling. For the unstructured expression of the operator information, firstly, the network crawler technology is used for crawling the text of the operator description, and then the regular expression is used for pretreating the text, and the key text paragraphs that may contain the operator name, parameters and description are located. Then, the natural language processing (NLP) tool is used for entity recognition and dependency parsing, so that the related information of the operator name, function description and input and output parameters is accurately extracted. After the extracted operator information is induced and verified for multiple rounds, the operator information is integrated according to a unified semantic model. Finally, the structured operator information is stored into the geoscience operator knowledge graph based on the ontology model. Through the structured processing process, the operator information of numerous geoscience software can be systematically integrated, and comprehensive operator function characteristics and applicable scene reference bases are provided for users. This not only facilitates the recommendation of operators that are most suitable for the needs of users, but also can efficiently answer the queries related to the operators. When the operator data is summarized, necessary role information, task description, input data and output template and the like are provided to the large language model, so that the large language model can condense the algorithm-related information. The role defines the identity of the task performer, and can be set as "you are a GIS expert", so as to help the large language model understand the professional field of the task. Meanwhile, the task information is clear, and the model is required to extract and summarize the key information of the algorithm from the operator information, including the algorithm name, description, general input and general output name, description and the like. The input data is the name, description and parameter information of the operator. The output template requires the large language model to output the attribute information of the algorithm in a specified format. Through the prompt engineering in semantic disambiguation, the three-layer architecture ontology model can refine the related node information of the algorithm layer from the operator layer data, realize the hierarchical mapping between the algorithm and the operator, and output the information in a structured manner, so as to ensure the accurate extraction and expression of the algorithm information. The above operation completes the summarization of the operator, but does not output the information that the operator belongs to which algorithm, therefore, the large language model is called again to classify the operator. In the operator classification process, the prompt engineering needs to set clear roles, tasks, output templates and the like. The role also defines the identity of the model performing the task, and ensures the professionalism of the model. The task requires the large language model to divide the operator into the category to which the operator belongs based on the input data, that is, the operator name, description, parameter information and the algorithm category, description and the like.The output template requires the category to which the large language model output operator belongs and its classification explanation. At the same time, the large language model quickly understands the task requirements through examples. At the same time, for the response that does not meet the expectation, a compensation mechanism is set to detect the divided category name, and the large language model is returned to the operator of the divided classification category that does not belong to the given algorithm category for re-classification. This process ensures that the operator can be classified into the correct algorithm category.
[0062] In step S12, according to the operator layer corresponding data, the attribute information corresponding to the algorithm layer related node is output by the large language model, and the association relationship between the operator layer and the algorithm layer is output by the large language model.
[0063] Specifically, the large language model is guided to summarize and classify the operator data operator layer corresponding data through the construction of the prompt engineering, and the attribute information corresponding to the algorithm layer related node is output by the large language model. That is, in order to construct the association relationship between the algorithm layer and the operator layer, and realize the induction, summary and classification of the operator information. The present application guides the large language model to induce and classify the operator data through the construction of the prompt engineering, and finally stores the attribute information of the algorithm layer related node into the algorithm operator knowledge graph. The prompt engineering can be constructed by the following formula:
[0064]
[0065] Wherein, θ * is the first prompt parameter, d i is the i-th operator layer corresponding data, t i is the attribute information corresponding to the algorithm layer related node associated with the i-th operator layer corresponding data, is the training data set, and θ is the candidate prompt parameter, is the output generated under the action of the i-th operator layer corresponding data and the candidate prompt parameter, represents the fitness function, ε is the generalization ability evaluation weight factor, and N is the total number of prompt samples used in the generalization ability evaluation process, represents the generalization ability evaluation function, θ j represents the j-th candidate prompt parameter used in the ability evaluation process, d j represents the j-th operator layer corresponding data used in the ability evaluation process, t j represents the attribute information corresponding to the algorithm layer related node corresponding to the j-th candidate prompt parameter.
[0066] Through gradient optimization, the second prompt parameter is constructed according to the following formula:
[0067]
[0068] Wherein, θ** is a second prompt parameter, and η is a learning rate, is a gradient operator, is an expected value of a reward function, is a reward function, and the reward function is used to evaluate the matching degree between the algorithm layer attribute information and the true target attribute information t; a prompt engineering is constructed according to the second prompt parameter. Please refer to , which shows a large language model API calling method schematic diagram provided in the embodiments of the present application. Please refer to Figure 3 , which shows a prompt engineering overall architecture schematic diagram provided in the embodiments of the present application. Figure 4
[0069] Step S13, according to the three-layer architecture ontology model, attribute information and association relationship, a geoscience operator knowledge graph is constructed.
[0070] Specifically, the historical execution information in the geoscience software is stored into the Neo4j graph database, and the instance information in the geoscience operator knowledge graph is further perfected. In the process of executing the operator in the geoscience software, the relevant processing information is usually stored in the historical execution information, and these records contain the execution situation of the operator, input and output data, parameter setting and other key information. By obtaining these historical execution information, and according to the three-layer architecture ontology model, attribute information and association relationship, the geoscience operator knowledge graph is constructed.
[0071] Step S105, input the question segment and the query result into the large language model, and output the natural language reply result corresponding to the question segment.
[0072] Specifically, the user question and the query result are passed to the large language model, and the reply result is returned through natural language processing after further processing and perfection by the large language model. Please refer to Figure 5 , which shows a question and answer process schematic diagram provided in the embodiments of the present application.
[0073] By adopting the above method, the present application obtains the question segment input by the user; inputs the question segment into the large language model to output the entity corresponding to the question segment; inputs the question segment and the entity into the large language model, and the large language model generates at least one query sentence corresponding to the question segment by combining the vector database; constructs the geoscience operator knowledge graph, and outputs the query result corresponding to the query sentence by combining the geoscience operator knowledge graph through the large language model; inputs the question segment and the query result into the large language model, and outputs the natural language reply result corresponding to the question segment, thereby simplifying the selection and decision-making process of the user with weak professional knowledge when facing a large number of geoscience operators and complex parameters, reducing the requirement of the user for professional knowledge and operation experience, and enabling the user to quickly and accurately locate and select the most suitable operator combination for the task requirement.
[0074] Please refer to Figure 6 , which shows a module schematic diagram of a geoscience operator organization and question and answer retrieval device based on a large language model and a knowledge graph provided by an embodiment of the application. The device comprises an acquisition module 61 and a processing module 62, wherein,
[0075] The acquisition module 61 is configured to acquire a question segment input by a user in response to a question and answer operation of the user; input the question segment into a large language model to output an entity corresponding to the question segment; and input the question segment and the entity into the large language model, and the large language model generates at least one query statement corresponding to the question segment by combining a vector database.
[0076] The processing module 62 is configured to construct a geoscience operator knowledge graph, and query a query result corresponding to the query statement by combining the large language model and the geoscience operator knowledge graph; input the question segment and the query result into the large language model, and output a natural language reply result corresponding to the question segment.
[0077] In a possible implementation, the processing module 62 is configured to input the question segment and the entity into the large language model, and the large language model generates at least one query statement corresponding to the question segment by combining the vector database, and specifically comprises: performing semantic disambiguation on the entity by the vector database, the vector database is configured to store vectorized name information, and the vectorized name information comprises vectorized geoscience operator name information and vectorized geoscience algorithm name information; input the question segment and the entity after semantic disambiguation into the large language model, and the large language model generates at least one query statement corresponding to the question segment by combining the vector database.
[0078] In a possible implementation, before performing semantic disambiguation on the entity by the vector database, the processing module 62 is configured to construct the vector database, and specifically comprises: establishing a target loss function, and constructing a text vectorization model by the target loss function; input the geoscience operator name information and the geoscience algorithm name information into the text vectorization model, and output the vectorized geoscience operator name information and the vectorized geoscience algorithm name information; and store the vectorized geoscience operator name information and the vectorized geoscience algorithm name information as the vectorized name information in the vector database.
[0079] In a possible implementation, the processing module 62 is configured to perform semantic disambiguation on the entity by the vector database, specifically including: vectorizing the entity by the intrinsic vectorization model, and calculating a similarity value between the vectorized entity and a target vector by using cosine similarity, the target vector being any one of the vectors of the quantized operator name information; determining whether the similarity value is greater than or equal to a preset similarity value; and if the preset similarity value is greater than or equal to the preset similarity value, taking the name corresponding to the target vector as the name corresponding to the vectorized entity for semantic disambiguation.
[0080] In a possible implementation, the processing module 62 is configured to construct a three-layer architecture ontology model, the three-layer architecture ontology model being composed of an algorithm layer, an operator layer and an instance information layer; output attribute information corresponding to a node of the algorithm layer by the large language model according to the data corresponding to the operator layer, and output an association relationship between the operator layer and the algorithm layer by the large language model; and construct the geo-algorithm operator knowledge graph according to the three-layer architecture ontology model, the attribute information and the association relationship.
[0081] In a possible implementation, the processing module 62 is configured to output attribute information corresponding to a node of the algorithm layer by the large language model according to the data corresponding to the operator layer, specifically including: guiding the large language model to summarize and classify the data corresponding to the operator layer by constructing a prompt engineering, and outputting the attribute information corresponding to the node of the algorithm layer by the large language model.
[0082] In a possible implementation, the processing module 62 is configured to construct a prompt engineering, specifically including: obtaining globally, and constructing a first prompt parameter according to the following formula:
[0083]
[0084] wherein θ * is the first prompt parameter, d i is the i th operator layer corresponding data, t i is attribute information corresponding to an algorithm layer related node associated with the i th operator layer corresponding data, is a training data set, θ is a candidate prompt parameter, is an output generated under the i th operator layer corresponding data and the candidate prompt parameter, represents an adaptation degree function, ε is a generalization ability evaluation weight factor, and N is the total number of prompt samples used in the generalization ability evaluation process, represents a generalization ability evaluation function, θ j represents the j th candidate prompt parameter used in the ability evaluation process, d j represents the j th operator layer corresponding data used in the ability evaluation process, t jrepresents attribute information corresponding to an algorithm layer related node corresponding to the jth candidate prompt parameter; through gradient optimization, and according to the following formula, the second prompt parameter is constructed:
[0085]
[0086] wherein, θ ** is the second prompt parameter, η is a learning rate, is a gradient operator, is an expected value of a reward function, is a reward function, and the reward function is used to evaluate the matching degree between the algorithm layer attribute information and the real target attribute information t; a prompt project is constructed according to the second prompt parameter.
[0087] It should be noted that: the apparatus provided in the above embodiments, when realizing its functions, only takes the above-mentioned division of each functional module as an example for illustration, and in actual application, the above-mentioned functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above-described functions. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be repeated here.
[0088] The present application also provides an electronic device. Referring to Figure 7 , Figure 7 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. The electronic device can include: at least one processor 701, at least one communication bus 702, a user interface 703, at least one network interface 704, and a memory 705.
[0089] The communication bus 702 is used to realize the connection and communication between the components.
[0090] The user interface 703 can include a display screen (Display), a camera (Camera), and optionally the user interface 703 can also include a standard wired interface, a wireless interface.
[0091] The network interface 704 can optionally include a standard wired interface, a wireless interface (such as a WI-FI interface).
[0092] The processor 701 can include one or more processing cores. The processor 701 connects various parts within the server through various interfaces and lines, performs various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 705, and calling data stored in the memory 705. Alternatively, the processor 701 can be implemented in at least one of a hardware form of a digital signal processing (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 701 can integrate a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes operating systems, user interfaces, and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; and the modem is used for processing wireless communication. It can be understood that the above-mentioned modem can also not be integrated into the processor 701, but can be realized by a separate chip.
[0093] The memory 705 can include a random access memory (RAM) and a read-only memory (ROM). Optionally, the memory 705 includes a non-transitory computer-readable storage medium. The memory 705 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 705 can include a program storage area and a data storage area, wherein the program storage area can store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area can store data involved in the above-mentioned various method embodiments, etc. The memory 705 can also be at least one storage device located away from the aforementioned processor 701. Referring to Figure 7 The memory 705 as a computer storage medium can include an operating system, a network communication module, a user interface module, and a geoscience operator organization and question and answer retrieval application based on a large language model and a knowledge graph.
[0094] In Figure 7In the electronic device shown, the user interface 703 is mainly used to provide an interface for the user to input, and obtain data input by the user; and the processor 701 can be used to call the geoscience operator organization and question-answer type retrieval application program stored in the memory 705 based on a large language model and a knowledge graph, and when executed by one or more processors 701, causes the electronic device to perform the method described in one or more of the above embodiments. It should be noted that, for the foregoing method embodiments, in order to simply describe, they are all expressed as a combination of a series of actions, but those skilled in the art should know that the present application is not limited to the order of the actions described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0095] The present application also provides a computer-readable storage medium storing instructions. When executed by one or more processors, the electronic device performs the method described in one or more of the above embodiments.
[0096] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0097] In several embodiments provided in the present application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division, and actual implementation can have another division manner. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some service interface, device or unit, and can be electrical or other forms.
[0098] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e. they can be located in one place, or distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the present embodiment.
[0099] In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically, or two or more units can be integrated into one unit. The integrated unit can be realized in the form of hardware, or in the form of a software functional unit.
[0100] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable memory. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a memory and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the embodiments of the present application. The aforementioned memory includes: a U disk, a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.
[0101] The above is only exemplary embodiments of the present application, and cannot limit the scope of the present application. That is, any equivalent changes and modifications made in accordance with the teachings of the present application are still within the scope of the present application.
[0102] The present application is intended to cover any variations, uses or adaptive changes of the present application, which follow the general principles of the present application and include common knowledge or conventional technical means in the technical field not disclosed in the present application.
Claims
1. A geoscientific operator organization and question-answering retrieval method based on large language models and knowledge graphs, characterized in that, The method includes: In response to a user's question-and-answer action, the question segment input by the user is obtained; The question segment is input into the large language model to output the entity corresponding to the question segment; The question segment and the entity are input into the large language model, which generates at least one query statement corresponding to the question segment by combining a vector database. A geoscientific operator knowledge graph is constructed, and the query results corresponding to the query statement are output through the large language model combined with the geoscientific operator knowledge graph. The construction of the geoscientific operator knowledge graph specifically includes: constructing a three-layer ontology model, which consists of an algorithm layer, an operator layer, and an instance information layer; outputting attribute information corresponding to relevant nodes of the algorithm layer through the large language model based on the data corresponding to the operator layer, and outputting the association relationship between the operator layer and the algorithm layer through the large language model; the outputting attribute information corresponding to relevant nodes of the algorithm layer through the large language model based on the data corresponding to the operator layer specifically includes: guiding the large language model to summarize and classify the operator data corresponding to the operator layer through a suggestion engineering process, and outputting the attribute information corresponding to relevant nodes of the algorithm layer through the large language model; the construction of the suggestion engineering specifically includes: globally acquiring and constructing a first suggestion parameter according to the following formula: ; in, The first prompt parameter, For the first The corresponding data for each of the aforementioned operator layers. In order to be with the first The attribute information corresponding to the relevant nodes of the algorithm layer associated with the data of each operator layer. For the training dataset, For candidate suggestion parameters, For the first The output generated under the action of the corresponding data of the operator layer and the candidate prompt parameters. Represents the fitness function. As a weighting factor for generalization ability assessment, This represents the total number of cue samples used in the generalization ability assessment process. This represents the function for evaluating generalization ability. The first one used in the competency assessment process The candidate prompt parameters, The first one used in the competency assessment process The corresponding data for each of the aforementioned operator layers. Indicates the first The attribute information corresponding to the relevant nodes of the algorithm layer for each of the candidate suggestion parameters; through gradient optimization, and according to the following formula, the second suggestion parameter is constructed: ; in, The second prompt parameter, For learning rate, For gradient operators, Let the expected value of the reward function be... The reward function is used to evaluate the attribute information of the algorithm layer. With the actual target attribute information The degree of matching between them; constructing the prompting project according to the second prompting parameter; constructing the geoscience operator knowledge graph according to the three-layer architecture ontology model, the attribute information and the association relationship; The question segment and the query result are input into the large language model, and the natural language response result corresponding to the question segment is output.
2. The method according to claim 1, characterized in that, The step involves inputting the question segment and the entity into the large language model, whereby the large language model, by combining a vector database, generates at least one query statement corresponding to the question segment, specifically including: The entity is semantically disambiguated using the vector database, which stores vectorized name information, including vectorized geoscientific operator name information and vectorized geoscientific algorithm name information. The question segment and the entity after semantic disambiguation are input into the large language model, which generates at least one query statement corresponding to the question segment by combining a vector database.
3. The method according to claim 2, characterized in that, Before performing semantic disambiguation on the entities using the vector database, the vector database needs to be constructed, specifically including: Establish a target loss function, and construct a text vectorization model using the target loss function; The geoscience operator name information and the geoscience algorithm name information are input into the text vectorization model, and the quantized geoscience operator name information and the vectorized geoscience algorithm name information are output. The vectorized operator name information and the vectorized geoscience algorithm name information are stored in the vector database as the quantized name information.
4. The method according to claim 3, characterized in that, The semantic disambiguation of the entities using a vector database specifically includes: The entity is vectorized using the aforementioned vectorization model, and the similarity value between the vectorized entity and the target vector is calculated using cosine similarity. The target vector is any vector among the quantized operator name information. Determine whether the similarity value is greater than or equal to a preset similarity value; If the preset similarity value is greater than or equal to the preset similarity value, then the name corresponding to the target vector is used as the vectorized name corresponding to the entity for semantic disambiguation.
5. A geoscientific operator organization and question-answering retrieval device based on a large language model and knowledge graph, characterized in that, The device includes an acquisition module and a processing module, wherein, The acquisition module is used to respond to the user's question and answer operation, acquire the question segment input by the user; input the question segment into a large language model to output the entity corresponding to the question segment; input the question segment and the entity into the large language model, and the large language model generates at least one query statement corresponding to the question segment by combining a vector database; The processing module is used to construct a geoscientific operator knowledge graph and query the query results corresponding to the query statement by combining the geoscientific operator knowledge graph with the large language model. The construction of the geoscientific operator knowledge graph specifically includes: constructing a three-layer ontology model, which consists of an algorithm layer, an operator layer, and an instance information layer; outputting attribute information corresponding to relevant nodes of the algorithm layer through the large language model based on the data corresponding to the operator layer, and outputting the association relationship between the operator layer and the algorithm layer through the large language model; the outputting attribute information corresponding to relevant nodes of the algorithm layer through the large language model based on the data corresponding to the operator layer specifically includes: guiding the large language model to summarize and classify the operator data corresponding to the operator layer through a hinting project, and outputting the attribute information corresponding to relevant nodes of the algorithm layer through the large language model; the construction of the hinting project specifically includes: acquiring globally and constructing a first hint parameter according to the following formula: ; in, The first prompt parameter, For the first The corresponding data for each of the aforementioned operator layers. In order to be with the first The attribute information corresponding to the relevant nodes of the algorithm layer associated with the data of each operator layer. For the training dataset, For candidate suggestion parameters, For the first The output generated under the action of the corresponding data of the operator layer and the candidate prompt parameters. Represents the fitness function. As a weighting factor for generalization ability assessment, This represents the total number of cue samples used in the generalization ability assessment process. This represents the function for evaluating generalization ability. The first one used in the competency assessment process The candidate prompt parameters, The first one used in the competency assessment process The corresponding data for each of the aforementioned operator layers. Indicates the first The attribute information corresponding to the relevant nodes of the algorithm layer for each of the candidate suggestion parameters; through gradient optimization, and according to the following formula, the second suggestion parameter is constructed: ; in, The second prompt parameter, For learning rate, For gradient operators, Let the expected value of the reward function be... The reward function is used to evaluate the attribute information of the algorithm layer. With the actual target attribute information The degree of matching between them; constructing the prompting project according to the second prompting parameter; constructing the geoscience operator knowledge graph according to the three-layer architecture ontology model, the attribute information and the association relationship; inputting the question segment and the query result into the large language model, and outputting the natural language response result corresponding to the question segment.
6. An electronic device, characterized in that, The device includes a processor, a communication bus, a user interface, a network interface, and a memory. The memory is used to store instructions. The user interface and the network interface are used to communicate with other devices. The processor is used to execute the instructions stored in the memory to cause the electronic device to perform the method as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed, perform the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Task processing method and automatic question answering method
CN117193964A
Question and answer method and system based on tin smelting knowledge graph
CN118779424A