Building material data unit conversion method and system based on retrieval enhancement generation

By building a local knowledge base and agent technology, combined with a generative model, automatic conversion of building material data units is performed, solving the problem of mismatch between building material units and carbon emission coefficients, achieving fast and accurate carbon emission calculations, and reducing human errors and complexity.

CN120670484APending Publication Date: 2025-09-19SHANDONG JIANZHU UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510777930.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-11
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

In the existing technology, the units of building materials and the calculation units of carbon emission coefficients do not match, resulting in low efficiency in carbon emission calculations and the need for manual unit conversion, which increases the difficulty of computer implementation.

Method used

A method based on retrieval-enhanced generation is adopted. By building a local knowledge base and agent technology, combined with a generative model, the unit conversion of building material data is automatically performed. The retrieval-enhanced generation module is used to match templated prompt words, and the numerical calculation tool is called by the agent to perform the conversion steps and generate natural language answers.

Benefits of technology

It achieves fast and accurate calculation of building materials carbon emissions, reduces human errors, unifies calculation rules, facilitates dynamic updates, has strong compatibility, and reduces the complexity and error probability of traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120670484A_ABST
    Figure CN120670484A_ABST
Patent Text Reader

Abstract

The invention relates to a building material data unit conversion method and system based on retrieval enhancement generation, and the method comprises the steps: obtaining a building material size parameter, a building material current unit and a to-be-converted target unit, forming a unit conversion problem, and inputting the unit conversion problem into a retrieval enhancement generation module; the retrieval enhancement generation module is used for performing text segmentation on an input unit conversion problem to obtain a problem text vector, and matching a plurality of texts with the highest similarity with the problem text vector in a local knowledge base through vector similarity retrieval to obtain a templated cue word; and the Agent module calls the generative model according to the obtained cue word to identify a conversion step needing to be executed, executes the corresponding conversion step by calling a numerical calculation tool, and returns an obtained conversion result to the generative model to generate a natural language answer. The unit conversion problem in the building material carbon emission period is solved through matching of retrieval enhancement generation and Agent technologies and a generative model, and the whole process is simple and easy to implement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to a method and system for converting building material data units based on retrieval-enhanced generation. Background Art

