Method, apparatus and electronic device for entity recognition

By adjusting the mask attention mechanism and feature output path of the generative model on edge devices and combining it with low-rank adapter technology, the lightweight model is optimized to adapt to the named entity recognition task. This solves the problem of limited performance of small parameter models in edge environments and achieves efficient, stable entity recognition performance and rapid adaptability.

CN122366431APending Publication Date: 2026-07-10PEKING UNIV +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
PEKING UNIV
Filing Date
2026-03-31
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

In edge environments, language models with small parameters have limited performance in named entity recognition, making it difficult to match traditional methods. Furthermore, the deployment cost of large parameter models is too high, making them difficult to deploy on edge devices with limited computing power.

Method used

By adjusting the masking attention mechanism and feature output path of the generative model on edge devices, and combining low-rank adapter technology, the lightweight model is optimized to adapt to the named entity recognition task, including full attention masking and Bi-LSTM extension, and the domain adapter is dynamically loaded to improve the model's adaptability.

Benefits of technology

Without increasing the model size, it improves the accuracy of named entity recognition on edge devices, achieves efficient and stable entity recognition performance, and adapts to rapid switching and low-latency inference in multiple scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122366431A_ABST
    Figure CN122366431A_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, and electronic device for entity recognition. The method includes: receiving text to be recognized input from an edge device; determining a target model corresponding to the text to be recognized from a named entity recognition model deployed on the edge device, wherein the named entity recognition model is obtained by adjusting the mask attention mechanism and feature output path of a generative model with fewer than a preset threshold of parameters; and using the target model to recognize the text to be recognized to obtain an entity recognition result. This application solves the technical problem of limited performance of named entity recognition in edge environments using language models with small parameters.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of natural language processing technology, and more specifically, to a method, apparatus, and electronic device for entity recognition. Background Technology

[0002] Named Entity Recognition (NER), a core task in information extraction, is widely used in knowledge graph construction, intelligent question answering, and semantic retrieval. In recent years, with the development of edge computing, centralized cloud-based inference faces challenges such as high computational load and high communication latency, driving the widespread exploration and application of cloud-edge collaborative technologies. Particularly for real-time text processing and data privacy-sensitive applications, natural language processing tasks such as NER are increasingly migrating to edge devices with limited computing power. Furthermore, large-scale model fine-tuning techniques are evolving rapidly, with large models with a large number of parameters showing significantly better fine-tuning performance than traditional methods in named entity recognition tasks.

[0003] However, fine-tuning large language models with a large number of parameters requires tens of gigabytes of on-chip cache, making it difficult to deploy in edge environments with limited computing power. While large language models with small parameters can be applied to edge environments, their fine-tuning performance for named entity recognition tasks is difficult to match that of traditional methods.

[0004] There is currently no effective solution to the above problems. Summary of the Invention

[0005] This application provides a method, apparatus, and electronic device for entity recognition, which at least solves the technical problem of limited performance of named entity recognition in edge environments using language models with small parameters.

[0006] According to one aspect of the embodiments of this application, a method for entity recognition is provided, comprising: receiving text to be recognized input from an edge device; determining a target model corresponding to the text to be recognized from a named entity recognition model deployed on the edge device, wherein the named entity recognition model is obtained by adjusting the mask attention mechanism and feature output path of a generative model with fewer than a preset threshold of parameters; and using the target model to recognize the text to be recognized to obtain an entity recognition result.

[0007] In some embodiments of this application, the named entity recognition model is trained in the following manner: obtaining a training dataset, wherein the training dataset is obtained by performing rule annotation of named entities on domain data collected locally on an edge device; determining a pre-trained initial generative model that matches the training dataset; adjusting the model structure of the initial generative model to obtain a target generative model, wherein the target generative model is used to enhance the initial generative model's learning of sequence labels and entity boundaries; and training the target generative model on the edge device using the training dataset to obtain the named entity recognition model.

[0008] In some embodiments of this application, the model structure of the initial generative model is adjusted to obtain the target generative model, including: adjusting the mask attention mechanism of the initial generative model to obtain an intermediate generative model, wherein the attention mask mechanism corresponding to the intermediate generative model matches the sequence labeling task of the training dataset; and cascading a deep learning architecture after the feature output layer of the intermediate generative model to obtain the target generative model, wherein the deep learning architecture is used to enhance the learning ability of the intermediate generative model to entity boundaries.

[0009] In some embodiments of this application, a named entity recognition model is trained on an edge device using a training dataset to obtain a training generative model. This includes: using the training dataset to identify the training dataset on the edge device using the training generative model to obtain a predicted label sequence; determining a statistical index between the predicted label sequence and the corresponding real label sequence in the training dataset, wherein the statistical index is used to quantify the accuracy and coverage of the training generative model in named entity recognition; and adjusting the target model parameters of the training generative model based on the statistical index to obtain a named entity recognition model, wherein the target model parameters include a first model parameter for enhancing the boundary awareness capability of named entity recognition and a second model parameter for enhancing the contextual semantic recognition capability.

[0010] In some embodiments of this application, the method further includes: obtaining model training results corresponding to the named entity recognition model, wherein the model training results are used to quantitatively represent the entity recognition performance of the named entity recognition model on an edge device; determining a baseline model corresponding to the named entity recognition model, wherein the baseline model includes the best-performing model in the named entity recognition field; comparing the model training results with the performance benchmark of the baseline model to obtain a comparison result; and replacing the initial generative model and retraining it to obtain an updated named entity recognition model if the comparison result indicates that the performance of the named entity recognition model does not meet the preset conditions.

[0011] In some embodiments of this application, the preset threshold is determined based on the physical resource constraints of the edge device; replacing the initial generative model includes: adjusting the preset threshold based on the comparison results to obtain a target preset threshold, wherein the target preset threshold satisfies the physical resource constraints; determining an updated generative model from generative models with fewer parameters than the target preset threshold, and replacing the initial generative model with the updated generative model.

[0012] In some embodiments of this application, the target model is used to recognize the text to be recognized and obtain entity recognition results, including: using the target model's word segmenter to convert the text to be recognized into a word sequence and a mask sequence; using the target model's embedding layer to determine a hidden state sequence based on the word sequence and mask sequence; using the target model's decoder to process the hidden state sequence to obtain a target hidden state sequence, wherein the target hidden state sequence contains contextual semantic information of the text to be recognized; using the target model's deep learning architecture to model the target hidden state sequence to obtain an emission score sequence, wherein the emission score sequence is used to reflect the dependency relationship between each word and the words before and after it; using the target model's linear layer to map the emission score sequence to obtain a label prediction probability score sequence; and using the target model to determine the entity recognition result from the label prediction probability score sequence.

