## 5 Model Training
### Model Evaluation and Generation Instances  
This study has trained an autoregressive language model based on the Transformer architecture, with the model weights saved as \"model.pth\" and a size of 1.5 GB. It can efficiently run on a GPU with 4 GB of video memory. Validated by a pre-trained SentencePiece tokenizer, the model demonstrates an end-to-end capability from text input to generation. In evaluating the model, we adopted several key metrics including accuracy, recall, F1 score, and loss function value to measure its performance. Accuracy refers to the proportion of positive samples that are correctly predicted as positive by the model, calculated as the true positives (TP) divided by the sum of true positives and false positives (FP). Recall measures the proportion of actual positive samples that are predicted as positive by the model, calculated as the true positives (TP) divided by the sum of true positives and false negatives (FN). The F1 score, as the harmonic mean of precision and recall, comprehensively considers the accuracy and completeness of the model. During the training process, the loss function value is used to measure the discrepancy between the model's predictions and the true values, where a lower value generally indicates better model performance. Our model exhibited excellent performance in all evaluation metrics, with a low loss value of 0.07, indicating a small prediction error and strong generalization ability. These results not only validate the effectiveness of the model but also provide strong support for its application in the agricultural field and other related areas. Here are the equations for accuracy, recall, F1 score, and loss function:  
* \(\text{Accuracy}/\text{Precision}\): \(\text{Precision}=\frac{TP}{TP+FP}\)
* \(\text{Recall}=\frac{TP}{TP+FN}\)
* \(\text{F1 Score}\): \(\text{F1}=\frac{2\times Precision\times Recall}{Precision+Recall}\)
* \(\text{Loss}=-\sum\limits_{\text{L}}\text{logP(yi|y1,\cdots,yi-1)}\)  
We have successfully trained an autoregressive language model based on Transformer, with its weight file \"model.pth\" sized at 1.5 GB, which can run smoothly on a GPU with at least 4 GB of video memory. By loading the pre-trained SentencePiece tokenizer (bird_shooter.model), the model has successfully completed the entire process from encoding text data to decoding, demonstrating its powerful generation capability. To comprehensively evaluate the model's performance, we have adopted multiple key indicators, including accuracy, recall, F1 score, and loss function value. These indicators collectively assess the model's correctness, precision, comprehensiveness, and learning effectiveness. In particular, the model has exhibited good convergence characteristics during the training process, with the final loss function value reduced to 0.07, indicating a high degree of consistency between the model's predictions and actual results. Based on Figure 10, which shows the loss function curve and accuracy curve, it can be observed that in the initial stage, the rapid decline of the loss function indicates that the model is converging quickly. In the later stages, the flattening of the loss function curve suggests that the model is approaching convergence. Initially, the accuracy rate is relatively low, but it gradually improves as the number of iterations increases. In the mid-to-late stages, although the growth rate slows down, the accuracy continues to increase overall, indicating that the model performs well in identifying correct samples. As shown in Table 3, after 3.9 h of training, the model achieved an accuracy, recall, and F1 score of 0.984, with a smooth loss rate of 0.067. This indicates that the model performs excellently in prediction tasks, demonstrating high generalization ability and reliability. Furthermore, we utilized the torchinfo. summary method to visualize the model structure, providing assistance in understanding and debugging the model architecture.