[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.

[0003] The carbon emission factor method is widely used to calculate carbon emissions during the production of building materials. It calculates carbon emissions by multiplying the quantity of building materials by the corresponding carbon emission factor for each material. Some existing technologies can match the correct carbon emission factor for different building materials input through text data processing. However, during this matching process, there is a mismatch between the building material units and the units used to calculate the carbon emission factor.

[0004] When calculating carbon emissions, a list of building materials used in the project is included, such as Figure 1 As shown in the left area, the list shows the name, quantity, unit and project of the building materials. When these building materials are matched with the corresponding carbon emission coefficient, the following is obtained: Figure 1 (right area) shows the content, but the units of the matched carbon emission coefficient are not consistent with the building material units in the building materials list and cannot be calculated directly.

[0005] For example, the carbon emission coefficient of metals is generally converted into carbon dioxide produced by weight, while in the building materials list, different sub-projects may use length or area to calculate the quantity of building materials, resulting in a unit mismatch problem.

[0006] The main reason for this problem is the lack of a standardized format for recording building material lists. There are many different types of building materials, and different suppliers or project stages may use different units of measurement. In actual projects, manual unit conversion is often required before subsequent carbon emission calculations, which makes it difficult to calculate carbon emissions using computers. Summary of the Invention

[0007] In order to solve the technical problems existing in the above-mentioned background technology, the present invention provides a method and system for converting building materials data units based on retrieval-enhanced generation, which utilizes the cooperation between retrieval-enhanced generation and Age nt technology and generative models to solve the unit conversion problem during the carbon emission period of building materials. The overall process is simple and easy, and can quickly and accurately calculate the carbon emissions during the building materials production stage.

[0008] In order to achieve the above object, the present invention adopts the following technical solutions:

[0009] A first aspect of the present invention provides a method for converting building material data units based on retrieval enhancement generation, comprising the following steps:

[0010] Obtain the building material size parameters, the current unit of the building material and the target unit to be converted to form a unit conversion problem;

[0011] Perform text segmentation on the input unit conversion question to obtain the question text vector. Then, through vector similarity search, match the texts with the highest similarity to the question text vector in the local knowledge base to obtain templated prompt words.

[0012] Based on the obtained prompt word, the generative model is called to identify the conversion steps that need to be performed. The corresponding conversion steps are executed by calling the numerical calculation tool, and the obtained conversion results are returned to the generative model to generate a natural language answer.

[0013] Furthermore, the construction process of the local knowledge base is specifically as follows: obtaining a list of building materials and a set of carbon emission coefficients, determining the conversion steps and corresponding mathematical expressions of typical building materials based on the unit differences between the list of building materials and the carbon emission coefficients, and forming a local knowledge base in text format.

[0014] Furthermore, the process of constructing the local knowledge base also includes using a generative model to obtain the conversion steps and corresponding mathematical expressions of materials similar to typical building materials to expand the local knowledge base.

[0015] Furthermore, during the construction of the local knowledge base, based on the unit difference between the building materials list and the carbon emission coefficient, the conversion steps and corresponding mathematical expressions of the building materials are determined, and text information containing "conversion step details" is generated, including the following steps:

[0016] Extract the material name, unit and quantity from the building materials list, and use set variables to replace fixed values ​​to form a smooth language description;

[0017] Extract key dimensional parameters based on the shape of building materials and add a description of the building material density;

[0018] According to the unit of the carbon emission coefficient, the shape and quantity of the building materials, a unit conversion mathematical expression consisting of size parameters and density information is determined.

[0019] Furthermore, the retrieval enhancement generation module loads the documents formed by the local knowledge base, segments the text into text paragraphs, and performs vectorization processing to form a word vector library;

[0020] The input unit conversion question is segmented to obtain the question text vector. Through vector similarity search, several texts with the highest similarity to the question text vector are matched in the word vector library to obtain templated prompt words.

[0021] Furthermore, the templated prompt words are specifically: the text obtained during the vector similarity search and the input question text are simultaneously input into a preset template, and the prompt words at least include the conversion steps of the corresponding building materials and the numerical calculation tools that can be called.

[0022] A second aspect of the present invention provides a building material data unit conversion system based on retrieval enhancement generation, comprising:

[0023] The question input module is configured to: obtain the building material size parameters, the current unit of the building material and the target unit to be converted, form a unit conversion question and input it into the retrieval enhancement generation module;

[0024] The search enhancement generation module is configured to: perform text segmentation on the input unit conversion question to obtain a question text vector; perform vector similarity search to match several texts with the highest similarity to the question text vector in the local knowledge base to obtain templated prompt words;

[0025] The Agent module is configured to: call the generative model to identify the conversion steps that need to be performed based on the obtained prompt word, and execute the corresponding conversion steps by calling the numerical calculation tool. The obtained conversion results are returned to the generative model to generate a natural language answer.

[0026] A third aspect of the present invention provides a computer program product comprising computer-readable instructions, which, when executed on an electronic device, enables the electronic device to implement the above-mentioned method for converting building material data units based on retrieval-enhanced generation.

[0027] The fourth aspect of the present invention provides an electronic device comprising at least one processor and a memory connected to the processor, the memory being used to store a computer program; and the processor being used to execute the computer program, so that the electronic device can implement the above-mentioned method for converting building material data units based on retrieval enhancement generation.

[0028] The fifth aspect of the present invention provides a computer storage medium, which carries one or more computer programs. When one or more computer programs are executed by an electronic device, the electronic device can implement the above-mentioned method for converting building material data units based on retrieval enhancement.

[0029] Compared with the existing technology, one or more of the above technical solutions have the following beneficial effects:

[0030] 1. Utilizing the collaboration between retrieval-enhanced generation, agent technology, and generative models, we solve the unit conversion problem during the calculation of building material carbon emissions. This allows the generative model's reasoning ability to be utilized using the local knowledge base rather than relying on inherent knowledge. The retrieval-enhanced generation module also uses the local knowledge base to help the generative model obtain templated prompt words, while the agent calls an external numerical calculation program as a tool. The numerical calculation program uses the unit conversion steps in the local knowledge base to perform the corresponding numerical operations. This can quickly and accurately achieve unit conversion during the calculation of building material carbon emissions, making the overall process simpler and avoiding the complex process of traditional text recognition algorithm design.

[0031] 2. By building a local knowledge base, calculation rules are unified. By clarifying the conversion steps (e.g., dimensional parameters → volume → weight → carbon emissions), the calculation logic for the same material is consistent across different systems, reducing errors caused by manual conversion. Later, new units or materials can be adapted by simply updating text documents, achieving dynamic updates at a relatively low cost. Without database support, the system has strong compatibility and facilitates version management and sharing.

[0032] 3. During the construction of the local knowledge base, a generative model is used to generate conversion rules for similar materials, which can quickly expand the local knowledge base.

[0033] 4. The Retrieval-Enhanced Generation Module extracts the most relevant passages from the local knowledge base through vector similarity searches, ensuring that generated prompts are based on the latest, most relevant authoritative data, rather than relying on the inherent knowledge of the generative model (which may be outdated or incomplete). Traditional generative models may fabricate false conversion formulas due to limited training data. However, the Retrieval-Enhanced Generation Module significantly reduces the probability of incorrect output and the risk of hallucinations by forcing references to passages in the local knowledge base.

[0034] 5. Through the retrieval-enhanced generation module, the deterministic knowledge of unit conversion (local documents) and the reasoning ability of the generative model (generating natural language answers) can be efficiently combined to achieve the "1+1>2" effect in the building materials carbon emission calculation task.

[0035] 6. Using the preset prompt word template, the generation direction of the generative model can be constrained to avoid deviation from the actual data. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] The accompanying drawings, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0037] Figure 1is a schematic diagram illustrating a mismatch between building material units and carbon emission coefficient units provided by one or more embodiments of the present invention;