[0013] According to another aspect of the embodiments of this application, an entity recognition apparatus is also provided, comprising: a receiving module for receiving text to be recognized input from an edge device; a determining module for determining a target model corresponding to the text to be recognized from a named entity recognition model deployed on the edge device, wherein the named entity recognition model is obtained by adjusting the mask attention mechanism and feature output path of a generative model with fewer than a preset threshold of parameters; and a recognizing module for recognizing the text to be recognized using the target model to obtain an entity recognition result.

[0014] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a memory and a processor, wherein the memory is used to store program instructions; and the processor is connected to the memory and used to execute the above-described entity recognition method.

[0015] According to another aspect of the embodiments of this application, a non-volatile storage medium is also provided, the non-volatile storage medium including a stored computer program, wherein the device on which the non-volatile storage medium is located executes the above-described entity recognition method by running the computer program.

[0016] According to another aspect of the embodiments of this application, a computer program product is also provided, including computer instructions that, when executed by a processor, implement the above-described entity recognition method.

[0017] In this embodiment, by receiving the text to be recognized from the terminal, a suitable target model is selected from the locally deployed named entity recognition models that have been adjusted by the masking attention mechanism and feature output path. The text is then recognized based on the model, thereby improving the accuracy of small parameter models in edge entity recognition. This achieves the technical effect of maintaining high recognition performance without increasing the model size, and solves the technical problem of limited named entity recognition performance of small parameter language models in edge environments. Attached Figure Description

[0018] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0019] Figure 1 This is a hardware structure block diagram of a computer terminal for an entity recognition method according to an embodiment of this application;

[0020] Figure 2 This is a flowchart of an entity recognition method according to an embodiment of this application;

[0021] Figure 3 This is a schematic diagram of named entity recognition according to an embodiment of the present application;

[0022] Figure 4 This is a schematic diagram of the model architecture of an entity recognition method according to an embodiment of this application;

[0023] Figure 5 This is a flowchart illustrating the calculation of statistical indicators for an entity recognition method according to an embodiment of this application.

[0024] Figure 6 This is a schematic diagram of the structure of an entity recognition device according to an embodiment of this application. Detailed Implementation

[0025] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present application.

[0026] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0027] To better understand the embodiments of this application, the technical terms involved in the embodiments of this application are explained below:

[0028] Named Entity Recognition (NER) is a sequence labeling task in Natural Language Processing (NLP) that aims to identify and classify entities with specific meanings from text, such as person names, place names, and organization names. In this application embodiment, NER is the core task objective, used to accurately extract structured semantic information from text on edge devices, supporting localized processing and privacy protection of data in vertical domains.

[0029] Large Language Model (LLM): A deep neural network model pre-trained on massive amounts of text data, possessing powerful language understanding and generation capabilities, typically containing hundreds of millions to trillions of parameters. In this embodiment, the large language model serves as the infrastructure, with its lightweight version (features fewer than a preset threshold) deployed on edge devices to handle entity recognition tasks with high semantic expressive power.

[0030] Masked Attention Mechanism: In the Transformer architecture, this mechanism controls the scope of attention computation by limiting the range of context that can be focused on at each location using a mask matrix. In this embodiment, the masked attention mechanism is optimized; for example, the default causal mask can be replaced with a full attention mask, enabling the model to perceive the entire context bidirectionally during the pre-filling stage, thereby enhancing its ability to model entity boundary information.

[0031] Feature Output Path: This refers to the path in the model from the high-dimensional semantic representation finally output by the backbone network (such as the Transformer decoder), through subsequent layers (such as linear layers, LSTM, etc.), and transformed into the task output. In the embodiments of this application, the feature output path is connected to a Bi-LSTM layer after the output of the lightweight large model to compensate for its lack of local sequence dependency learning and improve the accurate recognition capability of entity boundaries.

[0032] Bi-LSTM (Bidirectional Long Short-Term Memory): A recurrent neural network structure consisting of two LSTM networks, one forward and one backward, capable of simultaneously capturing the forward and backward contextual dependencies of a sequence. In this embodiment, Bi-LSTM is inserted as a post-processing module after the feature output path of a lightweight, large model to enhance the local semantic modeling of entity start and end positions, thereby improving the boundary discrimination performance of sequence annotation.

[0033] LoRA (Low-Rank Adaptation) is an efficient parameter fine-tuning method that adds a low-rank adaptation matrix to the original model weights, training only a small number of newly added parameters while freezing the backbone parameters, thus achieving model task adaptation. In this embodiment, LoRA is used to fine-tune lightweight large models on edge devices to reduce training memory overhead while maintaining inference speed, achieving efficient model optimization in resource-constrained environments.

[0034] As a classic work in information extraction, named entity recognition (NER) can identify important entities in text, such as names of people, places, and objects, directly impacting the performance of downstream applications like information retrieval and knowledge graphs. In recent years, technological development has shown two trends. On the one hand, with the development of edge computing, centralized cloud inference faces challenges such as high computational load and high communication latency, driving the widespread exploration and application of cloud-edge collaborative technologies. This is particularly true for real-time text processing and data privacy-sensitive applications, where natural language processing tasks such as NER are increasingly migrating to edge devices with limited computing power. On the other hand, large model fine-tuning techniques are evolving rapidly, achieving significantly better performance than previous methods in many industry applications. Some studies have shown that large models with over 7 billion parameters can significantly outperform previous deep learning methods such as BERT in NER fine-tuning tasks.

[0035] Despite the progress made, the significant performance advantages of large models in named entity recognition (NENT) also bring enormous computational costs. Fine-tuning a large model with 7 billion parameters requires tens of gigabytes of on-chip cache, making it difficult to deploy in edge environments with limited computing power. For example, in edge devices such as portable computers and computing boards, the size of the on-chip cache used for AI computing is typically 8 to 12 GB, and their hardware capabilities cannot support the application of such large models with such large parameters. Furthermore, while large models with small parameters can be applied to edge environments, their fine-tuning performance in NENT tasks cannot match that of BERT-based methods. Therefore, how to combine the powerful performance of large models in NENT fine-tuning tasks with edge devices with limited computing resources has become a critical problem that urgently needs to be solved.

[0036] To address the aforementioned technical problems, this application provides corresponding solutions, which are detailed below.

[0037] The entity recognition method embodiments provided in this application can be executed on mobile terminals, computer terminals, or similar computing devices. Figure 1 A hardware block diagram of a computer terminal for implementing an entity recognition method is shown. Figure 1 As shown, the computer terminal 10 may include one or more processors (shown as 102a, 102b, ..., 102n in the figure) (the processor may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission module 106 for communication functions connected via wired and / or wireless networks. In addition, it may also include: a display, a keyboard, a cursor control device, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, and a BUS bus. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0038] It should be noted that the aforementioned one or more processors and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10. As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0039] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the entity recognition method in this embodiment. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby realizing the aforementioned entity recognition method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0040] The transmission module 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission module 106 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission module 106 may be a radio frequency (RF) module, used for wireless communication with the Internet.

