Method and system for converting natural language instruction into operating system command
By employing a layered processing architecture that combines a lightweight model with a task knowledge base in resource-constrained environments, the efficiency, accuracy, and security issues of natural language instruction conversion are resolved. This enables low-latency, accurate conversion of natural language instructions into operating system commands, and facilitates efficient and secure interaction between edge computing devices and IoT terminals.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NAT UNIV OF DEFENSE TECH
- Filing Date
- 2026-04-14
- Publication Date
- 2026-05-12
AI Technical Summary
Existing technologies struggle to achieve efficient, accurate, low-power, and locally secure conversion of natural language instructions into operating system commands in resource-constrained environments. This is especially true in edge computing devices and IoT terminals, where existing solutions suffer from network latency, privacy risks, computational limitations, and insufficient semantic understanding capabilities.
A layered processing architecture combining a lightweight model and a task knowledge base is adopted, including an intent coarse screening layer, a fast matching layer, a fuzzy arbitration layer, and a secure execution layer. Through preprocessing, intent classification, mixed pattern matching, and three-level security verification, efficient conversion of natural language instructions is achieved.
It achieves low-latency and accurate natural language command conversion in resource-constrained environments, improves the accuracy of ambiguous scenarios, and ensures the security of interaction through three-level security verification, adapting to the efficient and secure interaction needs of resource-constrained terminals.
Smart Images

