Named entity recognition (NER) is a crucial step in building knowledge graphs for crop diseases and pests. To enhance NER accuracy, we propose a new NER model—GatedMan—based on the gated fusion unit and Manhattan attention. GatedMan utilizes RoBERTa as a pre-trained model and enhances it using bidirectional long short-term memory (BiLSTM) to extract features from the context. It uses a gated unit to perform weighted fusion between the outputs of RoBERTa and BiLSTM, thereby enriching the information flow. The fused output is then fed into a novel Manhattan attention mechanism to capture the long-range dependencies. The global optimum tagging sequence is obtained using the conditional random fields layer. To enhance the model’s robustness, we incorporate adversarial training using the fast gradient method. This introduces adversarial examples, allowing the model to learn more disturbance-resistant feature representations, thereby improving its performance against unknown inputs. GatedMan achieved F1 scores of 93.73%, 94.13%, 93.98%, and 96.52% on the AgCNER, Peoples_daily, MSRA, and Resume datasets, respectively, thereby outperforming the other models. Experimental results demonstrate that GatedMan accurately identifies entities related to crop diseases and pests and exhibits high generalizability in other domains.
Currently, there is no publicly available dataset for the classification of potato pest and disease-related queries. Moreover, traditional query classification models generally adopt a single maximum-pooling strategy when performing down-sampling operations. This mechanism only extracts the extreme value responses within the local receptive field, which leads to the degradation of fine-grained feature representation and significantly amplifies text noise. To address these issues, a dataset construction method based on prompt engineering is proposed, along with a question classification method utilizing a gated fusion–convolutional neural network (GF-CNN). By interacting with large language models, prompt words are used to generate potato disease and pest question templates and efficiently construct the Potato Pest and Disease Question Classification Dataset (PDPQCD) by batch importing named entities. The GF-CNN combines outputs from convolutional kernels of varying sizes, and after processing with max-pooling and average-pooling, a gating mechanism is employed to regulate the flow of information, thereby optimizing the text feature extraction process. Experiments using GF-CNN on the PDPQCD, Subj, and THUCNews datasets show F1 scores of 100.00%, 96.70%, and 93.55%, respectively, outperforming other models. The prompt engineering-based method provides a new paradigm for constructing question classification datasets, and the GF-CNN can also be extended for application in other domains.