[0041] The display can be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10.

[0042] It should be noted here that, in some optional embodiments, the above... Figure 1 The computer terminal shown may include hardware elements (including circuitry), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware and software elements. It should be noted that... Figure 1 This is only one instance of a specific particular instance, and is intended to illustrate the types of components that may exist in the aforementioned computer terminal.

[0043] In the above operating environment, this application provides an embodiment of a method for entity recognition. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than that shown here.

[0044] Figure 2 This is a flowchart of an entity recognition method according to an embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:

[0045] Step S202: Receive the text to be recognized input from the edge device.

[0046] In step S202 above, the edge device refers to a terminal hardware platform with limited computing resources, storage capacity, and power consumption constraints, such as a portable computer, industrial control board, or smart terminal equipped with an embedded GPU or low-power SoC. It should be noted that the edge device, as the execution carrier for the named entity recognition task, is primarily positioned to achieve localized data processing, avoiding the uploading of sensitive text to the cloud, thereby ensuring the privacy and real-time nature of data in vertical industries. The text to be recognized refers to the raw natural language sequence input to the edge device by the user or upper-layer application.

[0047] Step S204: Determine the target model corresponding to the text to be identified from the named entity recognition model deployed on the edge device. The named entity recognition model is obtained by adjusting the mask attention mechanism and feature output path of the generative model with fewer than a preset threshold of parameters.

[0048] In step S204 above, the named entity recognition model refers to a dedicated semantic recognition model that is pre-trained and embedded in edge hardware (such as embedded computing boards and portable terminals). Its architecture is based on a lightweight generative language model and has been structurally modified to adapt to sequence labeling tasks.

[0049] Generative models refer to language models whose total parameter size is controlled within the capacity of edge devices, such as lightweight versions with fewer than 1 billion parameters (e.g., Qwen2.5-0.5B-Instruct, LLaMA3.2-1B-Instruct). These models were originally designed for autoregressive text generation, not sequence labeling tasks. In this embodiment, the model serves as the infrastructure, with a parameter size below the memory capacity limit of the edge device, ensuring that the model can be fully loaded and run while retaining the rich semantic expressive power acquired during the pre-training phase.

[0050] The masked attention mechanism is a mechanism for controlling the scope of information interaction between lexical units in a Transformer structure. It uses a mask matrix to determine the range of context that each position can "see" when calculating attention. In some embodiments of this application, the original generative model, such as one using a causal mask (allowing attention only to historical lexical units), is not suitable for named entity recognition tasks requiring bidirectional understanding. It can be replaced with a full attention mask, allowing each lexical unit to pay attention to all other lexical units in the sequence, thereby fully activating the semantic association capabilities inherent in the model's pre-training stage.

[0051] The feature output path refers to the signal transmission path from the high-dimensional semantic representation output from the generative model backbone network (i.e., the last layer of the Transformer decoder) to the final transformation into the task prediction result after passing through subsequent processing modules (such as linear layers and recurrent networks). In some embodiments of this application, this path is extended after the generative model output and connected to a bidirectional long short-term memory network to further capture the sequential dependencies between local lexical units at the semantic representation level. This compensates for the lack of boundary discrimination ability of lightweight models in sequence labeling tasks, thereby improving the localization accuracy of entity start and end positions.

[0052] In some embodiments of this application, multiple named entity recognition model instances with different optimizations can be pre-configured locally on the edge device. Each instance corresponds to a specific language type (such as Chinese or English) or professional field (such as medical, financial, or news). When the text to be recognized is input, the system first extracts its linguistic features (such as character distribution and word length patterns) and domain keywords (such as "hospital," "patent," and "company"), and matches them against a preset rule base to automatically select the most suitable model instance.

[0053] To achieve task adaptation and performance optimization without increasing model size, the original generative model can be structurally modified as follows before deployment: First, the native causal mask is replaced with a full attention mask, enabling the model to have bidirectional context awareness during the inference phase; second, a bidirectional long short-term memory network module (i.e., a deep learning architecture) is cascaded after the output of the last Transformer layer as an extension unit for the feature output path; third, a low-rank adapter is used to fine-tune the model parameters, updating only a few newly added parameters, while the backbone weights are frozen and quantized for storage. Finally, the modified complete model is packaged into a single executable file and deployed to the local storage space of an edge device.

[0054] It should be noted that since edge devices are typically equipped with only 8–12GB of memory and need to run an operating system, other sensor tasks, and network services simultaneously, deploying independent, complete model copies for each language / domain (such as Chinese, English, medical versions, etc.) may exceed the device's capacity limit, leading to memory overflow, system crashes, or excessively long model loading times (>1 second), severely impacting system real-time performance and stability. To address this issue, the following steps can be performed:

[0055] All named entity recognition models share the same named entity recognition model backbone (such as a lightweight generative language model optimized with full attention masking and Bi-LSTM extension), with its weights stored in a quantized form (such as 8-bit integers). Differences in different contexts (such as domain-specific fine-tuning parameters) are stored independently as low-rank adapters (LoRA), each with a size of only tens to hundreds of KB. When switching target models, the system only needs to dynamically load the corresponding adapter module, without reloading the backbone model. This approach reduces memory usage from "full model × N" to "1 backbone + N adapters," compressing peak memory usage by more than 70% while maintaining model diversity. This ensures fast, stable, and low-latency model switching and continuous inference on edge devices across multiple scenarios.

[0056] For example, when a user inputs a piece of text to be recognized, the system first performs language detection (such as through character encoding distribution and statistics of common words) and keyword matching (such as detecting whether it contains medical words such as "diagnosis", "prescription", and "blood pressure") on the input text, and determines that the current context is "Chinese medical" (as an example).

[0057] The system then performs the following dynamic switching steps:

[0058] (1) The backbone model remains resident in memory: The system confirms that the lightweight generative language model backbone has been loaded and resides in memory, and its weight data does not need to be read or decompressed again, avoiding repeated disk I / O and memory copy overhead.

[0059] (2) Load the target adapter from local storage: The system locates and reads the Chinese medical field adapter file from the local Flash storage, and loads only about 3.2MB of adaptation parameters into the video memory (GPU memory). This process takes about 8 milliseconds, which is much shorter than the time required to load the complete model (usually >500 milliseconds).