[0038] Figure 2 This is a schematic diagram of a unit conversion process for building material data based on search enhancement generation provided by one or more embodiments of the present invention;

[0039] Figure 3 is a schematic diagram of the overall process of unit conversion provided by one or more embodiments of the present invention;

[0040] Figure 4 is a schematic diagram of generating a conversion result based on LLM provided by one or more embodiments of the present invention;

[0041] Figure 5 This is a schematic diagram of the conversion steps for generating more similar materials using LLM according to one or more embodiments of the present invention;

[0042] Figure 6 is a schematic diagram of the architecture of a RAG module provided by one or more embodiments of the present invention;

[0043] Figure 7 This is a flowchart of using an agent to solve a unit conversion problem provided by one or more embodiments of the present invention;

[0044] Figure 8 is a schematic diagram of a question answering period provided by one or more embodiments of the present invention;

[0045] Figure 9 Schematic diagram of similarity retrieval results and reasoning process provided by one or more embodiments of the present invention. DETAILED DESCRIPTION

[0046] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0047] It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present invention belongs.

[0048] As mentioned in the background, calculating carbon emissions from building materials suffers from unit mismatches, leading to inefficient calculations. Improving and designing the text processing algorithm would result in a complex algorithm structure and prohibitively high implementation costs. Therefore, this solution attempts to address this issue using a generative model.

[0049] The development of generative AI technology has provided a path to solving complex language-related problems. Large language models (LLMs), such as GPT, GLM, Spark, and Wenxinyiyan, represent cutting-edge advances in natural language processing. These models are pre-trained on large-scale corpora, enabling them to efficiently understand and generate natural language text.

[0050] While many LLMs have demonstrated near-human-level performance in general question answering, they still face some shortcomings. For one thing, LLMs can sometimes produce uncontrollable "hallucinations," resulting in output that is disconnected from reality or logically incoherent. Furthermore, because LLMs are often trained on relatively closed and limited data, they often perform poorly in specific domains.

[0051] Retrieval Augmented Generation (RAG) technology provides an effective solution to the limitations of LLM. Its framework consists of a retriever and a generator. The retriever retrieves information related to the user query from the local knowledge base, and the generator generates answers based on the retrieval results.

