Method and system for live pig breeding environment-behavior correlation modeling and cooperative regulation and control
By introducing a pre-trained large language model and multi-source perception data, a method for modeling and coordinating the relationship between pig farming environment and behavior was constructed. This method solved the problem of the relationship between multiple environmental factors and animal behavior, realized intelligent environmental regulation, and improved the efficiency and welfare of pig farming.
Patent Information
- Application Number
- CN202511379681.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-25
- Publication Date
- 2026-02-17
AI Technical Summary
Existing precision environmental control technologies for pig farming rely on threshold judgments of single environmental factors, making it difficult to analyze the complex relationship between multiple environmental factors and animal behavior. This leads to a disconnect between control strategies and animal needs. Furthermore, existing methods have failed to establish a two-way dynamic coupling mechanism between the environment and behavior, making it difficult to achieve truly intelligent and coordinated control.
By introducing a pre-trained Large Language Model (LLM) and combining it with multi-source sensing data, a correlation mechanism between multiple environmental factors and abnormal pig behaviors is constructed. Through dynamic masking and fine-tuning techniques using a multi-expert architecture, an environment-behavior collaborative decision-making system is realized. Multi-source data is integrated and cross-modal semantic alignment is performed to establish an intelligent control path.
It has achieved accurate modeling and analysis of complex environment-behavior relationships, promoted the evolution of environment-behavior collaborative regulation towards intelligence, broken through the limitations of traditional single factor analysis, and realized precise environmental regulation decision support.
Smart Images

