Aircraft system knowledge graph construction method, device, equipment and medium
Through the construction method of aircraft system knowledge graph, automatic batch triple extraction is used to use ChatGLM3-6B large model to solve the problems of low efficiency and high cost in the existing technology, and the rapid and accurate expression of aircraft system knowledge and maintenance process are realized. standardization.
Patent Information
- Application Number
- CN202410905037.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-11-01
AI Technical Summary
In the prior art, a large number of manual annotations and multiple calls to large models are required during the construction of the aircraft system knowledge graph, resulting in low efficiency and high cost of triple extraction, making it difficult to quickly and accurately master aircraft system knowledge.
A method for building an aircraft system knowledge graph is proposed. By obtaining the aircraft system knowledge text data to be extracted for preprocessing, manually extracting triples and modifying them into a format that can be recognized by the ChatGLM3-6B large model, and performing fine-tuning large model Localized deployment, using Python scripts to call the fine-tuned model for automatic batch extraction of triples, and generate evaluation indicators based on BERT-SCORE, and finally construct a knowledge graph through manual correction.
It improves the efficiency and accuracy of triple extraction in specific fields, reduces manual annotation work, realizes the intuitive expression of aircraft system knowledge and standardizes the maintenance process, and reduces maintenance costs.
Smart Images

Figure CN118886491A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of natural language processing and computer software technology, and in particular, relates to a method, device, equipment and medium for constructing an aircraft system knowledge graph. Background Art
[0002] With the continuous development of science and technology, the complexity of aircraft systems has increased, and the difficulty and cost of maintenance after a failure has also continued to increase. When performing aircraft maintenance operations, it is often time-consuming and labor-intensive to consult the aircraft-related maintenance manuals, and the aircraft maintenance manuals cannot intuitively represent the complex structure of the aircraft system and the operating logic between the various components, resulting in low efficiency and high costs for technicians during maintenance operations.
[0003] Knowledge graphs are usually composed of nodes and edges. Each node represents an "entity" and each edge is a "relationship" between entities. Each entity can represent a subsystem, component, operation, fault type, etc. in an aircraft system, and each two entities are connected by an edge to express the relationship between the two connected entities. Knowledge graphs are a knowledge base that extracts entities and relationships from unstructured knowledge and stores entities and their relationships in the form of a directed graph, which can achieve a unified and standardized expression of unstructured knowledge.
[0004] The use of knowledge graphs can integrate unstructured aircraft system knowledge, convert unstructured knowledge into intuitive data views, and provide correlation information between aircraft systems and components, which helps to quickly and accurately grasp the relevant knowledge of aircraft systems; knowledge graphs can also include a chain process from fault phenomena to fault type confirmation to troubleshooting and maintenance operations, which helps to standardize and optimize maintenance processes and ensure that maintenance work is performed according to established optimal processes.
[0005] Currently, most knowledge graph construction tasks are performed using neural networks, which are mainly divided into two parts: entity recognition and relationship extraction. Before performing entity recognition and relationship extraction tasks, a large amount of manual annotation of text is required, which has high labor costs. Large language models are usually pre-trained on a large amount of text data, which can better understand the semantics and contextual information in natural language. Only a small amount of data needs to be fine-tuned on the large language model, and the fine-tuned large model can perform triple extraction tasks in specific fields, greatly reducing the cost of triple extraction.
[0006] The extraction of triples from the fine-tuned large model currently mostly stays at the extraction of single text data in the form of dialogue. When a large amount of text data to be extracted is required, the fine-tuned large model needs to be called multiple times, which has low extraction efficiency and requires a lot of manpower. Therefore, how to improve the efficiency of using the fine-tuned large model to extract triples in specific fields is a problem that needs to be solved. Summary of the invention
[0007] In view of this, the present invention aims to overcome the deficiencies of the above-mentioned problems in the prior art and proposes a method, device, equipment and medium for constructing an aircraft system knowledge graph.
[0008] To achieve the above object, the technical solution of the present invention is achieved as follows:
[0009] The first aspect of the present invention provides a method for constructing an aircraft system knowledge graph, comprising the following steps:
[0010] Step 1: Obtain the aircraft system knowledge text data to be extracted and preprocess the text data;
[0011] Step 2: Manually extract some of the preprocessed text data to obtain triplets for fine-tuning the large model;
[0012] Step 3: Localize the ChatGLM3-6B large model and modify the aircraft system text data and the corresponding manually extracted triples into a prompt format recognizable by ChatGLM3-6B;
[0013] Step 4: Fine-tune the ChatGLM3-6B basic model;
[0014] Step 5: Use the Python script to call the fine-tuned ChatGLM3-6B model to automatically batch extract triples from the aircraft system knowledge text data and generate evaluation indicators based on BERT-SCORE;
[0015] Step 6: Manually correct the extracted triples and construct the knowledge graph.
[0016] Furthermore, the step 1 specifically includes:
[0017] Obtain the aircraft system knowledge text data to be extracted from the aircraft AMM manual and FIM manual, use the Python script program to separate each text data with a period, list each aircraft system knowledge text data to be extracted as a separate line, determine each relationship type that may be contained in the aircraft system knowledge text data triple, and ensure that at least 5 knowledge text data of each relationship type are included. For relationship types that appear more frequently, at least 10 knowledge text data should be retained.
[0018] Furthermore, the step 2 specifically includes:
[0019] The pre-processed aircraft system knowledge text data is manually extracted into triples, whose format is “E b ,R,E e ”, where E brepresents the head entity, R represents the relationship between two entities, and E e Indicates the tail entity. When a piece of knowledge text data contains multiple sets of triples, all triples are extracted. Its format is "E b ,R,E e .E b ,R,E e ……”.
[0020] Furthermore, the step 3 specifically includes:
[0021] Deploy the ChatGLM3-6B large model locally to ensure that the local hardware can meet the minimum operating conditions of the ChatGLM3-6B large model and test whether the ChatGLM3-6B large model can run normally;
[0022] The aircraft system text data and the corresponding manually extracted triples are modified into a prompt format recognizable by ChatGLM3-6B. The specific format is: {"conversations":[{"role":"user","content":"The aircraft system knowledge text data to be extracted."},{"role":"assistant","content":"E b ,R,E e ."}]}.
[0023] Furthermore, the step 4 specifically includes:
[0024] The manually extracted triplets are divided into training set, validation set and test set, and the ChatGLM3-6B basic model is fine-tuned using the low-rank adaptive fine-tuning technique (LORA);
[0025] Fine-tune parameter settings in the lora.yaml file;
[0026] Run python finetune_demo\finetune_hf.py finetune_demo\datachatglm3_6bfinetune_demo\configs\lora.yaml in the terminal to run the fine-tuning program;
[0027] Run python inference_hf.py . / output / checkpoint-3000 --prompt "Aircraft system knowledge text data to be extracted" in the terminal to extract a piece of knowledge text data and verify the fine-tuning results of the large model.
[0028] Furthermore, the step 5 specifically includes:
[0029] The remaining aircraft system knowledge text data to be extracted is stored in the INPUT_FILE file as the input file. If the precision, recall rate, and harmonic mean of precision and recall rate need to be output for the batch extraction results, the manual extraction results need to be placed in the GROUND_TRUTH_FILE file as a reference file when using BERT_SCORE for semantic similarity calculation;
[0030] The process of automatic batch extraction of triples is as follows: load the fine-tuned ChatGLM3-6B model and the corresponding tokenizer, read the INPUT_FILE file to be extracted, use the loaded model to extract triples for each line of text, and collect the results into a list. After the extraction is completed, convert the result list into a pandas DataFrame and save the DataFrame to the output file (OUTPUT_FILE) in CSV format;
[0031] The generated extraction results OUTPUT_FILE (CSV format file) and GROUND_TRUTH_FILE files are used as input to calculate the BERTScore between the candidate text (OUTPUT_FILE) and the reference text (GROUND_TRUTH_FILE). This score uses the BERT model to evaluate the semantic similarity and obtains the average precision (Precision), recall (Recall) and F1 score of the extraction result file OUTPUT_FILE relative to the reference text (GROUND_TRUTH_FILE). The calculation formula is as follows:
[0032] The calculation formula of recall is:
[0033]
[0034] Among them, T ic is the number of tokens matched by token i in the candidate text in the reference text, T iR is the total number of token i in the reference text;
[0035] The calculation formula of precision is:
[0036]
[0037] Among them, T iE is the number of tokens matched by token i in the reference text in the candidate text, T a is the total number of tokens in the candidate text;
[0038] The F1 score is the harmonic mean of precision and recall, and is calculated as follows:
[0039]
[0040] Among them, P BERT is the accuracy, R BERT is the recall rate.
[0041] Furthermore, the step 6 specifically includes:
[0042] Import the generated triples OUTPUT_FILE into an Excel table, and then modify the extraction results through manual screening; save the triples in the Neo4j graph database to complete the construction of the knowledge graph.
[0043] A second aspect of the present invention provides an aircraft system knowledge graph construction device, comprising:
[0044] The first module is used to obtain the aircraft system knowledge text data to be extracted and pre-process the text data;
[0045] The second module is used to manually extract some of the preprocessed text data to obtain triplets for fine-tuning the large model;
[0046] The third module is used to localize the deployment of the ChatGLM3-6B large model and modify the aircraft system text data and the corresponding manually extracted triples into a prompt format recognizable by ChatGLM3-6B;
[0047] The fourth module is used to fine-tune the ChatGLM3-6B basic model;
[0048] The fifth module is used to use Python scripts to call the fine-tuned ChatGLM3-6B model to automatically batch extract triples from aircraft system knowledge text data and generate evaluation indicators based on BERT-SCORE;
[0049] The sixth module is used to manually correct the extracted triples and construct the knowledge graph.
[0050] A third aspect of the present invention provides an electronic device, comprising a processor and a memory that is communicatively connected to the processor and is used to store instructions executable by the processor, wherein the processor is used to execute the above-mentioned method for constructing an aircraft system knowledge graph.
[0051] A fourth aspect of the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-mentioned method for constructing an aircraft system knowledge graph.
[0052] Compared with the prior art, the aircraft system knowledge graph construction method, device, equipment and medium described in the present invention have the following advantages:
[0053] 1. The present invention stores the unstructured knowledge of the aircraft system in a knowledge graph to form an intuitive graph database, which helps to quickly and accurately grasp the relevant knowledge of the aircraft system, standardize and optimize the maintenance process, and enhance the explainability of the maintenance process.
[0054] 2. The present invention proposes a method for triple extraction using a fine-tuned large model. The large language model is pre-trained on a large amount of text data, and can better understand the semantics and contextual information in natural language. After fine-tuning, it can improve the accuracy of triple extraction in specific fields, eliminating the need for a large amount of manual annotation of the data set before using a neural network for triple extraction.
[0055] 3. The original large model for triple extraction method can only realize the triple extraction of single text data in a conversational style. The present invention uses Python script to call the fine-tuned ChatGLM3-6B model, which can automatically batch extract triples for all text data to be extracted in the target file, and automatically save the extracted triples in a CSV file, which can greatly improve the efficiency of extracting triples for a large number of data samples, and can also output the average precision (Precision), recall (Recall) and F1 score relative to the reference text. When extracting triples for an aircraft system text data set with a sample size of 100, the obtained F1 value is 93.32%. The present invention has a wide range of practical application value, can be applied in the fields of aircraft fault detection and knowledge graphs, and is helpful to better solve practical problems. 。 BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:
[0057] Figure 1 A flowchart of a method for constructing an aircraft system knowledge graph provided by the first embodiment of the present invention;
[0058] Figure 2 Another embodiment of the present invention provides a flowchart for using a Python script to call a fine-tuned ChatGLM3-6B model to automatically batch extract triples from aircraft system knowledge text data and generate evaluation indicators based on BERT-SCORE. DETAILED DESCRIPTION
[0059] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0060] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and the like are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first", "second", and the like may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "multiple" means two or more.
[0061] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood by specific circumstances.
[0062] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0063] Embodiment 1:
[0064] like Figure 1-2 As shown, the flowchart of the method for constructing an aircraft system knowledge graph based on fine-tuning a large model and batch extraction of triples provided in this embodiment includes the following specific steps:
[0065] Step 1: Obtain the aircraft system knowledge text data to be extracted and preprocess the text data.
[0066] In this step, the aircraft system knowledge text data to be extracted is obtained from the aircraft AMM manual and FIM manual, and each piece of text data is separated by a period using a Python script program. Each piece of aircraft system knowledge text data to be extracted is listed as a separate line, and each relationship type that may be contained in the aircraft system knowledge text data triple is determined to ensure that at least 5 pieces of knowledge text data of each relationship type are included. For relationship types that appear more frequently, at least 10 pieces of knowledge text data should be retained.
[0067] In this embodiment, the AMM (Aircraft Maintenance Manual) and FIM (Fault Isolation Manual) are important technical documents used in aircraft maintenance and troubleshooting. The AMM manual includes a detailed description of each aircraft system, including components and working principles; specific steps for inspection, maintenance, parts replacement, and testing of each aircraft system and component; the FIM manual is a set of detailed fault diagnosis and isolation guidelines, including each possible fault phenomenon of the aircraft system and the corresponding troubleshooting process, which is intended to help maintenance personnel quickly and accurately locate the cause of the fault in the aircraft system and provide corresponding repair suggestions. By extracting unstructured data from the AMM manual and the FIM manual, unstructured knowledge is converted into an intuitive data view, providing the association information between the various systems and components of the aircraft, which helps to quickly and accurately master the relevant knowledge of the aircraft system; the knowledge graph can also include a chain process from fault phenomenon to fault type confirmation to troubleshooting and maintenance operations, which helps to standardize and optimize the maintenance process and ensure that the maintenance work is performed according to the established best process.
[0068] In order to make the fine-tuned large model better perform the triple extraction task, it is necessary to use Python scripts to preprocess the unstructured data, separate each text data with English periods, and list each aircraft system knowledge text data to be extracted in a separate line. Entering a long text at one time will affect the triple extraction effect of the large model. Determine all possible relationship types in all text data and limit the triple relationship types after extraction. Taking the aircraft engine bleed air system as an example, its triple relationship types are: "control", "contain", "location", "function", "open", "close", "supply", "supply(by)", "interface", "sources", "indicate", "use", "then", "perform", "failure mode", "reasons", "appear", "operate", "check". For relationship types with a high frequency of occurrence, at least 10 text data should be retained in the training set to increase the accuracy of their extraction.
[0069] Step 2: Manually extract some of the preprocessed text data to obtain triplets for fine-tuning the large model;
[0070] In this embodiment, the pre-processed aircraft system knowledge text data is manually extracted into triples, which are used as training sets and validation sets for fine-tuning the large model. The format is “Eb ,R,E e ”, where E b represents the head entity, R represents the relationship between two entities, and E e Represents the tail entity, taking the aircraft engine bleed air system as an example:
[0071] The original text data is: "At low engine speed the 5th stage check valves prevent reverse flow.". After manual extraction of triples, the triplet obtained is: "the 5th stage check valve, function, prevent reverse flow".
[0072] When a piece of knowledge text data contains multiple sets of triples, all triples should be extracted, and the format is "E b ,R,E e .E b ,R,E e ...", taking the aircraft engine bleed air system as an example:
[0073] The original text data is "At low engine speed the high stage regulators and highstage valves control the pressure of the engine bleed air.". After manual extraction of triples, the triples obtained are: "at low engine speed,open,high stage regulator.at lowengine speed,open,high stage valve.high stage regulator,control,the pressureof the engine bleed air.high stage valve,control,the pressure of the engine bleed air."
[0074] Step 3: Localize the ChatGLM3-6B large model and modify the aircraft system text data and the corresponding manually extracted triples into a prompt format recognizable by ChatGLM3-6B;
[0075] In this embodiment, it is ensured that the local hardware can meet the minimum conditions for the operation of the ChatGLM3-6B large model, and the basic ChatGLM3-6B large model is tested to be able to run normally; the ChatGLM3-6B large model is locally deployed for the purpose of fine-tuning the large model locally next. The aircraft system text data and the corresponding manually extracted triples are modified into the prompt format recognizable by ChatGLM3-6B. Specifically, its format is: {"conversations":[{"role":"user","content":"Text data of aircraft system knowledge to be extracted."},{"role":"assistant","content":"E b ,R,E e ."}]}。
[0076] Step 4: Fine-tune the ChatGLM3-6B basic large model;
[0077] In this embodiment, the manually extracted triples are divided into a training set, a validation set, and a test set according to 8:1:1, and the low-rank adaptation fine-tuning technology (LORA) is used to fine-tune the ChatGLM3-6B basic large model. LoRA introduces two low-rank matrices A and B in specific layers of the pre-trained model, and decomposes the parameter change matrix ΔW into the multiplication of two low-rank matrices AB. Assume B∈R d×r , A∈R r×k , r << min(r,k). During the training process, only the parameters of matrices A and B will be updated, and W will be frozen, significantly reducing the storage and computational requirements of the model, improving the fine-tuning speed, and reducing the fine-tuning cost. When performing LORA fine-tuning on ChatGLM3-6B, the total number of parameters is 6245533696, that is, W = 6245533696; the number of parameters to be modified is 1945696, that is, ΔW = 1945696, and the proportion of training parameters is 0.0312%. After training is completed, A and B can be merged with the original weight matrix W through the reparameterization technology, that is, W’ = W + ΔW = W + BA, and the fine-tuning of the basic ChatGLM3-6B large model can be completed.
[0078] In this embodiment, after multiple attempts to fine-tune the ChatGLM3-6B large model, fine-tuning parameters are set in the lora.yaml file. When "lora_alpha" (the scaling factor of LoRA) is set to 32, "lora's rank" is set to 8, "per_device_eval_batch_size" is set to 2, "eval_steps" is set to 3000, and "lora_dropout" is set to 0.1, the fine-tuned large model has the best effect on triple extraction of aircraft system text data; during the fine-tuning process, the fine-tuning program will dynamically adjust the learning rate according to the loss value of the large model on the validation set to speed up convergence or avoid overfitting.
[0079] Run python finetune_demo\finetune_hf.py finetune_demo\datachatglm3_6bfinetune_demo\configs\lora.yaml in the terminal to run the fine-tuning program. After the training is completed, the relevant model files of the fine-tuned large model will be obtained. Run python inference_hf.py . / output / checkpoint-3000 --prompt "Aircraft system knowledge text data to be extracted" in the terminal, call the fine-tuned model file to extract a single piece of knowledge text data, and verify the fine-tuning result of the large model.
[0080] Step 5: Use the Python script to call the fine-tuned ChatGLM3-6B model to automatically batch extract triples from the aircraft system knowledge text data and generate evaluation indicators based on BERT-SCORE;
[0081] In this embodiment, the remaining aircraft system knowledge text data to be extracted is stored in the INPUT_FILE file as the input file. If the precision (Precision, P), recall (Recall, R) and the harmonic mean of precision and recall (F1 value) need to be output for the batch extraction results, the manual extraction results need to be placed in the GROUND_TRUTH_FILE file as a reference file when using BERT_SCORE to calculate semantic similarity;
[0082] The process of batch extraction of triples is as follows: load the fine-tuned ChatGLM3-6B model and the corresponding word segmenter, read the INPUT_FILE file to be extracted, use the loaded model to extract triples for each line of text, and collect the results into a list. After the extraction is completed, convert the result list into a pandas DataFrame, and save the DataFrame to the output file (OUTPUT_FILE) in CSV format. The triples are stored in a CSV format file to facilitate manual inspection and importing the triples into the Neo4j graph database. Automatic batch calling of fine-tuned large models can solve the problem that only single data can be extracted when extracting triples in a conversational large model, and can greatly improve the efficiency of triple extraction tasks with large amounts of data.
[0083] It should be understood that since the ChatGLM3-6B large model is a generative model, the prediction of triples is directly generated, not like the label prediction of entities and relationships in the neural network, so it is necessary to use the evaluation index based on BERT-SCORE, which is characterized by taking the extraction results OUTPUT_FILE (CSV format file) and GROUND_TRUTH_FILE file generated in step 5 as input, calculating the BERTScore between the candidate text (OUTPUT_FILE) and the reference text (GROUND_TRUTH_FILE), which uses the BERT model to evaluate the semantic similarity, and obtains the average precision (Precision), recall (Recall) and F1 score of the extraction result file OUTPUT_FILE relative to the reference text (GROUND_TRUTH_FILE) as the evaluation index of the extraction result. The calculation formula is as follows:
[0084] The calculation formula of recall is:
[0085]
[0086] Among them, T ic is the number of tokens matched by token i in the candidate text in the reference text, T iR is the total number of token i in the reference text.
[0087] The calculation formula of precision is:
[0088]
[0089] Among them, T iE is the number of tokens matched by token i in the reference text in the candidate text, T a is the total number of tokens of the candidate text.
[0090] The F1 score is the harmonic mean of precision and recall, and is calculated as follows:
[0091]
[0092] Among them, P BERT is the accuracy, R BERT is the recall rate.
[0093] Step 6: Manually correct the extracted triples and construct the knowledge graph.
[0094] In this embodiment, the generated triples OUTPUT_FILE are imported into an Excel table, and then the extraction results are modified through manual screening; the triples are saved in the Neo4j graph database by importing the Excel table, completing the construction of the knowledge graph.
[0095] Embodiment 2:
[0096] A device for constructing an aircraft system knowledge graph, comprising:
[0097] The first module is used to obtain the aircraft system knowledge text data to be extracted and pre-process the text data;
[0098] The second module is used to manually extract some of the preprocessed text data to obtain triplets for fine-tuning the large model;
[0099] The third module is used to localize the deployment of the ChatGLM3-6B large model and modify the aircraft system text data and the corresponding manually extracted triples into a prompt format recognizable by ChatGLM3-6B;
[0100] The fourth module is used to fine-tune the ChatGLM3-6B basic model;
[0101] The fifth module is used to use Python scripts to call the fine-tuned ChatGLM3-6B model to automatically batch extract triples from aircraft system knowledge text data and generate evaluation indicators based on BERT-SCORE;
[0102] The sixth module is used to manually correct the extracted triples and construct the knowledge graph.
[0103] Embodiment three:
[0104] An electronic device includes a processor and a memory that is communicatively connected to the processor and is used to store instructions executable by the processor, wherein the processor is used to execute the above-mentioned aircraft system knowledge graph construction method.
[0105] Embodiment 4:
[0106] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the above-mentioned method for constructing an aircraft system knowledge graph.
[0107] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for constructing an aircraft system knowledge graph, characterized in that: The following steps are involved: Step 1: Obtain the aircraft system knowledge text data to be extracted and preprocess the text data; Step 2: Manually extract some of the preprocessed text data to obtain triplets for fine-tuning the large model; Step 3: Localize the ChatGLM3-6B large model and modify the aircraft system text data and the corresponding manually extracted triples into a prompt format recognizable by ChatGLM3-6B; Step 4: Fine-tune the ChatGLM3-6B basic model; Step 5: Use the Python script to call the fine-tuned ChatGLM3-6B model to automatically batch extract triples from the aircraft system knowledge text data and generate evaluation indicators based on BERT-SCORE; Step 6: Manually correct the extracted triples and construct the knowledge graph.
2. The method for constructing an aircraft system knowledge graph according to claim 1, characterized in that: The step 1 specifically includes: Obtain the aircraft system knowledge text data to be extracted from the aircraft AMM manual and FIM manual, use the Python script program to separate each text data with a period, list each aircraft system knowledge text data to be extracted as a separate line, determine each relationship type that may be contained in the aircraft system knowledge text data triple, and ensure that at least 5 knowledge text data of each relationship type are included. For relationship types that appear more frequently, at least 10 knowledge text data should be retained.
3. The method for constructing an aircraft system knowledge graph according to claim 1, characterized in that: The step 2 specifically includes: The pre-processed aircraft system knowledge text data is manually extracted into triples, whose format is "E b ,R,E e ”, where E b represents the head entity, R represents the relationship between two entities, and E e Indicates the tail entity. When a piece of knowledge text data contains multiple sets of triples, all triples are extracted. Its format is "E b ,R,E e .E b ,R,E e ……”.
4. The method for constructing an aircraft system knowledge graph according to claim 1, characterized in that: The step 3 specifically includes: Deploy the ChatGLM3-6B large model locally to ensure that the local hardware can meet the minimum operating conditions of the ChatGLM3-6B large model and test whether the ChatGLM3-6B large model can run normally; The aircraft system text data and the corresponding manually extracted triples are modified into a prompt format recognizable by ChatGLM3-6B. The specific format is: {"conversations":[{"role":"user","content":"The aircraft system knowledge text data to be extracted."},{"role":"assistant","content":"E b ,R,E e ."}]}.
5. The method for constructing an aircraft system knowledge graph according to claim 1, characterized in that: The step 4 specifically includes: The manually extracted triplets are divided into training set, validation set and test set, and the ChatGLM3-6B basic model is fine-tuned using the low-rank adaptive fine-tuning technique (LORA); Fine-tune parameter settings in the lora.yaml file; Run python finetune_demo\finetune_hf.py finetune_demo\datachatglm3_6bfinetune_demo\configs\lora.yaml in the terminal to run the fine-tuning program; Run python inference_hf.py . / output / checkpoint-3000 --prompt "Aircraft system knowledge text data to be extracted" in the terminal to extract a piece of knowledge text data and verify the fine-tuning results of the large model.
6. The method for constructing an aircraft system knowledge graph according to claim 1, characterized in that: The step 5 specifically includes: The remaining aircraft system knowledge text data to be extracted is stored in the INPUT_FILE file as the input file. If the precision, recall rate, and harmonic mean of precision and recall rate need to be output for the batch extraction results, the manual extraction results need to be placed in the GROUND_TRUTH_FILE file as a reference file when using BERT_SCORE for semantic similarity calculation; The process of automatic batch extraction of triples is as follows: load the fine-tuned ChatGLM3-6B model and the corresponding tokenizer, read the INPUT_FILE file to be extracted, use the loaded model to extract triples for each line of text, and collect the results into a list. After the extraction is completed, convert the result list into a pandas DataFrame and save the DataFrame to the output file (OUTPUT_FILE) in CSV format; The generated extraction results OUTPUT_FILE (CSV format file) and GROUND_TRUTH_FILE files are used as input to calculate the BERTScore between the candidate text (OUTPUT_FILE) and the reference text (GROUND_TRUTH_FILE). This score uses the BERT model to evaluate the semantic similarity and obtains the average precision (Precision), recall (Recall) and F1 score of the extraction result file OUTPUT_FILE relative to the reference text (GROUND_TRUTH_FILE). The calculation formula is as follows: The calculation formula of recall is: Among them, T ic is the number of tokens matched by token i in the candidate text in the reference text, T iR is the total number of tokens i in the reference text; The calculation formula of precision is: Among them, T iE is the number of tokens matched by token i in the reference text in the candidate text, T a is the total number of tokens in the candidate text; The F1 score is the harmonic mean of precision and recall, and is calculated as follows: Among them, P BERT is the accuracy, R BERT is the recall rate.
7. The method for constructing an aircraft system knowledge graph according to claim 6, characterized in that: The step 6 specifically includes: Import the generated triples OUTPUT_FILE into an Excel table, and then modify the extraction results through manual screening; save the triples in the Neo4j graph database to complete the construction of the knowledge graph.
8. A device for constructing an aircraft system knowledge graph, characterized in that: include: The first module is used to obtain the aircraft system knowledge text data to be extracted and pre-process the text data; The second module is used to manually extract some of the preprocessed text data to obtain triplets for fine-tuning the large model; The third module is used to localize the deployment of the ChatGLM3-6B large model and modify the aircraft system text data and the corresponding manually extracted triples into a prompt format recognizable by ChatGLM3-6B; The fourth module is used to fine-tune the ChatGLM3-6B basic model; The fifth module is used to use Python scripts to call the fine-tuned ChatGLM3-6B model to automatically batch extract triples from aircraft system knowledge text data and generate evaluation indicators based on BERT-SCORE; The sixth module is used to manually correct the extracted triples and construct the knowledge graph.
9. An electronic device, comprising a processor and a memory connected to the processor for storing instructions executable by the processor, characterized in that: The processor is used to execute the method for constructing an aircraft system knowledge graph as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for constructing an aircraft system knowledge graph as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Construction method and construction system for civil specification domain knowledge graph
CN116050408A
Entity relationship extraction method and system for knowledge graph construction in helicopter assembly field
CN117520561A
Cited By
Public data automatic classification and grading method and system
CN119128607A
A method and system for automatic classification and grading of public data
CN119128607B
Enzyme activity parameter extraction method and system based on large language model
CN119443093A
Geological prospecting literature knowledge extraction method and system based on large model
CN119760155A