[0052] However, the retrieval and generation process of RAG technology is relatively fixed, making it difficult to dynamically adapt to complex tasks, and it is also unable to actively call external tools. For example, in mathematical calculations, RAG technology is mainly used to assist LLM in providing problem-solving ideas. By retrieving relevant mathematical formulas, theorems, or problem-solving steps, RAG can provide LLM with more accurate contextual information, thereby improving the accuracy and efficiency of solving mathematical problems. However, RAG itself does not perform mathematical calculations, but relies on the mathematical reasoning ability of LLM, allowing LLM to "imitate" the calculation process in the mathematical formula. This "imitation" is essentially symbolic reasoning, not numerical calculation, and will lead to calculation errors.

[0053] Example 1:

[0054] like Figure 2 As shown, the unit conversion method of building material data based on retrieval enhancement generation includes the following steps:

[0055] Obtain building material size parameters, current units of building materials, and target units to be converted, form a unit conversion problem, and input it into the retrieval enhancement generation module;

[0056] The retrieval enhancement generation module performs text segmentation on the input unit conversion question to obtain the question text vector. Then, through vector similarity search, it matches several texts with the highest similarity to the question text vector in the local knowledge base to obtain templated prompt words.

[0057] The Agent module calls the generative model based on the prompt word to identify the conversion steps that need to be performed, and executes the corresponding conversion steps by calling the numerical calculation tool. The conversion results are returned to the generative model to generate a natural language answer.

[0058] like Figure 3 As shown, the data unit conversion method of this embodiment includes five steps:

[0059] Build a local knowledge base: By analyzing the main conversion types of materials involved in the bill of materials, we build detailed conversion steps for some typical materials and use LLM to generate more conversion steps for similar materials to form a local knowledge base.

[0060] Building RAG: A word embedding model is used to vectorize the text in the local knowledge base to build a word vector library. At the same time, the user's input question is represented by a cognate word embedding. Through vector similarity retrieval, the most relevant knowledge paragraphs are matched from the word vector library. This completes the construction of the RAG module and provides specific conversion steps for unit conversion problems.

[0061] Create an Agent: Configure the Agent tool, including removing redundant whitespace characters from input strings and pre-configuring mathematical calculation function tools to ensure that the agent has a certain level of mathematical understanding.

[0062] Design prompt words: Embed the user question and the matching knowledge paragraph into a preset prompt word template and input it into the locally deployed large language model;

[0063] Locally deployed LLM: The Agent uses the calculation steps provided by the RAG module and the preset mathematical calculation functions to complete the final numerical calculation through the LLM and output the complete conversion steps.

[0064] Build a local knowledge base and determine the type of unit conversion based on the difference between building material units and carbon emission coefficient units; build corresponding conversion step details for each conversion type, which describe the size parameters and density information of building materials, as well as the mathematical expression composed of size parameters and density information; use the generative model to obtain the conversion step details of more similar materials, and form a txt text document to obtain the constructed local knowledge base.

[0065] The following steps are involved:

[0066] S101: By comparing the material units in the "Building Materials Bill of Quantities" with the material units in the "Carbon Emission Factor Set", we can identify cases where the material type is the same but the units are different. After summarizing, the conversion methods can be divided into the following five types:

[0067] Length to weight conversion; area to weight conversion; volume to weight conversion; quantity (pieces, sets) to weight conversion; others.

[0068] Because the weight units in the "Carbon Emission Factor Set" are mostly weight "tons" and only international units are considered, the conversion methods can be specifically divided into:

[0069] Conversion from meter to ton; conversion from square meter to ton; conversion from cubic meter to ton; conversion from “piece” to “ton”; conversion from “set” to “ton”; others.

[0070] S102, by selecting typical materials for each part, construct the conversion step details. The construction process can be broken down into Figure 4 The three steps shown (taking "waterstop steel plate" as an example) are as follows:

[0071] The first step is to extract the material names, units, and quantities from the building materials list, replacing fixed values ​​with variables to create a coherent description. For example, the length of the waterstop steel plate δx*y is A meters.