Figure CN122018906A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of natural language processing and operating system interaction technology, and in particular to a method and system for converting natural language instructions into operating system commands. Background Technology
[0002] With the rapid development of artificial intelligence technology, users have placed higher demands on the naturalness and efficiency of human-computer interaction, expecting to directly control the desktop operating system and perform complex tasks such as file management, application control, and system settings through fuzzy and diverse natural language. The core of this interaction process is to accurately and efficiently parse and map the user's natural language expression into structured, semantically precise operating system commands (such as Shell commands and system API calls), achieving a seamless conversion from natural language instructions to executable system operations.
[0003] However, in desktop environments and resource-constrained local terminals (such as edge computing devices, IoT terminals, and low-configuration AIPCs), achieving reliable, responsive, and secure natural language interaction still faces technical bottlenecks, as exemplified by the following.
[0004] Most existing solutions rely on large cloud models to complete complex semantic understanding. While this can guarantee a certain level of understanding accuracy, it also presents significant risks such as network latency and user privacy leaks. Furthermore, these solutions are completely unavailable offline and cannot meet the requirements of local control scenarios with high real-time performance and data security. On the other hand, deploying large models directly on the terminal is limited by the terminal's computing power, memory capacity, and power consumption budget, making it difficult to achieve low-latency response.
[0005] To adapt to terminal resources, existing technologies often use highly customized lightweight models. However, the significant reduction in the model parameter size leads to a significant decrease in its semantic understanding and generalization capabilities. It has low accuracy in recognizing intent from diverse, colloquial, and ambiguous natural language expressions of users, and cannot effectively cover a wide range of user command scenarios, resulting in a poor user experience.
[0006] In addition, another type of solution uses rule matching based on keywords or fixed templates. Although it has the advantages of high speed and low power consumption, it can only handle a limited number of preset expressions. It is extremely poor in adapting to the flexibility of natural language, synonym replacement, and colloquial expressions, and has extremely low coverage (recall rate). It cannot handle complex or multi-step compound instructions, nor can it cope with users' personalized expression habits.
[0007] In summary, existing technical solutions fail to systematically address the comprehensive requirements of efficiency, accuracy, low power consumption, and local security in natural language instruction conversion under resource-constrained environments. There is an urgent need for a method specifically designed for resource-constrained environments that combines high-precision semantic understanding, low-latency response, and high security for converting natural language instructions into operating system commands. Summary of the Invention
[0008] This invention addresses the problems of the prior art mentioned in the background above, which fail to systematically solve the comprehensive requirements of efficiency, accuracy, low power consumption, and local security in natural language instruction conversion under resource-constrained environments. The technical solution is as follows: On the one hand, a method for converting natural language instructions into operating system commands is provided, the method comprising: Step S1: Deploy a lightweight model and build a task knowledge base. Deploy a lightweight large model in the local environment and build a standardized instruction template library containing regular expression template sets and semantic vector template sets offline to provide basic support for the layered processing architecture. Step S2: Obtain user input and perform preprocessing to output well-organized preprocessed text, which serves as input data for the hierarchical processing architecture; Step S3, based on the intent coarse screening layer and fast matching layer of the layered processing architecture, performs processing, specifically including: classifying the preprocessed text based on the lightweight model; if it is determined to be a system operation request, it is converted into a normalized instruction string; fast matching is performed in the task knowledge base through a hybrid mode; and traffic splitting is performed based on the matching confidence. Step S4 involves processing based on the fuzzy arbitration layer and secure execution layer of the layered processing architecture. Specifically, this includes: initiating dual-channel parallel inference arbitration for candidate instructions in the fuzzy range, mapping them to specific executable commands of the target operating system after three-level security verification, and then executing them. Step S5: Feedback is given to the user based on the execution result of the security execution layer or the classification result of the intent coarse screening layer, forming an interactive closed loop; The layered processing architecture includes an intent coarse screening layer, a fast matching layer, a fuzzy arbitration layer, and a secure execution layer. The information flow of each layer is transmitted through steps S2 to S4. The preprocessed text output in step S2 is classified by the intent coarse screening layer and then passed to the fast matching layer. The matching results of the fast matching layer are distributed according to confidence level to the fuzzy arbitration layer or directly to the secure execution layer. The execution results of the secure execution layer and the arbitration results of the fuzzy arbitration layer are both connected to the feedback loop in step S5.
[0009] Optionally, in step S1, the number of parameters of the lightweight model is 1 billion to 4 billion, and it is converted into INT4 or INT8 format after training quantization technology using GPTQ or AWQ, and deployed through Llama.cpp or OpenVINO inference framework. The lightweight model adopts a dynamic on-demand loading and unloading mechanism. The model is loaded when a complex understanding task is executed for the first time, and unloaded after entering the safe execution layer processing stage.
[0010] Optionally, the task knowledge base constructed in step S1 contains several standardized instruction strings, each of which corresponds to a unique instruction ID and function description, and is associated with two types of matching templates: The set of regular expression templates is generated manually or through expansion using a small number of samples. The semantic vector template set was constructed through manual writing, large model generation, synonym expansion, and collection of real corpora. It was encoded into 768-dimensional semantic vectors by the DmetaSoul semantic vector model and stored in the Milvus 2.0 vector database.
[0011] Optionally, in step S2, the user input can be obtained through text input, real-time voice input, and file input. The real-time voice input is converted into text using whisper.cpp automatic speech recognition technology and submitted after user confirmation or correction. The file input is obtained by parsing PDF documents using mupdf or extracting image text using OpenCV combined with OCR technology. Step S2 involves acquiring user input and performing preprocessing to output well-organized preprocessed text, including: Remove redundant words, interjections, and pause words; unify full-width characters to half-width characters; filter illegal control characters, special characters, or code snippets; merge consecutive spaces and remove extra leading and trailing spaces; and eliminate redundant and repeated punctuation. The preprocessed, regularized text is used as the input to the intent coarse screening layer.
[0012] Optionally, in step S3, the intent classification performed by the intent coarse screening layer is a ternary classification, including system operation requests, knowledge / information questions and answers, and unclear / casual intent. Only system operation requests enter the processing flow of the fast matching layer. The hybrid mode involves parallel execution of regular expression matching and vector similarity matching. The hybrid mode performs fast matching in the task knowledge base and performs splitting processing based on matching confidence, including: The regular expression template set is matched first using the regular expression engine, and the highest confidence score is assigned if a match is successful. When regular expression matching fails, the preprocessed text is encoded into a semantic vector, and an approximate nearest neighbor search is performed on the set of semantic vector templates to obtain the Top-K most similar templates and their corresponding normalization instruction strings; Specifically, when the confidence threshold is greater than 0.95, the instruction is directly output and passed to the secure execution layer; when the confidence threshold is in the range of 0.65-0.95, the processing of the fuzzy arbitration layer is initiated; when the confidence threshold is less than 0.65, the process proceeds to the interactive confirmation step S5.
[0013] Optionally, channel A is used to quantify and score each of the Top-K candidate instructions according to the four-dimensional scoring system, and output the first instruction X with a score greater than 80. The weight allocation of the four-dimensional scoring system is as follows: action consistency 30%, object matching degree 40%, core intent coverage 20%, and expression equivalence 10%. Channel B is used to guide the lightweight model to select the optimal instruction Y from the candidate list through a forced selection prompt. The decision logic is as follows: if X and Y are consistent, the instruction is output and passed to the secure execution layer; if they are inconsistent, the four-dimensional scoring verification is performed on Y. Y is adopted only if the score of Y is not lower than 80 and the original semantic similarity is close to that of X; otherwise, X is selected. In step S4, the three-level security verification includes: The first level of permission verification is based on the RBAC model to bind user roles and operation permissions. Sensitive or high-risk operations require secondary authorization. If the verification fails, the error code E401 is returned. The second-level parameter filtering and purification performs boundary correction and unit standardization on numerical parameters, filters out special characters injected for attack on string parameters, and returns error code E402 for abnormal input. The third-level blacklist interception uses a dual-mode detection approach combining regular expression matching and semantic analysis. It combines the real-time operating status of the device to perform dynamic risk assessment, blocks high-risk operation sequences in real time and records logs. The interception rules support hot updates.
[0014] Optionally, in step S4, after the final instruction is output by the fuzzy arbitration layer, the method further includes: The platform-related instruction mapping table is invoked. The fields of the mapping table include instruction ID, function description, target platform instruction, parameter range, required permissions, execution timeout, and remarks. The target platform includes openKylin, Windows, and Ubuntu. The standardized instruction string is converted into an executable command or API call for the corresponding platform by querying the mapping table. If there is no corresponding item in the mapping table, the preset information feedback in step S5 is triggered.
[0015] Optionally, step S5, which involves providing feedback to the user based on the execution result of the security execution layer or the classification result of the intent coarse screening layer to form an interactive closed loop, includes: When the instruction is successfully executed through the secure execution layer, the execution result is fed back, and the "user original input-normalized instruction" mapping pair is added to the local semantic vector library or rule template library after being desensitized; When instruction execution fails, the specific reason for the failure is reported, including security verification failure, no corresponding entry in the mapping table, and error in the underlying executor. If the intent confidence is deemed too low by the coarse intent screening layer, a confirmatory question with explicit options is generated through a lightweight model and interacted with the user in text, voice, or graphical form. After the user confirms, the user is redirected back to the fuzzy arbitration layer or directly enters the secure execution layer.
[0016] Optionally, the regular expression template set is constructed for each normalized instruction string and contains a pattern with a fixed structure; The natural language representation of the semantic vector template set, after being expanded with synonyms, is used to perform a millisecond-level approximate nearest neighbor search through the hybrid index of Milvus 2.0.
[0017] On the other hand, a system for converting natural language instructions to operating system commands is provided, the system comprising: The first system module is used to deploy lightweight models and build task knowledge bases. It deploys lightweight large models in the local environment and builds a standardized instruction template library containing regular expression template sets and semantic vector template sets offline, providing basic support for the layered processing architecture. The second system module is used to acquire user input and perform preprocessing, and output well-organized preprocessed text, which serves as the input data for the hierarchical processing architecture. The third system module is used to perform processing based on the intent coarse screening layer and fast matching layer of the layered processing architecture. Specifically, it includes: classifying the preprocessed text based on the lightweight model; if it is determined to be a system operation request, it is converted into a standardized instruction string; fast matching is performed in the task knowledge base through a hybrid mode; and traffic splitting is performed based on the matching confidence. The fourth system module is used to perform processing based on the fuzzy arbitration layer and the secure execution layer of the layered processing architecture. Specifically, it includes: initiating dual-channel parallel inference arbitration for candidate instructions in the fuzzy range, mapping them to specific executable commands of the target operating system after three-level security verification, and executing them. The fifth system module is used to provide feedback to the user based on the execution result of the security execution layer or the classification result of the intent coarse screening layer, forming an interactive closed loop; The layered processing architecture includes an intent coarse screening layer, a fast matching layer, a fuzzy arbitration layer, and a secure execution layer. The information flow of each layer is transmitted through the second system module to the fourth system module. The preprocessed text output by the second system module is classified by the intent coarse screening layer and then passed to the fast matching layer. The matching results of the fast matching layer are distributed according to confidence level to the fuzzy arbitration layer or directly to the secure execution layer. The execution results of the secure execution layer and the arbitration results of the fuzzy arbitration layer are both connected to the feedback loop of the fifth system module.
[0018] Compared with the prior art, the present invention has the following significant advantages.
[0019] This invention discloses a method for converting natural language instructions to operating system commands. Its core relies on a layered architecture of intent coarse screening, fast matching, fuzzy arbitration, and secure execution to achieve instruction conversion: First, a lightweight model and a knowledge base containing regular expressions and semantic templates are deployed to provide basic support for the architecture; after acquiring user input and completing preprocessing, the intent coarse screening and fast matching layers complete instruction classification and mixed-pattern matching and routing; then, the fuzzy arbitration layer dissolves ambiguous instructions, and after combining three levels of security verification, they are mapped to executable commands of the target operating system; finally, the results are fed back, forming an interactive closed loop.
[0020] This method is adapted to resource-constrained edge terminals, avoiding the latency and privacy risks of cloud-based reliance. It also balances the coverage of structured and conversational commands through hybrid matching, improves the accuracy of ambiguous scenarios through fuzzy arbitration, and achieves full-link security protection through three-level verification, thus achieving low-latency, accurate conversion, and secure and controllable interaction effects for natural language commands. Attached Figure Description
[0021] Figure 1 Flowchart of implementation steps; Figure 2 This is a schematic diagram of layered processing; Figure 3 This is a diagram illustrating intent determination and fast matching. Figure 4 This is a schematic diagram of fuzzy arbitration. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0023] In this article, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0024] This invention achieves the conversion of natural language instructions into operating system commands through the process of steps S1 to S5, combined with a layered processing architecture of "intent coarse screening layer - fast matching layer - fuzzy arbitration layer - secure execution layer".
[0025] Figure 1 The flowchart illustrates the execution flow of steps S1-S5, including model / knowledge base deployment, input preprocessing, intent matching, arbitration execution, and feedback loop, corresponding to the implementation logic of each embodiment.
[0026] Figure 2 This is a schematic diagram of the layered processing, used to illustrate the four-layer architecture of "intent coarse screening layer - fast matching layer - fuzzy arbitration layer - secure execution layer".
[0027] The technical solution is as follows.
[0028] Example 1.
[0029] This embodiment is based on text command conversion using the openKylin system. The target device is an AIPC configured with an x86 CPU and 8GB of memory. For the openKylin operating system, the user inputs the natural language command "adjust the screen brightness to 80%", thus converting the natural language command into an operating system command. The method includes: Step S1: Deploy a lightweight model and build a task knowledge base. Deploy a lightweight large model in the local environment and build a standardized instruction template library containing regular expression template sets and semantic vector template sets offline to provide basic support for the layered processing architecture.
[0030] Figure 1 The flowchart illustrates the execution flow of steps S1-S5, including model / knowledge base deployment, input preprocessing, intent matching, arbitration execution, and feedback loop, corresponding to the implementation logic of each embodiment.
[0031] The project deploys lightweight large models with 1 billion to 4 billion parameters in a local environment, using GPTQ / AWQ to quantize to INT4 / INT8 format, and deploys them through the Llama.cpp / OpenVINO framework, enabling dynamic on-demand loading (loading during complex tasks and unloading during safe execution); offline construction of a task knowledge base, containing several standardized instruction strings (corresponding to unique instruction IDs / functional descriptions), and associating them with two types of templates.
[0032] The regular expression template set is generated by manual writing / expansion with a small number of samples and is adapted to structured instructions; the semantic vector template set is constructed by manual writing + large model generation + synonym expansion, encoded into 768-dimensional vectors by the DmetaSoul model, and stored in the Milvus2.0 database.
[0033] For example, in this embodiment, a lightweight open-source model with 2 billion parameters (NineGrid fine-tuning version) is selected. After adopting the GPTQ post-training quantization technology, the model is converted from FP16 precision to INT4 format, and the memory occupancy is reduced from the original 40GB to 8GB, and it is deployed through the Llama.cpp inference framework; The lightweight model adopts a dynamic on-demand loading and unloading mechanism. The model is not pre-loaded when the system starts, and is only triggered to load in the subsequent intent classification link. [[ID=⑨]]
[0034] When building the task knowledge base offline, for the "brighten the screen" operation, the standard instruction ID is defined as "adjust_brightness", and the corresponding standardized instruction string is "brighten the screen"; among them, the regular expression template set contains fixed structures such as "brighten the screen" and "adjust the screen brightness to %", which are generated by manual writing; the semantic vector template set is constructed by combining manual writing and large model generation to generate 5,000 synonymous natural language expressions (such as "the screen is too dark, brighten it to 80%"). After being encoded into 768-dimensional semantic vectors by the DmetaSoul semantic vector model, they are stored in the Milvus2.0 vector database, and the memory occupancy is controlled within 2GB.
[0035] Step S2, obtain the user input and perform preprocessing, and output the regular preprocessed text, which is used as the input data of the hierarchical processing architecture.
[0036] Among them, the input data of the output hierarchical architecture supports input of text, real-time voice (confirmed by the user after recognition by whisper.cpp), and files (mupdf parsing PDF / OpenCV + OCR extracting image text); the preprocessing includes: removing redundant words / tone words, unifying full-width to half-width, filtering illegal characters, merging spaces / removing redundant punctuation.
[0037] For example, the user enters the natural language instruction "adjust the screen brightness to 80%" through the keyboard, and the system starts the preprocessing module after receiving the input; In the example, the preprocessing operations include the following. Remove the tone word "adjust", merge consecutive spaces, unify full-width characters to half-width, filter meaningless pause words, and finally output the regular preprocessed text "brighten the screen brightness to 80%", which is used as the input data of the intent rough screening layer in the hierarchical processing architecture.
[0038] Step S3 involves processing based on the intent coarse screening layer and fast matching layer of the layered processing architecture. Specifically, this includes: classifying the preprocessed text based on a lightweight model; if it is determined to be a system operation request, converting it into a standardized instruction string; performing fast matching in the task knowledge base through a hybrid mode; and performing triage processing based on the matching confidence.
[0039] Figure 3 This diagram illustrates the intent determination and rapid matching process, showcasing the internal flow of step S3, including intent classification, normalization, hybrid matching, and confidence-based traffic splitting. Corresponding to the matching logic in the embodiment, this step is used to achieve initial instruction matching and traffic splitting.
[0040] The intent coarse screening layer completes the triad classification (system operation request / knowledge question answering / unclear intent) based on a lightweight model, and only system operation requests enter the subsequent process; The fast matching layer adopts a hybrid mode of "regular expression matching + vector similarity matching". Successful regular expression matching is given the highest confidence score, and if it fails, a semantic vector approximate nearest neighbor search is performed. In one example, the traffic splitting rule is: confidence > 0.95 → directly enter the secure execution layer; 0.65-0.95 → activate the fuzzy arbitration layer; < 0.65 → proceed to interactive confirmation.
[0041] For example, after the system loads the lightweight model, it uses the intent coarse-screening layer to perform a ternary intent classification on the preprocessed text "brighten the screen to 80%", determining it to be a "system operation request". The lightweight model then converts this preprocessed text into the standardized instruction string "brighten the screen to 80%". During the mixed-pattern matching process, the system prioritizes matching the regular expression template set in the task knowledge base using the regular expression engine. If the pattern "brighten the screen to .*%" is successfully matched, the confidence level of the matching result is assigned to 1.0. Because the confidence level is greater than 0.95, the standardized instruction string is directly output and passed to the security execution layer of the layered processing architecture.
[0042] Step S4 involves processing based on the fuzzy arbitration layer and secure execution layer of the layered processing architecture. Specifically, this includes initiating dual-channel parallel inference arbitration for candidate instructions in the fuzzy range, mapping them to specific executable commands of the target operating system after three-level security verification, and then executing them.
[0043] Figure 4 This is a fuzzy arbitration diagram used to illustrate the dual-channel reasoning and adjudication logic in step S4.
[0044] The dual-channel system includes channels A and B, enabling ambiguity resolution and secure execution.
[0045] Channel A outputs the first instruction X with a score >80 based on a four-dimensional scoring system of "action consistency 30% + object matching degree 40% + core intent coverage 20% + expression equivalence 10%". Channel B guides the lightweight model to select instruction Y through a forced selection prompt; The corresponding decision logic is as follows: if X and Y are consistent, output the result; if they are inconsistent, verify the score of Y. If the score meets the standard and the similarity is close, adopt Y; otherwise, select X.
[0046] For example, in this embodiment, the matching confidence level is 1.0, which does not meet the condition of the fuzzy interval (0.65-0.95). Therefore, the fuzzy arbitration layer is not started, and the three-level security verification is directly performed by relying on the security execution layer.
[0047] The first-level permission verification uses the RBAC model to bind roles and permissions. High-risk operations require secondary authorization based on the RBAC model. "Brighten the screen" is a normal user permission. The current user role is "user", so the verification passes. In the second-level parameter filtering and purification, numerical parameter boundary correction and string parameter injection prevention are performed. In one example, the parameter "80%" is extracted. After querying the relevant instruction mapping table of the platform, it is found that its parameter range is "0-100%" and the parameter is valid and does not need to be corrected. The third-level blacklist interception uses a dual-mode detection of regular expressions and semantics, combined with dynamic risk assessment based on device status. That is, dual-mode detection of regular expression matching and semantic analysis. "Brightening the screen" is not considered a high-risk operation, so the detection passed.
[0048] Platform mapping calls a mapping table containing fields such as "instruction ID / target platform instruction / parameter range" and converts it into executable commands for systems such as openKylin / Windows / Ubuntu.
[0049] In one example, after verification, the platform's relevant command mapping table is queried, and the specific executable command corresponding to "adjust_brightness" in the openKylin system is: The system executor calls the command "dbus-send--session--dest=org.ukui.SettingsDaemon--type=method_call / org / ukui / SettingsDaemon / Powerorg.ukui.SettingsDaemon.Power.SetBrightnessint32:80" to adjust the screen brightness.
[0050] Step S5: Feedback is given to the user based on the execution results of the security execution layer or the classification results of the intent coarse screening layer, forming an interactive closed loop.
[0051] The feedback includes the following:
[0052] Upon successful execution, the results will be fed back, and the de-identified "raw input-normalized instruction" mapping pair will be added to the template library. Execution failed. Please provide the specific reason (security check failed / no mapping item / executor error). If the intent is unclear, generate a confirmatory option interaction, and reprocess it after the user confirms.
[0053] For example, when the system detects that the command in the security execution layer has been successfully executed, it sends the text message "Screen brightness has been adjusted to 80%" to the user. At the same time, the mapping pair of "user's original input - normalized instruction" (i.e. "adjust the screen brightness to 80%" - "brighten the screen by 80%) is added to the local semantic vector template library after being desensitized, in order to optimize the subsequent matching accuracy and form an interactive closed loop.
[0054] Therefore, it can be seen that the scenario exemplified in this application embodiment can adapt to the resource limitations of low-configuration AIPC through the INT4 quantization and dynamic loading mechanism of the lightweight model. In this embodiment, the response time of instruction conversion is as low as 300ms. The accurate matching of regular expression templates in the hybrid matching mode enables the conversion accuracy of structured natural language instructions to reach 99%, meeting the needs of efficient and accurate interaction in basic scenarios.
[0055] Example 2.
[0056] This embodiment is based on a fuzzy arbitration scenario for voice command conversion in a Windows system. The target device is a portable terminal configured with an ARM CPU and 6GB of memory. For the Windows 11 operating system, the user's voice input, "I want to turn off Bluetooth or view connected Bluetooth devices," proceeds as follows: Step S1: Deploy a lightweight model and build a task knowledge base. Deploy a lightweight large model in the local environment and build a standardized instruction template library containing regular expression template sets and semantic vector template sets offline to provide basic support for the layered processing architecture.
[0057] Specifically, a lightweight model with 1.5 billion parameters was selected, and AWQ quantization technology was used to convert it to INT8 format. It was deployed through the OpenVINO framework, with a memory footprint of 6GB. The task knowledge base includes two operations: "turn off Bluetooth" (command ID: close_bluetooth) and "check Bluetooth connected devices" (command ID: check_bluetooth_devices). The regular expression template sets are "turn off Bluetooth" and "check Bluetooth connection" respectively. The semantic vector template set contains 4,000 synonym expressions for each, which are encoded and stored in the Milvus 2.0 database.
[0058] Step S2: Obtain user input and perform preprocessing, outputting well-organized preprocessed text, which serves as input data for the hierarchical processing architecture.
[0059] Specifically, the user inputs a voice command through the microphone, and the system automatically converts the speech into text using whisper.cpp, such as "I want to turn off Bluetooth or view Bluetooth connected devices". After the user confirms, the command is submitted. The preprocessing removes "I want" and "or", and outputs "Turn off Bluetooth and view Bluetooth connected devices", which serves as the input for the intent coarse screening layer.
[0060] Step S3 involves processing based on the intent coarse screening layer and fast matching layer of the layered processing architecture. Specifically, this includes: classifying the preprocessed text based on a lightweight model; if it is determined to be a system operation request, converting it into a standardized instruction string; performing fast matching in the task knowledge base through a hybrid mode; and performing triage processing based on the matching confidence.
[0061] Specifically, the coarse intent screening layer determined it to be a "system operation request", but the text contained two parallel operations, which could not be directly normalized; in the mixed matching, the regular expression matching did not completely hit the target, and the vector matching returned the Top-2 candidates: "turn off Bluetooth" (similarity 0.85) and "view Bluetooth connected devices" (similarity 0.82), with confidence in the range of 0.65-0.95, so the fuzzy arbitration layer was activated.
[0062] Step S4 involves processing based on the fuzzy arbitration layer and secure execution layer of the layered processing architecture. Specifically, this includes initiating dual-channel parallel inference arbitration for candidate instructions in the fuzzy range, mapping them to specific executable commands of the target operating system after three-level security verification, and then executing them.
[0063] Specifically, the fuzzy arbitration layer initiates dual-channel inference: Channel A scores candidate instructions, with "Turn off Bluetooth" scoring 91 points (>80), and outputs instruction X; Channel B guides the model through a prompt to select instruction Y as "Turn off Bluetooth"; if X and Y match, the instruction is output. After the security execution layer passes the three-level verification, it queries the mapping table, and the corresponding command for Windows 11 is "powershell-Command"Get-Service-Namebthserv|Stop-Service"", and the executor calls this command to turn off Bluetooth.
[0064] Step S5: Feedback is given to the user based on the execution results of the security execution layer or the classification results of the intent coarse screening layer, forming an interactive closed loop.
[0065] Specifically, the feedback "Bluetooth has been successfully turned off" will be added to the template library after the mapping pair "I want to turn off Bluetooth or view Bluetooth connected devices" - "Turn off Bluetooth" is de-identified.
[0066] Thus, the dual-channel arbitration mechanism achieves an accuracy rate of 95% in identifying ambiguous instructions. The combination of a lightweight model and rule-based scoring ensures accuracy while adapting to the low computing power requirements of portable terminals.
[0067] Example 3.
[0068] This embodiment is based on a security interception scenario for file input command conversion in the Ubuntu system. The target device is an edge computing device configured with an x86 CPU and 16GB of memory, specifically an Ubuntu 22.04 operating system. The user uploads a TXT file containing the message "Delete log files in the system root directory." The process is as follows: Step S1: Deploy a lightweight model and build a task knowledge base. Deploy a lightweight large model in the local environment and build a standardized instruction template library containing regular expression template sets and semantic vector template sets offline to provide basic support for the layered processing architecture.
[0069] Specifically, a lightweight model with 3 billion parameters was selected, quantized to INT4 format using GPTQ, and deployed through the Llama.cpp framework; the regular expression / semantic template for "delete system files" in the task knowledge base has been completed.
[0070] Step S2: Obtain user input and perform preprocessing, outputting well-organized preprocessed text, which serves as input data for the hierarchical processing architecture.
[0071] Specifically, the system extracts the TXT text "Delete the log files in the system root directory" through the file parsing module, preprocesses it, and outputs "Delete the log files in the system root directory" as input for the intent coarse screening layer.
[0072] Step S3 involves processing based on the intent coarse screening layer and fast matching layer of the layered processing architecture. Specifically, this includes: classifying the preprocessed text based on a lightweight model; if it is determined to be a system operation request, converting it into a standardized instruction string; performing fast matching in the task knowledge base through a hybrid mode; and performing triage processing based on the matching confidence.
[0073] Specifically, the coarse screening layer determines the intent as "system operation request" and normalizes it to "delete system log file"; vector matching returns the candidate "delete system file" (similarity 0.78), with a confidence level in the range of 0.65-0.95, and the fuzzy arbitration layer is activated.
[0074] Step S4 involves processing based on the fuzzy arbitration layer and secure execution layer of the layered processing architecture. Specifically, this includes initiating dual-channel parallel inference arbitration for candidate instructions in the fuzzy range, mapping them to specific executable commands of the target operating system after three-level security verification, and then executing them.
[0075] Specifically, the fuzzy arbitration layer outputs the command "delete system files"; during the three-level verification of the security execution layer, the blacklist interception detects that "deleting system root directory files" is a high-risk operation, triggers real-time blocking, records the security log, and does not execute the command.
[0076] Step S5: Feedback is given to the user based on the execution results of the security execution layer or the classification results of the intent coarse screening layer, forming an interactive closed loop.
[0077] Specifically, the feedback was "The operation involves high risk and has been blocked".
[0078] Thus, the three-level security verification achieves 100% coverage of high-risk operation interception, and the secondary authorization of permissions and dynamic detection take into account both security and flexibility, adapting to the security management needs of edge devices.
[0079] On the other hand, a system for converting natural language instructions into operating system commands is also provided, the system including: The first system module is used to deploy lightweight models and build task knowledge bases. It deploys lightweight large models in the local environment and builds a standardized instruction template library containing regular expression template sets and semantic vector template sets offline, providing basic support for the layered processing architecture. The second system module is used to acquire user input and perform preprocessing, outputting well-organized preprocessed text, which serves as input data for the hierarchical processing architecture. The third system module is used to perform processing based on the intent coarse screening layer and fast matching layer of the layered processing architecture. Specifically, it includes: classifying the preprocessed text based on a lightweight model; if it is determined to be a system operation request, it is converted into a standardized instruction string; fast matching is performed in the task knowledge base through a hybrid mode; and traffic splitting is performed based on the matching confidence. The fourth system module is used to perform processing based on the fuzzy arbitration layer and the secure execution layer of the layered processing architecture. Specifically, it includes: initiating dual-channel parallel inference arbitration for candidate instructions in the fuzzy range, mapping them to specific executable commands of the target operating system after three-level security verification, and executing them. The fifth system module is used to provide feedback to the user based on the execution results of the security execution layer or the classification results of the intent coarse screening layer, forming an interactive closed loop; The layered processing architecture includes an intent coarse screening layer, a fast matching layer, a fuzzy arbitration layer, and a secure execution layer. The information flow of each layer is transmitted through the second system module to the fourth system module. The preprocessed text output by the second system module is classified by the intent coarse screening layer and then passed to the fast matching layer. The matching results of the fast matching layer are distributed to the fuzzy arbitration layer or directly to the secure execution layer according to the confidence level. The execution results of the secure execution layer and the arbitration results of the fuzzy arbitration layer are both connected to the feedback loop of the fifth system module.
[0080] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0081] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware, or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk. The above descriptions are merely optional embodiments of this application and are not intended to limit the application. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A method for converting natural language instructions into operating system commands, characterized in that, The method includes: Step S1: Deploy a lightweight model and build a task knowledge base. Deploy a lightweight large model in the local environment and build a standardized instruction template library containing regular expression template sets and semantic vector template sets offline to provide basic support for the layered processing architecture. Step S2: Obtain user input and perform preprocessing to output well-organized preprocessed text, which serves as input data for the hierarchical processing architecture; Step S3, based on the intent coarse screening layer and fast matching layer of the layered processing architecture, performs processing, specifically including: classifying the preprocessed text based on the lightweight model; if it is determined to be a system operation request, it is converted into a normalized instruction string; fast matching is performed in the task knowledge base through a hybrid mode; and traffic splitting is performed based on the matching confidence. Step S4 involves processing based on the fuzzy arbitration layer and secure execution layer of the layered processing architecture. Specifically, this includes: initiating dual-channel parallel inference arbitration for candidate instructions in the fuzzy range, mapping them to specific executable commands of the target operating system after three-level security verification, and then executing them. Step S5: Feedback is given to the user based on the execution result of the security execution layer or the classification result of the intent coarse screening layer, forming an interactive closed loop; The layered processing architecture includes an intent coarse screening layer, a fast matching layer, a fuzzy arbitration layer, and a secure execution layer. The information flow of each layer is transmitted through steps S2 to S4. The preprocessed text output in step S2 is classified by the intent coarse screening layer and then passed to the fast matching layer. The matching results of the fast matching layer are distributed according to confidence level to the fuzzy arbitration layer or directly to the secure execution layer. The execution results of the secure execution layer and the arbitration results of the fuzzy arbitration layer are both connected to the feedback loop in step S5.
2. The method according to claim 1, characterized in that, In step S1, the number of parameters of the lightweight model is 1 billion to 4 billion. After training and quantization using GPTQ or AWQ, the model is converted to INT4 or INT8 format and deployed through Llama.cpp or OpenVINO inference framework. The lightweight model adopts a dynamic on-demand loading and unloading mechanism. The model is loaded when a complex understanding task is executed for the first time, and unloaded after entering the safe execution layer processing stage.
3. The method according to claim 1, characterized in that, The task knowledge base constructed in step S1 contains several standardized instruction strings, each of which corresponds to a unique instruction ID and function description, and is associated with two types of matching templates: The set of regular expression templates is generated manually or through expansion using a small number of samples. The semantic vector template set was constructed through manual writing, large model generation, synonym expansion, and collection of real corpora. It was encoded into 768-dimensional semantic vectors by the DmetaSoul semantic vector model and stored in the Milvus 2.0 vector database.
4. The method according to claim 1, characterized in that, In step S2, the user input is obtained through text input, real-time voice input, and file input. The real-time voice input is converted into text using whisper.cpp automatic speech recognition technology and submitted after user confirmation or correction. The file input is obtained by parsing PDF documents using mupdf or extracting image text using OpenCV combined with OCR technology. Step S2 involves acquiring user input and performing preprocessing to output well-organized preprocessed text, including: Remove redundant words, interjections, and pause words; unify full-width characters to half-width characters; filter illegal control characters, special characters, or code snippets; merge consecutive spaces and remove extra leading and trailing spaces; and eliminate redundant and repeated punctuation. The preprocessed, regularized text is used as the input to the intent coarse screening layer.
5. The method according to claim 1, characterized in that, In step S3, the intent classification performed by the intent coarse screening layer is a ternary classification, including system operation requests, knowledge / information questions and answers, and unclear / casual intent. Only system operation requests enter the processing flow of the fast matching layer. The hybrid mode involves parallel execution of regular expression matching and vector similarity matching. The hybrid mode performs fast matching in the task knowledge base and performs splitting processing based on matching confidence, including: The regular expression template set is matched first using the regular expression engine, and the highest confidence score is assigned if a match is successful. When regular expression matching fails, the preprocessed text is encoded into a semantic vector, and an approximate nearest neighbor search is performed on the set of semantic vector templates to obtain the Top-K most similar templates and their corresponding normalization instruction strings; Specifically, when the confidence threshold is greater than 0.95, the instruction is directly output and passed to the secure execution layer; when the confidence threshold is in the range of 0.65-0.95, the processing of the fuzzy arbitration layer is initiated; when the confidence threshold is less than 0.65, the process proceeds to the interactive confirmation step S5.
6. The method according to claim 1, characterized in that, In step S4, the dual channels include: Channel A is used to quantify and score each of the Top-K candidate instructions according to the four-dimensional scoring system, and output the first instruction X with a score greater than 80. The weight allocation of the four-dimensional scoring system is as follows: action consistency 30%, object matching degree 40%, core intent coverage 20%, and expression equivalence 10%. Channel B is used to guide the lightweight model to select the optimal instruction Y from the candidate list through a forced selection prompt. The decision logic is as follows: if X and Y are consistent, the instruction is output and passed to the secure execution layer; if they are inconsistent, the four-dimensional scoring verification is performed on Y. Y is adopted only if the score of Y is not lower than 80 and the original semantic similarity is close to that of X; otherwise, X is selected. In step S4, the three-level security verification includes: The first level of permission verification is based on the RBAC model to bind user roles and operation permissions. Sensitive or high-risk operations require secondary authorization. If the verification fails, the error code E401 is returned. The second-level parameter filtering and purification performs boundary correction and unit standardization on numerical parameters, filters out special characters injected for attack on string parameters, and returns error code E402 for abnormal input. The third-level blacklist interception uses a dual-mode detection approach combining regular expression matching and semantic analysis. It combines the real-time operating status of the device to perform dynamic risk assessment, blocks high-risk operation sequences in real time and records logs. The interception rules support hot updates.
7. The method according to claim 1, characterized in that, In step S4, after the final instruction is output by the fuzzy arbitration layer, the method further includes: The platform-related instruction mapping table is invoked. The fields of the mapping table include instruction ID, function description, target platform instruction, parameter range, required permissions, execution timeout, and remarks. The target platform includes openKylin, Windows, and Ubuntu. The standardized instruction string is converted into an executable command or API call for the corresponding platform by querying the mapping table. If there is no corresponding item in the mapping table, the preset information feedback in step S5 is triggered.
8. The method according to claim 1, characterized in that, Step S5 involves providing feedback to the user based on the execution result of the security execution layer or the classification result of the intent coarse screening layer, forming an interactive closed loop, including: When the instruction is successfully executed through the secure execution layer, the execution result is fed back, and the "user original input-normalized instruction" mapping pair is added to the local semantic vector library or rule template library after being desensitized. When instruction execution fails, the specific reason for the failure is reported, including security verification failure, no corresponding entry in the mapping table, and error in the underlying executor. If the intent confidence is deemed too low by the coarse intent screening layer, a confirmatory question with explicit options is generated through a lightweight model and interacted with the user in text, voice, or graphical form. After the user confirms, the user is redirected back to the fuzzy arbitration layer or directly enters the secure execution layer.
9. The method according to claim 3, characterized in that, The regular expression template set is constructed for each normalized instruction string and contains a pattern with a fixed structure; The natural language representation of the semantic vector template set, after being expanded with synonyms, is used to perform a millisecond-level approximate nearest neighbor search through the hybrid index of Milvus 2.
0.
10. A system for converting natural language instructions to operating system commands, characterized in that, The system includes: The first system module is used to deploy lightweight models and build task knowledge bases. It deploys lightweight large models in the local environment and builds a standardized instruction template library containing regular expression template sets and semantic vector template sets offline, providing basic support for the layered processing architecture. The second system module is used to acquire user input and perform preprocessing, and output well-organized preprocessed text, which serves as the input data for the hierarchical processing architecture. The third system module is used to perform processing based on the intent coarse screening layer and fast matching layer of the layered processing architecture. Specifically, it includes: classifying the preprocessed text based on the lightweight model; if it is determined to be a system operation request, it is converted into a standardized instruction string; fast matching is performed in the task knowledge base through a hybrid mode; and traffic splitting is performed based on the matching confidence. The fourth system module is used to perform processing based on the fuzzy arbitration layer and the secure execution layer of the layered processing architecture. Specifically, it includes: initiating dual-channel parallel inference arbitration for candidate instructions in the fuzzy range, mapping them to specific executable commands of the target operating system after three-level security verification, and executing them. The fifth system module is used to provide feedback to the user based on the execution result of the security execution layer or the classification result of the intent coarse screening layer, forming an interactive closed loop; The layered processing architecture includes an intent coarse screening layer, a fast matching layer, a fuzzy arbitration layer, and a secure execution layer. The information flow of each layer is transmitted through the second system module to the fourth system module. The preprocessed text output by the second system module is classified by the intent coarse screening layer and then passed to the fast matching layer. The matching results of the fast matching layer are distributed according to confidence level to the fuzzy arbitration layer or directly to the secure execution layer. The execution results of the secure execution layer and the arbitration results of the fuzzy arbitration layer are both connected to the feedback loop of the fifth system module.