A lightweight large model intelligent question and answer optimization method and system for vertical industries
Patent Information
- Application Number
- CN202611093205.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-22
- Publication Date
- 2026-10-20
AI Technical Summary
1)本发明通过采用轻量级大语言模型作为基座,结合离线重负载预处理与在线轻量级检索的架构隔离设计,使系统能够在消费级显卡上实现本地化部署,同时通过私有工艺层与通用技术层的物理隔离存储,确保企业核心工艺数据不离开本地计算节点,从根本上杜绝云端API调用导致的数据泄露风险,实现了算力受限条件下的低成本私有化部署;
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and more specifically, to a lightweight, large-model intelligent question-answering optimization method and system for vertical industries. Background Technology
[0002] In recent years, large language model question-answering systems based on Retrieval-Augmented Generation (RAG) have gradually become the mainstream technical approach for building intelligent assistants in various industries. In the agricultural field, some patents have attempted to combine large models with agricultural knowledge bases to improve the intelligence level of agricultural technology services.
[0003] For example, patent CN119226483A discloses a method for optimizing agricultural knowledge domain question-and-answer applications using a large model. This method first performs coarse-grained segmentation of PDF agricultural books based on punctuation and line length. Then, it uses an open-source large model (such as Qwen1.5-14B-Chat) to refine the coarse knowledge points into precise knowledge points of 30-50 words. For Excel spreadsheet data, it uses predefined letter templates (such as AAA representing crops) to concatenate knowledge points, thus narrowing the semantic gap between user questions and the spreadsheet data. Simultaneously, it filters the open-source dataset using an agricultural dictionary and the large model to construct an agricultural knowledge base. This method improves the standardization and accuracy of agricultural knowledge question-and-answer to a certain extent.
[0004] Another patent, CN118939762A, proposes a generative large-scale agricultural intelligent question-answering method based on knowledge graph-enhanced retrieval. This scheme employs a low-rank adaptive (LoRA) algorithm to fine-tune a large model using agricultural pest and disease knowledge question-answering data. Simultaneously, it pre-constructs an agricultural pest and disease data knowledge graph (stored in the Neo4j graph database), vectorizes user questions, and performs subgraph traversal and cosine similarity retrieval within the knowledge graph to generate knowledge-based answers, thereby improving the transparency and interpretability of the reasoning process.
[0005] The aforementioned existing technologies provide valuable technical insights for constructing agricultural knowledge question-and-answer systems. However, when attempting to directly apply these solutions to vertical industries such as camellia oil and deploy them in the actual production environments of grassroots agricultural enterprises and agricultural technology stations, the following significant drawbacks still exist: 1) The contradiction between high computing power threshold and private data security and operating costs: The large-parameter models (up to 14B parameters) such as Qwen1.5-14B-Chat, upon which CN119226483A relies, require expensive enterprise-grade GPU clusters (such as A100 / H800) to achieve low-latency inference. However, grassroots agricultural enterprises or agricultural technology stations are usually only equipped with consumer-grade graphics cards with limited video memory (such as 8GB of video memory), making it difficult to achieve localized deployment of large models. If they turn to calling the API interfaces of large cloud companies, the long-term token-based billing model will bring high operating costs to grassroots agriculture. More importantly, there is a risk of leakage of core enterprise processes (such as camellia oil-specific formulas, unique extraction technologies, and other private data) during transmission and access. None of the above comparative documents propose a system-level resource scheduling and adaptation solution for the limited computing power environment, making it difficult for advanced large-scale model technology to be truly deployed to the grassroots production front line. 2) Traditional text segmentation algorithms disrupt the two-dimensional table structure, exacerbating the illusion of small models: Technical manuals and operating procedures in vertical industries such as camellia oil contain a large amount of dense two-dimensional table data (e.g., fertilizer application tables corresponding to different tree ages and growth stages, pesticide dilution ratio tables, etc.). Although CN119226483A proposes coarse segmentation based on punctuation and row length, as well as fine segmentation for large models, its processing objects are essentially pure text streams; for Excel tables, it only performs simple splicing using letter templates, without preserving the original physical structure of the tables' rows and columns. When using lightweight, small-parameter base models (such as those on the order of 2.5B) under computationally limited environments, this fragmented context with disrupted structure can cause the model to completely fail to align indicators with values, thus triggering a severe knowledge illusion. For example, the fertilizer application amount for "young tree stage" may be incorrectly matched to "peak production stage," or the pesticide concentration for "disease control" may be mistakenly used for "pest control." Although CN118939762A constructs a knowledge graph, its entity relationship extraction is mainly aimed at named entities in text, and it also lacks effective structure preservation and parsing capabilities for already segmented and scattered tabular data. 3) The default generated format is incompatible with field-based pure voice interaction devices (TTS): The large models used in the aforementioned comparison documents (including the Qwen series and various base models) tend to output structured layouts with special symbols such as asterisks, hash marks, and Markdown tags during low-level alignment training. However, in grassroots camellia oil applications, the question-and-answer system often needs to directly interface with voice broadcasting devices or screenless agricultural machinery in the fields. When an unformatted Markdown stream is pushed to the TTS engine, it easily leads to garbled pronunciations in the synthesized speech (such as pronouncing "asterisks" or "hash marks"), high-frequency abnormal pauses, and an overly formal and listing language style that does not conform to the natural speech listening habits of grassroots farmers. None of the existing comparison documents have optimized the output format for this actual deployment scenario. 4) Lack of deterministic safety constraints for high-risk agricultural operations: Agricultural Q&A related to camellia oil and other crops heavily involves high-risk operations such as pesticide formulation and fertilizer dosage. Whether it's the pure search-generation process in CN119226483A or the knowledge graph-enhanced search in CN118939762A, the final answer relies entirely on the large model's own black-box reasoning, lacking an external deterministic hard verification module for the model-generated values. If the large model produces numerical illusions (e.g., misreporting "3000 times diluted abamectin" as "1000 times diluted"), and this is directly output to farmers without an interception mechanism, it can easily lead to serious production accidents such as pesticide damage, reduced yields, or even total crop failure. None of the aforementioned comparative documents include such a safety catch-up mechanism.
[0006] In summary, existing large-model-based agricultural knowledge question-answering technologies still face multiple technical obstacles when applied to grassroots vertical industries such as camellia oil, including the conflict between computing power costs and data security, the failure of two-dimensional table structure parsing, incompatibility of voice interaction formats, and the lack of security interception mechanisms. Therefore, there is an urgent need to provide a lightweight large-model intelligent question-answering optimization method and system for vertical industries to solve the above problems. Summary of the Invention
[0007] This invention provides a lightweight large-model intelligent question answering optimization method and system for vertical industries. Its main purpose is to address the above-mentioned shortcomings of existing technologies by solving the problems that existing large-model question answering solutions are difficult to deploy in grassroots environments with limited computing power, that table structure segmentation destroys the integrity of knowledge, that the output format is incompatible with pure voice interaction scenarios, and that there is a lack of high-risk numerical security fallback mechanisms.
[0008] To achieve the above objectives, the technical solution adopted by the present invention is as follows: A lightweight, large-model intelligent question-answering optimization method for vertical industries includes: Knowledge base construction steps: 1. Acquire unstructured documents and structured tables from vertical industries to construct a two-layer knowledge base containing a general technology layer and a proprietary process layer; 2. Convert the structured table data into HTML text with complete closing tags; 3. Use a fixed-length sliding window to segment the converted text, constructing a document object model tree for boundary detection during the segmentation process. When a segmentation point falls inside a closing tag, trigger a backtracking or forward-looking mechanism to adjust the segmentation point to the nearest closing tag, generating text blocks that maintain structural integrity; 4. Inject metadata tags into the text blocks and store them in a vector database. Query routing steps: Receive a user's natural language query; extract intent slots from the query to obtain at least one slot feature; generate a routing determination result based on whether the slot feature matches a preset private entity dictionary; when the routing determination result is a match, force the query to the private process layer, and use the slot feature to perform metadata filtering and vector retrieval on the vector database of the private process layer to obtain a first retrieval result; when the routing determination result is a miss, route the query to the general technology layer for vector retrieval to obtain a second retrieval result. Constraint generation steps: Concatenate the first search result or the second search result with the query, inject a forced constraint instruction, input it into a lightweight large language model for reasoning, and generate smooth plain text without format markup symbols; The secure output step involves performing regular expression extraction on the smooth plain text to obtain triples containing entities, values, and units of measurement. These triples are then compared to recommended security thresholds in the local security threshold database. If the value exceeds the recommended security threshold, the smooth plain text is intercepted and replaced with a preset security prompt, which is then output to the voice broadcast front-end. If the value is not greater than the recommended security threshold, the smooth plain text is output to the voice broadcast front-end. The knowledge base construction step ensures that the segmented text blocks always contain complete headers and current row values through mandatory tag closure verification, completely preventing data misalignment during inference in small-parameter models. The query routing step ensures the security and absolute exclusivity of core business knowledge through a hard routing mechanism, while reducing retrieval computation. The constraint generation step abandons the traditional method of post-processing and cleaning the generated text with regular expressions, saving local computing power and resolving the incompatibility issue between the default output format of large models and voice broadcast devices. The secure output step completely blocks misleading production accidents caused by artificial intelligence digital illusions from the application end through an external hard logic firewall that does not rely on the large model's own judgment.
[0009] Furthermore, the segmentation of the converted text using a fixed-length sliding window specifically involves: The window length of the fixed-length sliding window is set to a first preset number of tokens; Using the first preset number of tokens as the dividing boundary, the HTML text is scanned segment by segment; Each time the scanning reaches the segmentation boundary, query the parent node label type of the current document object model tree at the location of the segmentation boundary; When the parent node label type is any one of table label, row label, or column label, it is determined that a structural truncation has occurred. In response to the structural truncation, calculate the first distance between the cutting boundary and the nearest previous closed label and the second distance between the cutting boundary and the nearest subsequent closed label; When the first distance is less than or equal to the second distance and the first distance does not exceed a preset semantic length threshold, the backtracking mechanism is executed to revert the segmentation boundary to the previous closed label. When the second distance is less than the first distance and the window length after rollback does not exceed the video memory safety boundary, the forward probe mechanism is executed to extend the split boundary to the next closed label. Lock the adjusted split boundaries and output the complete text block within the current window.
[0010] Furthermore, the intent slot extraction of the query to obtain at least one slot feature specifically includes: A lightweight named entity recognition model is invoked to perform sequence labeling on the query and extract entity words and attribute words from the query; The entity words and attribute words are matched according to the preset business rule dictionary to generate a slot feature set containing at least one of entity slots, growth stage slots, and agricultural action slots. When there is a slot in the slot feature set that matches the private entity dictionary, the routing flag is set to the first state; When there is no slot in the slot feature set that matches the private entity dictionary, the routing flag is set to the second state.
[0011] Furthermore, the step of generating a routing determination result based on whether the slot feature matches a preset private entity dictionary specifically involves: Read the routing flags; When the routing flag is in the first state, the routing determination result is a hit. The system's underlying scheduler forcibly intercepts the default retrieval request to the general technology layer and redirects the currently queried vector library index pointer to the high-dimensional vector library of the private process layer. When the routing flag is in the second state, the routing determination result is a miss, and the default configuration is maintained to perform the retrieval at the general technology layer.
[0012] Furthermore, the step of using the slot features to perform metadata filtering and vector retrieval on the vector database of the private process layer specifically involves: Using the growth stage slots or agricultural action slots in the slot features as metadata filtering conditions, hard filtering is performed on the vector database of the private process layer to obtain a candidate subset. The query is converted into a query vector, and the similarity between the query vector and each text block vector is calculated in the candidate subset; Sort the text blocks by similarity from high to low, and select the top K text blocks as the first search result, where the value of K is dynamically adjusted according to the current video memory usage.
[0013] Furthermore, in the constraint generation step, the mandatory constraint instructions include format constraint instructions, person constraint instructions, and style constraint instructions; The format constraint directive is used to prohibit the lightweight large language model from generating output containing any of the asterisks, hash symbols, minus signs, number sequences, and Markdown markup symbols, and forces the use of natural paragraphs and logical connectors for expression; The person constraint instruction is used to force the third person in the response to be replaced with the first person when the slot feature hits a private entity; The style constraint directive is used to specify a colloquial expression style; The inference temperature parameter of the lightweight large language model is locked within a preset low temperature range.
[0014] Furthermore, the regular expression extraction of the smooth plain text yields a triple containing entity, value, and unit of measurement, specifically as follows: A regular expression engine for measuring units and high-risk entities in vertical industries is constructed. The regular expression engine has built-in matching modes, which are used to match combinations of entities, numerical values and units of measurement. Ignore case sensitivity and agricultural slang separators to extract key triples from the smooth plain text; When multiple triples are extracted, a subsequent security comparison is performed on each triple.
[0015] Furthermore, the comparison of the triple with the recommended security threshold in the local security threshold database specifically involves: Using the entity in the triplet as an index, query the local security threshold database for the legally recommended security threshold of that entity under the unit of measurement in the triplet; Perform Boolean logic judgment: if the value in the triplet is greater than the legally recommended safety threshold, it is determined that there is an excessive risk; if the value in the triplet is not greater than the legally recommended safety threshold, it is determined that it is safe.
[0016] Furthermore, in the knowledge base construction step, the construction of the two-layer knowledge base specifically involves: The general technology layer is constructed by acquiring publicly available technical manuals and standard documents, and the proprietary process layer is constructed by acquiring the company's private formulas, original extraction processes and internal experimental data. The general technology layer and the private process layer are stored in physically isolated first vector databases and second vector databases, respectively. The metadata tags include at least one of the following: applicable area tags, growth stage tags, variety tags, and operation type tags.
[0017] Another technical solution adopted by the present invention is: A lightweight, large-model intelligent question-answering optimization system for vertical industries includes: The data foundation module is used to acquire unstructured documents and structured tables from vertical industries, and to build a two-layer knowledge base containing a general technology layer and a private process layer. The data foundation module includes a format mapping unit, a structure segmentation unit, and a vectorized storage unit. The format mapping unit converts the structured table data into HTML text with complete closing tags. The structure segmentation unit uses a fixed-length sliding window to segment the converted text. During the segmentation process, a document object model tree is built for boundary detection. When a segmentation point falls inside a closing tag, a backtracking or forward-looking mechanism is triggered to adjust the segmentation point to the nearest closing tag, generating a text block that maintains structural integrity. The vectorized storage unit injects metadata tags into the text block and stores it in a vector database. A dynamic scheduling module is used to receive user natural language queries, extract intent slots from the queries, generate routing determination results based on the extraction results, and route the queries to the corresponding knowledge layer for retrieval based on the routing determination results. The dynamic scheduling module includes a slot extraction unit, a routing control unit, and a memory awareness unit. The slot extraction unit is used to call a named entity recognition model to extract slot features from the queries. The routing control unit is used to generate the routing determination results based on whether the slot features match a private entity dictionary, and accordingly redirect the query vector library index pointer to the private process layer or keep it pointing to the general technology layer. The memory awareness unit is used to read the memory usage rate of the current computing node in real time, and dynamically reduce the number of vector retrievals when the memory usage rate exceeds a preset safety threshold. The constraint generation module is used to concatenate the search results with the query, inject mandatory constraint instructions, input them into a lightweight large language model for inference, and generate smooth plain text without formatting marks. The constraint generation module includes an instruction injection unit and an inference control unit. The instruction injection unit is used to encode formatting constraint instructions, person constraint instructions, and style constraint instructions into system prompt words. The inference control unit is used to lock the temperature parameters of the lightweight large language model within a preset low temperature range and perform inference. A security output module is used to perform regular expression extraction on the smooth plain text to obtain triples containing entities, values, and units of measurement. These triples are compared with recommended security thresholds in a local security threshold database. If the value exceeds the recommended security threshold, the smooth plain text is intercepted and replaced with a preset security prompt, which is then output to the voice broadcast front-end. The security output module includes a regular expression extraction unit, a threshold comparison unit, and an interception and replacement unit. The regular expression extraction unit is used to construct a regular expression engine to extract key triples from the smooth plain text. The threshold comparison unit is used to query the local security threshold database using the entities in the triples as indexes and perform Boolean logic judgments. The interception and replacement unit is used to block the original text output and return the preset security prompt when an excessive risk is detected.
[0018] Compared with the prior art, the present invention has the following advantages: 1) This invention uses a lightweight large language model as the base and combines an architecture isolation design of offline heavy-load preprocessing and online lightweight retrieval, enabling the system to be deployed locally on consumer-grade graphics cards. At the same time, through physical isolation storage between the private process layer and the general technology layer, it ensures that the core process data of the enterprise does not leave the local computing node, fundamentally eliminating the risk of data leakage caused by cloud API calls, and realizing low-cost private deployment under the condition of limited computing power. 2) This invention converts structured tabular data into HTML text with complete closing tags, and performs boundary detection and backtracking segmentation based on the DOM tree to force verification of tag closure, ensuring that each segmented text block contains a complete table header and the current row value; it improves the question-answering accuracy of complex agricultural charts, reduces the fatal error rate, and effectively solves the knowledge illusion problem in reasoning of small parameter models; 3) This invention injects format constraint instructions into the model input end to prohibit the generation of asterisks, hash symbols, minus signs, numerical serial numbers and Markdown markup symbols, and forces the use of natural paragraphs and logical connectors to express the text, thus physically stripping away structured code from the source; combined with the pronunciation correction mapping table of the rendering layer, it realizes full Chinese pronunciation of units of measurement, correct pronunciation of polyphonic characters, and native-language expression of percentages and years, completely solving the problems of garbled pronunciation and abnormal pauses caused by Markdown text being pushed to the TTS engine; 4) This invention constructs a regular expression extraction engine that does not rely on the judgment of the large model itself and a local security threshold comparison mechanism to perform numerical extraction and hard logic judgment on the generated plain text. When an excessive dose is detected, the output is physically blocked and replaced with a preset safety statement. This external hard logic firewall completely blocks misleading production accidents caused by AI digital illusions from the application end, giving the system extremely high industrial-grade security and fault tolerance. 5) This invention reads the memory usage rate of the current computing node in real time through the memory sensing unit. When the memory usage exceeds the preset safety threshold, a dynamic truncation mechanism is automatically triggered to dynamically reduce the number of vector retrievals from the default value to a safe value; reduce peak memory usage during high concurrency, eliminate memory thrashing, and ensure that the system does not crash under long text concurrent processing. Attached Figure Description
[0019] Figure 1 This is a schematic flowchart of the method of the present invention; Figure 2 This is a diagram of the overall module architecture of the system of the present invention; Figure 3 This is a flowchart illustrating the chart preprocessing and data entry process based on Hypertext Markup Language mapping according to the present invention. Figure 4 This is a flowchart of the dynamic scheduling process based on memory awareness and intent recognition in this invention. Figure 5 This is a diagram illustrating the strongly constrained generation and control structure of the model in this invention. Figure 6 This is a security verification and interception logic diagram for the present invention; Figure 7 This is a comparative diagram of the conventional segmentation method and the segmentation method of this invention. Figure 8 This is a logical diagram of table segmentation based on the document object model tree of this invention; Figure 9 This is a schematic diagram of the hard routing logic of the present invention. Detailed Implementation
[0020] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0021] The core concept of this invention is to address the four major technical challenges in vertical industry scenarios: limited computing power, easy loss of chart structures, incompatibility with voice interaction, and lack of security verification for high-risk operations. By adopting an architecture design that isolates offline heavy-load preprocessing and online lightweight retrieval, HTML mapping and DOM tree segmentation are completed in the knowledge base construction stage, and only lightweight retrieval and constraint generation are performed in the inference stage. This enables high-precision and high-security intelligent question answering for vertical industries on consumer-grade graphics cards.
[0022] Example 1
[0023] like Figure 1 As shown in the figure, this embodiment provides a lightweight large-model intelligent question answering optimization method for vertical industries, which includes four sequential stages: knowledge base construction, query routing, constraint generation, and secure output.
[0024] S1. Knowledge Base Construction Steps. This step completes all document parsing, HTML format mapping, DOM tree segmentation and validation, and metadata injection operations in the offline batch processing stage. The processed structured text blocks are persistently stored in a local high-dimensional vector database. This architecture design, which isolates offline heavy-load preprocessing and online lightweight retrieval, fundamentally eliminates the real-time memory occupation of data preprocessing, enabling the system to achieve millisecond-level smooth question-and-answer response on a single 16GB graphics card.
[0025] S2. Query Routing Step. This step is activated when a front-end user initiates a real-time voice interaction request. First, the current memory usage of the computing node is read in real time through the underlying driver interface. When the memory usage exceeds a preset safety threshold, a dynamic truncation mechanism is automatically triggered, dynamically reducing the number of vector retrieval requests from the default value to a safe value, ensuring that the core program does not crash under long text concurrent processing from the system's bottom layer. Then, a lightweight named entity recognition component is called to extract intent slots and determine routing flags for the user query. Based on the determination result, the query is forcibly routed to the corresponding knowledge layer for retrieval.
[0026] S3. Constraint Generation Step. This step is initiated after resource allocation and knowledge retrieval are completed. A lightweight large language model with approximately 2.5B parameters is used for inference. The retrieved knowledge fragments are concatenated with the user query, and multi-dimensional mandatory constraint instructions are injected to control the model to generate smooth plain text without formatted symbols.
[0027] S4. Safe Output Step. This step serves as the last line of defense before reaching the user's front end. After generating plain text and before triggering text-to-speech playback, a security verification and interception mechanism based on a deterministic algorithm is forcibly connected to fundamentally prevent large language models from generating catastrophic numerical illusions.
[0028] The working principle of this invention is as follows: In the offline stage, step S1 converts unstructured documents and structured table data of vertical industries into HTML text with complete closed tags, segments them into structurally complete text blocks through DOM tree boundary detection and backtracking mechanism, injects metadata tags and stores them in a vector database; In the online stage, step S2 receives user queries, extracts intent slots and routes the queries to the corresponding knowledge layer for retrieval based on the private entity hit rate, and dynamically adjusts the recall quantity based on the memory usage rate; Step S3 inputs the retrieval results and mandatory constraint instructions into a lightweight large language model to generate smooth plain text; Step S4 performs regular expression extraction and safety threshold comparison on the generated plain text, performs interception and replacement when excessive doses are detected, and finally pushes the safe plain text to the voice broadcast front end.
[0029] Example 2
[0030] like Figure 3 As shown, based on Example 1, the specific workflow of the knowledge base construction steps is as follows: The system acquires unstructured documents and structured table data from vertical industries to construct a two-layer knowledge base consisting of a general technology layer and a proprietary process layer. The general technology layer contains publicly available technical manuals and standard documents, while the proprietary process layer contains proprietary formulas, unique extraction processes, and internal experimental data. The construction process of the two-layer knowledge base is as follows: The system acquires publicly available technical manuals and standard documents through a pre-defined data acquisition interface, and stores them in the general technology layer after format verification; it acquires proprietary formulas, unique extraction processes, and internal experimental data through a secure encrypted transmission channel, and stores them in the proprietary process layer after anonymization. The two layers are physically isolated and stored in a first vector database and a second vector database, respectively.
[0031] During the document parsing phase, for densely packed tabular data in vertical industry documents, the format mapping module is invoked to convert it into text paragraphs with complete closed HTML tags, preserving hierarchical tags such as table tags, row tags, and column tags to ensure semantic representation of the physical relationship between rows and columns. The specific conversion rules of the format mapping module are as follows: for the input structured table data, the header row is extracted as the first row within the table tag, each data row is extracted as the row structure within the row tag, and each cell data is extracted as the data unit within the column tag.
[0032] The converted text is segmented using a fixed-length sliding window. Specifically, the window length of the fixed-length sliding window is set to the first preset number of tokens, and the HTML text is scanned segment by segment using the first preset number of tokens as the segmentation boundary. During this process, a micro document object model tree is built in the background to strictly detect the segmentation boundary. When the segmentation point of the 512th token falls within the complete table tag and end tag interval, or the line interval between the line tag and end tag, it is determined that a structural truncation has occurred.
[0033] In response to structural truncation, calculate the first distance between the segmentation boundary and the nearest preceding closed label and the second distance between the segmentation boundary and the nearest following closed label; when the first distance is less than or equal to the second distance and the first distance does not exceed a preset semantic length threshold, execute the backtracking mechanism to backtrack the segmentation boundary to the preceding closed label; when the second distance is less than the first distance and the window length after backtracking does not exceed the video memory safety boundary, execute the forward probing mechanism to extend the segmentation boundary to the following closed label; lock the adjusted segmentation boundary and output the complete text block within the current window.
[0034] In this embodiment, a maximum constraint is set for the forward expansion token: when the forward mechanism extends the segmentation boundary backward, the maximum number of expandable tokens is limited; if the total text length exceeds the expansion threshold when extending to the next closing tag, the tag alignment strategy is abandoned, and the text is directly segmented at the original 512 token window position; at the same time, a fallback strategy for incomplete HTML is added: if no paired complete table row tags are identified when traversing the entire HTML text, the DOM boundary correction logic is no longer executed, and mechanical segmentation using a fixed-length sliding window is directly adopted; the minimum semantic length threshold is only used for backtracking branch verification, and it is only used to determine whether the length of the backtracked text block meets the standard when the backtracking mechanism is executed; the forward branch relies on the aforementioned maximum expansion token threshold for length control, and no additional verification of the minimum semantic length is required.
[0035] To more clearly illustrate the difference between the segmentation mechanism of this invention and the traditional segmentation mechanism, Figure 7 This diagram illustrates a comparison between traditional segmentation schemes and the segmentation scheme of this invention. When processing tables with complex two-dimensional row and column relationships, the traditional 512Token blind segmentation scheme directly truncates the closed structure of row and column labels at the segmentation point, disrupting the association between the table header and the values. This invention's DOM tree-based closed segmentation scheme, through boundary detection and backtracking mechanisms, ensures that each segmented text block contains a complete row structure and corresponding table header information. Figure 8 This demonstrates a DOM tree-based table segmentation logic diagram. The table is parsed into a DOM tree structure, preserving the hierarchical relationship between table tags, row tags, and column tags. Collision detection is continuously performed during window scrolling. When a segmentation point falls inside a tag, the token distance to the previous and next closing tags is calculated and compared. The optimal adjustment direction is selected, ultimately locking in complete HTML tags at both ends and outputting a structurally complete text block. This forced tag closure validation strategy ensures that the segmented text data block always contains a complete table header and the current row value, locking the row and column correspondence.
[0036] Structured metadata tags are injected into the segmented text blocks, including at least one of the following: applicable region tag, growth stage tag, variety tag, and operation type tag, and stored in the corresponding high-dimensional vector database. Specifically, text blocks corresponding to the general technology layer are stored in the first vector database, and text blocks corresponding to the private process layer are stored in the second vector database. The two databases are physically isolated from each other.
[0037] In this embodiment, by mapping HTML format and splitting DOM trees, the small-parameter model can accurately capture the row and column relationships of agricultural technology data during inference, improving the question-answering accuracy of complex agricultural charts from 41.6% in the traditional solution to 95.8%. All high-consumption document parsing and splitting calculations are completed offline, without consuming the GPU memory resources of online inference.
[0038] Example 3
[0039] like Figure 4 As shown, based on Example 2, the specific workflow of the route query step is as follows: After receiving a user's natural language query, the system first calls a lightweight named entity recognition model to perform sequence labeling on the query, extracting entity words and attribute words from the query. Then, it matches the entity words and attribute words according to a pre-defined business rule dictionary, generating a slot feature set containing at least one of entity slots, growth stage slots, and agricultural action slots. The specific process for slot extraction is as follows: the lightweight named entity recognition model performs word segmentation and part-of-speech tagging on the query text; based on the tagging results, it identifies entity words, such as company names, variety names, and place names; it matches attribute words, such as growth stage words and agricultural action words, according to a pre-defined business rule dictionary; and it combines the identified entity words and attribute words to generate a structured slot feature set.
[0040] Read the routing flag. If a slot matching the private entity dictionary exists in the slot feature set, set the routing flag to the first state, determine a hit, forcibly intercept the default retrieval request to the general technology layer, and exclusively redirect the current queried vector library index pointer to the high-dimensional vector library of the private process layer. If no slot matching the private entity dictionary exists in the slot feature set, set the routing flag to the second state, determine a miss, and maintain the default configuration to perform the retrieval in the general technology layer.
[0041] Figure 9 This diagram illustrates the hard routing logic based on named entity recognition. After extracting the slot feature set from the query, the slot set is traversed to check if it matches a preset private high-security entity dictionary. If it matches, hard routing is triggered to redirect the vector library index pointer to the second vector database corresponding to the private process layer. The extracted sub-slots are used as metadata for the first hard filtering, followed by vector similarity retrieval in the subset, completely shielding the interference from the general knowledge base. If it does not match, the default configuration is maintained, and a regular search is performed in the first vector database corresponding to the general technology layer.
[0042] After entering the corresponding knowledge layer, the slot features are used for retrieval; the growth stage slots or agricultural action slots in the slot features are used as metadata filtering conditions to perform hard filtering on the vector database of the corresponding layer to obtain a candidate subset; the query is converted into a query vector, and the similarity between the query vector and each text block vector is calculated in the candidate subset. The similarity is sorted from high to low, and the top K text blocks are selected as the retrieval results.
[0043] During the inference process, memory awareness is continuously performed. The memory usage of the current computing node is read in real time at a fixed frequency by calling the underlying driver interface. When the memory usage exceeds the preset safety threshold, a dynamic truncation mechanism is automatically triggered to dynamically reduce the number of vector retrievals from the default value to a safe value.
[0044] In this embodiment, a memory-aware dynamic scheduling mechanism is used to ensure that the core program does not crash under concurrent processing of long texts from the system bottom layer; and a hardware routing mechanism based on intent recognition is used to ensure the security and absolute exclusivity of the enterprise's core business knowledge from the system link.
[0045] Example 4
[0046] like Figure 5 As shown, based on Example 3, the specific workflow of the constraint generation step is as follows: After resource allocation and obtaining a high-quality retrieval context, the constraint generation step begins. This step uses a lightweight large language model with approximately 2.5B parameters for inference. To maximize the performance of the small model and control its free divergence under limited computing power, this step incorporates system-level control design for inference parameters and input stream structure.
[0047] By locking the inference temperature parameter of the large model in an extremely low range, the randomness of the model output is reduced, ensuring rigorous answers based on the retrieved facts.
[0048] Modular instruction splicing technology is used at the model input end to hard-code multi-dimensional constraint rules as system-level prompts and inject them into the model inference pipeline. Among them, the mandatory constraint instructions include format constraint instructions, person constraint instructions, and style constraint instructions. The format constraint instructions are used to prohibit the lightweight large language model from generating output containing any of the asterisks, hash symbols, minus signs, numerical ordinal numbers, and Markdown markup symbols, and force the use of natural paragraphs and logical connectors for expression. The person constraint instructions are used to force the replacement of the third person in the response with the first person when the slot feature hits a private entity. The style constraint instructions are used to specify the colloquial expression style.
[0049] Through the aforementioned pre-construction hard constraint engineering, the probability distribution of the large language model during the generation stage is effectively controlled. This method eliminates the need for complex regular expression post-processing and cleaning of the generated text in traditional solutions, greatly saving the computing power of local computing nodes and completely solving the technical problem of incompatibility between the default output format of the large model and the basic voice broadcasting equipment.
[0050] Example 5
[0051] like Figure 6 As shown, based on Example 4, the specific workflow of the safe output step is as follows: After generating smooth plain text and before triggering text-to-speech playback, a security verification and interception mechanism based on a deterministic algorithm is forcibly connected.
[0052] We build a regular expression engine for measurement units and high-risk entities in vertical industries. The engine has built-in matching modes, ignores case sensitivity and agricultural colloquialisms as separators, and accurately extracts key triples from smooth plain text, including entities, values, and units of measurement. When multiple triples are extracted, each triple is subjected to a subsequent security comparison.
[0053] Using the entity in the triplet as an index, query the legal or recommended safety threshold for that entity in a physically isolated local safe medication threshold database at a specific unit of measurement; then, perform a Boolean logic judgment: if the value in the triplet is greater than the legal recommended safety threshold, it is determined that there is an overdose risk; if the value in the triplet is not greater than the legal recommended safety threshold, it is determined to be safe.
[0054] When an excessive risk is detected, a high-priority interceptor is triggered to physically block the output of the abnormal text stream and forcibly replace it with a preset fallback safety message; if the verification passes, the original plain text stream is allowed to the voice broadcast front end.
[0055] In this embodiment, an external hard logic firewall that does not rely on the large model's own judgment completely blocks misleading production accidents caused by artificial intelligence digital illusions from the application end, giving the method extremely high industrial-grade security and fault tolerance.
[0056] Example 6
[0057] like Figure 2 As shown, the lightweight, large-model intelligent question-answering optimization system for vertical industries provided by this invention includes four core modules connected in series: a data foundation module, a dynamic scheduling module, a constraint generation module, and a security output module. The data flow and control flow relationships between the modules are as follows: The data foundation module, serving as the system's underlying data support module, completes all document parsing, HTML format mapping, DOM tree segmentation and validation, and metadata injection operations during the offline batch processing phase. The processed structured text blocks are persistently stored in a local high-dimensional vector database. The output of this module is the text block in the vector database, which is then used by the dynamic scheduling module in the subsequent online phase.
[0058] The dynamic scheduling module, serving as the core control hub of the system, is activated when a front-end user initiates a real-time voice interaction request. This module first reads the current memory usage of the computing node in real time through the underlying driver interface. When memory usage exceeds a preset safety threshold, a dynamic truncation mechanism is automatically triggered, dynamically reducing the number of vector retrieval requests from the default value to a safe value. Subsequently, the module calls a lightweight named entity recognition component to extract intent slots and determine routing flags for the user query. Based on the determination results, the query is forcibly routed to the corresponding knowledge layer for retrieval. The input to this module is the user query and the vector database, and the output is the retrieved text block.
[0059] The constraint generation module starts after the dynamic scheduling module completes resource allocation and knowledge retrieval. The input to this module is the retrieved text block and the user query. It uses a lightweight large language model with approximately 2.5 bytes of parameters for inference, concatenating the retrieved knowledge fragments with the user query and injecting multi-dimensional mandatory constraint instructions to control the model to generate smooth plain text without formatted symbols. The output of this module is smooth plain text.
[0060] The security output module serves as the last line of defense before the system reaches the user's front end. After the constraint generation module outputs plain text and before triggering text-to-speech playback, it enforces a security verification and interception mechanism based on a deterministic algorithm. The input to this module is the smooth plain text output by the constraint generation module, and the output is the final text that has undergone security verification.
[0061] To verify the effectiveness of the method and system of this invention, automated testing was conducted based on a test set of 120 questions from vertical industries. The test environment used a single 4060Ti graphics card paired with a quantized 2.5B lightweight large language model. The comparison data for question-answering accuracy is shown in Table 1, the comparison data for video memory usage is shown in Table 2, and the comparison data for text-to-speech synthesis results is shown in Table 3.
[0062] Table 1. Comparison of Question-Answer Accuracy Data
[0063] As shown in Table 1, when processing tables with complex two-dimensional row and column relationships, the overall question-answering accuracy of the traditional 512Token blind segmentation scheme is only 41.6%, with a fatal error rate of 35.0%. After adopting the closed segmentation scheme of this invention, the overall question-answering accuracy is improved to 95.8%, and the fatal error rate is reduced to 0%.
[0064] Table 2 Comparison of video memory usage data
[0065] As shown in Table 2, in terms of resource consumption, the solution of this invention reduces the peak memory usage for high concurrency from 31GB to 24GB through HTML closure segmentation, lightweight model and containerized compression, eliminating memory fluctuations and ensuring stable operation of video memory.
[0066] Table 3 Comparison of Text-to-Speech Synthesis Results
[0067] As shown in Table 3, in terms of text-to-speech synthesis effect, this invention achieves full Chinese pronunciation of units of measurement, correct pronunciation of polyphonic characters, and native-language expression of percentages and years through the format constraints of the text layer and the pronunciation correction mapping table of the rendering layer.
[0068] Example 7: Specific Application Case: Application Example 1: User inquiry: Recently, camellia oleifera looper has been rampant. In order to kill the insects quickly, is it okay if I spray it directly with 1000 times diluted abamectin? System Reply: Oh dear, that's absolutely not advisable! We're eager to control the pests, but the method must be correct. Using a 1000-fold dilution is too high a concentration; it can easily burn the trees, causing the leaves to yellow and curl, ultimately harming our precious trees. We have a safer method for dealing with the camellia looper. First, you must choose the right time; you must spray before the larvae reach the third instar, when the insects are small and less resistant, resulting in the best effect. Second, the pesticide concentration must be followed according to the instructions. For 1.8% abamectin EC, a 3000-fold dilution is sufficient. When spraying, make sure to thoroughly wet both sides of the leaves. Additionally, spray once every seven days, for two consecutive applications, to ensure a thorough effect. If the insects are particularly numerous, we can also combine this with biological control, such as hanging 10,000 to 20,000 Trichogramma wasp egg cards per acre, or spraying with an 800-fold dilution of Bacillus thuringiensis wettable powder. This is safer and leaves less pesticide residue. Remember, pest control shouldn't be rushed; protecting the tree is the fundamental solution. In this example, the response is a smooth plain text paragraph without any Markdown symbols or numbered points. The speech is natural and conversational, and can be directly pushed to a field loudspeaker or voice device for broadcast.
[0069] Application Example 2: User inquiry: What is the dosage per acre of borax and zinc sulfate in the summer fruit-stabilizing fertilizer during peak production season? System Reply: The dosage of borax and zinc sulfate for fruit-setting fertilizer during peak production periods is crucial. Based on our experience, 1 kg of borax and 0.5 kg of zinc sulfate per acre is just right. These two micronutrients are particularly important for improving fruit set and reducing deformed fruit. When fertilizing, they can be mixed evenly with phosphorus and potassium compound fertilizer and applied in trenches along the drip line of the tree canopy. However, I recommend a more efficient method: foliar spraying. Prepare 0.2% to 0.3% solutions of both and spray evenly on both sides of the leaves on cloudy days or in the evening. This allows for faster absorption by the tree and a more direct effect. Remember, while boron and zinc are important, they are micronutrients, so the dosage must be precise. Overdoing it can be counterproductive.
[0070] In this example, the system output values are verified through a safety output procedure to ensure they are within the recommended safety threshold range, thus avoiding production accidents caused by excessive fertilization.
[0071] This invention can be widely applied to intelligent question-and-answer scenarios in vertical agricultural industries such as camellia oil, tea, fruit trees, and Chinese medicinal herbs. By achieving low-cost localized deployment on consumer-grade graphics cards, it solves the dual contradiction of limited computing power and data security for grassroots agricultural enterprises, providing strong technical support for the intelligent promotion of vertical industries.
[0072] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made by those skilled in the art to the technical solutions of the present invention without departing from the principles and essence of the present invention should fall within the protection scope defined by the claims of the present invention.
Claims
1. A lightweight, large-model intelligent question-answering optimization method for vertical industries, characterized in that, include: Knowledge base construction steps: Obtain unstructured documents and structured table data from vertical industries, and construct a two-layer knowledge base containing a general technology layer and a proprietary process layer; The structured table data is converted into HTML text with complete closing tags; the converted text is segmented using a fixed-length sliding window. During the segmentation process, a document object model tree is constructed for boundary detection. When the segmentation point falls inside the closing tag, a backtracking or forward-looking mechanism is triggered to adjust the segmentation point to the nearest closing tag, generating a text block that maintains structural integrity. Inject metadata tags into the text block and store them in a vector database; Query routing steps: Receive user natural language query, extract intent slots from the query, and obtain at least one slot feature; Based on whether the slot features match a preset private entity dictionary, a routing determination result is generated; When the routing determination result is a hit, the query is forcibly routed to the private process layer, and the vector database of the private process layer is filtered for metadata and retrieved using the slot features to obtain the first retrieval result; When the routing determination result is a no-match, the query is routed to the general technology layer for vector retrieval to obtain a second retrieval result; Constraint generation steps: Concatenate the first search result or the second search result with the query, inject a forced constraint instruction, input it into a lightweight large language model for reasoning, and generate smooth plain text without format markup symbols; The secure output step involves performing regular expression extraction on the smooth plain text to obtain triples containing entities, values, and units of measurement; comparing the triples with recommended security thresholds in the local security threshold database; if the value is greater than the recommended security threshold, intercepting the smooth plain text and replacing it with a preset security prompt, and outputting the replaced prompt to the voice broadcast front-end; if the value is not greater than the recommended security threshold, outputting the smooth plain text to the voice broadcast front-end.
2. The lightweight, large-model intelligent question-answering optimization method for vertical industries as described in claim 1, characterized in that, The method of segmenting the converted text using a fixed-length sliding window is as follows: The window length of the fixed-length sliding window is set to a first preset number of tokens; Using the first preset number of tokens as the dividing boundary, the HTML text is scanned segment by segment; Each time the scanning reaches the segmentation boundary, query the parent node label type of the current document object model tree at the location of the segmentation boundary; When the parent node label type is any one of table label, row label, or column label, it is determined that a structural truncation has occurred. In response to the structural truncation, calculate the first distance between the cutting boundary and the nearest previous closed label and the second distance between the cutting boundary and the nearest subsequent closed label; When the first distance is less than or equal to the second distance and the first distance does not exceed a preset semantic length threshold, the backtracking mechanism is executed to revert the segmentation boundary to the previous closed label. When the second distance is less than the first distance and the window length after rollback does not exceed the video memory safety boundary, the forward probe mechanism is executed to extend the split boundary to the next closed label. Lock the adjusted split boundaries and output the complete text block within the current window.
3. The lightweight, large-model intelligent question-answering optimization method for vertical industries as described in claim 1, characterized in that, The intent slot extraction of the query, to obtain at least one slot feature, specifically includes: A lightweight named entity recognition model is invoked to perform sequence labeling on the query and extract entity words and attribute words from the query; The entity words and attribute words are matched according to the preset business rule dictionary to generate a slot feature set containing at least one of entity slots, growth stage slots, and agricultural action slots. When there is a slot in the slot feature set that matches the private entity dictionary, the routing flag is set to the first state; When there is no slot in the slot feature set that matches the private entity dictionary, the routing flag is set to the second state.
4. The lightweight, large-model intelligent question-answering optimization method for vertical industries according to claim 3, characterized in that, The step of generating a routing determination result based on whether the slot feature matches a preset private entity dictionary is as follows: Read the routing flags; When the routing flag is in the first state, the routing determination result is a hit. The system's underlying scheduler forcibly intercepts the default retrieval request to the general technology layer and redirects the currently queried vector library index pointer to the high-dimensional vector library of the private process layer. When the routing flag is in the second state, the routing determination result is a miss, and the default configuration is maintained to perform the retrieval at the general technology layer.
5. The lightweight, large-model intelligent question-answering optimization method for vertical industries according to claim 1, characterized in that, The process of using the slot features to perform metadata filtering and vector retrieval on the vector database of the private process layer specifically involves: Using the growth stage slots or agricultural action slots in the slot features as metadata filtering conditions, hard filtering is performed on the vector database of the private process layer to obtain a candidate subset. The query is converted into a query vector, and the similarity between the query vector and each text block vector is calculated in the candidate subset; Sort the text blocks by similarity from high to low, and select the top K text blocks as the first search result, where the value of K is dynamically adjusted according to the current video memory usage.
6. The lightweight, large-model intelligent question-answering optimization method for vertical industries according to claim 1, characterized in that, In the constraint generation step, the mandatory constraint instructions include format constraint instructions, person constraint instructions, and style constraint instructions; The format constraint directive is used to prohibit the lightweight large language model from generating output containing any of the asterisks, hash symbols, minus signs, number sequences, and Markdown markup symbols, and forces the use of natural paragraphs and logical connectors for expression; The person constraint instruction is used to force the third person in the response to be replaced with the first person when the slot feature hits a private entity; The style constraint directive is used to specify a colloquial expression style; The inference temperature parameter of the lightweight large language model is locked within a preset low temperature range.
7. The lightweight, large-model intelligent question-answering optimization method for vertical industries according to claim 1, characterized in that, The process of performing regular expression extraction on the smooth plain text yields a triple containing entity, value, and unit of measurement, specifically: A regular expression engine for measuring units and high-risk entities in vertical industries is constructed. The regular expression engine has built-in matching modes, which are used to match combinations of entities, numerical values and units of measurement. Ignore case sensitivity and agricultural slang separators to extract key triples from the smooth plain text; When multiple triples are extracted, a subsequent security comparison is performed on each triple.
8. The lightweight, large-model intelligent question-answering optimization method for vertical industries according to claim 7, characterized in that, The step of comparing the triplet with the recommended security threshold in the local security threshold database specifically involves: Using the entity in the triplet as an index, query the local security threshold database for the legally recommended security threshold of that entity under the unit of measurement in the triplet; Perform Boolean logic judgment: if the value in the triplet is greater than the legally recommended safety threshold, it is determined that there is an excessive risk; if the value in the triplet is not greater than the legally recommended safety threshold, it is determined that it is safe.
9. The lightweight, large-model intelligent question-answering optimization method for vertical industries according to claim 1, characterized in that, In the knowledge base construction steps, the construction of the two-layer knowledge base specifically involves: The general technology layer is constructed by acquiring publicly available technical manuals and standard documents, and the proprietary process layer is constructed by acquiring the company's private formulas, original extraction processes and internal experimental data. The general technology layer and the private process layer are stored in physically isolated first vector databases and second vector databases, respectively. The metadata tags include at least one of the following: applicable area tags, growth stage tags, variety tags, and operation type tags.
10. A lightweight, large-model intelligent question-answering optimization system for vertical industries, characterized in that: The method described by any one of claims 1 to 9 comprises: The data foundation module is used to acquire unstructured documents and structured tables from vertical industries, and to build a two-layer knowledge base containing a general technology layer and a private process layer. The data foundation module includes a format mapping unit, a structure segmentation unit, and a vectorized storage unit. The format mapping unit converts the structured table data into HTML text with complete closing tags. The structure segmentation unit uses a fixed-length sliding window to segment the converted text. During the segmentation process, a document object model tree is built for boundary detection. When a segmentation point falls inside a closing tag, a backtracking or forward-looking mechanism is triggered to adjust the segmentation point to the nearest closing tag, generating a text block that maintains structural integrity. The vectorized storage unit injects metadata tags into the text block and stores it in a vector database. A dynamic scheduling module is used to receive user natural language queries, extract intent slots from the queries, generate routing determination results based on the extraction results, and route the queries to the corresponding knowledge layer for retrieval based on the routing determination results. The dynamic scheduling module includes a slot extraction unit, a routing control unit, and a memory awareness unit. The slot extraction unit is used to call a named entity recognition model to extract slot features from the queries. The routing control unit is used to generate the routing determination results based on whether the slot features match a private entity dictionary, and accordingly redirect the query vector library index pointer to the private process layer or keep it pointing to the general technology layer. The memory awareness unit is used to read the memory usage rate of the current computing node in real time, and dynamically reduce the number of vector retrievals when the memory usage rate exceeds a preset safety threshold. The constraint generation module is used to concatenate the search results with the query, inject mandatory constraint instructions, input them into a lightweight large language model for inference, and generate smooth plain text without formatting marks. The constraint generation module includes an instruction injection unit and an inference control unit. The instruction injection unit is used to encode formatting constraint instructions, person constraint instructions, and style constraint instructions into system prompt words. The inference control unit is used to lock the temperature parameters of the lightweight large language model within a preset low temperature range and perform inference. A security output module is used to perform regular expression extraction on the smooth plain text to obtain triples containing entities, values, and units of measurement. These triples are compared with recommended security thresholds in a local security threshold database. If the value exceeds the recommended security threshold, the smooth plain text is intercepted and replaced with a preset security prompt, which is then output to the voice broadcast front-end. The security output module includes a regular expression extraction unit, a threshold comparison unit, and an interception and replacement unit. The regular expression extraction unit is used to construct a regular expression engine to extract key triples from the smooth plain text. The threshold comparison unit is used to query the local security threshold database using the entities in the triples as indexes and perform Boolean logic judgments. The interception and replacement unit is used to block the original text output and return the preset security prompt when an excessive risk is detected.
Citation Information
Patent Citations
Method for generating large model agricultural intelligent questions and answers based on knowledge graph enhanced retrieval
CN118939762A
Large model optimization agricultural knowledge field question and answer application method
CN119226483A