[0060] (3) Bind the adapter parameters to the backbone model: The system injects the loaded low-rank matrix parameters into the computation path of the corresponding linear layer in the backbone model through the memory mapping mechanism. The injection process is the superposition of weight increment (ΔW). That is, in the forward calculation process of the original weight (W_original) of the backbone model, the multiplication operation of the low-rank matrix (W_new=W_original+ΔW) is inserted. The original structure of the backbone is not modified, but its semantic expression ability is dynamically enhanced.

[0061] (4) Perform reasoning and output results: The system uses a combination of the backbone model and the Chinese medical adapter to perform named entity recognition on the input text and outputs a sequence of labels such as “B-PER”, “I-DISEASE”, “B-ORG” that are consistent with the medical context, and identifies the corresponding entities.

[0062] (5) Replace only the adapter when switching context: If the user input is converted to English news text, the system will perform context recognition again, find keywords in other fields, release the video memory space occupied by the current medical adapter, load the adapter in the corresponding field, and repeat the binding and inference process. The entire switching process is completed within 15 milliseconds. The backbone model always remains active and does not need to be restarted or re-initialized.

[0063] In some embodiments of this application, the named entity recognition model is trained in the following manner: obtaining a training dataset, wherein the training dataset is obtained by performing rule annotation of named entities on domain data collected locally on an edge device; determining a pre-trained initial generative model that matches the training dataset; adjusting the model structure of the initial generative model to obtain a target generative model, wherein the target generative model is used to enhance the initial generative model's learning of sequence labels and entity boundaries; and training the target generative model on the edge device using the training dataset to obtain the named entity recognition model.

