Special vehicle operation and maintenance knowledge retrieval method based on large model
Through the special vehicle operation and maintenance knowledge retrieval method based on large models, the problem of inefficient traditional operation and maintenance knowledge retrieval is solved, semantic matching and precise retrieval are achieved, the maintenance and operation efficiency of special vehicles is improved, and their safety and reliability are ensured.
Patent Information
- Application Number
- CN202411169869.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-03
AI Technical Summary
The traditional special vehicle operation and maintenance knowledge retrieval method is inefficient, relies on experience and a large amount of historical data, making it difficult to quickly and accurately locate faults, and the search results are fragmented, lack of semantic understanding, and are easily missed.
Using a large model-based special vehicle operation and maintenance knowledge retrieval method, including document knowledge data loading, document content splitting, text block vector processing, text vector data storage and index construction, knowledge base search and iterative question-and-answer search, through semantic similarity Calculation and vectorization processing to achieve accurate matching and retrieval of special vehicle operation and maintenance knowledge.
It improves the efficiency and accuracy of special vehicle operation and maintenance knowledge retrieval, provides comprehensive, real-time and personalized knowledge support, and ensures the safe operation and maintenance efficiency of the vehicle.
Smart Images

Figure CN119066144A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of equipment operation and maintenance, and specifically relates to a special vehicle operation and maintenance knowledge retrieval method based on a large model. Background Art
[0002] With the continuous advancement and application of science and technology, predictive maintenance of special vehicles has become an area of great concern. Special vehicles play an important role in the military, security and industrial fields. However, they are often used in extreme environments and high-risk tasks, so timely and effective maintenance is crucial. The maintenance knowledge retrieval system refers to the organization, summarization and indexing of information such as maintenance manuals, technical documents, historical maintenance records and expert experience, so that users can quickly and accurately obtain knowledge and information related to special vehicle maintenance. Such a system can help maintenance personnel better understand the structure and working principle of special vehicles, identify potential faults and problems, and learn methods and techniques to solve problems.
[0003] With the rapid development of special vehicles, the structure and operation style of vehicle components are becoming more and more complex, and the requirements for the emergency response capabilities of special vehicles are becoming more and more stringent. In the current operation and maintenance work, when a system fails, the support personnel need to quickly locate the fault location and cause, and take immediate action to repair it. However, traditional methods often rely on the experience of support personnel, or require consulting a large amount of historical data, such as fault handling manuals, case records, etc. This method is often inefficient and prone to omissions. Although the traditional method of text retrieval using keywords can locate paragraphs, it causes fragmented and unorganized search results, and cannot deeply understand and handle the semantic information of the problem. There are often incomplete searches and irrelevant answers, which are prone to negligence and omissions, which aggravates the reduction of operation and maintenance efficiency.
[0004] Therefore, it is very necessary to use advanced information technology and artificial intelligence algorithms to establish an intelligent special vehicle operation and maintenance knowledge retrieval system. By correctly understanding the user's query intention, intelligent classification and rapid retrieval of information can be achieved so that maintenance personnel can quickly and accurately obtain the required information, ensure the safe operation and continuous performance of the vehicle, and meet the requirements of rapid fault analysis and disposal. Summary of the invention
[0005] 1. Technical issues to be resolved
[0006] The technical problem to be solved by the present invention is: how to provide an intelligent, accurate and interactive special vehicle operation and maintenance knowledge retrieval method.
[0007] (II) Technical solution
[0008] In order to solve the above technical problems, the present invention provides a special vehicle operation and maintenance knowledge retrieval method based on a large model, the method comprising the following steps:
[0009] Step 1: Document knowledge data loading;
[0010] Step 2: Document content splitting;
[0011] Step 3: vectorization processing of text blocks;
[0012] Step 4: Text vector data storage and index construction;
[0013] Step 5: Knowledge base search;
[0014] Step 6: Result generation;
[0015] Step 7: Iterate question-answer retrieval.
[0016] Wherein, in said step 1, document knowledge data is loaded;
[0017] Use the document loader to obtain operation and maintenance related document data from the local special vehicle operation and maintenance knowledge database, and extract the content and metadata in the document;
[0018] The acquired document knowledge data document_data is stored in the memory in a dictionary format, and the dictionary includes two fields: content and metadata;
[0019] The content field stores the text information in the document, and the metadata field stores the metadata of the document, including the document name, storage address, page number, and author information.
[0020] Wherein, in said step 2, the document content is split;
[0021] The long text of special vehicle operation and maintenance knowledge loaded in step 1 is split into text blocks of shorter length so that it does not exceed the input window length L of the text embedding model; the documents after block division can be more finely semantically matched according to the content of the blocks, thereby enhancing the accuracy of the model's semantic understanding and reasoning in the field of special vehicle operation and maintenance, and improving the accuracy, reliability and query efficiency of special vehicle operation and maintenance information; the step 2 specifically includes the following steps:
[0022] S21, read the document data document_data loaded in step 1 one by one in order, each document is an independent data;
[0023] S22, dividing each document data into small blocks to obtain text chunks, each text chunk contains no more than 256 characters, and the overlap rate of the first and last characters of consecutive text chunks is 25%, to ensure the continuity of semantic information of the long text context;
[0024] S23, adding metadata to the text block data, including document name, storage address, page number, and start index; the metadata records information such as the source of the special vehicle operation and maintenance knowledge data, facilitates data tracing and quality control, and ensures the reliability, traceability, and authenticity of the retrieval-generated answers;
[0025] S24, stores the text block data set in the database, uses a non-relational database to store the special vehicle operation and maintenance knowledge text block data, creates a table chunk_table to store the text block data and metadata, and the table contains chunk_id (primary key), doc_id (document ID), chunk_text (Chunk text content), and metadata (metadata in JSON format) fields.
[0026] Wherein, in said step 3, the text block is vectorized;
[0027] The special vehicle operation and maintenance knowledge text block dataset generated in step 2 is converted into a dense vector, and the semantic information in the text is expressed by vectors, so as to solve the special vehicle operation and maintenance retrieval problem based on vectors; the high-dimensional text data is mapped to a low-dimensional vector space through a language embedding model, which can not only extract the semantic information of words and sentences, but also perform computational analysis in the form of vectors in the vector space, which can significantly improve the computational efficiency;
[0028] Specifically, step 3 adopts the Chinese large language embedding model
[0029] M3E_PHM_Embedding encodes each special vehicle operation and maintenance knowledge text block data into a dense vector; based on the general large language embedding model, the model is fine-tuned using special vehicle operation and maintenance knowledge data to enable it to better understand the semantic information in the field of special vehicle operation and maintenance, ensuring that the generated vector can not only understand general semantic information, but also have the ability to understand professional field information; the calculation process of the vector representation dv of the text block chunk is as follows:
[0030] dv=M3E_PHM_Embedding(chunk)
[0031] Among them, the length of dv is 768.
[0032] Wherein, in said step 4, text vector data is stored and index is constructed;
[0033] After the special vehicle operation and maintenance knowledge text block is mapped into dense vector data, it needs to be stored in the vector database, and the vector data is associated with the text block through the primary key chunk_id as the index to achieve persistent storage and management of the vector data and provide efficient vector query, editing and deletion services; the database data format is defined as follows:
[0034]
[0035] The embeddings are composed of text block vectors dv, documents are composed of text block chunks, and chunk_ids are composed of primary keys chunk_id.
[0036] Wherein, in said step 5, knowledge base retrieval;
[0037] In the process of special vehicle operation and maintenance knowledge retrieval, semantic-based retrieval is used to match queries and documents using semantic information. It can accurately understand the meaning of special vehicle operation and maintenance knowledge, thereby finding document knowledge that is semantically related to the problem. Knowledge retrieval is implemented using semantic similarity, and the main steps include system role definition, system initialization, parsing user input, semantic similarity calculation, and candidate answer generation.
[0038] Wherein, the step 5 comprises:
[0039] Step 51: System role definition; Step 51 defines the role "role_definition" of "special vehicle operation and maintenance knowledge retrieval assistant" through 5 fields, including "role" role name, "description" general description, "abilities" specific capabilities, "knowledge_domains" knowledge domains, and "behavior_guidelines" behavior norms. Through the role definition, the retrieval system is initialized, and the user is briefly introduced to the function and usage information in the form of an opening statement, which helps to ensure the professionalism, accuracy, efficiency and practicality of the large model assistant, so as to better serve users and improve the quality and efficiency of equipment operation and maintenance;
[0040] Specifically, the design of the role definition prompt role_definition_prompt is as follows:
[0041] role_definition_prompt = {
[0042] "role":"Special Vehicle Operation and Maintenance Knowledge Retrieval Assistant",
[0043] "description":"You are a professional special vehicle operation and maintenance knowledge retrieval intelligent assistant, designed to help users solve various problems related to special vehicle maintenance and operation. Users will use natural language to ask questions. You need to understand the user's questions and provide relevant and useful information;",
[0044] "abilities":[
[0045] "Quickly and accurately retrieve knowledge related to special vehicle operation and maintenance",
[0046] "Be familiar with the daily maintenance and care knowledge of special vehicles to provide users with correct operating instructions and suggestions",
[0047] "Have the ability to identify and troubleshoot special vehicle faults, diagnose problems based on the symptoms described by the user, and provide solutions or suggestions",
[0048] "Understanding the potential safety hazards and emergency response measures during the operation of special vehicles, and being able to provide users with safe operation guidance and suggestions for dealing with emergencies",
[0049] "Have an in-depth understanding of the structure, working principle, technical parameters, etc. of special vehicles, so as to accurately understand and answer users' related questions",
[0050] "Able to interpret technical documents and standards related to special vehicles, including operation manuals, maintenance manuals, technical specifications, etc., and provide users with accurate interpretation and application guidance"
[0051] ],
[0052] "knowledge_domains":[
[0053] "Tank", "Armored Vehicle", "Military Truck", "Military Transport Vehicle", "Command Vehicle", "Communication Vehicle", "Other Special Vehicles"
[0054] ],
[0055] "behavior_guidelines":[
[0056] "Always remain professional, objective and neutral",
[0057] "Prioritize official operation and maintenance manuals and technical documents and other authoritative sources",
[0058] "Ensure that the information retrieved is accurate, reliable, and relevant to the user's query",
[0059] "Avoid providing any unverified or outdated information",
[0060] "Communicate with users using clear, concise and understandable language",
[0061] "If you don't know the answer or the search knowledge is empty, please say you don't know",
[0062] "The first sentence you output is "Hello! I am a special vehicle operation and maintenance knowledge retrieval assistant; I am designed to help you obtain information about the field of special vehicle operation and maintenance; whether you are looking for a specific vehicle's operation and maintenance manual, laws and regulations, standards and specifications, or want to understand operation and maintenance case knowledge, I can help you; \nPlease tell me what kind of information you need, or ask your questions, and I will do my best to provide you with accurate and useful answers; if you are not sure how to start, you can try asking me questions about specific equipment types, FAQs, or best practices; let's get started!"]
[0063] };
[0064] Step 52: System initialization; input the role definition prompt sentence role_definition_prompt into the large language model Llama3_zh_phm, so that the large model completes the initialization of the special vehicle operation and maintenance knowledge retrieval assistant and obtains the capabilities defined in the role definition prompt sentence; wherein, the Llama3_zh_phm model is a special vehicle operation and maintenance Chinese large model obtained by fine-tuning hundreds of thousands of special vehicle operation and maintenance knowledge texts on the basis of the general pre-trained Chinese model Llama3_zh; the system initialization response initial_response is calculated as follows:
[0065] initial_response=Llama3_zh_phm(role_definition_prompt);
[0066] Step 53: Parsing user input: Receive the user's input query statement q and convert the unstructured query query statement q into a structured query embedding vector q v ; Among them, q v The text embedding vector converted by the M3E_PHM_Embedding large language embedding model as in step 3 ensures the consistency of semantics and contextual understanding in the field of special vehicle operation and maintenance during storage and retrieval, and improves the retrieval effect of special vehicle operation and maintenance knowledge;
[0067] q v =M3E_PHM_Embedding(q)
[0068] Step 54: Calculate semantic similarity; calculate the similarity between the question retrieval statement q and each text block d in the special vehicle operation and maintenance knowledge base, measure the relevance between the question and each special vehicle operation and maintenance knowledge text block, and sort the similarities, and only retain the index ID corresponding to the top K text data block vectors in similarity ranking i As the search result, a more accurate reference answer index is left to achieve the screening of the search results;
[0069] First, the BM25 algorithm is used to calculate the score S of the search statement q and all text blocks d in the database. BM25 (q, d), retain the text blocks corresponding to the top 2K scores; BM25 is an efficient document retrieval algorithm, and its calculation process is as follows, S BM25 (q, d) represents the correlation between document d and query q. It has good support for both long documents and short texts, and is suitable for large-scale and small-scale document retrieval such as special vehicle operation and maintenance knowledge.
[0070]
[0071] Where n is the number of words in the query, q i is the □th word in the query, IDF(q i ) is the word q i The inverse document frequency, f(q i ,d) is word q i The frequency in document d, |d| is the length of document d, avgdl is the average document length of the entire document set, k1 and b are adjustment parameters, usually set to empirical values, in this step k1 = 1.3, b = 0.7;
[0072] Then, the text blocks retrieved by the BM25 algorithm are sorted twice, and the top K results after the second sort are returned; the calculation formula for the score S(q,d) in the second sort is as follows:
[0073] S(q,d)=αS BM25 (q,d)+(1-α)S L (q,d)
[0074]
[0075] S L (q, d) is the semantic similarity between the search sentence q and the text block d, which is calculated using the cosine similarity function. v is the text embedding vector corresponding to the text block d in the vector database;
[0076] Step 55: Candidate answers are returned; according to the index ID corresponding to the top K text embedding vectors iRetrieve the corresponding knowledge text block d i , as a knowledge information source for special vehicle operation and maintenance knowledge related issues; and the knowledge text block d i The document name and path in the corresponding metadata are returned together with the reference answer to ensure that the retrieved answer can be traced. Users can find the original document by the document name and path, which enhances the credibility of the result. The file format is designed as follows:
[0077] {
[0078] "question":"Questions raised by users",
[0079] "answer":{"Reference text block 1","Reference text block 2",…,"Reference text block K"},
[0080] "metadata":{
[0081] "name":{"Data 1","Data 2",…,"Data K",},
[0082] "path":{"Path 1","Path 2",…,"Path K",},
[0083] }
[0084] }.
[0085] Wherein, in said step 6, a result is generated;
[0086] Based on the candidate answers obtained in step 5, the model is guided to evaluate the accuracy, completeness, and relevance of each answer by constructing a generated prompt statement, synthesizing the information of multiple candidate answers or selecting the best answer, and providing explanations and supplements to provide the user with the most accurate, complete, and relevant final answer;
[0087] Step 61: Restate the question. Re-define the user question in the result generation prompt. Use the field "user_query" to define the question to ensure that the model understands the core content and objectives of the question. The format is defined as follows:
[0088] "user_query":"Questions asked by users";
[0089] Step 62: Presentation of candidate answers. The top K candidate answers retrieved in step 5 are presented to the special vehicle operation and maintenance model in a clear manner, and their ranking order is indicated. The field "candidate_answers" defines the candidate answers, and the field "rank" defines the ranking. The field "candidate_answers" is displayed as follows:
[0090] "candidate_answers":[
[0091] {
[0092]
[0093] Step 63: Guide the model analysis, through the field "analysis_instruction", guide the special vehicle operation and maintenance Chinese model to analyze the candidate answers, and evaluate the accuracy, completeness and relevance of the answers based on the question and context information;
[0094] The field "analysis_instruction" is defined as follows:
[0095] "analysis_instruction":"Please carefully analyze the candidate answers above and evaluate the accuracy, completeness, and relevance of each answer based on the user's question and background information; consider the following factors:
[0096] Does the answer directly answer the user's question?
[0097] Does the answer provide enough detail and information?
[0098] Does the answer come from a reliable source?
[0099] Does the answer apply to the user's specific situation?";
[0100] Step 64: Instruct answer generation. Through the field "final_answer_instruction", instruct the special vehicle operation and maintenance Chinese model to generate the final answer based on the analysis results; require the model to integrate the information of multiple candidate answers, or select the best answer and explain and supplement it;
[0101] The field "final_answer_instruction" is defined as follows:
[0102] "final_answer_instruction":"Based on your analysis, please generate the final answer to provide users with the most accurate, complete, and relevant solution; you can combine information from multiple candidate answers, or select the best answer and explain and supplement it;"
[0103] Step 65: Generate answers to questions; Use prompts to build a thinking chain to guide the special vehicle operation and maintenance Chinese large model to generate ideal answers, merge the aforementioned "role_definition", "candidate_answers", "analysis_instruction", and "final_answer_instruction" into answer_generat_prompt, and then inject prompt into the large model to generate the final answer;
[0104] answer_generat_prompt={"role_definition","candidate_answers","analysis_instruction","final_answer_instruction"}
[0105] final_answer=Llama3_zh_phm(answer_generat_prompt).
[0106] Wherein, in said step 7, iterative question and answer retrieval;
[0107] In the process of retrieving information, it is not possible to get the ideal answer through just one search. By tracking the conversation history and recording the context information, the system can more accurately understand the user's questions, supplement the details of the questions, correct the wrong information, and thus provide more relevant answers, improve the accuracy and efficiency of special vehicle operation and maintenance knowledge retrieval, and provide an interactive knowledge retrieval experience;
[0108] During the iterative knowledge retrieval process, the special vehicle operation and maintenance Chinese large model needs to refer to historical conversation records to form memory, reconstruct questions according to the context to form new questions, and re-retrieve answers.
[0109] The step 7 comprises the following steps:
[0110] Step 71: Construct a dialogue record chain; it is used to record the dialogue record between the system and the user during the knowledge retrieval process. After each interactive question and answer retrieval, the dialogue record chain needs to be updated. The format of the dialogue record chain is as follows, which is composed of dialogue records of user input "user_input" and machine output "system_response" alternately;
[0111] history:[{"user_input":"...",
[0112] "system_response":"..."},{"user_input":"...","system_response":"..."},…]
[0113] Step 72: construct a new question generation prompt new_question_prompt; by giving constraints to control input information, avoid generating questions that are irrelevant to special vehicle operation and maintenance knowledge, provide more customized services and solutions in the field of special vehicle operation and maintenance, thereby improving the quality of generated questions and making the system more intelligent and effective; the composition of the question reconstruction prompt new_question_prompt is as follows: the historical retrieval dialogue is injected into the history field, and the user question is injected into the question field;
[0114] new_question_prompt:["Generate a new question based on historical conversation records and the latest user questions, and meet the following requirements:
[0115] (1) If there are missing pronouns or conditions in the question, please ask a complete question based on the context;
[0116] (2) If the question information is complete enough, please keep the original question; otherwise, please prompt the user to provide additional information;
[0117] (3) If the user's question deviates from the field of special vehicle operation and maintenance knowledge retrieval, please remind the user to limit the scenario to special vehicle operation and maintenance knowledge retrieval;
[0118] (4)Understandable without chat log; do not answer the question, just rewrite it if necessary, otherwise return it as is;",
[0119] {"history conversation record": {history}},
[0120] {"question": {question}}]
[0121] Step 73: Generate a new question; input the integrated question reconstruction prompt new_question_prompt containing historical dialogue information and questions into the special vehicle operation and maintenance model, and the model regenerates a new question by understanding the context and the question;
[0122] new_question=Llama3_zh_phm(new_question_prompt)
[0123] Step 74: Answer retrieval and generation; based on the newly generated question, restart the retrieval process, refer to the process in step 6 for details.
[0124] (III) Beneficial effects
[0125] Compared with the prior art, the special vehicle operation and maintenance knowledge retrieval model constructed by the present invention based on the large model method not only improves the efficiency and accuracy of information retrieval, but also provides comprehensive, real-time and personalized knowledge support for maintenance personnel, ultimately helping to improve the maintenance and operation efficiency of special vehicles and ensure their safety and reliability. BRIEF DESCRIPTION OF THE DRAWINGS
[0126] Figure 1 It is a schematic diagram of the special vehicle operation and maintenance knowledge retrieval process of the present invention.
[0127] Figure 2 Schematic diagram of the initialization results of the special vehicle operation and maintenance knowledge retrieval assistant.
[0128] Figure 3 This is a schematic diagram of the system search results.
[0129] Figure 4 Schematic diagram of iterative retrieval results. DETAILED DESCRIPTION
[0130] In order to make the purpose, content, and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the accompanying drawings and examples.
[0131] Example 1
[0132] This embodiment provides a special vehicle operation and maintenance knowledge retrieval method based on a large model, which mainly includes the following steps:
[0133] Step 1: Document knowledge data loading. Use the document loader to obtain operation-related document data from the local special vehicle operation and maintenance knowledge database, and extract the content and metadata in the document. The data used in this example includes special vehicle basic data, vehicle structure and principle data, vehicle operation and maintenance data, vehicle operation status data, case data, legal and regulatory data, and other related data, totaling about 5,000 documents, mainly in Word, TXT, and PDF formats.
[0134] The acquired document data document_data is stored in the memory in a dictionary format, and the dictionary includes two fields: content and metadata. The content field stores the text information in the document, and the metadata field stores the metadata of the document, including the document name, storage address, page number, author and other information.
[0135] Step 2: Document content splitting. Split the long text of special vehicle operation and maintenance knowledge loaded in step 1 into shorter text blocks so that it does not exceed the input window length L of the text embedding model. The input window length of the text embedding model used in this example is 512. Since the documents related to special vehicle operation and maintenance vary in length, including very long documents such as operation and maintenance manuals and short documents such as maintenance records, the segmented documents can perform more refined semantic matching based on the content of the blocks, enhance the accuracy of the model's semantic understanding and reasoning in the field of special vehicle operation and maintenance, improve the accuracy, reliability and query efficiency of special vehicle operation and maintenance information, and avoid retrieving the entire document at one time, resulting in problems such as loss of key information and semantics. The specific steps include:
[0136] S21, read the document data document_data loaded in step 1 one by one in order, each document is an independent data;
[0137] S22, divide each document data into small blocks to obtain text chunks, each text chunk has no more than 256 characters, and the overlap rate of the first and last characters of consecutive text chunks is 25%, to ensure the continuity of semantic information of the long context.
[0138] S23, add metadata to the text block data, including document name, storage address, page number, and start index. Metadata can record information such as the source of special vehicle operation and maintenance knowledge data, facilitate data tracing and quality control, and ensure the reliability, traceability, and authenticity of the retrieval-generated answers.
[0139] S24, stores the text block data set in the database, uses a non-relational database to store the special vehicle operation and maintenance knowledge text block data, creates a table chunk_table to store the text block data and metadata, and the table contains chunk_id (primary key), doc_id (document ID), chunk_text (Chunk text content), and metadata (metadata in JSON format) fields.
[0140] Step 3: Text block vectorization processing. Convert the special vehicle operation and maintenance knowledge text block dataset generated in step 2 into a dense vector, express the semantic information in the text with a vector, and solve the special vehicle operation and maintenance retrieval problem based on the vector. By mapping high-dimensional text data to a low-dimensional vector space through a language embedding model, not only can the semantic information of words and sentences be extracted, but also computational analysis can be performed in the form of vectors in the vector space, which can significantly improve computational efficiency.
[0141] The present invention uses the Chinese large language embedding model M3E_PHM_Embedding to encode each special vehicle operation and maintenance knowledge text block data into a dense vector. The model is trained with 22 million sentence pairs of samples from more than 30 fields, and is fine-tuned with special vehicle operation and maintenance knowledge data to enable it to better understand the semantic information in the field of special vehicle operation and maintenance, ensuring that the generated vector can not only understand general semantic information, but also have the ability to understand information in the field of special vehicle operation and maintenance. The calculation process of the vector representation dv of the text block chunk is as follows:
[0142] dv=M3E_PHM_Embedding(chunk)
[0143] Among them, the length of dv is 768.
[0144] Step 4: Text vector data storage and index construction. After the special vehicle operation and maintenance knowledge text block is mapped into dense vector data, it needs to be stored in the vector database, and the vector data is associated with the text block through the primary key chunk_id as the index to achieve persistent storage and management of vector data and provide efficient vector query, editing and deletion services.
[0145] The following is sample data containing two text blocks and their corresponding vector representations:
[0146]
[0147] The embeddings are composed of text block vectors, documents are composed of text blocks, and chunk_ids are composed of the primary key chunk_id.
[0148] Step 5: Knowledge base retrieval. In the process of special vehicle operation and maintenance knowledge retrieval, semantic-based retrieval uses semantic information to match queries and documents. Compared with traditional keyword matching, it can more accurately understand the meaning of special vehicle operation and maintenance knowledge and more easily find document knowledge related to the semantics of the problem. The main steps of knowledge retrieval using semantic similarity include system role definition, system initialization, parsing user input, semantic similarity calculation, and candidate answer generation.
[0149] S51, system role definition. The present invention defines the role "role_definition" of "special vehicle operation and maintenance knowledge retrieval assistant" through 5 fields, including "role" role name, "description" general description, "abilities" specific capabilities, "knowledge_domains" knowledge domains, and "behavior_guidelines" behavior norms. Through the role definition, the retrieval system can be initialized to briefly introduce the functions and usage information to the user in the form of an opening statement, which helps to ensure the professionalism, accuracy, efficiency and practicality of the large model assistant, so as to better serve users and improve the quality and efficiency of equipment maintenance. The design of the role definition prompt role_definition_prompt is as follows:
[0150] role_definition_prompt = {
[0151] "role":"Special Vehicle Operation and Maintenance Knowledge Retrieval Assistant",
[0152] "description":"You are a professional special vehicle operation and maintenance knowledge retrieval intelligent assistant, designed to help users solve various problems related to special vehicle maintenance and operation. Users will use natural language to ask questions. You need to understand the user's questions and provide relevant and useful information.",
[0153] "abilities":[
[0154] "Quickly and accurately retrieve knowledge related to special vehicle operation and maintenance",
[0155] "Be familiar with the daily maintenance and care knowledge of special vehicles to provide users with correct operating instructions and suggestions",
[0156] "Have the ability to identify and troubleshoot special vehicle faults, diagnose problems based on the symptoms described by the user, and provide solutions or suggestions",
[0157] "Understanding the potential safety hazards and emergency response measures during the operation of special vehicles, and being able to provide users with safe operation guidance and suggestions for dealing with emergencies",
[0158] "Have an in-depth understanding of the structure, working principle, technical parameters, etc. of special vehicles, so as to accurately understand and answer users' related questions",
[0159] "Able to interpret technical documents and standards related to special vehicles, including operation manuals, maintenance manuals, technical specifications, etc., and provide users with accurate interpretation and application guidance"
[0160] ],
[0161] "knowledge_domains":[
[0162] "Tank", "Armored Vehicle", "Military Truck", "Military Transport Vehicle", "Command Vehicle", "Communication Vehicle", "Other Special Vehicles"
[0163] ],
[0164] "behavior_guidelines":[
[0165] "Always remain professional, objective and neutral",
[0166] "Prioritize official operation and maintenance manuals and technical documents and other authoritative sources",
[0167] "Ensure that the information retrieved is accurate, reliable, and relevant to the user's query",
[0168] "Avoid providing any unverified or outdated information",
[0169] "Communicate with users using clear, concise and understandable language",
[0170] "If you don't know the answer or the search knowledge is empty, please say you don't know",
[0171] "The first sentence you output is "Hello! I am a special vehicle operation and maintenance knowledge retrieval assistant. I am designed to help you obtain information about the field of special vehicle operation and maintenance. Whether you are looking for operation and maintenance manuals, laws and regulations, standards and specifications for a specific vehicle, or want to understand operation and maintenance case knowledge, I can help you. \nPlease tell me what kind of information you need, or ask your questions, and I will do my best to provide you with accurate and useful answers. If you are not sure how to start, you can try asking me questions about specific equipment types, FAQs, or best practices. Let's get started!"]
[0172] }
[0173] S52, system initialization. Input the role definition prompt role_definition_prompt into the large language model Llama3_zh_phm, so that the large model completes the initialization of the special vehicle operation and maintenance knowledge retrieval assistant and obtains the capabilities defined in the role definition prompt. Among them, the Llama3_zh_phm model is a special vehicle operation and maintenance Chinese large model obtained by fine-tuning hundreds of thousands of special vehicle operation and maintenance knowledge texts based on the general pre-trained Chinese model Llama3_zh. The system initialization response initial_response is calculated as follows:
[0174] initial_response=Llama3_zh_phm(role_definition_prompt)
[0175] When the user opens the search assistant, the system automatically completes the initialization. Figure 2 shown.
[0176] S53, parsing user input: receiving the user's input search sentence q, and converting the unstructured question search sentence q into a structured query embedding vector q v Among them, q v The text embedding vector converted by the M3E_PHM_Embedding large language embedding model as in step 3 ensures the consistency of semantic and contextual understanding in the field of special vehicle operation and maintenance during the storage and retrieval processes, and improves the retrieval effect of special vehicle operation and maintenance knowledge.
[0177] q v =M3E_PHM_Embedding(q)
[0178] S54, semantic similarity calculation. Calculate the similarity between the question retrieval statement q and each text block d in the special vehicle operation and maintenance knowledge base, measure the relevance between the question and each special vehicle operation and maintenance knowledge text block, and sort the similarities, only retaining the index ID corresponding to the top K text data block vectors in similarity ranking i As the retrieval result, a more accurate reference answer index is left to implement the screening of the retrieval results. In this example, K is defined as 5.
[0179] First, the BM25 algorithm is used to calculate the score S of the search statement q and all text blocks d in the database. BM25 (q, d), retain the text blocks corresponding to the top 2K scores. BM25 is an efficient document retrieval algorithm. Its calculation process is as follows: S BM25 (q, d) represents the correlation between text block d and query q. It has good support for both long and short documents and is suitable for large-scale and small-scale document retrieval such as special vehicle operation and maintenance knowledge.
[0180]
[0181] Where n is the number of words in the query, q i Is the first words, IDF(q i ) is the word q i The inverse document frequency, f(q i ,d) is word q iis the frequency in text block d, |d| is the length of text block d, avgdl is the average document length of the entire document set, k1 and b are adjustment parameters, usually set to empirical values, in the present invention k1=1.3, b=0.7.
[0182] Then, the text blocks retrieved by the BM25 algorithm are sorted twice, and the top K results after the second sort are returned. The calculation formula for the score S(q,d) in the second sort is as follows:
[0183] S(q,d)=αS BM25 (q,d)+(1-α)S L (q,d)
[0184]
[0185] S L (q, d) is the semantic similarity between the search sentence q and the text block d, which is calculated using the cosine similarity function. v is the text embedding vector corresponding to the text block d in the vector database.
[0186] S55: Candidate answers are returned. According to the index ID corresponding to the top K text embedding vectors, i Retrieve the corresponding knowledge text block d i , as a knowledge information source for special vehicle operation and maintenance knowledge related issues. And the knowledge text block d i The document name and path in the corresponding metadata are returned together with the reference answer to ensure that the retrieved answer can be traced. Users can find the original document by the document name and path, which enhances the credibility of the result. The file format is designed as follows:
[0187]
[0188] In this example, taking the question "What are the consequences of low brake fluid pressure in an armored vehicle?" as an example, the candidate answers in the specified format are returned as follows:
[0189] {
[0190] "question":"What are the consequences of low brake fluid pressure in armored vehicles?",
[0191] "answer":{"Weakened braking effect: Brake fluid is the medium for transmitting braking force. Insufficient pressure means that the energy transmission efficiency of the braking system is reduced, resulting in weakened braking force and increased braking distance. This may make it impossible to stop the car in time in an emergency, posing a very high safety risk.","Brake failure: If the brake fluid is seriously insufficient, it may cause complete brake failure. Because air can enter the braking system, and air is compressible, this will seriously affect the cylinder from building up enough pressure to perform effective braking.",…,"Safety hazards: When driving at high speeds or in complex terrain, the decline in braking efficiency will greatly increase the probability of accidents, posing a threat to vehicle occupants and surrounding personnel."},
[0192] "metadata":{
[0193] "name":{"Armored Vehicle Maintenance Manual","Common Armored Vehicle Failure Cases",…,"Armored Vehicle Training Materials",},
[0194] "path":{"…\Special vehicle knowledge base\Fault knowledge","…\Special vehicle knowledge base\Fault knowledge",…,"…\Special vehicle knowledge base\Faultknowledge",},
[0195] }
[0196] }
[0197] Step 6: Result generation. Based on the candidate answers obtained in step 5, the model is guided by constructing a prompt statement to evaluate the accuracy, completeness, and relevance of each answer, synthesize the information of multiple candidate answers or select the best answer, and explain and supplement it to provide the user with the most accurate, complete, and relevant final answer.
[0198] S61, Question Restatement, re-clarifies the user question in the result generation prompt, and defines the question with the field "user_query" to ensure that the model understands the core content and objectives of the question. The format is defined as follows:
[0199] "user_query":"Questions asked by users"
[0200] S62, candidate answer presentation, present the top K candidate answers retrieved in step 5 to the special vehicle operation and maintenance model in a clear manner, and indicate their ranking order, where the field "candidate_answers" defines the candidate answers and the field "rank" defines the ranking. The use case example is shown below:
[0201] "candidate_answers":[
[0202] {
[0203] "rank":1,"content":"Search content 1","path":"Path 1"
[0204] },
[0205]
[0206] S63, guides model analysis, through the field "analysis_instruction", guides the special vehicle operation and maintenance Chinese model to analyze candidate answers, and evaluates the accuracy, completeness and relevance of the answers based on the question and context information. The use case definition is as follows:
[0207] "analysis_instruction":"Please carefully analyze the candidate answers above and evaluate the accuracy, completeness, and relevance of each answer based on the user question and background information. Consider the following factors:
[0208] Does the answer directly answer the user's question?
[0209] Does the answer provide enough detail and information?
[0210] Does the answer come from a reliable source?
[0211] Does the answer apply to your specific situation? "
[0212] S64, guides answer generation, through the field "final_answer_instruction", guides the special vehicle operation and maintenance Chinese model to generate the final answer based on the analysis results. The model is required to integrate the information of multiple candidate answers, or select the best answer and explain and supplement it. The use case definition is as follows:
[0213] "final_answer_instruction":"Based on your analysis, please generate a final answer that provides the most accurate, complete, and relevant solution to the user. You can combine information from multiple candidate answers, or select the best answer and provide explanations and supplements."
[0214] S65, generate answers to questions. Use prompts to build a thinking chain to guide the special vehicle operation and maintenance Chinese large model to generate ideal answers, merge the aforementioned "role_definition", "candidate_answers", "analysis_instruction", and "final_answer_instruction" into answer_generat_prompt, and then inject prompt into the large model to generate the final answer.
[0215] answer_generat_prompt={"role_definition","candidate_answers","analysis_instruction","final_answer_instruction"}
[0216] final_answer=Llama3_zh_phm(answer_generat_prompt)
[0217] In this example, taking the question "What are the consequences of low brake fluid pressure in armored vehicles?" as an example, the final answer format is obtained through the special vehicle operation and maintenance Chinese large model retrieval. Figure 3 shown.
[0218] Step 7: Iterative question-answer retrieval. In the process of retrieving information, you cannot get the ideal answer through just one search. By tracking the conversation history and recording context information, the system can more accurately understand the user's questions, supplement the details of the questions, correct the wrong information, and provide more relevant answers, thereby improving the accuracy and efficiency of special vehicle operation and maintenance knowledge retrieval and providing an interactive knowledge retrieval experience.
[0219] In the process of iterative knowledge retrieval, the special vehicle operation and maintenance Chinese model needs to refer to historical conversation records to form memory, reconstruct questions according to the context to form new questions, and re-retrieve answers. The following steps are included:
[0220] S71: Construct a dialogue record chain. This is used to record the dialogue record between the system and the user during the knowledge retrieval process. After each interactive question and answer retrieval, the dialogue record chain needs to be updated. The format of the dialogue record chain is as follows, which is composed of dialogue records of user input "user_input" and machine output "system_response" alternately.
[0221] history:[{"user_input":"...",
[0222] "system_response":"..."},{"user_input":"...","system_response":"..."},…]
[0223] S72: Construct a new question generation prompt new_question_prompt. By giving constraints to control input information, avoid generating questions that are irrelevant to special vehicle operation and maintenance knowledge, provide more customized services and solutions in the field of special vehicle operation and maintenance, thereby improving the quality of generated questions and making the system more intelligent and effective. The question reconstruction prompt new_question_prompt is composed as follows: the historical search dialogue is injected into the history field, and the user question is injected into the question field.
[0224] new_question_prompt:["Generate a new question based on historical conversation records and the latest user questions, and meet the following requirements:
[0225] 1. If there are missing pronouns or conditions in the question, ask a complete question based on the context.
[0226] 2. If the question information is complete enough, please keep the original question, otherwise please prompt the user to provide additional information.
[0227] 3. If the user's question deviates from the field of special vehicle operation and maintenance knowledge retrieval, please remind the user to limit the scenario to special vehicle operation and maintenance knowledge retrieval.
[0228] 4.Understandable without chat history. Don't answer the question, just rewrite it if necessary, otherwise return it as is. ",
[0229] {"history conversation record": {history}},
[0230] {"question": {question}}]
[0231] S73: Generate new questions. The integrated question reconstruction prompt new_question_prompt containing historical dialogue information and questions is input into the special vehicle operation and maintenance model. The model regenerates new questions by understanding the context and questions.
[0232] new_question=Llama3_zh_phm(new_question_prompt)
[0233] Taking the question "What are the consequences of low brake fluid pressure in armored vehicles?" as an example, after the first round of search, we get the following results: Figure 3The candidate answer in the question continues to ask "What should I do if the first consequence occurs?" Then the special vehicle operation and maintenance knowledge retrieval assistant combines historical consultation records and generates a new question: "If the armored vehicle does have a weakened braking effect, how should it be handled urgently to ensure safety?"
[0234] S74: Answer retrieval and generation: Based on the newly generated question, the retrieval process is restarted, and the specific process is as follows: step 6.
[0235] Based on the new question "If the brakes of an armored vehicle do weaken, what emergency measures should be taken to ensure safety?", the following results are retrieved: Figure 4 New results.
[0236] In summary, the present invention belongs to the field of equipment operation and maintenance, and specifically relates to a special vehicle operation and maintenance knowledge retrieval method based on a large model, including: document knowledge data loading, using a document loader to obtain operation and maintenance related document data from a local special vehicle operation and maintenance knowledge database; document content splitting, splitting the long text of special vehicle operation and maintenance knowledge into text blocks of shorter length; text block vectorization processing, converting the special vehicle operation and maintenance knowledge text block data set into a dense vector, and expressing the semantic information in the text with a vector; text vector data storage and index construction, storing the dense vector data in a vector database, and associating the vector data with the text block through the primary key as an index; knowledge base retrieval, using semantic-based retrieval to match queries and documents using semantic information; result generation, guiding the model to evaluate the accuracy, completeness and relevance of each answer by constructing a prompt statement, and providing the user with the most accurate, complete and relevant final answer; iterative question and answer retrieval, tracking the conversation history, recording context information, improving the accuracy and efficiency of special vehicle operation and maintenance knowledge retrieval, and providing an interactive knowledge retrieval experience. The special vehicle operation and maintenance knowledge retrieval model constructed by the present invention based on the large model method not only improves the efficiency and accuracy of information retrieval, but also provides comprehensive, real-time and personalized knowledge support for maintenance personnel, which ultimately helps to improve the maintenance and operation efficiency of special vehicles and ensure their safety and reliability.
[0237] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A special vehicle operation and maintenance knowledge retrieval method based on a large model, characterized in that: The method comprises the following steps: Step 1: Document knowledge data loading; Step 2: Document content splitting; Step 3: vectorization processing of text blocks; Step 4: Text vector data storage and index construction; Step 5: Knowledge base search; Step 6: Result generation; Step 7: Iterate question-answer retrieval.
2. The large model-based special vehicle operation and maintenance knowledge retrieval method according to claim 1, characterized in that: In the step 1, document knowledge data is loaded; Use the document loader to obtain operation and maintenance related document data from the local special vehicle operation and maintenance knowledge database, and extract the content and metadata in the document; The acquired document knowledge data document_data is stored in the memory in a dictionary format, and the dictionary includes two fields: content and metadata; The content field stores the text information in the document, and the metadata field stores the metadata of the document, including the document name, storage address, page number, and author information.
3. The large model-based special vehicle operation and maintenance knowledge retrieval method according to claim 2, characterized in that: In the step 2, the document content is split; The long text of special vehicle operation and maintenance knowledge loaded in step 1 is split into text blocks of shorter length so that it does not exceed the input window length L of the text embedding model; the documents after block division can be more finely semantically matched according to the content of the blocks, thereby enhancing the accuracy of the model's semantic understanding and reasoning in the field of special vehicle operation and maintenance, and improving the accuracy, reliability and query efficiency of special vehicle operation and maintenance information; the step 2 specifically includes the following steps: S21, read the document data document_data loaded in step 1 one by one in order, each document is an independent data; S22, dividing each document data into small blocks to obtain text chunks, each text chunk contains no more than 256 characters, and the overlap rate of the first and last characters of consecutive text chunks is 25%, to ensure the continuity of semantic information of the long text context; S23, adding metadata to the text block data, including document name, storage address, page number, and start index; the metadata records information such as the source of the special vehicle operation and maintenance knowledge data, facilitates data tracing and quality control, and ensures the reliability, traceability, and authenticity of the retrieval-generated answers; S24, stores the text block data set in the database, uses a non-relational database to store the special vehicle operation and maintenance knowledge text block data, creates a table chunk_table to store the text block data and metadata, and the table contains chunk_id (primary key), doc_id (document ID), chunk_text (Chunk text content), and metadata (metadata in JSON format) fields.
4. The large model-based special vehicle operation and maintenance knowledge retrieval method according to claim 3, characterized in that: In the step 3, the text block is vectorized; The special vehicle operation and maintenance knowledge text block dataset generated in step 2 is converted into a dense vector, and the semantic information in the text is expressed by vectors, so as to solve the special vehicle operation and maintenance retrieval problem based on vectors; the high-dimensional text data is mapped to a low-dimensional vector space through a language embedding model, which can not only extract the semantic information of words and sentences, but also perform computational analysis in the form of vectors in the vector space, which can significantly improve the computational efficiency; Specifically, the step 3 uses the Chinese large language embedding model M3E_PHM_Embedding to encode each special vehicle operation and maintenance knowledge text block data into a dense vector; based on the general large language embedding model, the model uses special vehicle operation and maintenance knowledge data for fine-tuning, so that it can better understand the semantic information in the field of special vehicle operation and maintenance, ensuring that the generated vector can not only understand general semantic information, but also have the ability to understand professional field information; the calculation process of the vector representation dv of the text block chunk is as follows: dv=M3E_PHM_Embedding(chunk) Among them, the length of dv is 768.
5. The large model-based special vehicle operation and maintenance knowledge retrieval method according to claim 4, characterized in that: In step 4, text vector data is stored and index is constructed; After the special vehicle operation and maintenance knowledge text block is mapped into dense vector data, it needs to be stored in the vector database, and the vector data is associated with the text block through the primary key chunk_id as the index to achieve persistent storage and management of the vector data and provide efficient vector query, editing and deletion services; the database data format is defined as follows: { embeddings=[dv1,dv2,…], documents=["chunk1","chunk 2",…], chunk_ids=["chunk_id1","chunk_id2",…] } The embeddings are composed of text block vectors dv, documents are composed of text block chunks, and chunk_ids are composed of primary keys chunk_id.
6. The large model-based special vehicle operation and maintenance knowledge retrieval method according to claim 5, characterized in that: In the step 5, the knowledge base is searched; In the process of special vehicle operation and maintenance knowledge retrieval, semantic-based retrieval is used to match queries and documents using semantic information. It can accurately understand the meaning of special vehicle operation and maintenance knowledge, thereby finding document knowledge that is semantically related to the problem. Knowledge retrieval is implemented using semantic similarity, and the main steps include system role definition, system initialization, parsing user input, semantic similarity calculation, and candidate answer generation.
7. The large model-based special vehicle operation and maintenance knowledge retrieval method according to claim 6, characterized in that: The step 5 comprises: Step 51: System role definition; Step 51 defines the role "role_definition" of "special vehicle operation and maintenance knowledge retrieval assistant" through 5 fields, including "role" role name, "description" general description, "abilities" specific capabilities, "knowledge_domains" knowledge domains, and "behavior_guidelines" behavior norms. Through the role definition, the retrieval system is initialized, and the user is briefly introduced to the function and usage information in the form of an opening statement, which helps to ensure the professionalism, accuracy, efficiency and practicality of the large model assistant, so as to better serve users and improve the quality and efficiency of equipment operation and maintenance; Specifically, the design of the role definition prompt role_definition_prompt is as follows: role_definition_prompt = { "role":"Special Vehicle Operation and Maintenance Knowledge Retrieval Assistant", "description":"You are a professional special vehicle operation and maintenance knowledge retrieval intelligent assistant, designed to help users solve various problems related to special vehicle maintenance and operation. Users will use natural language to ask questions. You need to understand the user's questions and provide relevant and useful information;", "abilities":[ "Quickly and accurately retrieve knowledge related to special vehicle operation and maintenance", "Be familiar with the daily maintenance and care knowledge of special vehicles to provide users with correct operating instructions and suggestions", "Have the ability to identify and troubleshoot special vehicle faults, diagnose problems based on the symptoms described by the user, and provide solutions or suggestions", "Understanding the potential safety hazards and emergency response measures during the operation of special vehicles, and being able to provide users with safe operation guidance and suggestions for dealing with emergencies", "Have an in-depth understanding of the structure, working principle, technical parameters, etc. of special vehicles, so as to accurately understand and answer users' related questions", "Able to interpret technical documents and standards related to special vehicles, including operation manuals, maintenance manuals, technical specifications, etc., and provide users with accurate interpretation and application guidance" ], "knowledge_domains":[ "Tank", "Armored Vehicle", "Military Truck", "Military Transport Vehicle", "Command Vehicle", "Communication Vehicle", "Other Special Vehicles" ], "behavior_guidelines":[ "Always remain professional, objective and neutral", "Prioritize official operation and maintenance manuals and technical documents and other authoritative sources", "Ensure that the information retrieved is accurate, reliable, and relevant to the user's query", "Avoid providing any unverified or outdated information", "Communicate with users using clear, concise and understandable language", "If you don't know the answer or the searched knowledge is empty, please say you don't know", "The first sentence you output is "Hello! I am a special vehicle operation and maintenance knowledge retrieval assistant; I am designed to help you obtain information about the field of special vehicle operation and maintenance; whether you are looking for a specific vehicle's operation and maintenance manual, laws and regulations, standards and specifications, or want to understand the operation and maintenance case knowledge, I can help you; \nPlease tell me what kind of information you need, or ask your questions, and I will try my best to provide you with accurate and useful answers; if you are not sure how to start, you can try asking me questions about specific equipment types, FAQs, or best practices; get started!"] }; Step 52: System initialization; input the role definition prompt sentence role_definition_prompt into the large language model Llama3_zh_phm, so that the large model completes the initialization of the special vehicle operation and maintenance knowledge retrieval assistant and obtains the capabilities defined in the role definition prompt sentence; wherein, the Llama3_zh_phm model is a special vehicle operation and maintenance Chinese large model obtained by fine-tuning hundreds of thousands of special vehicle operation and maintenance knowledge texts on the basis of the general pre-trained Chinese model Llama3_zh; the system initialization response initial_response is calculated as follows: initial_response=Llama3_zh_phm(role_definition_prompt); Step 53: Parsing user input: Receive the user's input query statement q and convert the unstructured query query statement q into a structured query embedding vector q v ; Among them, q v The text embedding vector converted by the M3E_PHM_Embedding large language embedding model as in step 3 ensures the consistency of semantics and contextual understanding in the field of special vehicle operation and maintenance during storage and retrieval, and improves the retrieval effect of special vehicle operation and maintenance knowledge; q v =M3E_PHM_Embedding(q) Step 54: Calculate semantic similarity; calculate the similarity between the question retrieval statement q and each text block d in the special vehicle operation and maintenance knowledge base, measure the relevance between the question and each special vehicle operation and maintenance knowledge text block, and sort the similarities, and only retain the index ID corresponding to the top K text data block vectors in similarity ranking i As the search result, a more accurate reference answer index is left to achieve the screening of the search results; First, the BM25 algorithm is used to calculate the score S of the search statement q and all text blocks d in the database. BM25 (q, d), retain the text blocks corresponding to the top 2K scores; BM25 is an efficient document retrieval algorithm, and its calculation process is as follows, S BM25 (q, d) represents the correlation between document d and query q. It has good support for both long documents and short texts, and is suitable for large-scale and small-scale document retrieval such as special vehicle operation and maintenance knowledge. Where n is the number of words in the query, q i is the □th word in the query, IDF(q i ) is the word q i The inverse document frequency, f(q i ,d) is word q i The frequency in document d, |d| is the length of document d, avgdl is the average document length of the entire document set, k1 and b are adjustment parameters, usually set to empirical values, in this step k1 = 1.3, b = 0.7; Then, the text blocks retrieved by the BM25 algorithm are sorted twice, and the top K results after the second sort are returned; the calculation formula for the score S(q,d) in the second sort is as follows: S(q,d)=αS BM25 (q,d)+(1-α)S L (q,d) S L (q, d) is the semantic similarity between the search sentence q and the text block d, which is calculated using the cosine similarity function. v is the text embedding vector corresponding to the text block d in the vector database; Step 55: Candidate answers are returned; according to the index ID corresponding to the top K text embedding vectors i Retrieve the corresponding knowledge text block d i , as a knowledge information source for special vehicle operation and maintenance knowledge related issues; and the knowledge text block d i The document name and path in the corresponding metadata are returned together with the reference answer to ensure that the retrieved answer can be traced. Users can find the original document by the document name and path, which enhances the credibility of the result. The file format is designed as follows:
8. The large model-based special vehicle operation and maintenance knowledge retrieval method according to claim 7, characterized in that: In step 6, a result is generated; Based on the candidate answers obtained in step 5, the model is guided to evaluate the accuracy, completeness, and relevance of each answer by constructing a generated prompt statement, synthesizing the information of multiple candidate answers or selecting the best answer, and providing explanations and supplements to provide the user with the most accurate, complete, and relevant final answer; Step 61: Restate the question. Re-define the user question in the result generation prompt. Use the field "user_query" to define the question to ensure that the model understands the core content and purpose of the question. The format is defined as follows: "user_query":"Questions asked by users"; Step 62: Presentation of candidate answers. The top K candidate answers retrieved in step 5 are presented to the special vehicle operation and maintenance model in a clear manner, and their ranking order is indicated. The field "candidate_answers" defines the candidate answers, and the field "rank" defines the ranking. The field "candidate_answers" is displayed as follows: Step 63: Guide the model analysis, through the field "analysis_instruction", guide the special vehicle operation and maintenance Chinese model to analyze the candidate answers, and evaluate the accuracy, completeness and relevance of the answers based on the question and context information; The field "analysis_instruction" is defined as follows: "analysis_instruction":"Please carefully analyze the candidate answers above and evaluate the accuracy, completeness and relevance of each answer based on the user's question and background information; Consider the following factor: Does the answer directly answer the user's question? Does the answer provide enough detail and information? Does the answer come from a reliable source? Does the answer apply to the user's specific situation?"; Step 64: Instruct answer generation. Through the field "final_answer_instruction", instruct the special vehicle operation and maintenance Chinese model to generate the final answer based on the analysis results; require the model to integrate the information of multiple candidate answers, or select the best answer and explain and supplement it; The field "final_answer_instruction" is defined as follows: "final_answer_instruction":"Based on your analysis, please generate the final answer to provide users with the most accurate, complete, and relevant solution; you can combine information from multiple candidate answers, or select the best answer and explain and supplement it;" Step 65: Generate answers to questions; Use prompts to build a thinking chain to guide the special vehicle operation and maintenance Chinese large model to generate ideal answers, merge the aforementioned "role_definition", "candidate_answers", "analysis_instruction", and "final_answer_instruction" into answer_generat_prompt, and then inject prompt into the large model to generate the final answer; answer_generat_prompt={"role_definition","candidate_answers","analysis_instruction","final_answer_instruction"} final_answer=Llama3_zh_phm(answer_generat_prompt).
9. The large model-based special vehicle operation and maintenance knowledge retrieval method according to claim 8, characterized in that: In the step 7, iterative question-answer retrieval; In the process of retrieving information, it is not possible to get the ideal answer through just one search. By tracking the conversation history and recording the context information, the system can more accurately understand the user's questions, supplement the details of the questions, correct the wrong information, and thus provide more relevant answers, improve the accuracy and efficiency of special vehicle operation and maintenance knowledge retrieval, and provide an interactive knowledge retrieval experience; During the iterative knowledge retrieval process, the special vehicle operation and maintenance Chinese large model needs to refer to historical conversation records to form memory, reconstruct questions according to the context to form new questions, and re-retrieve answers.
10. The large model-based special vehicle operation and maintenance knowledge retrieval method according to claim 9, characterized in that: The step 7 comprises the following steps: Step 71: Construct a dialogue record chain; it is used to record the dialogue record between the system and the user during the knowledge retrieval process. After each interactive question and answer retrieval, the dialogue record chain needs to be updated. The format of the dialogue record chain is as follows, which is composed of dialogue records of user input "user_input" and machine output "system_response" alternately; history:[{"user_input":"...", "system_response":"..."},{"user_input":"...","system_response":"..."},…] Step 72: construct a new question generation prompt new_question_prompt; by giving constraints to control input information, avoid generating questions that are irrelevant to special vehicle operation and maintenance knowledge, provide more customized services and solutions in the field of special vehicle operation and maintenance, thereby improving the quality of generated questions and making the system more intelligent and effective; the composition of the question reconstruction prompt new_question_prompt is as follows: the historical retrieval dialogue is injected into the history field, and the user question is injected into the question field; new_question_prompt:["Generate a new question based on historical conversation records and the latest user questions, and meet the following requirements: (1) If there are missing pronouns or conditions in the question, please ask a complete question based on the context; (2) If the question information is complete enough, please keep the original question; otherwise, please prompt the user to provide additional information; (3) If the user's question deviates from the field of special vehicle operation and maintenance knowledge retrieval, please remind the user to limit the scenario to special vehicle operation and maintenance knowledge retrieval; (4)Understandable without chat log; do not answer the question, just rewrite it if necessary, otherwise return it as is;", {"history conversation record": {history}}, {"question": {question}}] Step 73: Generate a new question; input the integrated question reconstruction prompt new_question_prompt containing historical dialogue information and questions into the special vehicle operation and maintenance model, and the model regenerates a new question by understanding the context and the question; new_question=Llama3_zh_phm(new_question_prompt) Step 74: Answer retrieval and generation; based on the newly generated question, restart the retrieval process, refer to the process in step 6 for details.
Citation Information
Cited By
AI-based information retrieval method and system
CN119357336A
Retrieval enhancement generation method and system based on long-term memory, electronic equipment and storage medium
CN119415664A
Psychological support question and answer generation method and system based on two-stage retrieval enhanced LLM
CN119760102A
Large-model-based full-duty investigation method and large-model-based full-duty investigation device
CN119886834A
Pseudo document generation method and system based on multiple models
CN120316201A
