Ecological environment intelligent dialogue method and system based on large language model
Through the ecological environment intelligent dialogue method based on large language model, the retrieval enhancement generation technology and unstructured database are used to solve the problem that text data in the ecological environment is difficult to deeply utilize, and the rapid and accurate professional Q&A and text generation are achieved, which improves the Management efficiency and user trust.
Patent Information
- Application Number
- CN202411487607.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-24
- Publication Date
- 2024-11-22
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The text language data in the ecological environment field has many formats and strong logic, and traditional technologies are difficult to deeply explore and utilize, resulting in low management and decision-making efficiency.
Using an ecological environment intelligent dialogue method based on large language models, an artificial intelligence assistant with professional knowledge is built through search augmented generation (RAG) technology, and using deep learning models and unstructured databases to achieve fast and accurate text retrieval and generation.
It improves the accuracy of Q&A in the field of ecological environment, reduces the cost of model parameter adjustment, supports dynamic management and update of the knowledge base, and enhances users' sense of trust in the generated results.
Smart Images

Figure CN119003745A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of environmental monitoring and protection, and in particular to an ecological environment intelligent dialogue method and system based on a large language model. Background Art
[0002] There are a large number of policy documents, normative guidelines, technical reports and other documents in the field of ecological environment, and they are updated quickly. Management departments at all levels, enterprise managers and business personnel need to manage and update general ecological environment knowledge, and also need to establish a text knowledge base related to their own business to achieve rapid retrieval of text knowledge, information integration and text generation to assist efficient decision-making and work. However, at the same time, the text language data in the field of ecological environment has various formats and strong logic, and traditional technologies are difficult to deeply mine and utilize the information contained in it.
[0003] To this end, we propose an ecological environment intelligent dialogue method and system based on a large language model to solve the above problems. Summary of the invention
[0004] The technical problem to be solved by the present invention is to overcome the defects of the prior art. The present invention proposes an ecological environment intelligent dialogue method and system based on a large language model. Through the retrieval enhanced generation (RAG) technology, an artificial intelligence dialogue assistant with professional knowledge in the field of ecological environment is quickly and low-cost constructed to provide users with fast and accurate professional question and answer and text generation services.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is: an ecological environment intelligent dialogue method based on a large language model, comprising the following steps: S1. Build a knowledge base and digitize the document information in the knowledge base to obtain corresponding text data, divide the text data into multiple text segments according to delimiters and segmentation length parameters, and simultaneously embed feature vectors of the multiple text segments through a deep learning model; S2. Build a large language model base to uniformly encapsulate different large language models and provide external calling interfaces; S3. Retrieve digital content in the knowledge base based on user query content, embed query content characters into feature space vectors, calculate the distance between any knowledge base text fragment and the space vector, and use the first K knowledge base text fragments with the smallest distance as the retrieval structure, where K is an adjustable variable. Finally, the retrieval results are logically integrated through the large language model in S2.
[0006] Furthermore, the specific processing process of step S1 is as follows: Determine the text type based on the file name suffix submitted by the user and convert it into plain text. The text types include PDF, Word, and TXT. Define the document to obtain text data as S={S1, S2,…,S N}, where N is the total number of characters in the document, and the text data is segmented according to the set delimiter library, which includes period, line break, and page break; then for a segmented segment S'={S a , S a+1 ,…,S b}, add more overlap characters before and after it, that is, the final slice segment is S'={S a-overlap , S a-overlap+1 ,…,S b+overlap}, Overlap parameter is set to the average length of text segmentation segments; The above text fragments are embedded into the vector feature space using the deep learning model. For the above segmented fragments S'={S a-overlap , S a-overlap+1 ,…,S b+overlap}, after model embedding, it is transformed into a feature vector V'=[v1, v2, …, v M ], where the vector element v is a real number and M is the dimension of the embedding space; Use unstructured database to store user information and knowledge base data.
[0007] Furthermore, the user information and knowledge base data include a user table, a knowledge base table, a document table and a vector embedding table, wherein the user table includes user basic information and a list of user's currently loaded knowledge base IDs; the knowledge base table includes the knowledge base ID, the user ID to which it belongs and the knowledge base type; the document table includes the document ID, the knowledge base ID to which it belongs and the document length; the vector embedding table includes the embedded file ID, the document ID to which it belongs and the embedded file path.
[0008] Furthermore, the large language model in step S2 includes ChatGPT-4 and ChatGPT-3.5 based on API calls; and locally deployed ChatGLM3, Qwen, and InterLM.
[0009] Furthermore, the specific steps of step S3 are as follows: Use deep learning models to embed user query strings Q into feature space vectors ; In the feature vector space, query the distance space vector The K most recent knowledge base text fragments S' K , where K is 5, and the specific query process is: Compute arbitrary knowledge base text fragments and The distance is defined as ,in represents the 2-norm of a vector; Sort d and select the top K text fragments with the smallest d as the knowledge base content associated with the user query; The performance of the calculation process is optimized through the spatial binary tree.
[0010] A system constructed according to any of the above-mentioned ecological environment intelligent dialogue methods based on a large language model, comprising: The knowledge base processing module is used to digitize the professional knowledge documents submitted by users in the knowledge base, perform OCR recognition according to the document type and convert it into plain text. The conversion process quantitatively segments the text data and assigns vectors. The large language model base module adapts to different types of large language models and implements fast background switching. It can uniformly encapsulate different large language models and provide a unified calling interface to the outside world. The retrieval module searches the knowledge base content according to the user's query content, and outputs the search results after logical integration through the large language model; The knowledge base management module is used to realize knowledge base creation, document addition and deletion, knowledge base sharing and knowledge base dynamic loading functions.
[0011] Furthermore, for any knowledge base, there is a corresponding knowledge base ID. During the page loading process, it is first checked whether the knowledge base ID already exists in the user's existing knowledge base list. If not, an add button is displayed, otherwise "already owned" is displayed. When the user clicks the add button, the corresponding knowledge base ID is added to the knowledge base list in the user table of the unstructured database.
[0012] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the ecological environment intelligent dialogue method based on a large language model as described above are implemented.
[0013] A non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, is used to implement the steps of any of the above-mentioned ecological environment intelligent dialogue methods based on a large language model.
[0014] Compared with the prior art, the beneficial effects of the present invention include: 1. This invention realizes the adaptation and application of large language models in professional fields through the retrieval augmentation generation (RAG) technology method, improves the accuracy of the model in the field of ecological environment questions and answers, and avoids the shortcomings of parameter adjustment methods such as high cost, slow update, and unstable training effect; 2. The present invention realizes the creation and management of user knowledge base through unstructured database technology, supports users to add and delete documents and share knowledge base, and improves users' perception of the basis for model generation; 3. The present invention designs a large language model base module to uniformly encapsulate different large language models, making it convenient for administrators to switch between different large language model bases and update the logical basic capabilities of the underlying model. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The disclosure of the present invention is described with reference to the accompanying drawings. It should be understood that the drawings are for illustrative purposes only and are not intended to limit the scope of protection of the present invention. In the accompanying drawings, the same reference numerals are used to refer to the same components. Among them: Figure 1 A schematic diagram showing the logic principle of a dialogue system according to an embodiment of the present invention is shown; Figure 2 The schematic diagram shows a principle diagram of a knowledge base management module in a dialogue system according to an embodiment of the present invention. DETAILED DESCRIPTION
[0016] It is easy to understand that according to the technical solution of the present invention, without changing the essential spirit of the present invention, a person skilled in the art can propose a variety of interchangeable structural modes and implementation modes. Therefore, the following specific implementation modes and drawings are only exemplary descriptions of the technical solution of the present invention, and should not be regarded as the whole of the present invention or as a limitation or restriction to the technical solution of the present invention.
[0017] According to one embodiment of the present invention, Figure 1-Figure 2 Shown.
[0018] In this embodiment, an ecological environment intelligent dialogue method based on a large language model mainly includes the following steps: S1. Build a knowledge base and digitize the document information in the knowledge base to obtain corresponding text data, divide the text data into multiple text segments according to delimiters and segmentation length parameters, and simultaneously embed feature vectors of the multiple text segments through a deep learning model; S2. Build a large language model base to uniformly encapsulate different large language models and provide external calling interfaces; S3. Retrieve digital content in the knowledge base based on user query content, embed query content characters into feature space vectors, calculate the distance between any knowledge base text fragment and the space vector, and use the first K knowledge base text fragments with the smallest distance as the retrieval structure, where K is an adjustable variable. Finally, the retrieval results are logically integrated through the large language model in S2.
[0019] The following is a further explanation of the system construction process combined with the above method steps: (1) Build a professional knowledge base in the field This process processes the professional domain knowledge documents submitted by users and digitizes the information therein for subsequent search and retrieval based on user needs, assisting the large model in providing accurate question and answer services.
[0020] 1.1 Import file format recognition and conversion: Determine the text type based on the suffix of the file name submitted by the user and convert it into plain text. The system supports three mainstream formats: PDF, WORD and TXT. For PDF, you need to first determine whether it is a text type PDF or an image type PDF. If it is an image type PDF, you need to perform OCR recognition first and then convert it into plain text.
[0021] 1.2 Text segmentation: Assume that the text data obtained by reading the document is S={S1, S2,…,S N}, where N is the total number of characters in the document. First, the text data is segmented according to the set delimiter library. The delimiters usually include period, line break, page break, etc. The system sets the overlap parameter for text data segmentation. For a segmentation segment S'={S a , S a+1 ,…,S b}, add more overlap characters before and after it, that is, the final slice segment is S'={S a-overlap , S a-overlap+1 ,…,S b+overlap},This method can ensure the relevance and continuity of the segmented segments. The Overlap parameter is generally set to the average length of the text segmented segments.
[0022] 1.3 Vector Embedding: Vector embedding uses a deep learning model to embed the aforementioned text fragments into a vector feature space, so that text fragments with related semantics are aggregated in the vector feature space, and fragments with different semantics are far away from each other in the vector feature space. a-overlap , S a-overlap+1 ,…,S b+overlap}, after model embedding, it can be transformed into a feature vector V'=[v1, v2, …, v M ], where the vector element v is a real number and M is the dimension of the embedding space. Taking the embedding model text2vec-large-chinese as an example, M=1024.
[0023] 1.4 Text knowledge base: Use unstructured database to store user knowledge base information and knowledge base data. The database includes user table, knowledge base table, document table and vector embedding table. Among them, the user table includes relevant basic information such as user ID and the list of knowledge base IDs currently loaded by the user; the key information of the knowledge base table includes the knowledge base ID and the user ID to which it belongs, and the knowledge base type; the key information of the document table includes the document ID, the knowledge base ID to which it belongs, and the document length; the key information of the vector embedding table includes the embedded file ID, the document ID to which it belongs, and the embedded file path. Through this setting, it can provide convenience for user management and dynamic loading of knowledge bases.
[0024] (2) Large Language Model Base The large language model base is a functional module designed to better adapt to the fast-iterating large language model technology and to assist administrators and users in quickly configuring basic large language models. At present, there are many types of large language models suitable for natural language question and answer in the ecological environment professional field. API-based calls include ChatGPT-4, ChatGPT-3.5, etc., and localized deployment models include ChatGLM3, Qwen, InterLM, etc. In order to adapt to different types of large language models and realize fast background switching, a large language model base module is designed. This module uniformly encapsulates different large language models and provides a unified calling interface to the outside world. Different underlying models can be switched through simple configuration.
[0025] (3) Intelligent question-answering process: This process will search the knowledge base content according to the user's query content, and logically integrate the search results through a large language model, ultimately forming professional and accurate answer results in the industry field.
[0026] 3.1 User query embedding: Using the same text embedding model as in Section 1.3 above, the user query string Q is embedded into the feature vector space vector .
[0027] 3.2 Relevant knowledge retrieval: In the feature vector space, query the distance space vector The K most recent knowledge base text fragments S' K K is an adjustable variable, usually with a value of 5. The specific query method is: Compute arbitrary knowledge base text fragments and The distance is defined as ,in Represents the 2-norm of the vector. Sort d and select the first K text segments with the smallest d as the knowledge base content associated with the user query. The calculation process can be optimized by methods such as spatial binary tree.
[0028] 3.3 Answers based on professional knowledge: Based on the results of step 3.2, the system organizes the corpus data for reference by the large language model. For example, the user asks, what is the limit? This question involves the limit of nouns in the field of ecological environment. In step 3.2, the system will obtain 5 knowledge base fragments that are closest to the user's question: Serial number Text content source 1 What is the limit value and quantity management of industrial parks? Implement the limit value and quantity management of pollutant emissions in industrial parks (concentrated areas) (collectively referred to as industrial parks) Basic knowledge of limit value and quantity.docx 2 The so-called "limits" are to formulate environmental quality targets for industrial parks and clarify the emission concentration values of major pollutants based on the ecological environment quality status of the industrial parks and their surroundings; the so-called "limits" are to clarify the total amount of major pollutants allowed to be discharged from the industrial parks based on the environmental quality target status of the industrial parks. What is the connotation of limit and quantity management in industrial parks? It can be simply summarized in "20 words": measurement and metering, dual control in accordance with the law, quantitative control based on values, quantity control and quality improvement, and market allocation. "Measurement and metering" is the basis of the work, which is to calculate the actual pollutant emissions of industrial parks and enterprises by monitoring the environmental quality values of industrial parks and their surroundings, as well as the pollutant emission concentration values of enterprises. "Dual control in accordance with the law" is a legal requirement, which is to carry out "dual control" of pollutant concentrations and total emissions in accordance with laws and regulations. Basic knowledge of limit value and quantity.docx 3 At the industrial park level, work is also carried out in a "1+1+N" manner, that is, a park work plan is formulated in a "one park, one policy" manner, a park monitoring and supervision capacity project is built, and a number of specific management measures such as the construction of park ecological environment infrastructure and off-site verification capacity are promoted. What are the work requirements for limit and quantity management in industrial parks? They can be summarized as "four determinations" and "three mechanisms." The "four determinations" are: determining the control scope of limit and quantity limits in industrial parks, determining the main indicators of limit and quantity limits in industrial parks, determining the total amount of major pollutants allowed to be discharged in industrial parks, and determining the actual total amount of major pollutants discharged in industrial parks. Basic knowledge of limit value and quantity.docx 4 What is the relationship between the two? The "Provincial Provincial and Above Industrial Park (Concentrated Area) Monitoring and Supervision Capacity Construction Plan" (Suhuanban
[2021] No. 144) requires the industrial park to strengthen the monitoring and supervision of the surrounding environmental quality of the park and the centralized sewage treatment facilities in the park, which is the basis for the limit and quantity management of the park. At the same time, the limit and quantity management of industrial parks requires higher construction requirements for calculating the emission of major air and water pollutants in the park. Therefore, it is necessary to supplement and improve monitoring facilities and auxiliary facilities, such as air micro stations, etc. Basic knowledge of limit value and quantity.docx 5 Urge pollutant-discharging units to implement the installation and networking of online monitoring equipment at sewage outlets, effectively improve regional environmental monitoring capabilities, promptly study and solve problems found in the process of limit and quantity management, summarize experiences and lessons, promote and apply mature experiences, and give full play to the positive role of limit and quantity management. Increase capital investment. To ensure the smooth and steady progress of limit and quantity management in petrochemical bases, relevant departments should provide matching special funds, and allocate funds for the construction of online monitoring platforms, automatic monitoring stations, etc. according to the implementation plan, to provide strong financial support for the improvement of the development zone's environmental monitoring capabilities. Gradually establish a normalized and stable fiscal funding mechanism, strengthen the adaptation of financial support to construction and maintenance needs, and improve the diversified environmental protection investment and financing mechanism. Basic knowledge of limit value and quantity.docx Based on the above content, the system automatically generates a model prompt with the following content: Known information: What is the limit value and quantity management of industrial parks? Implement the limit value and quantity management of pollutant emissions in industrial parks (concentrated areas) (collectively referred to as industrial parks). The so-called "limit value" is to formulate the environmental quality target of the industrial park and clarify the emission concentration value of the main pollutants according to the ecological environment quality status of the industrial park and its surrounding areas; the so-called "limit" is to clarify the total amount of main pollutants allowed to be discharged in the industrial park according to the environmental quality target status of the industrial park. What is the connotation of the limit value and quantity management of industrial parks? It can be simply summarized as "20 words", measurement and measurement, dual control according to law, quantitative value, quantity control and quality improvement, and market allocation. "Measurement and measurement" is the basis of work, which is to calculate the actual emission of pollutants from industrial parks and enterprises by monitoring the environmental quality values of industrial parks and their surrounding areas, as well as the emission concentration values of pollutants from enterprises. "Dual control according to law" is a legal requirement, which means to carry out "dual control" of pollutant concentration and total emission in accordance with laws and regulations.
[0029] At the industrial park level, work is also carried out in a "1+1+N" manner, that is, a park work plan is formulated in a "one park, one policy" manner, a park monitoring and surveillance capacity project is built, and a number of specific management measures such as the construction of park ecological environment infrastructure and off-site verification capacity are promoted. What are the work requirements for the limit and quantity management of industrial parks? It can be summarized as "four determinations" and "three mechanisms". The "four determinations" are: determining the control scope of the limit and quantity of the industrial park, determining the main indicators of the limit and quantity of the industrial park, determining the total amount of the main pollutants allowed to be discharged from the industrial park, and determining the actual total amount of the main pollutants discharged from the industrial park.
[0030] What is the relationship between the two? The "Provincial Provincial and Above Industrial Park (Centralized Area) Monitoring and Supervision Capacity Construction Plan" (Suhuanban
[2021] No. 144) requires the industrial park to strengthen the monitoring and supervision of the environmental quality around the park and the centralized sewage treatment facilities in the park. The construction is the basis for the park's limit and quantity management. At the same time, the limit and quantity management of industrial parks requires higher construction requirements for calculating the main air and water pollutant emissions in the park. Therefore, it is necessary to supplement and improve monitoring facilities and auxiliary facilities, such as air micro stations.
[0031] Urge pollutant-discharging units to implement the installation and networking of online monitoring equipment at sewage outlets, effectively improve regional environmental monitoring capabilities, promptly study and solve problems found in the process of limit and quantity management, summarize experiences and lessons, promote and apply mature experiences, and give full play to the positive role of limit and quantity management. Increase capital investment. To ensure the smooth and steady progress of the limit and quantity management of the petrochemical base, relevant departments should provide special funds and allocate funds for the construction of online monitoring platforms, automatic monitoring stations, etc. according to the implementation plan, so as to provide strong financial support for the improvement of the development zone's environmental monitoring capabilities. Gradually establish a normalized and stable fiscal funding mechanism, strengthen the adaptation of financial support to construction and maintenance needs, and improve the diversified environmental protection investment and financing mechanism. Answer the user's question concisely and professionally based on the known information above. If you cannot get the answer from it, please say "I cannot answer this question based on the known information" or "Not enough relevant information is provided". It is not allowed to add fabricated elements to the answer. Please use Chinese for the answer.
[0032] The question is: What is the limit? Note that at this time, the information related to the user query obtained by the system query is still fragmented and illogical. Therefore, it is necessary to further generate accurate and concise text information based on the user's questions based on the logic and information integration capabilities of the large language model itself.
[0033] Finally, the answer from the large language model is: Limits and limits refer to the formulation of environmental quality targets for industrial parks based on the ecological environment quality of the park and its surroundings, clarifying the concentration values of major pollutants, and clarifying the total amount of major pollutants allowed to be discharged from the park based on the environmental quality target of the industrial park. The implementation of the management of pollutant emission limits and limits in industrial parks aims to achieve effective control of the concentration and total amount of pollutants discharged from industrial parks through monitoring and measurement.
[0034] In contrast, if there is no large language model generated by knowledge base construction and retrieval enhancement, it will be impossible to get accurate answers when answering such professional questions. For example, when using ChatGPT-3.5 to ask the same question: The phrase "limits" may have different contexts and meanings. The specific interpretation may depend on the field in question. Here are some possible interpretations: Laws and regulations: In the context of the environment, health or safety, "limits" may refer to the upper limit or maximum allowable amount of a substance or condition specified in a regulation or standard. This is to ensure the safety and welfare of the public and prevent possible harm caused by exceeding a certain limit; Economics and trade: In business or trade negotiations, "limits" may also mean a maximum or quota for a resource, product, or service to ensure a balanced market and fair trade; Pharmaceuticals and food safety: In the pharmaceutical or food industry, "limit value" may be used to describe the maximum allowed concentration or amount of a certain ingredient or additive to ensure product safety and compliance; If you could provide more context or field-specific information I might be able to provide a more accurate explanation.
[0035] 4. Knowledge base management: The knowledge base management module can provide users with functions such as knowledge base creation, document addition and deletion, knowledge base sharing, and knowledge base dynamic loading. This process allows users to create personalized knowledge bases as needed, enhance their perception of the model generation process, and increase their trust in the model system.
[0036] 4.1 Knowledge base data management: Knowledge base data is stored in documents. This solution allows users to view documents in the knowledge base and add or delete documents. Figure 2 As shown in the figure, based on the structured database, the basic information and embedding vector library of each document are saved independently, and the ID of the knowledge base in which it is located is saved. Similarly, the knowledge base data includes the basic information of the knowledge base and the ID of the user who created it. The knowledge base can be owned by multiple users.
[0037] 4.1 Knowledge base file upload and display: Users can upload text to the knowledge base and complete the text extraction, segmentation and embedding process according to the process in Part 1 of the above solution. The front-end interface can display the text documents contained in the knowledge base and support users to delete documents.
[0038] 4.2 Knowledge Base Market: The Ecological Environment Knowledge Base Market allows users to share knowledge bases. For any knowledge base, there is a corresponding knowledge base ID. During the page loading process, it first checks whether the knowledge base ID already exists in the user's existing knowledge base list. If not, the Add button is displayed, otherwise it displays "Already Owned". When the user clicks the Add button, the corresponding knowledge base ID is added to the knowledge base list in the user table of the unstructured database.
[0039] 4.3 Dynamic loading of knowledge base: Users can choose to enable or disable a knowledge base individually to adjust the amount of text content that the large language model can refer to and obtain more accurate answers. When the knowledge base dynamic loading page is refreshed, the user's currently loaded knowledge base ID list is first obtained from the user information table, and the corresponding knowledge base status is displayed as enabled; when the user modifies the enabled knowledge base, the new enabled knowledge base list is first synchronized to the user information table, and then the new enabled knowledge base document vector embedding results are merged, that is, the union of different knowledge base document embedding vectors is taken as the new user document reference knowledge base.
[0040] Through the above construction, the intelligent dialogue method and system of the present invention have the following advantages compared with the existing large language model: 1. It is difficult and costly to train large language models in professional fields. The application of large language models in professional fields usually requires fine-tuning of parameters of large language models. Although there are many methods for fine-tuning model parameters, model fine-tuning still requires professionals to prepare training data sets, and requires more computing resources and training time. The relative cost is high, the professional requirements are strong, and it is difficult to meet the changes in the continuous updating and iteration of professional field knowledge. The present invention adopts a retrieval enhancement generation scheme, and by establishing an external text knowledge base, there is no need to fine-tune the model parameters.
[0041] 2. Large language models have the phenomenon of "hallucination", which affects their application in fields with high professional requirements. For knowledge that it does not understand, the generative large language model uses the conditional probability distribution that has been learned to calculate the most likely subsequent content. This process may generate results that do not conform to facts and professional field knowledge. This phenomenon is called the "hallucination" phenomenon. This problem makes it difficult for large language models to be implemented in fields with high professional requirements. This solution uses prompt design and retrieval enhancement solutions to enable the model to answer questions as much as possible based on the content of the knowledge base, thereby improving the accuracy of question and answer.
[0042] 3. Users do not have enough understanding of the process of large language models generating texts, and it is difficult for them to have a sense of trust. As a "black box" model of deep learning, the generation process of large language models lacks explanation. In fields with high professional requirements, users lack a sense of trust in such models, which leads to difficulties in implementation. This technical solution allows users to participate in the model adjustment process by building a knowledge base and adjusting the knowledge base loading process independently, thereby enhancing users' trust in the system.
[0043] In addition, the above-mentioned method steps and system can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0044] The technical scope of the present invention is not limited to the contents in the above description. Those skilled in the art can make various deformations and modifications to the above embodiments without departing from the technical idea of the present invention, and these deformations and modifications should all fall within the protection scope of the present invention.
Claims
1. An ecological environment intelligent dialogue method based on a large language model, characterized in that: The steps include: S1. Build a knowledge base and digitize the document information in the knowledge base to obtain corresponding text data, divide the text data into multiple text segments according to delimiters and segmentation length parameters, and simultaneously embed feature vectors of the multiple text segments through a deep learning model; S2. Build a large language model base to uniformly encapsulate different large language models and provide external calling interfaces; S3. Retrieve digital content in the knowledge base based on user query content, embed query content characters into feature space vectors, calculate the distance between any knowledge base text fragment and the space vector, and use the first K knowledge base text fragments with the smallest distance as the retrieval structure, where K is an adjustable variable. Finally, the retrieval results are logically integrated through the large language model in S2.
2. The ecological environment intelligent dialogue method based on a large language model according to claim 1, characterized in that: The specific processing process of step S1 is as follows: Determine the text type based on the file name suffix submitted by the user and convert it into plain text. The text types include PDF, Word, and TXT. Define the document to obtain text data as S={S1, S2,…,S N }, where N is the total number of characters in the document, and the text data is segmented according to the set delimiter library, which includes period, line break, and page break; then for a segmented segment S'={S a , S a+1 ,…,S b }, add more overlap characters before and after it, that is, the final slice segment is S'={S a-overlap ,S a-overlap+1 ,…,S b+overlap }, Overlap parameter is set to the average length of text segmentation segments; The above text fragments are embedded into the vector feature space using the deep learning model. For the above segmented fragments S'={S a-overlap , S a-overlap+1 ,…,S b+overlap }, after model embedding, it is transformed into a feature vector V'=[v1, v2, …, v M ], where the vector element v is a real number and M is the dimension of the embedding space; Use unstructured database to store user information and knowledge base data.
3. The ecological environment intelligent dialogue method based on a large language model according to claim 2 is characterized by: The user information and knowledge base data include a user table, a knowledge base table, a document table and a vector embedding table, wherein the user table includes user basic information and a list of knowledge base IDs currently loaded by the user; the knowledge base table includes the knowledge base ID, the user ID to which it belongs and the knowledge base type; the document table includes the document ID, the knowledge base ID to which it belongs and the document length; the vector embedding table includes the embedded file ID, the document ID to which it belongs and the embedded file path.
4. The ecological environment intelligent dialogue method based on a large language model according to claim 1, characterized in that: The large language models in step S2 include ChatGPT-4 and ChatGPT-3.5 based on API calls; and locally deployed ChatGLM3, Qwen, and InterLM.
5. The ecological environment intelligent dialogue method based on a large language model according to claim 1, characterized in that: The specific steps of step S3 are as follows: Use deep learning models to embed user query strings Q into feature space vectors ; In the feature vector space, query the distance space vector The K most recent knowledge base text fragments S' K , where K is 5, and the specific query process is: Compute arbitrary knowledge base text fragments and The distance is defined as ,in represents the 2-norm of a vector; Sort d and select the top K text fragments with the smallest d as the knowledge base content associated with the user query; The performance of the calculation process is optimized through the spatial binary tree.
6. A system constructed according to the ecological environment intelligent dialogue method based on a large language model as described in any one of claims 1 to 5, characterized in that: include: The knowledge base processing module is used to digitize the professional knowledge documents submitted by users in the knowledge base, perform OCR recognition according to the document type and convert it into plain text. The conversion process quantitatively segments the text data and assigns vectors. The large language model base module adapts to different types of large language models and implements fast background switching. It can uniformly encapsulate different large language models and provide a unified calling interface to the outside world. The retrieval module searches the knowledge base content according to the user's query content, and outputs the search results after logical integration through the large language model; The knowledge base management module is used to realize knowledge base creation, document addition and deletion, knowledge base sharing and knowledge base dynamic loading functions.
7. The system according to claim 6, characterized in that: For any knowledge base, there is a corresponding knowledge base ID. During the page loading process, it is first checked whether the knowledge base ID already exists in the user's existing knowledge base list. If not, the Add button is displayed, otherwise "Already Owned" is displayed. When the user clicks the Add button, the corresponding knowledge base ID is added to the knowledge base list in the user table of the unstructured database.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that :When the processor executes the program, the steps of the ecological environment intelligent dialogue method based on a large language model as described in any one of claims 1 to 5 are implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it is used to implement the steps of the ecological environment intelligent dialogue method based on a large language model as described in any one of claims 1 to 5 above.
Citation Information
Patent Citations
Document abstract processing method and device, equipment and medium
CN114461795A
Knowledge base construction method and question and answer dialogue method and system based on generative large language model
CN117056471A
Question and answer method and device based on large language model, electronic equipment and storage medium
CN117891927A
Intelligent coal mine method based on local knowledge base and natural language processing large model
CN117891956A
Question and answer method and device, storage medium and computing equipment
CN118035413A
Cited By
Environment regulation case auxiliary analysis system based on large language model
CN119202141A
Cross-language vector knowledge base construction method and device
CN119988584A
RAG-oriented document analysis method and system and computer equipment
CN120849350A