[0064] Specifically, in actual business systems running on edge devices (such as hospital mobile terminals and industrial field inspection tablets), the system automatically collects raw text data (such as doctor's dictated medical record summaries and equipment fault description texts). This data is manually labeled by domain experts according to the Named Entity Labeling Specification. The labeling rules clearly distinguish between entity types (such as "B-disease", "I-drug", "B-hospital") and non-entities ("O"), and ensure that entity boundaries are accurate to the character level.

[0065] Furthermore, the system automatically matches the most suitable pre-trained model based on the linguistic features of the training dataset (such as Chinese character density and word length distribution) and domain keywords (such as the high frequency of "diagnosis," "dosage," and "CT" in medical texts). In some embodiments of this application, the system evaluates the currently available memory resources of the edge device (such as 8GB of video memory) and only allows the selection of models with a total number of parameters less than a preset threshold (such as 1 billion), thus avoiding the risk of deployment failure from the source.

[0066] Furthermore, the model structure of the initial generative model can be adjusted to obtain the target generative model in the following ways: the mask attention mechanism of the initial generative model is adjusted to obtain an intermediate generative model, wherein the attention mask mechanism of the intermediate generative model is matched with the sequence labeling task of the training dataset; a deep learning architecture is cascaded after the feature output layer of the intermediate generative model to obtain the target generative model, wherein the deep learning architecture is used to enhance the intermediate generative model's ability to learn entity boundaries.

[0067] It should be noted that the initial generative model refers to a lightweight language model that has been pre-trained on a large-scale general text corpus and possesses language generation capabilities. Its original structure predicts output word by word in an autoregressive manner and usually uses a causal masking mechanism to restrict the direction of information flow. The intermediate generative model is a transitional structure obtained by reconstructing the masking attention mechanism based on the initial generative model. Its core improvement is to replace the original causal mask with a full attention masking mechanism, which allows each word to simultaneously pay attention to all other words in the sequence, realizing bidirectional semantic interaction and enabling the model to fully activate the semantic association capabilities accumulated in the pre-training stage. The target generative model is a complete model architecture specifically for named entity recognition tasks, formed by cascading deep learning architectures based on the intermediate generative model.

[0068] Deep learning architecture refers to non-Transformer structures introduced into the model output path specifically designed to enhance the ability to model local sequence dependencies. These include, but are not limited to, bidirectional long short-term memory networks. This architecture captures the forward and backward contextual information of the sequence through two LSTM units, one forward and one backward, and merges the outputs to form a feature representation containing complete boundary context.

[0069] Specifically, during the model loading phase, the system reads the attention calculation module of the initial generative model and replaces the causal mask matrix (upper triangular mask) originally used for autoregressive decoding with a matrix of all ones (i.e., no masking). This allows each lexical unit to access all other lexical units in the sequence during the attention calculation of each Transformer layer. For long text or cross-sentence entity recognition scenarios, the system can also dynamically generate adaptive masks based on the syntactic structure of the input text (such as punctuation breaks, subject-verb-object structure) during inference. For example, for the two sentences "Li Ming is a doctor at a certain hospital. He specializes in cardiovascular diseases," the system can preserve the inter-sentence isolation but allow "he" to establish a cross-sentence association with the previous sentence "Li Ming," thus forming an entity link between "Li Ming" and "a certain hospital." This approach adds semantic coherence constraints on top of full attention, making it suitable for complex annotation tasks that require contextual continuity and improving the accuracy of long-distance entity recognition.

[0070] Subsequently, after the high-dimensional semantic vector output from the last Transformer layer of the intermediate generative model, a two-layer bidirectional long short-term memory network is directly connected. This network takes the semantic representation of each word as input, and the forward LSTM sequentially passes the hidden states from left to right, while the backward LSTM passes them backward from right to left. Finally, the hidden states from both directions are concatenated dimensionally to form an enhanced representation containing complete contextual dependencies. To enhance adaptability to entities of varying lengths, an attention-weighted pooling module is further introduced after the cascaded bidirectional long short-term memory network. This module automatically assigns weights based on the confidence of each word in the LSTM output, performing weighted aggregation of the feature vectors of the entire sequence and retaining the most discriminative boundary information.

[0071] After obtaining the target generative model, further, on edge devices, the backbone parameters of the initial model can be left unchanged, and only the newly added low-rank adapter module (such as the LoRA structure) can be trained, with its parameters accounting for less than 0.1% of the backbone. During training, the cross-entropy loss function is used, and the optimization objective is to make the BIO label sequence output by the model consistent with the labeled data, ultimately training a named entity recognition model.

[0072] To ensure the convergence and stability of the model trained on the edge device, the target generative model can be trained on the edge device using a training dataset to obtain a named entity recognition model. This can be achieved by: using the target generative model to recognize the training dataset on the edge device to obtain predicted label sequences; determining statistical metrics between the predicted label sequences and the corresponding ground truth label sequences in the training dataset, where the statistical metrics quantify the accuracy and coverage of the target generative model in named entity recognition; and adjusting the target model parameters of the target generative model based on the statistical metrics to obtain the named entity recognition model. The target model parameters include first model parameters to enhance the boundary awareness capability of named entity recognition and second model parameters to enhance the contextual semantic recognition capability.

[0073] It should be noted that the target model parameters refer to the adjustable parameters within the model that need to be updated during training. For example, they can be divided into two categories: the first type of model parameters are the parameters in the bidirectional long short-term memory network and its subsequent linear layers, which enhance the ability to model local sequence dependencies of entity start and end positions; the second type of model parameters are the low-rank adapter parameters (such as the LoRA module) used for semantic representation learning in lightweight generative models, which fine-tune the model's discriminative ability at the contextual semantic level to make it more consistent with the language patterns of the vertical domain.

[0074] Specifically, the system sequentially inputs each text from the training dataset into the target generative model. The model first maps tokens into high-dimensional vectors through an embedding layer, then encodes them using a multi-layer Transformer with a full attention mechanism, and finally processes them through a bidirectional long short-term memory network. The linear layer then outputs the raw scores (logits) of each token on various BIO tags. The system employs a greedy decoding strategy, selecting the tag with the highest score at each position as the prediction result to form a complete predicted tag sequence.

[0075] To improve training efficiency, the system can group the training dataset into multiple batches of fixed length (e.g., 128 words), load multiple samples at a time and input them into the model in parallel, leveraging the parallel computing capabilities of edge devices' GPUs to accelerate forward propagation. Simultaneously, intermediate activation values ​​are released immediately after computation, retaining only the final output, avoiding accumulated GPU memory usage and ensuring efficient processing of large-scale datasets with limited memory (e.g., 8GB).

[0076] Furthermore, the system performs entity-by-entity comparisons between the predicted label sequence and the true label sequence, evaluating complete entities rather than individual words. A true positive (TP) is only counted when the entity type and boundary are completely identical; if a non-existent entity is predicted, it is counted as a false positive (FP); if an entity is missed, it is counted as a false negative (FN). Based on these three statistical measures (TP, FP, and FN), the system automatically calculates statistical indicators.

[0077] Furthermore, the system can adopt a two-stage parameter update strategy: in the first stage, the second model parameters (i.e., the low-rank adapters of the generative model) are fixed, and only the first model parameters (bidirectional long short-term memory network and linear layer) are updated by gradient. The goal is to prioritize enhancing the model's ability to model local dependencies of entity boundaries. In the second stage, the first model parameters are frozen, and only the second model parameters are fine-tuned to better adapt to the domain semantics (e.g., "Concord" often co-occurs with "hospital"). This step-by-step training method avoids interference between parameter updates and ensures that the two types of capabilities converge gradually according to the priority.

[0078] To facilitate understanding of the above model training process, the following will be explained in conjunction with some specific embodiments.

[0079] The named entity recognition model based on the lightweight large model (i.e., the target generative model) and the named entity recognition dataset (i.e., the training dataset) are fine-tuned and trained on the edge device. The training hyperparameters in the edge environment are: the batch size is 4, the input sequence length is 128, the hidden dimension is 128, the number of training epochs is 10, and the learning rate is 1e-4. The configuration parameters of LoRA are 32, the rank is 16, the dropout is 0.1, the target module is all linear layers, and cross-entropy is used for loss optimization during training;

[0080] Through training iterations, the LoRA parameters (i.e., the second model parameters) and the deep learning hyperparameters (i.e., the first model parameters) are tuned to align various statistical metrics such as precision and recall and F1 score, etc. The statistical methods are used to optimize the model performance. Combined with Figure 5 , where, (the first statistical metric) is used to evaluate the proportion of entities correctly identified by the model among all the identified entities; (the second statistical metric) is used to evaluate the proportion of entities identified by the model among all the real entities; F1 score (the third statistical metric) represents the and harmonic mean, which is used to comprehensively evaluate the performance of the named entity recognition model. Its calculation formula is as follows:

[0081]

[0082]

[0083]

[0084] In the above formula, (True Positive) is used to count the number of named entities correctly identified by a statistical model; (False Positive) is used to count the number of irrelevant entities that the model identifies as named entities; (FalseNegative) is used to count the number of named entities that the model identifies as irrelevant entities. , , The statistics are obtained by comparing the predicted label sequence output by the model with the real label sequence in the dataset.

[0085] Subsequently, based on accuracy Recall rate and The scores are used to adjust the model parameters.

[0086] In some embodiments of this application, the following steps may also be performed: obtaining model training results corresponding to the named entity recognition model, wherein the model training results are used to quantitatively represent the entity recognition performance of the named entity recognition model on an edge device; determining a baseline model corresponding to the named entity recognition model, wherein the baseline model includes the best-performing model in the named entity recognition field; comparing the model training results with the performance benchmark of the baseline model to obtain a comparison result; if the comparison result indicates that the performance of the named entity recognition model does not meet the preset conditions, replacing the initial generative model and retraining to obtain an updated named entity recognition model.

[0087] It should be noted that the model training results refer to a set of evaluation metrics that quantify the actual performance of the named entity recognition model after training on an edge device and through a standard evaluation process. These metrics may include precision, recall, and F1 score. The results are an objective description of the model's comprehensive capabilities in a specific vertical domain and a specific hardware environment.

[0088] The comparison result refers to the quantitative judgment conclusion obtained after systematically comparing the performance index of the named entity recognition model trained in this application with the benchmark performance of the baseline model. The result is presented in the form of numerical difference or relative improvement rate (such as "F1 score is 4.2% lower"), and combined with a preset threshold (such as "performance loss is allowed to be no more than 3%) to form a decision signal for whether to trigger model replacement.

[0089] The preset conditions are a multi-dimensional performance evaluation threshold system designed to meet the characteristics of edge environments and application scenario requirements. For example, it can be a comprehensive criterion consisting of at least one of the following dimensions: accuracy, efficiency, resource adaptability, and stability.

[0090] (1) Accuracy dimension: Entity recognition performance is not lower than the tolerance threshold of the industry benchmark;

[0091] (2) Efficiency dimension: The inference response time meets the real-time interaction requirements of the edge terminal;

[0092] (3) Resource adaptability dimension: The resource consumption of the model deployment does not exceed the equipment's carrying capacity;

[0093] (4) Stability and robustness dimension: The model maintains stable performance under complex inputs.

[0094] Specifically, after training, the system inputs an independent test set (not used in training) into the current named entity recognition model. The model outputs a predicted label sequence, which is then compared with the manually labeled real label sequence. True positives, false positives, and false negatives are counted at the entity level, and precision, recall, and F1 score are calculated. The system has a built-in baseline model library, storing performance benchmarks of the current state-of-the-art (SOTA) models categorized by language (Chinese / English), domain (medical / financial / industrial), and device type. If the data used for training is from a specific domain (such as ancient medical texts or dialect texts), the system will not force the use of a general model as the baseline. Instead, it will select the best-performing model from the open-source community or historical projects that is relevant to the domain as a reference.

[0095] The system samples the model training results multiple times (e.g., 5 retests), calculates the mean and standard deviation of the F1 score, and forms a confidence interval (e.g., 0.89±0.01). If the upper limit of this interval is still lower than the lower limit of the baseline model (e.g., the baseline is 0.93±0.005), it is judged as "significantly inferior to the baseline". Regardless of whether the single result is close, the optimization process is triggered to improve the robustness of the judgment.

[0096] When performance is deemed insufficient, the system automatically selects a replacement model with similar parameter counts and stronger semantic capabilities from the local model library, and automatically loads the new model. It reuses the original structural modifications (full attention + Bi-LSTM) and adapter configuration, requiring only minor readjustments to save on reconstruction costs. In some embodiments of this application, after replacing the model, the system does not train from scratch. Instead, it uses the low-rank adapter parameters trained in the previous model as initial weights and migrates them to the corresponding modules of the new model, achieving rapid convergence in only a few rounds (e.g., 3 rounds).

[0097] In some embodiments of this application, the preset threshold is determined based on the physical resource constraints of the edge device. Based on this, the initial generative model can be replaced in the following way: the preset threshold is adjusted based on the comparison results to obtain a target preset threshold, wherein the target preset threshold satisfies the physical resource constraints; an updated generative model is determined from generative models with fewer parameters than the target preset threshold, and the updated generative model is used to replace the initial generative model.

[0098] It should be noted that the preset threshold refers to a hard upper limit on the parameter size of the generative model, calculated based on the physical resource constraints of the edge device. Essentially, it is a safety red line set by the system in the resource dimension to ensure the model's deployability and operability. This threshold is not a fixed value, but rather precisely calculated through dynamic modeling of the edge device's video memory capacity, total system memory, storage space, and peak runtime load. For example, when the edge device is equipped with 8GB of video memory, the system will set the preset threshold to no more than 5.6GB (i.e., 70% of the video memory) based on the video memory usage model required for model inference and fine-tuning. This reserve buffer space prevents system crashes and constrains the boundary conditions for all model selections and structural modifications.

[0099] In some embodiments of this application, when the system is first deployed on an edge device, it automatically performs a hardware resource scan to obtain core parameters such as video memory capacity, system memory, storage space, and GPU computing power. Subsequently, the system establishes a "resource-model scale" prediction model based on model structural characteristics (such as the number of Transformer layers, hidden dimensions, and the number of attention heads) to simulate the peak video memory usage of generative models with different parameter amounts during the inference and fine-tuning stages. For example, calculations show that a 1-parameter model, if using a full attention mechanism and cascading a bidirectional long short-term memory network, has a peak inference video memory usage of approximately 4.2GB. Fine-tuning requires an additional 1.8GB of cache. Considering the device's 8GB video memory capacity, the system sets a preset threshold of 5.6GB (8GB × 70%) to ensure the model can still run stably under worst-case loads and avoid task interruption due to memory overflow.

[0100] The preset threshold can also be a comprehensive result of considering constraints across four dimensions: video memory, RAM, storage, and power consumption. Specifically, the system calculates each of these separately:

[0101] Memory constraint: The sum of model parameters, activation values, and gradient cache ≤ 70% of GPU memory;

[0102] Memory constraint: Total runtime memory usage ≤ 80% of system memory;

[0103] Storage constraint: Offline model file size ≤ storage space × 10%;

[0104] Power consumption constraint: Inference power consumption ≤ device rated power consumption × 85%.

[0105] The system uses the most stringent constraint among the four as the final preset threshold. For example, if the video memory is allowed to be 5.6GB, but the storage space is only 10GB, and the model file needs to be compressed to less than 1GB to meet the requirements, the system will adjust the upper limit of the parameter size to the generative model with a corresponding model file size ≤1GB (such as Qwen2.5-0.5B). Even if its video memory usage is lower, it must still comply with the storage constraint. This mechanism ensures that there is no risk of resource overruns in the entire lifecycle of the model (storage, loading, inference, and updating).

[0106] To address uncertainties in real-world operation (such as multi-task concurrency, temperature-induced frequency throttling, and cache jitter), the system can proactively inject safety margins when calculating thresholds. For example, based on historical operational data, the system found that the actual available memory of the same model of device was only about 65% under high load. Therefore, the theoretical threshold of 5.6GB was further lowered to 5.0GB as the admission standard for actual sampling. Simultaneously, when selecting models, the system prioritizes models with parameter counts significantly lower than the threshold (e.g., controlled within 4.0GB), reserving flexibility for subsequent model upgrades, dynamic context loading, or caching of intermediate results. This mechanism significantly improves the system's robustness in complex edge environments and prevents the risk of crashes caused by critical deployments.

[0107] It should be noted that the target preset threshold refers to the new performance and resource admission standard formed by the system dynamically adjusting or fine-tuning the original preset threshold based on comparative analysis results when the model performance evaluation results do not meet expectations, without violating physical resource constraints. This threshold is a dynamic balance point between performance requirements and resource availability, and its essence is a reflection of the system's adaptive capability. For example, if the current model's F1 score is 0.87, while the baseline model is 0.93, and the device still has 1.2GB of spare video memory, the system can increase the upper limit of the parameter size from 4.8GB to 5.2GB to support the introduction of higher performance models.

[0108] Specifically, after completing model training, the system quantitatively compares the F1 score, inference latency, and resource usage of the current named entity recognition model with a preset baseline model. If the model's F1 score is found to be more than 3 percentage points lower than the baseline, while the device's remaining video memory exceeds 1.5GB, the system automatically initiates a threshold tuning process. For example, if the original preset threshold is 4.5GB (corresponding to a 0.5B model), the current model's F1 score is 0.86, and the baseline is 0.92, the system determines that there is a significant performance gap. Therefore, while ensuring that the total resource usage does not exceed 70% of the device's maximum capacity, the model size threshold is increased from 4.5GB to 5.0GB, forming the target preset threshold. This mechanism ensures that potential is released first when resources are not saturated, thereby improving recognition accuracy.

[0109] Furthermore, the system maintains a structurally compatible lightweight generative model library, labeled with attributes such as parameter size, language adaptability, domain semantic richness, whether it supports full attention mechanism, and whether it supports LoRA fine-tuning. When the target preset threshold is 5.0GB, the system selects all candidate models from the library with parameter size less than 5.0GB that support the structural modification of this application (full attention + Bi-LSTM), and ranks them comprehensively according to "F1 score first, inference latency second, and smallest model size".

[0110] Furthermore, after selecting the updated generative model, the system does not perform training from scratch, but instead performs structural adaptation transfer: the pre-trained low-rank adapter parameters (such as LoRA modules) in the original model are mapped to the adapter positions of the corresponding layers in the new model through linear projection and dimension alignment techniques. For example, the LoRA matrix dimension of the original 0.5B model is 512×16, while that of the new 0.8B model is 768×16. The system calculates the projection matrix using the least squares method, maps the original parameters to the new space, and then fine-tunes it in combination with the pre-trained weights of the new model. This method enables the new model to achieve an initial F1 score of 0.89, and only 2-3 rounds of fine-tuning are needed to approach the optimal value, greatly improving the replacement efficiency and reducing the training cost at the edge.

[0111] Step S206: Use the target model to recognize the text to be recognized and obtain the entity recognition result.

[0112] In step S206 above, the entity recognition result refers to the sequence of entity labels that conform to the BIO annotation specification and are output by the target model after reasoning on the text to be recognized. It is used to clearly identify semantic entities such as names of people, places, organizations, times, and drugs in the text and their boundaries.

[0113] In some embodiments of this application, the text to be identified can be identified to obtain entity recognition results in the following manner: the target model's word segmenter converts the text to be identified into a word sequence and a mask sequence; the target model's embedding layer determines a hidden state sequence based on the word sequence and mask sequence; the target model's decoder processes the hidden state sequence to obtain a target hidden state sequence, wherein the target hidden state sequence contains contextual semantic information of the text to be identified; the target model's deep learning architecture models the target hidden state sequence to obtain an emission score sequence, wherein the emission score sequence reflects the dependency relationship between each word and its preceding and following words; the target model's linear layer maps the emission score sequence to obtain a label prediction probability score sequence; and the target model determines the entity recognition result from the label prediction probability score sequence.

[0114] Specifically, Figure 4 This is a schematic diagram of the model architecture of an entity recognition method according to an embodiment of this application, such as... Figure 4As shown, in some embodiments of this application, the named entity recognition model may include a word segmenter 402, an embedding layer 404, a decoder 406, a deep learning architecture 408, and a linear layer 410.

[0115] exist Figure 4 Based on, combined Figure 3 The above steps will be explained using a specific embodiment:

[0116] Given the input text sequence "Los Angeles is in the USA.", let the number of tokens in the text be . First, the input text is tokenized into a sequence of IDs (i.e., a sequence of terms) corresponding to the token. and attention mask sequence (i.e., mask sequence) Subsequently, T is mapped to a sequence of hidden states by the word embedding layer. ,in This represents the batch size, and s represents the sequence length. This represents the hidden dimension of a lightweight, large model. Then, These are sequentially used as inputs to each layer of the decoder in the lightweight, large model. After the last layer has been computed, the result from that layer is... The data is fed into a Bi-LSTM layer (i.e., a deep learning architecture) to fully utilize the contextual semantic information learned during the lightweight large model pre-filling stage. Then, the Bi-LSTM layer generates the emission score sequence. ,in This represents the hidden dimension of the Bi-LSTM. Finally, A tensor representing the probability prediction score of the BIO tag is obtained through linear layer mapping: ,in This indicates the number of BIO tags.

[0117] like Figure 3 As shown, the values ​​of the probability score sequence r0 corresponding to the word "Los" are -0.79, -1.14, -1.8, 0.44, -2.38, 7.45, -0.89, 0.5, and -2.49, respectively. The corresponding BIO labels are: O, B-MISC, I-MISC, B-PER, I-PER, B-LOC, I-LOC, B-ORG, and I-ORG. Then, the maximum probability score is taken during output. Figure 3 The labels corresponding to the scores marked in red are used as the predicted labels for words, i.e., B-LOC. The prediction process for other words is the same.

[0118] For lightweight large models, which mainly consist of multi-layer Transformer structures, the core computation involves the self-attention mechanism, and the calculation formula is as follows:

[0119]

[0120] in , , Let represent the trainable query, key, and value weight matrices, respectively. The calculation idea of ​​this attention formula is to calculate... and To aggregate the required similarity Information regarding the scaling factor used. Mainly used to prevent and The dot product is too large, which is used to stabilize the gradient. Secondly, The obtained attention weights can be converted into normalized probability scores to represent the current... The Transformer layer should focus on the degree distribution of all keys. Then, the Transformer module structure of the model is analyzed and located. For example, LLaMA3.2-1B-Instruct and Qwen2.5-0.5B-Instruct are both decoder architectures. The mask attention mechanism used by the large model in the pre-filling stage is also analyzed and located. Generally, it is a causal mask attention mechanism. For attention masks, considering that causal masks are only suitable for autoregressive inference tasks and not for sequence labeling tasks that learn entity information bidirectionally, lightweight large models use full attention masks that allow attention to all positions instead of causal masks, making them compatible with sequence labeling tasks such as named entity recognition. Figure 3 As shown in the attention mask optimization section, this is because the full attention mask allows each token to be seen by other tokens, which is beneficial for large models to fully learn entity boundaries by utilizing the powerful semantic understanding capabilities given in the pre-training stage, and further unleash the potential of large models in named entity recognition.

[0121] Next, we will further introduce the Bi-LSTM layer, which consists of LSTMs in both the forward and backward directions. The main calculation formula is as follows:

[0122]

[0123]

[0124]

[0125]

[0126] The Bi-LSTM layer first processes the output of the lightweight large model layer. Decomposed into sequences according to the time dimension: ( ), each of which Then, the forward LSTM is in chronological order ( Learning input Calculate the hidden state sequence The backward LSTM is in reverse order ( Learning input Calculate the hidden state sequence The results of the two LSTMs are merged at output to obtain the Bi-LSTM layer at time step [time value missing]. The output result In merging all Finally, the output of the Bi-LSTM layer is Thus, the Bi-LSTM layer enables lightweight large models to understand text by incorporating contextual information, enhances the learning of local dependencies between tokens, and helps improve the ability to learn named entity boundaries.

[0127] Through steps S202 to S206 above, by receiving the text to be recognized input from the terminal, a suitable target model is selected from the locally deployed named entity recognition models that have been adjusted by the masking attention mechanism and feature output path, and named entity recognition is performed on the text based on the model. This achieves the goal of improving the accuracy of small parameter models in edge entity recognition, thereby achieving the technical effect of maintaining high recognition performance without increasing the model size, and thus solving the technical problem of limited named entity recognition performance of small parameter language models in edge environments.

[0128] The lightweight large-model named entity recognition method provided in this application optimizes the named entity recognition performance of lightweight large models in resource-constrained edge environments, which can promote the efficient application of edge-side named entity recognition tasks and ensure the real-time performance and security of edge-side vertical domain data processing.

[0129] This application's embodiments improve the mask attention mechanism in the pre-filling stage of a lightweight large model and incorporate deep learning methods with good local context learning capabilities, thereby enhancing the performance of lightweight large models in named entity recognition in resource-constrained edge environments. The core of this method is to improve the pre-filling stage of the large model using supervised learning methods from classic sequence labeling tasks, optimizing the mask attention mechanism of each Transformer layer within the large model to improve its adaptability to sequence labeling tasks; and further, combining this with deep learning methods used in traditional named entity recognition tasks to enhance the large model's ability to learn entity boundaries, ultimately synergistically improving the named entity recognition performance of the lightweight large model.

[0130] Figure 6 This is a structural diagram of an entity recognition device according to an embodiment of this application, such as... Figure 6 As shown, the device includes:

[0131] The receiving module 602 is used to receive the text to be recognized input from the edge device;

[0132] The determination module 604 is used to determine the target model corresponding to the text to be identified from the named entity recognition model deployed on the edge device. The named entity recognition model is obtained by adjusting the mask attention mechanism and feature output path of the generative model with fewer than a preset threshold parameters.

[0133] The recognition module 606 is used to recognize the text to be recognized using the target model and obtain entity recognition results.

[0134] It should be noted that, Figure 6 The entity recognition device shown is used to perform Figure 2 The entity recognition method shown, therefore Figure 2 The relevant explanations in the entity recognition methods also apply to Figure 6 The entity recognition device shown will not be described in detail here.

[0135] This application also provides an electronic device, which includes a memory and a processor, wherein the memory is used to store program instructions; the processor is connected to the memory and is used to execute the steps of implementing the entity recognition method in various embodiments of this application.

[0136] This application also provides a non-volatile storage medium including a stored computer program, wherein the device containing the non-volatile storage medium executes the steps of the entity recognition method in various embodiments of this application by running the computer program.

[0137] This application also provides a computer program product, including computer instructions that, when executed by a processor, implement the steps of the entity recognition method in various embodiments of this application.

[0138] This application also provides a computer program that, when executed by a processor, implements the steps of the entity recognition method in various embodiments of this application.

[0139] 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.

[0140] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0141] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0142] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0143] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0144] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0145] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for entity recognition, characterized in that, include: Receive the text to be recognized from the edge device; The target model corresponding to the text to be identified is determined from the named entity recognition model deployed on the edge device, wherein the named entity recognition model is obtained by adjusting the mask attention mechanism and feature output path of the generative model with fewer than a preset threshold of parameters; The target model is used to identify the text to be identified, and entity recognition results are obtained.

