Automobile fault diagnosis answer generation method, electronic equipment and computer storage medium
By constructing a car fault diagnosis knowledge graph and using RAG technology, the problem of hallucination phenomena in the car fault diagnosis Q&A knowledge base based on big model is solved, and the accuracy and reliability of diagnostic answers are improved.
Patent Information
- Application Number
- CN202411396442.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-08
- Publication Date
- 2025-02-18
AI Technical Summary
The big model-based car fault diagnosis knowledge base is prone to hallucinations, resulting in low accuracy of diagnostic answers.
By constructing a knowledge graph of related diagnostic problems, RAG technology is used to retrieve diagnostic answers from vector databases, and troubleshooting answers are generated in combination with optimized large language models.
It effectively reduces the occurrence of hallucinations and improves the accuracy, interpretability and reliability of fault diagnosis answers.
Smart Images

Figure CN119474297A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of automobile fault diagnosis, and in particular to a method for generating an answer to automobile fault diagnosis, an electronic device and a computer storage medium. Background Art
[0002] It is inevitable that various faults will occur during the use of cars. These faults will not only affect the performance and safety of the car, but also cause inconvenience and economic losses to the car owner. Even professionals find it increasingly difficult to quickly locate and solve the problem, which also makes it difficult for ordinary consumers to judge the impact of the fault and make the right decision.
[0003] At present, the automobile fault diagnosis question and answer knowledge base based on the large model can provide users with intelligent and instant automobile diagnosis question and answer services. Whether it is the car owner or the maintenance personnel, they can quickly obtain relevant diagnosis suggestions and solutions by inputting the diagnosis questions.
[0004] However, the automobile fault diagnosis question-and-answer knowledge base based on the big model also has some defects that cannot be ignored. The underlying principle of the big model text generation is to process text information one by one based on probability (Token By Token), so it will inevitably produce the situation of "serious nonsense", that is, it is easy to produce hallucinations that do not conform to the factual content, and the accuracy rate is low. Summary of the invention
[0005] In response to the above technical problems, the present application provides a method for generating automobile fault diagnosis answers, an electronic device and a computer storage medium, aiming to solve the problem of hallucinations that are easily generated when applying an automobile fault diagnosis question and answer knowledge base based on a large model, and to improve the accuracy of the diagnosis answers.
[0006] In order to solve the above technical problems, the present application provides a method for generating an answer to a vehicle fault diagnosis, the method comprising:
[0007] Construct a knowledge graph of related diagnostic issues based on the accumulated empirical automotive fault diagnosis knowledge;
[0008] In response to an input of a diagnostic anchor question, inputting the diagnostic anchor question into a preset embedding model to obtain a first embedding vector;
[0009] Obtaining a preset number of diagnostic answers that match the first embedded vector from a preset vector database, and determining the diagnostic answers as the diagnostic anchor answer contexts;
[0010] Indexing the most relevant diagnostic question set from the diagnostic question knowledge graph according to a preset indexing algorithm;
[0011] Acquire a diagnosis enhancement context according to the diagnosis anchor question and the most relevant diagnosis question set;
[0012] The diagnosis anchor question, the diagnosis anchor answer context, and the diagnosis enhancement context are input into an optimized large language model to obtain a fault diagnosis answer.
[0013] Optionally, indexing the most relevant diagnostic question set from the diagnostic question knowledge graph according to a preset indexing algorithm includes:
[0014] Calculate the index score of each of the related diagnostic questions in the related diagnostic question knowledge graph using the index algorithm;
[0015] A preset number of the relevant diagnostic questions with the highest scores are selected according to the index scores to construct the most relevant diagnostic question set.
[0016] Optionally, the step of constructing a knowledge graph of related diagnostic problems based on the accumulated empirical automobile fault diagnosis knowledge includes:
[0017] Relevant diagnostic questions related to each of the random diagnostic questions in the preset random diagnostic question pool are respectively obtained from the accumulated empirical automobile fault diagnosis knowledge, and a first relevant diagnostic question knowledge graph is constructed according to the relevant diagnostic questions;
[0018] Adding the diagnostic anchor question to the first related diagnostic question knowledge graph;
[0019] Calculating the cosine similarity between the diagnostic anchor question and each of the related diagnostic questions in the first related diagnostic question knowledge graph respectively, and constructing a second related diagnostic question knowledge graph based on the related diagnostic questions whose cosine similarity is greater than a preset similarity threshold;
[0020] The using the indexing algorithm to calculate the index score of each of the related diagnostic questions in the related diagnostic question knowledge graph includes:
[0021] The indexing algorithm is used to calculate an index score for each of the related diagnostic questions in the second related diagnostic question knowledge graph.
[0022] Optionally, before respectively acquiring relevant diagnostic problems related to each diagnostic random problem in a preset diagnostic random problem pool from the accumulated empirical automobile fault diagnostic knowledge, the method further comprises:
[0023] Extracting automobile fault diagnosis question-answer pairs from the accumulated experience automobile fault diagnosis knowledge, and constructing a basic diagnosis experience question-answer pair pool based on the automobile fault diagnosis question-answer pairs, wherein each automobile fault diagnosis question-answer pair includes a diagnostic question and a corresponding answer;
[0024] Inputting the automobile fault diagnosis question-answer pair in the basic diagnosis experience question-answer pair pool into the embedding model to obtain a second embedding vector, and storing the second embedding vector in the vector database;
[0025] A preset number of the diagnostic questions randomly selected from the basic diagnostic experience question-answer pair pool are used as diagnostic random questions, and the preset diagnostic random question pool is constructed based on the diagnostic random questions.
[0026] Optionally, acquiring the diagnosis enhancement context according to the diagnosis anchor question and the most relevant diagnosis question set includes:
[0027] Acquire the initial context of the diagnostic anchor question according to the most relevant diagnostic question set and the most relevant diagnostic question answer set;
[0028] Inputting the initial context and the preset prompt text into the initial large language model, performing a triple extraction task to obtain a first context triple set;
[0029] Acquire a sub-context set according to the first context triple set and the automobile fault diagnosis knowledge graph;
[0030] The subcontext set and the initial context are concatenated to obtain the diagnosis enhancement context.
[0031] Optionally, the acquiring a sub-context set according to the first context triple set and the automobile fault diagnosis knowledge graph includes:
[0032] Acquire a one-hop neighbor of each entity in the first context triple set from the automobile fault diagnosis knowledge graph, and determine a second context triple set based on the one-hop neighbor;
[0033] adding the second set of context triples to the first set of context triples to obtain an extended set of triples;
[0034] The head entity, the relationship and the tail entity of each triple in the extended triple set are concatenated respectively to obtain the context set.
[0035] Optionally, before acquiring the diagnosis enhancement context according to the diagnosis anchor question and the most relevant diagnosis question set, the method further includes:
[0036] Constructing the automobile fault diagnosis knowledge graph based on the accumulated empirical automobile fault diagnosis knowledge;
[0037] The most relevant diagnostic question answer set is constructed according to the answer corresponding to each of the relevant diagnostic questions in the most relevant diagnostic question set.
[0038] Optionally, before inputting the diagnosis anchor question, the diagnosis anchor answer context, and the diagnosis enhancement context into the optimized large language model to obtain the fault diagnosis answer, the method further includes:
[0039] The initial large language model is constructed by fine-tuning a data set to obtain the optimized large language model.
[0040] The present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned method for generating an answer to automobile fault diagnosis when executing the computer program.
[0041] The present application also provides a computer storage medium, wherein the computer storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the above-mentioned method for generating an answer to automobile fault diagnosis are implemented.
[0042] By constructing a knowledge graph of related diagnostic questions, this application can provide a large language model with rich expert knowledge and semantic information on automobile fault diagnosis, so that each fault diagnosis answer is based on the retrieval and is well-founded, effectively reducing the occurrence of hallucinations and improving the accuracy, interpretability and reliability of the fault diagnosis answers. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 This is a flow chart of a method for generating an automobile fault diagnosis answer according to an embodiment of the present application. Figure 1 ;
[0045] Figure 2 This is a flow chart of a method for generating an automobile fault diagnosis answer according to an embodiment of the present application. Figure 2 ;
[0046] Figure 3 It is a structural schematic diagram of an electronic device shown in an embodiment of the present application. DETAILED DESCRIPTION
[0047] The following is an explanation of the implementation of the present application by means of specific embodiments. People familiar with the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification.
[0048] In the following description, reference is made to the accompanying drawings, which describe several embodiments of the present application. It should be understood that other embodiments may be used and that mechanical, structural, electrical, and operational changes may be made without departing from the spirit and scope of the present application. The following detailed description should not be considered limiting, and the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit the present application.
[0049] Although the terms first, second, etc. are used herein to describe various elements in some instances, these elements should not be limited by these terms. These terms are only used to distinguish one element from another element.
[0050] Furthermore, as used in this article, the singular forms "one", "an" and "the" are intended to include plural forms as well, unless there is an indication to the contrary in the context. It should be further understood that the terms "comprise", "include" indicate the presence of the described features, steps, operations, elements, components, projects, kinds, and / or groups, but do not exclude the presence, occurrence or addition of one or more other features, steps, operations, elements, components, projects, kinds, and / or groups. The terms "or" and "and / or" used herein are interpreted as inclusive, or mean any one or any combination. Therefore, "A, B or C" or "A, B and / or C" means "any of the following: A; B; C; A and B; A and C; B and C; A, B and C". Exceptions to this definition will only occur when the combination of elements, functions, steps or operations is inherently mutually exclusive in some way.
[0051] The following is an explanation of the terms that may be involved in this application, as follows:
[0052] LLM (Large Language Models) is a type of deep learning model with a large number of parameters that performs well in the field of natural language processing (NLP). These models are pre-trained on large amounts of text data to learn the structure, grammar, semantics, and usage of a language, so that they can understand and generate natural language.
[0053] RAG (Retrieval-Augmented Generation) technology is a natural language processing (NLP) technology that combines retrieval and generation functions. It assists text generation by combining retrieval models and generation models. Specifically, RAG uses retrieval models to search for relevant information from large data sets or knowledge bases, combines it with the user's query, and then inputs it into the generation model (such as a large language model, LLM) to generate accurate and contextual text responses.
[0054] M3E (Moka Massive Mixed Embedding) embedding model, which is a Chinese text embedding model trained and open sourced by MokaAI. This model is designed specifically for the Chinese language and can convert natural language text into dense vector form. These vectors can capture the semantic information of the text and are used in various natural language processing tasks, such as text similarity calculation, text classification, information retrieval, etc.
[0055] The Personalized PageRank (PPR) algorithm is a variation of the PageRank algorithm that calculates the importance or relevance of a node in a graph relative to a specific source node. Unlike the traditional PageRank algorithm, which assigns a static ranking score to each node in the entire network, the PPR algorithm provides a dynamic perspective, that is, evaluating the importance of other nodes from the perspective of the source node.
[0056] Prompt, which is a text input used to guide the AI system to generate a specific output or perform a specific task. Prompts can be as simple as a direct question, or more complex, containing detailed instructions and contextual information to ensure that the AI system can provide accurate and useful answers. The design of prompts is crucial to obtaining high-quality output because it directly affects the performance and results of the AI system.
[0057] Constructing an instruction fine-tuning dataset is a key step in optimizing a large language model. It involves combining instructions in natural language form with the output of the model to further train the large language model and enhance its ability to follow instructions, thereby improving the performance and controllability of the model on specific tasks.
[0058] This application proposes a large language model (LLM) knowledge base for automobile fault diagnosis based on knowledge graph and RAG technology, aiming to solve the technical problems described in the background technology.
[0059] Please refer to Figure 1 , Figure 1 A flow chart of a method for generating an answer to a vehicle fault diagnosis is shown, the method comprising:
[0060] S10. Construct a knowledge graph of related diagnostic problems based on the accumulated empirical automobile fault diagnosis knowledge. Specifically, the accumulated empirical automobile fault diagnosis knowledge may include, for example, basic fault diagnosis, electrical system fault diagnosis, engine fault diagnosis, transmission system fault diagnosis, brake system fault diagnosis, suspension system fault diagnosis, steering system fault diagnosis, air conditioning system fault diagnosis, emission control system fault diagnosis, safety system fault diagnosis, fault code interpretation, repair and maintenance knowledge, etc. In this embodiment, a knowledge graph of related diagnostic problems is constructed by performing conceptual modeling, knowledge extraction, entity alignment and other steps on the accumulated empirical automobile fault diagnosis knowledge, and then, structured automobile fault diagnosis expert knowledge is obtained.
[0061] S20, in response to the input of the diagnostic anchor question, input the diagnostic anchor question into a preset embedding model to obtain a first embedding vector. Specifically, in this embodiment, for each diagnostic anchor question input by the user, the diagnostic anchor question will be automatically input into the M3E embedding model to obtain the diagnostic anchor embedding, that is, the first embedding vector.
[0062] S30. Obtain a preset number of diagnostic answers that match the first embedded vector from a preset vector database, and determine the diagnostic answers as the diagnostic anchor answer context. Specifically, based on the construction process of RAG technology, a vector database is constructed to store embedded vectors of various types of automobile fault diagnosis problems and their corresponding solutions, and diagnostic background knowledge is added to each query statement match through a similarity function. In this embodiment, a preset number of diagnostic answers with the highest cosine similarity to the first embedded vector are found from the vector database, and the preset number of diagnostic answers are determined as the diagnostic anchor answer context. Among them, the preset number is preferably three, and of course it can also be other integers, which are not uniquely limited here.
[0063] It can be understood that each diagnosis answer is obtained based on the retrieval from the vector database, which can effectively reduce the generation of hallucinations. In addition, the real-time update and rapid enrichment of automobile fault diagnosis knowledge can also be achieved through the additional vector database.
[0064] S40, indexing the most relevant diagnostic question set from the diagnostic question knowledge graph according to a preset indexing algorithm. Specifically, in this embodiment, for each diagnostic anchor question input by the user, the PPR algorithm is used to index the most relevant diagnostic question set that is most relevant to the diagnostic anchor question from the diagnostic question knowledge graph.
[0065] S50, obtaining diagnostic enhancement context according to the diagnostic anchor question and the most relevant diagnostic question set. Specifically, in this embodiment, for each diagnostic anchor question input by the user, the text sequence obtained by extracting and splicing entities in the diagnostic question knowledge graph and the most relevant diagnostic question set is the diagnostic enhancement context. In the process of extracting entities, multi-hop reasoning can be performed on complex diagnostic questions, thereby realizing multi-hop question answering.
[0066] S60, input the diagnostic anchor question, the diagnostic anchor answer context, and the diagnostic enhancement context into the optimized large language model to obtain the fault diagnosis answer. Specifically, in this embodiment, the diagnostic anchor question, the diagnostic anchor answer context, and the diagnostic enhancement context are input into the optimized large language model to obtain a fault diagnosis answer with high accuracy.
[0067] Among them, the optimized large language model is specifically a large language model obtained by constructing an instruction fine-tuning dataset for the initial large language model. It can be understood that in order to guide different diagnostic anchor point problems and reduce the occurrence of hallucination problems, by constructing an instruction fine-tuning dataset for the initial large language model, the fine-tuned large language model can better understand and perform specific downstream tasks, improve its performance on specific tasks, and maintain the basic capabilities of the model. In this way, the diagnostic anchor point problem, the diagnostic anchor point answer context, and the diagnostic enhancement context are input into the optimized large language model, and the fault diagnosis answer obtained is highly accurate, reliable, and interpretable, effectively reducing the occurrence of hallucinations.
[0068] By executing the method for generating answers to automobile fault diagnosis in steps S10 to S60, firstly, the use of RAG technology can effectively alleviate the problem that the traditional automobile fault diagnosis large model knowledge base in the prior art is prone to hallucination. Secondly, constructing a knowledge graph can add rich expert knowledge to the RAG technology, thereby achieving the purpose of enhancing the RAG technology and improving the accuracy, interpretability and reliability of automobile fault diagnosis answers.
[0069] Optionally, the step of indexing the most relevant diagnostic question set from the diagnostic question knowledge graph according to a preset indexing algorithm in step S40 includes:
[0070] S41, using an indexing algorithm to calculate the index score of each relevant diagnostic question in the relevant diagnostic question knowledge graph. Specifically, in this embodiment, a personalized PPR algorithm is used to calculate the PPR scores, i.e., index scores, of nodes corresponding to all relevant diagnostic questions except the relevant diagnostic question in the relevant diagnostic question knowledge graph.
[0071] S42. Select a preset number of related diagnostic questions with the highest scores according to the index scores to construct a most relevant diagnostic question set. Specifically, in this embodiment, the N (N is a positive integer and greater than or equal to one) related diagnostic questions with the highest PPR scores in step S41 are selected as the most relevant diagnostic question set for the diagnostic anchor question. It can be understood that the higher the PPR score, the higher the authority, credibility and relevance of the output content.
[0072] Optionally, the step S10 of constructing a knowledge graph of related diagnostic problems based on the accumulated empirical automobile fault diagnosis knowledge includes:
[0073] S11. Relevant diagnostic questions related to each of the preset diagnostic random questions pool are obtained from the accumulated empirical automobile fault diagnosis knowledge, and a first relevant diagnostic question knowledge graph is constructed based on the relevant diagnostic questions. Specifically, in this embodiment, for each diagnostic random question in the preset diagnostic random question pool, questions related to it, i.e., relevant diagnostic questions, are obtained from the accumulated empirical automobile fault diagnosis knowledge, and a first relevant diagnostic question knowledge graph is constructed based on the relevant diagnostic questions. The first relevant diagnostic question knowledge graph is composed of a node set and a relationship set, each node represents a relevant diagnostic question, and each relationship represents that the cosine similarity between two relevant diagnostic questions is greater than a preset similarity threshold.
[0074] S12: Add the diagnostic anchor question to the first related diagnostic question knowledge graph. Specifically, in this embodiment, for each diagnostic anchor question input by the user, add it as a node to the first related diagnostic question knowledge graph.
[0075] S13. Calculate the cosine similarity between the diagnostic anchor question and each related diagnostic question in the first related diagnostic question knowledge graph, and construct a second related diagnostic question knowledge graph based on the related diagnostic questions whose cosine similarity is greater than a preset similarity threshold. Specifically, in this embodiment, the cosine similarity between the node corresponding to the diagnostic anchor question and the node corresponding to each related diagnostic question in the first related diagnostic question knowledge graph is calculated, and the nodes corresponding to the related diagnostic questions whose cosine similarity is greater than the preset similarity threshold are selected to establish a relationship with the diagnostic anchor question, thereby constructing the second related diagnostic question knowledge graph.
[0076] Further, the use of an index algorithm to calculate the index score of each relevant diagnostic question in the relevant diagnostic question knowledge graph described in step S41 includes: using an index algorithm to calculate the index score of each relevant diagnostic question in the second relevant diagnostic question knowledge graph. Specifically, in this embodiment, a personalized PPR algorithm is used to calculate the PPR scores, i.e., index scores, of the nodes corresponding to all relevant diagnostic questions except the relevant diagnostic questions in the second relevant diagnostic question knowledge graph obtained in step S13.
[0077] Optionally, before respectively acquiring relevant diagnostic problems related to each of the diagnostic random problems in the preset diagnostic random problem pool from the accumulated empirical automobile fault diagnostic knowledge in step S11, the method further comprises:
[0078] S101. Extract automobile fault diagnosis question-answer pairs from the accumulated experience automobile fault diagnosis knowledge, and construct a basic diagnosis experience question-answer pair pool based on the automobile fault diagnosis question-answer pairs, wherein each automobile fault diagnosis question-answer pair includes a diagnostic question and a corresponding answer. Specifically, in the present embodiment, each automobile fault diagnosis question-answer pair is composed of a diagnostic question extracted from the accumulated experience automobile fault diagnosis knowledge and a corresponding answer. Exemplarily, the diagnostic question extracted from the accumulated experience automobile fault diagnosis knowledge may be: the engine is difficult to start or cannot start. In this case, the corresponding answer may be any one of the following answers: (1) the vehicle has not been used for a long time or the battery is aged, resulting in insufficient power; (2) the starter is damaged or worn and cannot work normally; (3) the fuel pump or fuel filter is clogged or the fuel supply is insufficient; (4) the spark plug is aged or the ignition coil is faulty.
[0079] S102, input the automobile fault diagnosis question and answer pairs in the basic diagnosis experience question and answer pair pool into a preset embedding model to obtain a second embedding vector, and store the second embedding vector into the vector database. Specifically, in this embodiment, for each automobile fault diagnosis question and answer pair in the basic diagnosis experience question and answer pair pool, the diagnostic question and the corresponding answer are concatenated and then input into the M3E embedding model to obtain the question and answer pair embedding vector, i.e., the second embedding vector, and the second embedding vector is stored in the vector database.
[0080] S103, randomly selecting a preset number of diagnostic questions from the basic diagnostic experience question-answer pair pool as diagnostic random questions, and constructing a preset diagnostic random question pool based on the diagnostic random questions. Specifically, in this embodiment, a portion of diagnostic questions are randomly selected from the basic diagnostic experience question-answer pair pool as diagnostic random questions, and a diagnostic random question pool is constructed based on the randomly selected diagnostic random questions.
[0081] Optionally, the step of acquiring the diagnosis enhancement context according to the diagnosis anchor question and the most relevant diagnosis question set in step S50 includes:
[0082] S51. Obtain the initial context of the diagnostic anchor question based on the most relevant diagnostic question set and the most relevant diagnostic question answer set. Specifically, in this embodiment, for each diagnostic anchor question input by the user, the corresponding most relevant diagnostic question set and the most relevant diagnostic question answer set are set as the initial context of the diagnostic anchor question. The logic of obtaining the initial context is: find the parts that can be naturally connected through the connection points, and ensure the coherence of the text through transitional words or phrases, and adjust the order of the paragraphs appropriately according to the logical relationship of the content to ensure the logic and orderliness of the overall text.
[0083] S52, input the initial context and the preset prompt text into the initial large language model, and perform the triple extraction task to obtain the first context triple set. Specifically, in this embodiment, the preset prompt text is Prompt, and Prompt is first added to the initial context obtained in step S51, and then the combined text of the two is input into the initial large language model, and finally the triple extraction task is performed on the result output by the initial large language model to obtain the first context triple set. Among them, the triple extraction task is also called relationship extraction, which is used to identify and extract the relationship between entities from the text, and the result is usually expressed in the form of a "subject-predicate-object" triple.
[0084] S53, obtaining a sub-context set according to the automobile fault diagnosis knowledge graph and the first context triple set. Specifically, in this embodiment, a sub-context set is obtained by performing entity extraction, relationship integration, splicing and other operations on the automobile fault diagnosis knowledge graph obtained in step S43 and the first context triple set obtained in step S52.
[0085] S54, concatenate the subcontext set and the initial context to obtain the diagnosis enhancement context. Specifically, in this embodiment, the text sequence, ie, the diagnosis enhancement context, is obtained by performing entity extraction and concatenation operations on the subcontext set obtained in step S53 and the initial context obtained in step S51.
[0086] Optionally, the step of obtaining a sub-context set according to the automobile fault diagnosis knowledge graph and the first context triple set in step S53 includes:
[0087] S531. Obtain one-hop neighbors of each entity in the first context triple set from the automobile fault diagnosis knowledge graph, and determine the second context triple set based on the one-hop neighbors. Specifically, the first context triple set obtained by executing the triple extraction task in step S52 includes an entity set that includes all entities in the first context triple set. In this embodiment, the one-hop neighbors (including relationships and nodes) of each entity in the entity set are obtained from the automobile fault diagnosis knowledge graph, and then a new triple set, i.e., the second context triple set, is constructed based on all one-hop neighbors. Among them, only triples whose head and tail nodes appear in the initial context are considered.
[0088] In this way, for multi-hop problems that require reasoning, by executing step S531, it is possible to effectively respond and generate reasonable and accurate answers. For example, the diagnostic anchor point problem is: "What should I do if the piston in the crankcase of the engine in the engine compartment fails?" By executing step S531, each hop neighbor in the diagnostic anchor point problem can be selected, that is, engine compartment-engine-crankcase-piston, and then the root cause of the diagnostic anchor point problem can be accurately located, effectively improving the accuracy.
[0089] S532: Add the second context triple set to the first context triple set to obtain an extended triple set. Specifically, in this embodiment, the second context triple set is merged with the first context triple set to obtain an extended triple set.
[0090] S533, respectively concatenate the head entity, the relation, and the tail entity of each triple in the extended triple set to obtain a context set. Specifically, in this embodiment, the head entity, the relation, and the tail entity of each triple in the extended triple set are concatenated to form text sequences, and the set obtained by merging all the text sequences is the context set.
[0091] Optionally, before obtaining the diagnosis enhancement context according to the diagnosis anchor question and the most relevant diagnosis question set in step S50, the following steps are included:
[0092] S501. Construct an automobile fault diagnosis knowledge graph based on the accumulated empirical automobile fault diagnosis knowledge. Specifically, in this embodiment, the accumulated empirical automobile fault diagnosis knowledge includes but is not limited to maintenance manuals, technical documents, fault cases, expert experience, public databases, professional forums, academic papers, etc. The general steps of constructing an automobile fault diagnosis knowledge graph can be divided into the following steps: (1) Extract fault diagnosis-related knowledge from the collected data, including fault phenomena, possible causes, diagnostic methods and solutions, etc.; (2) Classify the extracted knowledge and establish categories such as fault types, causes, diagnostic methods and solutions; (3) Classify the extracted knowledge and establish categories such as fault types, causes, diagnostic methods and solutions; (4) Define the ontology structure of the knowledge graph, including entity types, attributes and relationships between entities; (5) Convert the classified and extracted knowledge into nodes and edges in the graph to form the basic structure of the knowledge graph; (6) Use a graph database or other suitable knowledge storage system to input the encoded knowledge into the knowledge graph; (7) Verify the accuracy and completeness of the knowledge graph to ensure that all information is reliable and accurate.
[0093] S502: Construct a most relevant diagnostic question answer set based on the answer corresponding to each relevant diagnostic question in the most relevant diagnostic question set. Specifically, in this embodiment, based on the most relevant diagnostic question set obtained in step S42, the answer corresponding to each relevant diagnostic question therein constitutes a most relevant diagnostic question answer set.
[0094] Optionally, before the diagnostic anchor point question, diagnostic anchor point answer context, and diagnostic enhancement context are input into the optimized large language model to obtain the fault diagnosis answer as described in step S60, it includes: constructing an instruction fine-tuning data set for the initial large language model to obtain the optimized large language model. Specifically, in this embodiment, in order to guide different diagnostic anchor point questions and reduce the occurrence of hallucination problems, by constructing an instruction fine-tuning data set for the initial large language model, the fine-tuned large language model can better understand and perform specific downstream tasks, improve its performance on specific tasks, and maintain the basic capabilities of the model. In this way, the diagnostic anchor point question, diagnostic anchor point answer context, and diagnostic enhancement context are input into the optimized large language model, and the fault diagnosis answer obtained has high accuracy, reliability, and interpretability, effectively reducing the occurrence of hallucinations.
[0095] The initial large language model is constructed by fine-tuning a data set to obtain the optimized large language model.
[0096] Please refer to Figure 2 , Figure 2A flow chart of a method for generating automobile fault diagnosis answers based on knowledge graph and RAG technology is shown. As shown in the figure, in response to the input of a diagnosis anchor question, the RAG technology starts to work. On the one hand, corresponding to the above step S30, a preset number of diagnosis answers with the highest cosine similarity with the first embedded vector are found from the vector database, and the preset number of diagnosis answers are determined as the diagnosis anchor answer context.
[0097] On the other hand, corresponding to the above steps S12 to S13, the diagnostic anchor question is added as a node to the first related diagnostic question knowledge graph, and then the cosine similarities between the node corresponding to the diagnostic anchor question and the nodes corresponding to each related diagnostic question in the first related diagnostic question knowledge graph are calculated respectively, and the nodes corresponding to the related diagnostic questions whose cosine similarities are greater than the preset similarity threshold are selected to establish a relationship with the diagnostic anchor question. In the diagram structure, the black q1, q2, q3, and q4 represent nodes whose cosine similarities between the nodes corresponding to the diagnostic anchor question are greater than the preset similarity threshold, and the gray q5 and q6 represent nodes whose cosine similarities between the nodes corresponding to the diagnostic anchor question are less than the preset similarity threshold, that is, only the nodes q1 to q4 are selected to establish a relationship with the diagnostic anchor question.
[0098] Then, corresponding to the above steps S53 (S531~S533)~S54, obtain the one-hop neighbor of each entity in the first context triple set from the automobile fault diagnosis knowledge graph, and determine the second context triple set based on the one-hop neighbor; add the second context triple set to the first context triple set to obtain an extended triple set; concatenate the head entity, relationship and tail entity of each triple in the extended triple set to obtain a context set; concatenate the subcontext set and the initial context to obtain a diagnosis enhanced context. In the diagram structure, the black node in the automobile fault diagnosis knowledge graph represents an entity, and the white node represents the one-hop neighbor of each entity. In this way, all white one-hop neighbors are aggregated to obtain the second context triple set, which effectively copes with multi-hop reasoning and question-answering.
[0099] Finally, corresponding to step S6 described above, the diagnosis anchor question, the diagnosis anchor answer context, and the diagnosis enhancement context are input into the optimized large language model to obtain the fault diagnosis answer.
[0100] The prior art described in the background technology also has the following defects:
[0101] (1) Knowledge real-time problem: The large model acquires general language capabilities through pre-training, and new knowledge can only be infused during training and fine-tuning. However, a lot of knowledge is constantly updated, and the large model cannot learn the latest knowledge in real time, resulting in the problem of knowledge expiration;
[0102] (2) Limited memory problem: Although large language models have a large number of parameters, they are still unable to remember a large amount of specific factual knowledge and perform poorly on tasks that require memory;
[0103] (3) Data security issues: General large language models do not have internal enterprise data and user data. If online large models are used, confidentiality leaks may occur, affecting enterprise data security.
[0104] Based on the above defects, this application proposes a large language model (LLM) knowledge base for automobile fault diagnosis based on knowledge graph and RAG technology, which can provide the following solutions:
[0105] (1) RAG technology ensures that knowledge is always up-to-date by continuously querying the vector database and the automobile fault diagnosis knowledge graph. There is no need for manual and frequent fine-tuning of the model and repeated training. Compared with existing technologies, the training cost is greatly reduced.
[0106] (2) RAG technology is good at utilizing external automobile fault diagnosis resources and is very suitable for documents or other structured / unstructured automobile fault diagnosis databases. It does not require remembering a large amount of specific factual knowledge while being able to obtain more fault diagnosis expert knowledge.
[0107] (3) By storing all of the enterprise's internal automobile fault diagnosis data and user data locally, all business calculations of the enterprise data can be completed locally, and the online large language model only realizes the function of induction.
[0108] This application enhances RAG technology by building a knowledge graph, which also has the following advantages:
[0109] (1) Different from the black-box probability model (Token By Token) in the existing technology, the automobile fault diagnosis knowledge graph can provide the large language model with rich automobile fault diagnosis expert knowledge and semantic information in a graph structure, so that each fault diagnosis answer generated has a basis, the interpretability and reliability are greatly improved, and the generation of large model hallucinations is effectively reduced.
[0110] (2) It can combine knowledge graphs to perform multi-hop reasoning on complex diagnostic problems and realize multi-hop question answering.
[0111] (3) The introduction of the automobile fault diagnosis knowledge graph can reduce the reliance on large-scale models. Compared with the existing technology described in the background technology, the automobile fault diagnosis knowledge graph focuses more on the knowledge structure and semantic relationship of automobile fault diagnosis, thereby providing more accurate automobile fault diagnosis knowledge support for solving practical problems. After using RAG technology in combination with the automobile fault diagnosis knowledge graph, complex problems can be handled more efficiently, reducing excessive demands on computing resources and storage space.
[0112] (4) The automobile fault diagnosis knowledge graph can also improve the generalization ability of RAG. By utilizing the semantic information and entity relationships in the knowledge graph, RAG can better understand the data distribution and pattern, and thus better generalize to unknown data. This helps to reduce the overfitting phenomenon of the model when facing new data and improve the robustness and generalization performance of the model.
[0113] Based on the same inventive concept as the above embodiments, an embodiment of the present invention provides an electronic device, such as Figure 3 As shown, the device includes: a processor 310 and a memory 311 storing a computer program; wherein, Figure 3 The processor 310 shown in the figure is not used to indicate that the number of the processor 310 is one, but is only used to indicate the positional relationship of the processor 310 relative to other devices. In actual applications, the number of the processor 310 may be one or more; similarly, Figure 3 The memory 311 shown in the figure has the same meaning, that is, it is only used to refer to the position relationship of the memory 311 relative to other devices. In practical applications, the number of memories 311 can be one or more. When the processor 310 runs the computer program, the method applied to the above device is implemented.
[0114] The device may also include: at least one network interface 312. The various components in the device are coupled together via a bus system 313. It is understood that the bus system 313 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 313 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 3 Various buses are labeled as bus system 313.
[0115] The memory 311 may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories. The nonvolatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM); the magnetic surface memory may be a disk memory or a tape memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 311 described in the embodiments of the present invention is intended to include but is not limited to these and any other suitable types of memories.
[0116] The memory 311 in the embodiment of the present invention is used to store various types of data to support the operation of the device. Examples of these data include: any computer program used to operate on the device, such as an operating system and an application; contact data; phone book data; messages; pictures; videos, etc. Among them, the operating system includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application program may include various applications, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. Here, the program that implements the method of the embodiment of the present invention may be included in the application program.
[0117] Based on the same inventive concept as the above-mentioned embodiment, this embodiment further provides a computer-readable storage medium, in which a computer program is stored. The computer-readable storage medium may be a ferromagnetic random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); it may also be various devices including one or any combination of the above memories, such as a mobile phone, a computer, a tablet device, a personal digital assistant, etc. When the computer program stored in the computer-readable storage medium is executed by the processor, the above method is implemented. For the specific steps implemented when the computer program is executed by the processor, please refer to Figure 1 The description of the illustrated embodiment will not be repeated here.
[0118] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0119] In this document, the terms "comprises," "comprising," or any other variations thereof, are intended to cover a non-exclusive inclusion of elements other than those listed and may also include additional elements not expressly listed.
[0120] All the above embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solution of the present application rather than to limit it. The protection scope of the present application is not limited thereto. Any equivalent deformation or replacement of the technical solution recorded in the above embodiments by any technician familiar with the technical field is included in the scope defined by the claims of the present application.
Claims
1. A method for generating an answer to a vehicle fault diagnosis, characterized in that: The method comprises: Construct a knowledge graph of related diagnostic issues based on the accumulated empirical automotive fault diagnosis knowledge; In response to an input of a diagnostic anchor question, inputting the diagnostic anchor question into a preset embedding model to obtain a first embedding vector; Obtaining a preset number of diagnostic answers that match the first embedded vector from a preset vector database, and determining the diagnostic answers as the diagnostic anchor answer contexts; Indexing the most relevant diagnostic question set from the diagnostic question knowledge graph according to a preset indexing algorithm; Acquire a diagnosis enhancement context according to the diagnosis anchor question and the most relevant diagnosis question set; The diagnosis anchor question, the diagnosis anchor answer context, and the diagnosis enhancement context are input into an optimized large language model to obtain a fault diagnosis answer.
2. The method according to claim 1, characterized in that The step of indexing the most relevant diagnostic question set from the diagnostic question knowledge graph according to a preset indexing algorithm includes: Calculate the index score of each of the related diagnostic questions in the related diagnostic question knowledge graph using the index algorithm; A preset number of the relevant diagnostic questions with the highest scores are selected according to the index scores to construct the most relevant diagnostic question set.
3. The method according to claim 2, characterized in that The knowledge graph of related diagnostic problems is constructed based on the accumulated experience of automobile fault diagnosis knowledge, including: Relevant diagnostic questions related to each of the random diagnostic questions in the preset random diagnostic question pool are respectively obtained from the accumulated empirical automobile fault diagnosis knowledge, and a first relevant diagnostic question knowledge graph is constructed according to the relevant diagnostic questions; Adding the diagnostic anchor question to the first related diagnostic question knowledge graph; Calculating the cosine similarity between the diagnostic anchor question and each of the related diagnostic questions in the first related diagnostic question knowledge graph respectively, and constructing a second related diagnostic question knowledge graph based on the related diagnostic questions whose cosine similarity is greater than a preset similarity threshold; The using the indexing algorithm to calculate the index score of each of the related diagnostic questions in the related diagnostic question knowledge graph includes: The indexing algorithm is used to calculate an index score for each of the related diagnostic questions in the second related diagnostic question knowledge graph.
4. The method according to claim 3, characterized in that Before respectively obtaining relevant diagnostic problems related to each of the diagnostic random problems in the preset diagnostic random problem pool from the accumulated empirical automobile fault diagnostic knowledge, the method further includes: Extracting automobile fault diagnosis question-answer pairs from the accumulated experience automobile fault diagnosis knowledge, and constructing a basic diagnosis experience question-answer pair pool based on the automobile fault diagnosis question-answer pairs, wherein each automobile fault diagnosis question-answer pair includes a diagnostic question and a corresponding answer; Inputting the automobile fault diagnosis question-answer pair in the basic diagnosis experience question-answer pair pool into the embedding model to obtain a second embedding vector, and storing the second embedding vector in the vector database; A preset number of the diagnostic questions randomly selected from the basic diagnostic experience question-answer pair pool are used as diagnostic random questions, and the preset diagnostic random question pool is constructed based on the diagnostic random questions.
5. The method according to claim 1, characterized in that The obtaining of the diagnosis enhancement context according to the diagnosis anchor question and the most relevant diagnosis question set includes: Acquire the initial context of the diagnostic anchor question according to the most relevant diagnostic question set and the most relevant diagnostic question answer set; Inputting the initial context and the preset prompt text into the initial large language model, performing a triple extraction task to obtain a first context triple set; Acquire a sub-context set according to the first context triple set and the automobile fault diagnosis knowledge graph; The subcontext set and the initial context are concatenated to obtain the diagnosis enhancement context.
6. The method according to claim 5, characterized in that The acquiring of a sub-context set according to the first context triple set and the automobile fault diagnosis knowledge graph includes: Acquire a one-hop neighbor of each entity in the first context triple set from the automobile fault diagnosis knowledge graph, and determine a second context triple set based on the one-hop neighbor; adding the second set of context triples to the first set of context triples to obtain an extended set of triples; The head entity, the relationship and the tail entity of each triple in the extended triple set are concatenated respectively to obtain the context set.
7. The method according to claim 5, characterized in that Before acquiring the diagnosis enhancement context according to the diagnosis anchor question and the most relevant diagnosis question set, the method further includes: Constructing the automobile fault diagnosis knowledge graph based on the accumulated empirical automobile fault diagnosis knowledge; The most relevant diagnostic question answer set is constructed according to the answer corresponding to each of the relevant diagnostic questions in the most relevant diagnostic question set.
8. The method according to claim 5, characterized in that Before inputting the diagnosis anchor question, the diagnosis anchor answer context, and the diagnosis enhancement context into the optimized large language model to obtain the fault diagnosis answer, the method includes: The initial large language model is constructed by fine-tuning a data set to obtain the optimized large language model.
9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for generating an answer to automobile fault diagnosis as claimed in any one of claims 1 to 8 are implemented.
10. A computer storage medium, characterized in that: The computer storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the method for generating an automobile fault diagnosis answer as claimed in any one of claims 1 to 8 are implemented.
Citation Information
Cited By
Fault diagnosis method and device of energy storage system, storage medium and program product
CN120492597A