[0072] The second step is to extract key dimensional parameters (thickness, width, length, diameter, etc.) based on its shape and add a description of the material density. For example, its thickness is x mm, which is 0.001*x m, its width is y mm, which is 0.001*y m, and the density of steel is a specific value of 7.85 tons per cubic meter.

[0073] The third step is to develop a formula for calculating weight. For linear or plate-shaped materials, the volume is calculated based on length, width, and thickness. For cylindrical materials, the volume is calculated based on radius and length. For materials counted by piece, the volume is multiplied by the quantity. For materials with known mass, the formula is directly converted, ultimately resulting in a mathematical expression composed of dimensional parameters and density information. For example, to convert A meters of waterstop steel plate (δx*y) into tons, the steps are: thickness multiplied by width multiplied by length multiplied by density, resulting in the mathematical expression (0.001*x*0.001*y*A*7.85) tons.

[0074] In this embodiment, Tables 1 to 5 are examples of detailed steps for converting different unit types.

[0075] Table 1 Details of the unit conversion steps for "length (meters) to weight (tons)"

[0076]

[0077] Table 2 Details of the unit conversion steps for "Area (square meters) to weight (tons)"

[0078]

[0079]

[0080] Table 3 Details of the steps for converting "volume (cubic meters) to weight (tons)"

[0081]

[0082] Table 4 Details of the unit conversion steps for "Quantity (sets, pieces) to weight (tons)"

[0083]

[0084]

[0085] Table 5 Details of the unit conversion steps for "Other weight (tons)"

[0086]

[0087] S103, based on the constructed conversion step details, by replacing some parameter information, using LLM to generate more conversion step details of similar materials, such as Figure 5 As shown, the types of information contained in the local knowledge base are more comprehensive.

[0088] S104, summarizing all the conversion step details into a txt text document to obtain a complete and comprehensive local knowledge base.

[0089] The local knowledge base obtained by the above method unifies the calculation rules and ensures that different systems have consistent calculation logic for the same material by clarifying the conversion steps (such as size parameters → volume → weight → carbon emissions), thereby reducing errors caused by human conversion.

[0090] The generative model is used to generate conversion rules for similar materials, which can quickly expand the local knowledge base.

[0091] By updating the TXT document, you can adapt to new units or new materials, and achieve dynamic updates at a relatively low cost. In addition, the TXT format does not require database support, has strong compatibility, and is convenient for version management and sharing.

[0092] Build the RAG module, such as Figure 6 As shown, the following steps are included:

[0093] S201, loading the document formed by the local knowledge base;

[0094] S202, using a text segmenter to segment the loaded text into text paragraphs, and performing vectorization processing on the obtained text paragraphs using a word embedding model to form a word vector library;

[0095] S203, using the same word embedding model, performs text vectorization processing on the input unit conversion question to obtain a question text vector;

[0096] S204: Search the word vector library for several texts that are most similar to the question text vector, and integrate them into the preset prompt word template to generate the prompt word to be sent to the LLM.

[0097] Using this approach, the RAG module extracts the most relevant passages from the local knowledge base through vector similarity searches, ensuring that generated prompts are based on the latest, most relevant authoritative data, rather than relying on the LLM's inherent knowledge (which may be outdated or incomplete). Traditional LLMs may fabricate false conversion formulas due to limited training data. However, RAG significantly reduces the probability of incorrect output and the risk of hallucinations by forcing references to passages in the local knowledge base (such as retrieved TXT document snippets).

[0098] When new materials are added or coefficients are revised (for example, it is found that "the carbon emission coefficient of aluminum needs to be reduced by 10%"), it is only necessary to update the TXT document of the knowledge base and rebuild the word vector library. There is no need to retrain LLM. The system takes effect immediately, realizing hot updates of the knowledge base.

[0099] By using the preset prompt word template, the generation direction of LLM can be constrained to avoid deviation from the actual data.

[0100] Through the RAG module, the deterministic knowledge of unit conversion (local documents) and the reasoning ability of LLMS (generating natural language answers) can be efficiently combined to achieve the "1+1>2" effect in the building materials carbon emission calculation task.

[0101] Create an agent.

[0102] LLM does not have the precise calculation capabilities of a calculator or programming language, essentially because its design goals and working mechanisms determine that it only "predicts words" rather than "executes instructions" or "calculates step by step."