2. The method according to claim 1, characterized in that, The named entity recognition model is trained in the following way: Obtain a training dataset, wherein the training dataset is obtained based on the rule-based annotation of named entities on the domain data collected locally on the edge device; Determine a pre-trained initial generative model that matches the training dataset; The model structure of the initial generative model is adjusted to obtain a target generative model, wherein the target generative model is used to enhance the learning of sequence labels and entity boundaries by the initial generative model; The target generative model is trained on the edge device using the training dataset to obtain the named entity recognition model.

3. The method according to claim 2, characterized in that, The model structure of the initial generative model is adjusted to obtain the target generative model, including: The mask attention mechanism of the initial generative model is adjusted to obtain an intermediate generative model, wherein the attention mask mechanism of the intermediate generative model is matched with the sequence labeling task of the training dataset. A deep learning architecture is cascaded after the feature output layer of the intermediate generative model to obtain the target generative model, wherein the deep learning architecture is used to enhance the intermediate generative model's ability to learn entity boundaries.

4. The method according to claim 2, characterized in that, The target generative model is trained on the edge device using the training dataset to obtain the named entity recognition model, including: The target generative model is used on the edge device to identify the training dataset and obtain a predicted label sequence; Determine a statistical index between the predicted label sequence and the corresponding real label sequence in the training dataset, wherein the statistical index is used to quantify the accuracy and coverage of the target generative model in named entity recognition; The target model parameters of the target generative model are adjusted based on the statistical indicators to obtain the named entity recognition model. The target model parameters include a first model parameter for enhancing the boundary awareness capability of named entity recognition and a second model parameter for enhancing the contextual semantic recognition capability.