Figure CN121541458A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of precision environmental control technology for pig farming, specifically involving a method and system for modeling and collaboratively regulating the relationship between the environment and behavior in pig farming. Background Technology
[0002] Smart pig farming is an important tool in the process of national agricultural modernization. Among them, building a precise environmental control system based on the synergistic mechanism of environment and behavior is a key breakthrough in improving farming efficiency and animal welfare, and is of great significance to promoting the intelligent upgrading of the pig industry.
[0003] The hog industry is a pillar industry of my country's animal husbandry. Statistics show that in 2024, China's hog slaughter exceeded 700 million heads, accounting for more than 50% of the global total, with an industry scale reaching 1.51 trillion yuan. However, under the background of large-scale farming, environmental factors such as temperature and humidity fluctuations and excessive ammonia concentrations are increasingly negatively impacting hog health and welfare as well as production efficiency. Especially during the nursery stage, piglets, due to their weak immune systems and poor environmental adaptability, are susceptible to multiple stressors, leading to a high incidence of diarrhea and respiratory diseases, directly threatening survival rates and later production performance. Studies have shown that cyclic heat stress reduces average daily feed intake and average daily weight gain in pigs by 15.1% and 15.2%, respectively; under continuous heat stress, the reduction in these two indicators widens to 23.2% and 25.3%, respectively. Therefore, developing full-cycle environmental monitoring and precise control technologies has become an urgent need to improve hog welfare and ensure farming efficiency.
[0004] Advantages of Precision Environmental Control Technology in Pig Farming: Precision environmental control technology in pig farming, through real-time monitoring and intelligent regulation of multi-source environmental parameters (temperature, humidity, ammonia concentration, etc.), can significantly improve the health and production performance of pig herds. Studies have shown that precise temperature control implemented according to standards such as "Environmental Parameters and Management of Large-Scale Pig Farms (GB / T 17824.3-2008)" can significantly reduce the daily weight gain loss of pigs caused by heat and cold stress, and precise humidity control can effectively inhibit the growth of pathogenic microorganisms and reduce the incidence of respiratory diseases. Simultaneously, through the integrated and coordinated control of ventilation, heating, and spraying equipment, feed conversion rate optimization and energy utilization efficiency can be achieved, providing technical support for increased profitability in large-scale farming.
[0005] Challenges of Precision Environmental Control Technology in Pig Farming: Despite the significant advantages of existing precision environmental control technologies, their practical application still faces multiple bottlenecks. Traditional control methods rely on environmental parameter threshold feedback mechanisms, requiring intervention only after local environmental conditions exceed limits, resulting in response lag and control biases caused by subjectively preset thresholds. While predictive control, developed in recent years, uses time-series models to predict environmental change trends, its essence is the same as the aforementioned methods: relying solely on a one-way data flow of environmental parameters for decision-making. It cannot analyze the pigs' perceptual feedback to the environment, leading to a disconnect between control strategies and the animals' actual needs. Considering that animal behavior can reflect their welfare status and environmental stress levels in real time, researchers have recently begun exploring innovative control methods that combine behavioral monitoring with environmental parameter prediction. By establishing a behavior-environment collaborative response mechanism, they aim to develop a more timely and precise intelligent environmental control paradigm.
[0006] However, existing methods that combine behavioral monitoring with environmental parameter prediction still face the following two key challenges in complex aquaculture scenarios: (1) Most existing research methods are limited to analyzing the association between a single environmental factor and specific pig behaviors, and fail to fully consider the synergistic effects of multiple environmental parameters such as temperature, humidity, and ammonia concentration and their comprehensive impact on abnormal behaviors. This single-factor analysis framework is difficult to accurately capture the complex mechanism of multi-factor coupling in actual breeding environment, which leads to biases in the decision-making of the constructed regulatory model and insufficient applicability and robustness.
[0007] (2) Although some current environmental control schemes attempt to integrate environmental monitoring with behavioral representation, their control logic is still mainly based on a one-way inference from behavior to environment, that is, inferring the environmental state from observed behavioral changes and implementing control accordingly. This method fails to establish a two-way dynamic coupling mechanism between environment and behavior, and lacks in-depth modeling of the real-time feedback and co-evolution relationship between the two, thus failing to achieve true "environment-behavior" intelligent collaborative control.
[0008] Given that existing text databases have demonstrated a significant correlation between environmental factors and abnormal behavior, and that pre-trained large language models exhibit powerful semantic representation and information extraction capabilities, this invention aims to introduce a large language model to integrate diverse environmental parameters with pig behavior monitoring data to deeply explore the correlation mechanism between the two. The primary key issue to be addressed is how to fully exploit the correlation mechanism between diverse environmental factors and abnormal pig behavior using a pre-trained large language model. Furthermore, existing technologies largely rely on single-modal models, making it difficult to dynamically integrate multimodal data such as physical sensor signals, visual behavior sequences, and language knowledge bases. After establishing the correlation between the environment and animal behavior, another crucial issue to be addressed is how to construct a cross-modal alignment mechanism to eliminate the semantic gap between different modalities in practical applications and achieve interpretable feedback-enhanced decision optimization. Summary of the Invention
[0009] This invention aims to overcome the problem that existing precision environmental control technologies for pig farming rely on single environmental factor thresholds for judgment, making it difficult to analyze the synergistic effects of multiple environmental factors and their complex correlation with animal behavior. It provides a method and system for modeling and coordinating the relationship between environment and behavior in pig farming, which integrates pre-trained large language models and multi-source sensory data. This method can accurately model and analyze complex environment-behavior relationships while ensuring processing efficiency.
[0010] To achieve the above-mentioned objectives, the present invention adopts the following technical solution: A method for modeling and coordinating the relationship between environment and behavior in pig farming includes the following steps: S1, Modeling the association mechanism between multiple environmental factors and abnormal behavior in pigs: By introducing a pre-trained large language model (LLM), the correlation between multiple environmental factors in the existing knowledge base and abnormal pig behavior is fully explored and modeled. S2, Construction of an Environment-Behavior Collaborative Decision-Making System Guided by a Large Language Model: A multi-source real-time data acquisition system was built to simultaneously acquire and integrate environmental and pig behavior data. At the same time, an environment-behavior collaborative decision-making system was constructed based on a finely tuned large language model to achieve multi-factor collaborative attribution and intelligent regulation.
[0011] Preferably, step S1 includes the following process: S11, a corpus for modeling the relationship between environment and behavior was constructed; S12, Based on the corpus organized in step S11, design a dynamic masking preprocessing mechanism; S13, based on the original large language model architecture, designs and inserts a low-rank decoupling expert module for environmental factors before the last fully connected layer; S14. The large language model is fine-tuned using the dynamic mask preprocessing mechanism and the low-rank decoupling expert module for environmental factors. Preferably, step S11 includes the following steps: S111 constructs the original corpus by integrating multi-source heterogeneous data from academic literature, professional books, industry standards, sensor data, and practical texts, and by introducing LLM question-answer pairs. S112, For the collected original corpus, perform OCR recognition and text extraction on the original documents, and remove irrelevant information such as headers, footers, references, and figure / table numbers; S113 uses the FastText model and Dolma rules for data filtering, and utilizes locality-sensitive hashing and exact matching to achieve data deduplication at the sentence level. S114, standardize the terminology and unit expression for filtered and deduplicated text data; S115, in terms of entity recognition technology, combines word segmentation tools, readers and BERT-based named entity recognition models to automatically annotate text; S116, further transform the statements corresponding to different behavior changes into structured text; S117, construct a glossary of terms in Chinese and English, including four core aspects: "environmental factors", "animal behavior", "environmental regulation" and "change trends"; S118 uses a deep learning-based word segmentation tool to segment Chinese text and spaCy tool to lexicalize English text, thereby generating a unified lexical sequence suitable for LLM modeling.
[0012] Preferably, in step S12, the dynamic masking preprocessing mechanism refers to randomly selecting the coding segments corresponding to one or more environmental factors for masking, and inputting them into the large language model for forward propagation.
[0013] Preferably, step S13 includes the following steps: S131, Setting This represents the feature data output from the previous layer, and has a total of Several environmental factors were considered and customized. A network of experts, recorded as , Indicates the first A network of experts; S132, through the division of labor and collaboration within an expert network, aims to capture the interrelationships between various environmental factors and anomalous behavior, thereby obtaining... , Indicates the first A network of experts For input The output result obtained after processing; S133. To capture the synergistic effect of multiple environmental factors on abnormal behavior, a flexible gating network is designed, drawing on the gating network mechanism in the hybrid expert MoE model, to predict the value scores corresponding to the outputs of each expert, denoted as . ( The first one was predicted through a flexible gating network. Each expert network outputs a corresponding value score), and ; S134, the value score is weighted and summed with the features extracted by the corresponding expert network to obtain new feature data reflecting the synergistic effect. : (1) S135, introduce residual connections and obtain features. The obtained features will be input into the linear output layer, and the large language model will be optimized using autoregressive language modeling loss.
[0014] Preferably, in step S2, the construction of the multi-source real-time data acquisition system specifically includes the following steps: S211, deploy digital temperature and humidity sensors, carbon dioxide sensors, ammonia sensors and hydrogen sulfide sensors in the breeding farm, and select appropriate communication methods to complete the Internet of Things sensor network to obtain key indicators including temperature, relative humidity, ammonia concentration, carbon dioxide concentration, hydrogen sulfide concentration and light intensity. S212 encrypts sensor nodes in the feeding and rest areas and uses a Kalman filter algorithm to eliminate measurement noise.
[0015] Preferably, in step S2, the acquisition and fusion of environmental and pig behavior data specifically includes the following steps: S213, acquires video image data from a top-down angle using a camera installed on top of the pigpen; S214 uses the YOLOv8 multi-target tracking algorithm to achieve real-time detection and bounding box localization of pigs, and assigns them a unique ID; S215 applies the robust multi-target tracking algorithm DeepSORT, combining detection box position, size, appearance features and Kalman filter motion prediction to achieve stable identity association of individual pigs across video frames and construct continuous motion trajectories; S216, Establish a pairwise interaction screening mechanism with spatial proximity constraints, calculate the Euclidean distance between the center points of the bounding boxes of pig pairs, and set a dynamic distance threshold in combination with the pig population density to effectively identify potential pig pairs that may interact. S217. Based on the detection, tracking and filtering results, two types of sub-video segments are generated: For a single pig, the corresponding bounding box is used as the region for segmentation, and the segmented sub-video is used for independent behavior recognition; For interactive pig pairs, the segmentation is based on the minimum bounding rectangle of the pig pair's bounding box to ensure that the rectangular region completely contains the interaction area of the two pigs, and the segmented sub-video is used for social behavior recognition. S218, Based on the sub-video stream obtained in step S217, for independent behavior detection, a 3D convolutional neural network with strong temporal modeling capability is used to process the single pig sub-video stream to extract the temporal dynamic features of individual actions. S219 proposes a spatiotemporal collaborative detection method based on CNN-LSTM for social behavior detection, as detailed below: A lightweight 2D CNN was used to extract the spatial interaction features of pig pairs frame by frame. Subsequently, a bidirectional LSTM was used to model the temporal evolution of the interaction behavior. A temporal attention mechanism was introduced to focus on key behavioral segments in order to suppress the interference of irrelevant frames. S220, based on real-time acquired spatiotemporal data of individual pig behavior, models the spatiotemporal relationships between individuals through dynamic graph networks, and uses group state quantification indicators and graph neural network classifiers to achieve real-time transformation from individual behavior to group behavior patterns.
[0016] Preferably, in step S2, the construction of the environment-behavior collaborative decision-making system based on the fine-tuned large language model specifically includes the following steps: S221 integrates a dynamic rule engine to build a real-time processing architecture, dynamically parsing the raw data stream from environmental sensors and pig behavior visual monitoring devices into structured text; at the same time, it sets formatted output, including: multi-environmental factor synergistic attribution conclusions and priority control schemes; S222: Input the structured text and formatted output examples into the fine-tuned large language model to generate the final attribution conclusions and control schemes. S223, professional managers conduct real-time review and feedback on the output decision results of the large language model; among them, the collected feedback discourse is used to build a knowledge base and serve the retrieval enhancement generation of the large language model.
[0017] This invention also provides a system for modeling and coordinating the relationship between environment and behavior in pig farming, including: The association mechanism construction module is used to fully explore the association between multiple environmental factors in the existing knowledge base and abnormal pig behavior by introducing a pre-trained large language model (LLM) and to model it. The decision-making system construction module is used to build a multi-source real-time data acquisition system, synchronously acquire and integrate environmental and pig behavior data, and build an environment-behavior collaborative decision-making system based on a fine-tuned large language model to achieve multi-factor collaborative attribution and intelligent regulation.
[0018] Compared with the prior art, the beneficial effects of this invention are: (1) The method of this invention is based on a pre-trained large language model, deeply explores the correlation mechanism between multi-source environmental parameters and abnormal pig behavior, and constructs an intelligent decision-making system that integrates multi-source data. It can achieve accurate modeling and analysis of complex environment-behavior relationships while ensuring processing efficiency, thereby promoting the evolution of environment-behavior collaborative regulation towards intelligence; (2) This invention innovatively introduces a pre-trained large language model, cleverly integrates multi-source environmental parameters and pig behavior monitoring data, and for the first time constructs a domain knowledge-enhanced corpus covering environmental parameters, pig behavior and regulation measures; based on this corpus, the pre-trained large language model is fine-tuned using a fine-tuning technique based on dynamic masking and multi-expert architecture to achieve correlation modeling between multi-source environmental factors and abnormal pig behavior; this method fully utilizes the powerful semantic representation and information extraction capabilities of the large language model, breaks through the limitations of traditional single environmental factor analysis, and can accurately capture the complex relationship between multi-source environmental factors and abnormal pig behavior, providing a basis for accurate environmental regulation. The control provides a brand-new decision support path; (3) In response to the cross-modal fusion and semantic alignment problem in the collaborative decision-making of multi-source heterogeneous environmental-behavior data, the present invention ingeniously constructs an environmental-behavior collaborative decision-making system guided by a large language model; the system first utilizes the advantages of real-time data processing and complex logical reasoning of the dynamic rule engine to quickly parse monitoring data and generate structured semantic descriptions according to preset rules, providing accurate input for the large language model; then integrates the finely tuned large language model, and uses its powerful semantic understanding ability to achieve semantic alignment of cross-modal data and generate collaborative decisions; finally, it establishes a feedback mechanism based on retrieval enhancement generation to enhance and optimize the system decision; this fusion scheme fully leverages the respective advantages of the dynamic rule engine and the large language model, effectively compensates for the limitations of single technology in dealing with complex environmental-behavior collaborative control problems, realizes the intelligent leap from raw data to decision knowledge, provides a practical and feasible technical path for intelligent and precise pig farming environment control, and demonstrates clear innovation and broad application prospects. Attached Figure Description
[0019] Figure 1 This is a flowchart of a method for modeling and coordinating the relationship between environment and behavior in pig farming, as described in this invention. Figure 2 This is a flowchart of the corpus construction process in this invention; Figure 3This is a schematic diagram of a framework for a large language model based on dynamic masking and multi-expert architecture in this invention. Figure 4 This is a schematic diagram of a process for studying the pig behavior detection method in this invention; Figure 5 This is a flowchart illustrating one implementation of the environment-behavior collaborative decision-making system in this invention. Detailed Implementation
[0020] To more clearly illustrate the embodiments of the present invention, specific implementation methods will be described below with reference to the accompanying drawings. Obviously, the drawings described below are merely some embodiments of the present invention. For those skilled in the art, other drawings and other implementation methods can be obtained based on these drawings without any creative effort.
[0021] like Figure 1 As shown, this invention provides a method for modeling and coordinating the relationship between environment and behavior in pig farming, comprising the following steps: S1, Modeling the association mechanism between multiple environmental factors and abnormal behavior in pigs: By introducing a pre-trained large language model (LLM), the correlation between multiple environmental factors in the existing knowledge base and abnormal pig behavior is fully explored and modeled. S2, Construction of an Environment-Behavior Collaborative Decision-Making System Guided by a Large Language Model: A multi-source real-time data acquisition system was built to simultaneously acquire and integrate environmental and pig behavior data. At the same time, an environment-behavior collaborative decision-making system was constructed based on a finely tuned large language model to achieve multi-factor collaborative attribution and intelligent regulation.
[0022] Furthermore, in step S1, a pre-trained LLM is introduced to fully explore the correlation between multiple environmental factors in the existing knowledge base and abnormal pig behavior, and to model the relationship between the two, as follows: The modeling of the association mechanism between multiple environmental factors and abnormal pig behavior proposed in this invention includes four parts: constructing a corpus for modeling the relationship between environment and behavior, designing a dynamic masking preprocessing mechanism, designing a low-rank decoupling expert module for environmental factors, and fine-tuning a large language model.
[0023] S11, such as Figure 2 As shown, this invention constructs a corpus for modeling the relationship between environment and behavior. The specific steps are as follows: S111 integrates heterogeneous data from multiple sources, including academic literature, professional books, industry standards, sensor data, and practical texts, and incorporates LLM question-answering pairs. Specifically, in terms of academic literature, a large number of Chinese and English papers and conference abstracts were retrieved and downloaded from databases such as PubMed, CNKI, and Google Scholar, focusing on keywords such as "nursery pigs," "pig behavior," "environmental factors," and "environmental control." For example, studies such as "Evaluation of Pig Behavior Changes Related to Temperature, Humidity, Volatile Organic Compounds, and Illuminance" explored the impact of environmental factors such as temperature and humidity on pig behavior, providing theoretical guidance for corpus construction. In terms of professional books, official websites and targeted web crawling tools were used to batch-grab works such as "Modern Pig Production Technology" and "Pig Housing and Equipment Handbook," systematically acquiring knowledge in areas such as pig physiology, behavior, pen structure, and equipment layout. To acquire practical knowledge from the front lines of the industry, technical manuals and standard documents published by industry associations and leading feed companies were consulted, such as "Pig Behavior and Feeding Management," "Livestock and Poultry Breeding Technology Manual," and "Code of Practice for the Welfare of Pigs." Regarding industry standards, documents such as "Environmental Parameters and Environmental Management of Large-Scale Pig Farms (GB / T17824.3-2008)" and "Standardized Pig Farms (NY / T 2661-2014)" were incorporated to provide a foundation for extracting structured indicators. Furthermore, sensor data and alarm logs recorded by the pig house environmental monitoring system were integrated, and threshold events were converted into natural language descriptions to enhance the model's understanding of actual breeding environment events. Finally, experiential texts from breeding forums, Q&A platforms, and professional blogs were collected to further enrich the diversity of language and application scenarios in the corpus.
[0024] S112, for the collected original corpus, firstly, perform OCR recognition and text extraction on the original documents such as PDFs and scanned copies, and remove irrelevant information such as headers, footers, references, and figure numbers.
[0025] S113. Secondly, the FastText model and Dolma rules are used to filter out low-quality and sensitive content in the data, and the Locality-sensitive hashing (LSH) algorithm and exact matching method are used to achieve data deduplication at the sentence granularity.
[0026] S114, subsequently, standardized terminology and unit expressions were implemented, such as uniform coding for units like "°C," "ppm," and "%," and standardized numerical values. Referring to general agricultural vocabularies and veterinary professional dictionaries, synonymous expressions were normalized; for example, "heat stress" and "high-temperature stress" were considered synonymous entities, and "feed intake" and "daily meat consumption" were grouped into the same category.
[0027] S115, in terms of entity recognition technology, combines spaCy, Stanza and BERT-based named entity recognition models to automatically annotate text, and incorporates domain expert suggestions to ensure annotation accuracy and industry adaptability, obtaining changes in multiple environmental factors such as "when the temperature rises and the humidity decreases, the piglets eat less and drink more frequently, so it is recommended to open the ventilation windows of the pigsty".
[0028] S116 corresponds to statements about different behavioral changes and is further converted into structured text, such as {“Animal type”: “nursery pig”, “Changes in environmental factors”: [“Temperature increases”, “Humidity decreases”], “Changes in animal behavior”: [“Feeding decreases”, “Watering frequency increases”], “Environmental control”: “Open ventilation window”}.
[0029] S117 constructs a bilingual (Chinese and English) glossary covering the following four core aspects: "Environmental Factors," "Animal Behavior," "Environmental Regulation," and "Change Trends." Specifically, the glossary of environmental factors includes: Temperature, Humidity, Ammonia (NH3) concentration, Illuminance, etc.; animal behavior includes: Feeding, Drinking, Lying, Wallowing, etc.; environmental regulation includes: Activate ventilation fans, Engage cooling pads, Open ventilation windows, Adjust curtain openings, etc.; and descriptions of change trends include: Increase, Decrease, Remain stable, etc.
[0030] S118 Next, the Chinese text is segmented using the deep learning-based word segmentation tool Language Technology Platform (LTP), while the English text is lexicalized using the spaCy tool, thereby generating a unified lexical sequence suitable for LLM modeling.
[0031] Based on the corpus compiled in the above stages, such as Figure 3 As shown, this stage aims to fine-tune the pre-trained LLM and develop a fine-tuning technique based on dynamic masking and a multi-expert architecture. The specific steps are as follows: S12, after the structured text is lexicalized, a dynamic masking preprocessing is designed and adopted, that is, the coding segments corresponding to one or more environmental factors (such as temperature, ammonia concentration) are randomly selected for masking and input into the model for forward propagation.
[0032] S13. Subsequently, based on the original Llama2-7B model (large language model) architecture, a low-rank decoupling expert module for environmental factors is inserted before the last fully connected layer. The specific steps are as follows: S131, Assume This represents the feature data output from the previous layer, and has a total of Several environmental factors (temperature, humidity, light intensity, NH3 concentration, CO2 concentration, H2S concentration, etc.) were considered and customized. A network of experts, recorded as , Indicates the first A network of experts.
[0033] S132, through the division of labor and collaboration within an expert network, accurately captures the interrelationships between various environmental factors and anomalous behaviors, thus obtaining... , Indicates the first A network of experts For input The output result obtained after processing.
[0034] S133, In order to capture the synergistic effect of multiple environmental factors on abnormal behavior, this invention draws on the gating network mechanism in the Mixture of Experts (MoE) model and designs a flexible gating network to predict the value score corresponding to the output of each expert, denoted as . ( The first one was predicted through a flexible gating network. Each expert network outputs a corresponding value score), and .
[0035] S134, these value scores are weighted and summed with the features extracted by the corresponding expert network to obtain new feature data reflecting this synergistic effect, namely: (1) S135, Finally, residual connections are introduced and features are obtained. The obtained features will be input into the linear output layer, and the model will be optimized using an autoregressive language modeling loss.
[0036] Furthermore, in step S2, a multi-source real-time data acquisition system is built to synchronously acquire and integrate environmental and pig behavior data. Then, based on a finely tuned large language model, an environment-behavior collaborative decision-making system is constructed to achieve multi-factor collaborative attribution and precise intelligent regulation, as detailed below: The environment-behavior collaborative decision-making system guided by a large language model proposed in this invention comprises four parts: synchronous acquisition of environmental parameters and visual behavior monitoring data; design of a dynamic rule engine to achieve structured text conversion; output of environment-behavior attribution conclusions and control schemes; and construction of a human feedback knowledge base to achieve system decision optimization. The details are as follows: S21, To construct a precise control model for pigsty environment that integrates multiple environmental factors and individual behavioral expressions, this invention establishes a multi-source real-time data acquisition system. The specific steps are as follows: S211 deploys digital temperature and humidity sensors (-40℃-80℃, ±0.3℃), carbon dioxide (CO2) sensors (0-5000ppm, ±200ppm), ammonia (NH3) sensors (0-20ppm, ±0.8ppm), and hydrogen sulfide (H2S) sensors (±0.5ppm) in the farm. A high-precision Internet of Things (IoT) sensor network is established using a reliable communication method to acquire key indicators affecting pig production, including temperature (T, ℃), relative humidity (RH, %), ammonia concentration (NH3, ppm), carbon dioxide concentration (CO2, ppm), hydrogen sulfide concentration (H2S, ppm), and light intensity (Lux).
[0037] S212 densifies sensor nodes in key areas such as foraging and rest areas, and uses Kalman filtering algorithm to eliminate measurement noise, ensuring the spatiotemporal continuity and reliability of environmental data.
[0038] Given that existing methods are mostly limited to detecting single, independent, or social behaviors, such as Figure 4 As shown in the figure, this embodiment studies a fine-grained group pig behavior detection method based on spatiotemporal feature fusion. The specific steps are as follows: S213 acquires video image data from a top-down angle using a camera installed on top of the pigpen.
[0039] S214 uses the YOLOv8 multi-target tracking algorithm to achieve real-time detection and bounding box localization of pigs, and assigns them a unique ID.
[0040] S215 applies the robust multi-target tracking algorithm DeepSORT, combining detection box position, size, appearance features, and Kalman filter motion prediction to achieve stable identity association of individual pigs across video frames and construct continuous motion trajectories.
[0041] S216 establishes a pairwise interaction screening mechanism with spatial proximity constraints, calculates the Euclidean distance between the center points of the bounding boxes of pig pairs, and sets a dynamic distance threshold in combination with the pig population density to effectively identify potential pig pairs that may interact. This calculation process references the rules for constructing pig pairs proposed in the reference [Liu D, Oczak M, Maschat K, et al. A computer vision-based method for spatial-temporal action recognition of tail-biting behaviour in group-housedpigs[J]. Biosystems Engineering, 2020, 195: 27-41.].
[0042] S217. Based on the detection, tracking, and filtering results, two types of sub-video segments are generated: for a single pig, the segment is directly cut using its bounding box as the region (for independent behavior recognition); for an interacting pair of pigs, the segment is cut based on the minimum bounding rectangle of their bounding boxes, ensuring that the rectangular region completely includes the interaction area of the two pigs (for social behavior recognition). The segmented sub-videos are used for subsequent independent behavior recognition and social behavior recognition analysis, respectively.
[0043] S218. Based on the sub-video streams obtained above, for independent behavior detection (including eating, drinking, wallowing, etc.), a 3D convolutional neural network with strong temporal modeling capabilities is used to process the single pig sub-video stream and extract the temporal dynamic features of individual actions.
[0044] S219 proposes a spatiotemporal collaborative detection method based on CNN (Convolutional Neural Networks)-LSTM (Long Short-Term Memory) for social behavior detection (including tail-biting, ear-biting, fighting, etc.). First, a lightweight 2D CNN is used to extract the spatial interaction features of pig pairs frame by frame. Then, a bidirectional LSTM is used to model the temporal evolution of the interaction behavior. A temporal attention mechanism is introduced to focus on key behavior segments to suppress interference from irrelevant frames.
[0045] S220, based on the real-time acquired spatiotemporal data of individual pig behavior, models the spatiotemporal relationship between individuals through a dynamic graph network, and uses a group state quantification index and a graph neural network classifier to achieve real-time conversion from individual behavior to group behavior patterns.
[0046] Based on the acquisition of real-time environmental-behavioral monitoring data and the fine-tuning of the LLM based on a professional corpus, such as Figure 5 As shown, this invention constructs an environment-behavior collaborative decision-making system, and the specific steps are as follows: S221, firstly, integrates Flink CEP and Drools rule engine to build a real-time processing architecture, dynamically parsing the raw data streams from environmental sensors and pig behavior visual monitoring devices into structured text. For example, when the rule detects that the temperature increases by more than 2.3°C within 30 minutes, the humidity increases by more than 10% within 30 minutes, and the pigs' drinking frequency increases by more than 20% and lying time decreases by more than 20% compared to normal levels, it will be converted into structured text: {“Animal Type”: “Nurse Pig”, “Environmental Factor Changes”: [“Temperature increased by 3°C”, “Humidity increased by 12%”], “Animal Behavior Changes”: [“Drinking frequency increased by 23%”, “Lying time decreased by 30%”}. Simultaneously, formatted output is set, including: multi-factor co-attribution conclusions (e.g., “High temperature and humidity caused a 23% increase in drinking frequency and a 30% decrease in lying time”) and priority control schemes (e.g., “Due to a significant increase in temperature and humidity, it is recommended to turn on the misting system and open the roof ventilation”).
[0047] S222, Subsequently, these structured texts and formatted output cases are input into the fine-tuned large language model Llama2-7B to generate the final attribution conclusions and control schemes.
[0048] S223 Finally, continuous optimization is driven by real-time review and feedback of the system's output decisions by professional managers. The collected feedback is used to build a knowledge base, serving to enhance the retrieval and generation of the language model.
[0049] In addition, the present invention also provides a system for modeling and coordinating the relationship between environment and behavior in pig farming, including: The association mechanism construction module is used to fully explore the association between multiple environmental factors in the existing knowledge base and abnormal pig behavior by introducing a pre-trained large language model (LLM) and to model it. The decision-making system construction module is used to build a multi-source real-time data acquisition system, synchronously acquire and integrate environmental and pig behavior data, and build an environment-behavior collaborative decision-making system based on a fine-tuned large language model to achieve multi-factor collaborative attribution and intelligent regulation.
[0050] This invention aims at the precise control of the environment in nursery pig houses. It combines a pre-trained Large Language Model (LLM) with multi-source heterogeneous real-time sensing data to study a method for environment-behavior correlation modeling and collaborative control guided by the LLM. Its advantages and benefits are mainly reflected in the following two aspects: First, we developed a multivariate environmental factor decoupling technique based on LLM (Liquidity Modeling). This technique integrates heterogeneous data from multiple sources to construct a domain knowledge-enhanced corpus, and then uses a fine-tuning technique based on dynamic masking and a multi-expert architecture to fine-tune the pre-trained LLM, thereby achieving the correlation modeling between multivariate environmental factors and abnormal pig behaviors. This method overcomes the limitations of traditional single-environment factor analysis, utilizes dynamic masking training to capture the interaction effects between factors, and the multi-expert architecture enhances the model's expressive power through expert division of labor. This approach achieves accurate modeling and analysis of complex environment-behavior relationships while ensuring high efficiency.
[0051] Secondly, an intelligent decision-making system based on multi-source data fusion is constructed. Through a real-time structured transformation engine, sensor environmental data and visual behavior recognition results are uniformly encoded into structured semantic descriptions, and integrated with the aforementioned finely tuned LLM, achieving cross-modal semantic alignment and collaborative decision-making. This system overcomes the limitations of single-modal analysis, effectively integrating multi-source heterogeneous information such as physical signals, spatiotemporal sequences, and text corpora, and continuously improving decision-making accuracy through a feedback enhancement mechanism, thus realizing the intelligent evolution of environment-behavior collaborative regulation.
[0052] The above description is merely a detailed explanation of preferred embodiments and principles of the present invention. For those skilled in the art, there may be changes in specific implementation methods based on the ideas provided by the present invention, and these changes should also be considered within the scope of protection of the present invention.
Claims
1. A method for pig breeding environment-behavior correlation modeling and collaborative regulation, characterized in that, Comprising the following steps: S1, modeling the correlation mechanism of multiple environmental factors and pig abnormal behavior: By introducing a pre-trained large language model LLM, the correlation between the existing knowledge base and the pig abnormal behavior is fully mined, and modeling is performed; S2, environment-behavior collaborative decision system guided by large language model: Build a multi-source real-time data acquisition system to synchronously acquire and fuse environment and pig behavior data, and build an environment-behavior collaborative decision system based on the fine-tuned large language model to realize multi-factor collaborative attribution and intelligent regulation.
2. The method for pig breeding environment-behavior association modeling and collaborative regulation according to claim 1, characterized in that, Step S1 includes the following process: S11, build an environment and behavior relationship modeling corpus; S12, based on the corpus sorted in step S11, design a dynamic mask preprocessing mechanism; S13, based on the original large language model architecture, design and insert an environment factor low-rank decoupling expert module before the last full connection layer; S14, fine-tune the large language model using the dynamic mask preprocessing mechanism and the environment factor low-rank decoupling expert module.
3. The method for pig breeding environment-behavior association modeling and collaborative regulation according to claim 2, characterized in that, Step S11 includes the following steps: S111, by integrating multi-source heterogeneous data such as academic literature, professional books, industry standards, sensor data and practice texts, and introducing LLM question and answer pairs, the original corpus is constructed; S112, for the collected original corpus, the original document is subjected to OCR recognition and text extraction, and irrelevant information such as headers and footers, references, and chart numbers is removed; S113, data filtering is performed using the FastText model and Dolma rules, and data deduplication is performed at the sentence level using the local sensitive hashing algorithm and the exact matching method; S114, unify the term and unit expression of the filtered and deduplicated text data; S115, in the entity recognition technology, the text is automatically annotated by combining the use of word segmentation tools, readers and BERT-based named entity recognition models; S116, the sentences corresponding to different behavior changes are further converted into structured text; S117, build an English-Chinese term table, including four core aspects: "environmental factors", "animal behavior", "environmental regulation" and "trend of change"; S118, the Chinese text is segmented using a deep learning-based segmentation tool, and the English text is tokenized using the spaCy tool, thereby generating a unified token sequence suitable for LLM modeling.
4. The method for pig breeding environment-behavior association modeling and collaborative regulation according to claim 3, characterized in that, In step S12, the dynamic mask preprocessing mechanism refers to randomly selecting a single or multiple environmental factor encoding segment for masking and inputting into the large language model for forward propagation.
5. The method for pig breeding environment-behavior association modeling and collaborative regulation according to claim 4, characterized in that, Step S13 includes the following steps: S131, set feature data representing the output of the previous layer, and common environmental factors are considered, and customized expert networks, denoted as , representing the first expert network; S132, through the division of labor and cooperation of the expert network, to capture the mutual relationship between each environmental factor and abnormal behavior, get , represent the first expert network after processing the input output results obtained; S133, in order to capture the synergistic effect of multiple environmental factors on abnormal behavior, a flexible gating network is designed for predicting the value score corresponding to the output of each expert, denoted as , is the value score corresponding to the output of the first expert network predicted by the flexible gating network, and ; S134, weight and sum the value scores and the features extracted from the corresponding expert network to obtain new feature data reflecting the synergistic effect : (1) S135, introduce residual connection and get features ; wherein the obtained features will be input to the linear output layer, and the autoregressive language modeling loss is used to optimize the large language model.
6. The method for pig breeding environment-behavior association modeling and collaborative regulation according to claim 5, characterized in that, In step S2, the multi-source real-time data acquisition system is built, specifically including the following steps: S211, deploy digital temperature and humidity sensors, carbon dioxide sensors, ammonia sensors and hydrogen sulfide sensors in the farm, and select appropriate communication methods to complete the Internet of Things sensor network networking to acquire key indicators including temperature, relative humidity, ammonia concentration, carbon dioxide concentration, hydrogen sulfide concentration and light intensity; S212, encrypt sensor nodes in the feeding area and the resting area, and eliminate measurement noise by using Kalman filtering algorithm.
7. The method for pig breeding environment-behavior association modeling and collaborative regulation according to claim 6, characterized in that, In step S2, the environment and pig behavior data are acquired and fused, specifically including the following steps: S213, video image data at a top view angle is acquired by a shooting device installed on the top of the pigsty; S214, a multi-target tracking algorithm YOLOv8 is used to realize real-time detection and boundary box positioning of pigs, and a unique ID is assigned; S215, a robust multi-target tracking algorithm DeepSORT is applied, combined with the position, size, appearance features of the detection box, and Kalman filter motion prediction, to realize stable identity association of pig individuals across video frames and construct continuous motion trajectories; S216, a pair interaction screening mechanism with spatial proximity constraints is established, the Euclidean distance between pig pairs is calculated, and a dynamic distance threshold is set according to the pig group density, which is used to effectively identify potential interacting pig pairs; S217, according to the detection, tracking and screening results, two types of sub-video clips are generated: for a single pig, the corresponding boundary box is directly used as the region for cutting, and the cut sub-video is used for independent behavior recognition; for interacting pig pairs, the minimum circumscribed rectangle of the pig pair boundary box is cut to ensure that the rectangle region completely contains the interaction region of the two pigs, and the cut sub-video is used for social behavior recognition; S218, based on the sub-video stream obtained in step S217, for independent behavior detection, a 3D convolutional neural network with strong time sequence modeling capability is used to process single pig sub-video stream to extract time domain dynamic features of individual actions; S219, for social behavior detection, a spatio-temporal collaborative detection method based on CNN-LSTM is proposed, specifically as follows: Lightweight 2D CNN is used to extract spatial interaction features of pig pairs frame by frame, and then bidirectional LSTM is used to model the time sequence evolution law of interaction behavior, and time sequence attention mechanism is introduced to focus on key behavior fragments to suppress irrelevant frame interference; S220, based on the real-time acquired spatio-temporal data of pig individual behavior, the spatio-temporal correlation between individuals is modeled by dynamic graph network, and the group state quantitative index and graph neural network classifier are used to realize real-time conversion from individual behavior to group behavior pattern.
8. The method for pig breeding environment-behavior association modeling and collaborative regulation according to claim 7, characterized in that, In step S2, the environment-behavior collaborative decision system is constructed based on the fine-tuned large language model, specifically including the following steps: S221, a dynamic rule engine is integrated to build a real-time processing architecture, and the raw data from the environment sensors and pig behavior visual monitoring devices are dynamically parsed into structured text; At the same time, format output is set, including: multi-element environment factor collaborative attribution conclusion and priority control scheme; S222, the structured text and formatted output cases are input into the fine-tuned large language model to generate the final attribution conclusion and control scheme; S223, professional management personnel conduct real-time audit and feedback on the output decision results of the large language model; wherein the collected feedback utterances are used to build a knowledge base and serve the retrieval enhancement generation of the large language model.
9. A system for modeling and co-regulating the environment-behavior association of live pig breeding, for implementing the method for modeling and co-regulating the environment-behavior association of live pig breeding according to any one of claims 1-8, characterized in that, The system for pig breeding environment-behavior correlation modeling and collaborative regulation comprises; The association mechanism construction module is used for introducing a pre-trained large language model (LLM) to fully mine the association between the multi-environment factors in the existing knowledge base and the abnormal behaviors of pigs, and to model the association; The decision system construction module is used for building a multi-source real-time data acquisition system, synchronously acquiring and fusing environment and pig behavior data, and simultaneously constructing an environment-behavior collaborative decision system based on the fine-tuned large language model, to realize multi-factor collaborative attribution and intelligent regulation.
Citation Information
Cited By
Pig behavior recognition method based on heterogeneous hybrid expert mechanism and recognition system thereof
CN122223790A