[0103] For example, if you ask an LLM, "237 × 48 = ?" it might answer "11376" (correct), "11370," or "11400" because it's not calculating, but rather guessing which answer is most common. In a Python program, however, executing "print(237 * 48)" will always return 11376 because Python has computational capabilities and actually performs multiplication.

[0104] An Agent is a system that introduces a mechanism for invoking external tools based on the LLM. By enabling LLM models to call computing engines, programming environments, or APIs, it enables them to "think before they act" like humans, thus compensating for the shortcomings of their native computing capabilities. Therefore, the introduction of an Agent can effectively improve the accuracy and practicality of the LLM in numerical computing tasks.

[0105] In this embodiment, the process of using Agent to solve the unit conversion problem is as follows: Figure 7 As shown, the prompt word generated by the RAG module is input into the Agent module. The Agent module triggers the LLM model (the Qwen2-Math model is selected in this embodiment) to perform reasoning and thinking based on the content of the prompt word, and calls the "tool" (the numerical calculation program is selected in this embodiment) to solve the unit conversion problem in this solution.

[0106] The LLM model then verifies the accuracy of the answer through repeated reasoning and self-checking. If an error is found, the agent will correct the answer and regenerate the output. The specific process is as follows Figure 6 As shown, the following steps are included:

[0107] 1. Generate preliminary results. After the agent uses mathematical tools to obtain preliminary results, it inputs the results into the Qwen2-Math model for preliminary solution;

[0108] 2. Self-checking and logical verification. LLM will verify the results as follows:

[0109] Logical consistency check: Re-examine the problem conditions, parameters, and calculation steps to ensure that each step of the derivation complies with mathematical rules (such as unit conversion, formula applicability conditions, etc.);

[0110] Reverse verification: Try to reverse the deduction (for example, use the result to reverse the input parameters) to verify whether it is consistent with the original problem;

[0111] Boundary condition checking: Verify that the results meet real-world constraints (e.g., mass cannot be negative).

[0112] 3. Error identification and correction. If a logical contradiction, numerical error, or tool calculation deviation is found, the agent will recheck the tool input parameters, re-invoke the tool calculation, or generate a new solution.

[0113] The "tool" here is a numerical calculation program that can specify Arabic numerals appearing in the text as floating-point numbers, then perform numerical calculations on mathematical expressions in the local knowledge base and return the calculation results.

[0114] The agent performs reasoning tasks based on the provided LLM, tools, and prompts, returning the final answer through multiple rounds of reasoning and detailed log output. The entire process includes error resolution capabilities to ensure the accuracy and robustness of the reasoning process.

[0115] While LLM models have reasoning capabilities and excel at generating text, they are prone to errors when it comes to precise calculations, real-time information, and complex logic (such as multi-step math problems). Agents, by invoking tools, "outsource" these tasks to specialized systems, thus addressing LLM's inherent shortcomings.

[0116] Throughout the entire process, by building a local knowledge base, the reasoning ability of the LLM model is brought into play using the local knowledge base. The RAG module also uses the local knowledge base to help the LLM model generate templated prompt words, while the Agent calls an external numerical calculation program as a tool. The numerical calculation program also uses the unit conversion steps in the local knowledge base to perform corresponding numerical operations, ultimately forming a RAG+Agent collaboration method to achieve unit conversion during the calculation of building materials carbon emissions.

[0117] Design prompt words.

[0118] In the RAG module, after searching the local knowledge base for relevant text similar to the question text, the input question and the response text are simultaneously passed to the prompt word template. The prompt word template compiles and integrates these inputs to generate appropriate prompt words to guide the LLM model in executing subsequent tasks.

[0119] The prompt word can be regarded as an instruction or context guidance. Its main goal is to clearly inform the LLM model of the type of task to be performed and the form in which the LLM model is expected to respond to the input data.

[0120] The prompt word template contains at least three types of content: "specific conversion steps", "structured output format" and "tool call specifications". Among them:

[0121] Specific conversion steps (RAG knowledge guidance) call the local knowledge base content generated by RAG through "knowledge+requirements" (such as unit conversion formulas, mathematical rules, etc.).