5. The method according to claim 2, characterized in that, The method further includes: Obtain the model training result corresponding to the named entity recognition model, wherein the model training result is used to quantitatively represent the entity recognition performance of the named entity recognition model on the edge device; Determine a baseline model corresponding to the named entity recognition model, wherein the baseline model includes the best-performing model in the named entity recognition field; The training results of the model are compared with the performance benchmark of the baseline model to obtain the comparison results; If the comparison results indicate that the performance of the named entity recognition model does not meet the preset conditions, the initial generative model is replaced and retrained to obtain an updated named entity recognition model.

6. The method according to claim 5, characterized in that, The preset threshold is determined based on the physical resource constraints of the edge device; The initial generative model is replaced, including: Based on the comparison results, the preset threshold is adjusted to obtain a target preset threshold, wherein the target preset threshold satisfies the physical resource constraints; An updated generative model is determined from generative models with fewer parameters than the target preset threshold, and the updated generative model is used to replace the initial generative model.

7. The method according to claim 1, characterized in that, The target model is used to identify the text to be identified, and entity recognition results are obtained, including: The target model's word segmenter is used to convert the text to be recognized into a sequence of tokens and a mask sequence; The embedding layer of the target model determines the hidden state sequence based on the word sequence and the mask sequence; The hidden state sequence is processed by the decoder of the target model to obtain the target hidden state sequence, wherein the target hidden state sequence contains the contextual semantic information of the text to be identified; The target hidden state sequence is modeled using the deep learning architecture of the target model to obtain an emission score sequence, wherein the emission score sequence is used to reflect the dependency relationship between each word and the words before and after it; The emission score sequence is mapped using the linear layer of the target model to obtain the label prediction probability score sequence; The target model is used to determine the entity recognition result from the label prediction probability score sequence.

8. An entity recognition device, characterized in that, include: The receiving module is used to receive the text to be recognized input from the edge device; The determination module is used to determine the target model corresponding to the text to be identified from the named entity recognition model deployed on the edge device, wherein the named entity recognition model is obtained by adjusting the mask attention mechanism and feature output path of the generative model with fewer than a preset threshold of parameters; The recognition module is used to recognize the text to be recognized using the target model to obtain entity recognition results.

9. An electronic device, characterized in that, include: A memory and a processor, the memory being used to store program instructions; the processor being connected to the memory and used to execute the entity recognition method according to any one of claims 1 to 7.

10. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored computer program, wherein the device containing the non-volatile storage medium executes the entity recognition method according to any one of claims 1 to 7 by running the computer program.

11. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the entity recognition method according to any one of claims 1 to 7.