[0122] The structured output format must follow the "Question-Thought-Action-Observation" process, that is, the "Question-Thought-Action-Observation" cycle: For example:

[0123] Question: Identify the user's problem;

[0124] Thought: current reasoning step (the logic of knowledge / tool ​​selection must be explained);

[0125] Action: Select a unique tool (Calculator) from [{tool_names}];

[0126] ActionInput: structured parameters (such as {"expression":"12500*0.1"});

[0127] Observation: the original results returned by the tool;

[0128] Termination sign: Thought: I now know the final answer → Final Answer.

[0129] Tool calling specification is used to clearly list the available tool names ({tool_names}). Actions must strictly match tool names and free play is prohibited.

[0130] The prompt word template in this embodiment is shown in Table 6, and the words in brackets are additional explanations.

[0131] Table 6 Prompt word template

[0132]

[0133]

[0134] The prompt word template first clarifies the question (question), then requires the LLM to perform preliminary reasoning (Thought) based on the local knowledge base (knowledge), and then call (Acti on) external tools (tools). Through the output of the tools (Observation), the reasoning process is continuously adjusted until the final answer (Final Answer) is obtained.

[0135] This structured prompt word design enables the model to reason step by step, select the appropriate tool to perform the task, and update the thinking process based on the action results, ultimately converging to the correct answer.

[0136] Deploy large language models locally.

[0137] In this step, no specific LLM is required; you can choose an LLM with sufficient mathematical reasoning capabilities. This example uses Qwen2-Math as an example. Its mathematical reasoning capabilities, formula processing accuracy, and complex problem-solving efficiency all outperform similar models, and it has achieved the highest scores among current open-source models in authoritative mathematical benchmarks such as MATH and GSM8K.

[0138] Install the Ollama platform locally and start Ollama in a command-line terminal. Enter the command "ollama pullqwen2-math:7b" to download the Qwen2-Math-7B model. After the download is complete, enter the command "ollama run qwen2-math:7b" to start the model. Then, enter questions in the terminal. If you receive answers, the local deployment is successful.

[0139] Create a FastAPI application locally and view the complete running results of the model on the web and local console.

[0140] During the execution of the model's RAG module, when performing a similarity search on a unit conversion problem using a vector database, the model retrieves k similar conversion step details from the database based on the problem content and sorts them from highest to lowest similarity. The model then selects the first conversion step with the highest similarity as a reference and uses this step for subsequent reasoning.

[0141] For example, when k is set to 3 and the model is asked "What is the weight of a water-stop steel plate that is 2 meters long, 3 mm wide, and 400 mm thick?", the model's answer and reasoning process are as follows: Figure 8 and Figure 9 shown.

[0142] Example 2:

[0143] The building material data unit conversion system based on retrieval enhancement generation includes:

[0144] The question input module is configured to: obtain the building material size parameters, the current unit of the building material and the target unit to be converted, form a unit conversion question and input it into the retrieval enhancement generation module;

[0145] The search enhancement generation module is configured to: perform text segmentation on the input unit conversion question to obtain a question text vector; perform vector similarity search to match several texts with the highest similarity to the question text vector in the local knowledge base to obtain templated prompt words;

[0146] The Agent module is configured to: call the generative model to identify the conversion steps that need to be performed based on the obtained prompt word, and execute the corresponding conversion steps by calling the numerical calculation tool. The obtained conversion results are returned to the generative model to generate a natural language answer.

[0147] The unit conversion problem during the carbon emission period of building materials is solved by using retrieval-enhanced generation and the combination of agent technology and generative models. The overall process is simple and easy, and can quickly and accurately calculate the carbon emissions during the building materials production stage.

[0148] Example 3:

[0149] A computer program product includes computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the above-mentioned method for converting building material data units based on retrieval enhancement generation.

[0150] Example 4:

[0151] An electronic device includes at least one processor and a memory connected to the processor, the memory being used to store a computer program; the processor being used to execute the computer program, so that the electronic device can implement the above-mentioned method for converting building material data units based on retrieval enhancement generation.

[0152] Embodiment 5:

[0153] A computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enables the electronic device to implement the above-mentioned method for converting building material data units based on retrieval enhancement generation.

[0154] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.

Claims

1. The unit conversion method for building material data based on retrieval enhancement generation is characterized by: The following steps are involved: Obtain the building material size parameters, the current unit of the building material and the target unit to be converted to form a unit conversion problem; Perform text segmentation on the input unit conversion question to obtain the question text vector. Then, through vector similarity search, match the texts with the highest similarity to the question text vector in the local knowledge base to obtain templated prompt words. Based on the obtained prompt word, the generative model is called to identify the conversion steps that need to be performed. The corresponding conversion steps are executed by calling the numerical calculation tool, and the obtained conversion results are returned to the generative model to generate a natural language answer.

2. The method for converting building material data units based on search enhancement generation according to claim 1, characterized in that: The process of constructing the local knowledge base is as follows: obtaining the building materials list and the carbon emission coefficient set, determining the conversion steps and corresponding mathematical expressions of typical building materials based on the unit difference between the building materials list and the carbon emission coefficient, and forming a local knowledge base in text format.

3. The method for converting building material data units based on search-enhanced generation according to claim 2, characterized in that: The process of constructing the local knowledge base further includes using a generative model to obtain conversion steps and corresponding mathematical expressions for materials similar to typical building materials, thereby expanding the local knowledge base.

4. The method for converting building material data units based on search enhancement generation according to claim 1, characterized in that: During the construction of the local knowledge base, based on the unit difference between the building materials list and the carbon emission coefficient, the conversion steps and corresponding mathematical expressions of building materials are determined to form a local knowledge base in text format, including the following steps: Extract the material name, unit and quantity from the building materials list, and use set variables to replace fixed values ​​to form a smooth language description; Extract key dimensional parameters based on the shape of building materials and add a description of the building material density; According to the unit of the carbon emission coefficient, the shape and quantity of the building materials, a unit conversion mathematical expression consisting of size parameters and density information is determined to form a local knowledge base in text format.

5. The method for converting building material data units based on search-enhanced generation according to claim 1, characterized in that: Use the retrieval enhancement generation module to load the documents formed by the local knowledge base, segment the text into text paragraphs, and perform vectorization processing to form a word vector library; The input unit conversion question is segmented to obtain the question text vector. Through vector similarity search, several texts with the highest similarity to the question text vector are matched in the word vector library to obtain templated prompt words.

6. The method for converting building material data units based on search-enhanced generation according to claim 1, characterized in that: The templated prompt words are specifically: the text obtained during the vector similarity search and the input question text are simultaneously input into a preset template, and the prompt words at least include the conversion steps of the corresponding building materials and the numerical calculation tools that can be called.

7. The building material data unit conversion system based on retrieval enhancement generation is characterized by: include: The question input module is configured to: obtain the building material size parameters, the current unit of the building material and the target unit to be converted, form a unit conversion question and input it into the retrieval enhancement generation module; The search enhancement generation module is configured to: perform text segmentation on the input unit conversion question to obtain a question text vector; perform vector similarity search to match several texts with the highest similarity to the question text vector in the local knowledge base to obtain templated prompt words; The Agent module is configured to: call the generative model to identify the conversion steps that need to be performed based on the obtained prompt word, and execute the corresponding conversion steps by calling the numerical calculation tool. The obtained conversion results are returned to the generative model to generate a natural language answer.

8. A computer program product, characterized in that The method comprises computer-readable instructions, which, when executed on an electronic device, enable the electronic device to implement the steps in the method for converting building material data units based on retrieval enhancement generation as described in any one of claims 1 to 6.

9. An electronic device, characterized in that: The electronic device comprises at least one processor and a memory connected to the processor, the memory being used to store a computer program; the processor being used to execute the computer program, so that the electronic device can implement the steps in the method for converting building material data units based on retrieval enhancement generation as described in any one of claims 1 to 6.

10. A computer storage medium, characterized in that The storage medium carries one or more computer programs, which, when executed by an electronic device, enable the electronic device to implement the steps in the building material data unit conversion method based on retrieval enhancement generation as described in any one of claims 1 to 6.