Exploring parameter-efficient fine-tuning (PEFT) of billion-parameter vision models with QLoRA and DoRA: insights into generalization for limited-data image classification under a 98:1 test-to-train regime
Organizations: Cornell University, College of Agriculture and Life Sciences, Ithaca, NY 14853
Abstract
Automated behavior classification is essential for precision livestock farming but faces challenges of high computational costs and limited labeled data. This study systematically compared three approaches: training from scratch (ResNet-18, ViT-Small), frozen feature extraction, and parameter-efficient fine-tuning (PEFT) of the DINOv3 foundation model (6.7 billion parameters). We evaluated QLoRA and DoRA across multiple configurations varying rank (8, 16, 64) and target modules (q_proj versus all-linear layers). With 2,160 verified training images, we assessed generalization of our model on 211,800 test samples, which is essentially a 98:1 test-to-train ratio. Results demonstrated that PEFT substantially outperformed alternatives, where the best QLoRA configuration (all-linear layers and rank=64) achieved 83.16% test accuracy with only 2.72% parameters (183.0M) in 5.8 hours, compared to 72.87% for ResNet-18 (16.8 hours), 61.91% for ViT-Small (18.7 hours), and 76.56% for frozen DINOv3 (17.5 hours). DoRA achieved comparable accuracy (83.14%) but with longer training time (11.0 hours). Notably, increasing adapter capacity consistently improved generalization while simultaneously not causing overfitting: reducing rank from 16 to 8 decreased test accuracy from 78.38% to 77.17%, while expanding from q_proj-only to all-linear layers with rank=64 improved accuracy from 78.38% to 83.16%. This suggests underfitting, instead of overfitting, is the primary challenge when adapting foundation models to agricultural imagery. Our findings provide guidelines for deploying billion-parameter vision models with PEFT in agricultural livestock applications.
Figures & tables
| Behavior Class | Primary Anatomical Criteria | Postural Requirements | Spatial Relationships | Additional Verification Points |
|---|---|---|---|---|
| Drinking | Muzzle oriented toward and in proximity to water source | Head lowered with neck extended forward | Animal positioned near water trough or bowl | Water source visible in frame; head position distinctly lower than eating postures |
| Eating head down | Muzzle positioned below shoulder height | Head angled downward toward feed surface | Body at or near feed bunk or eating area | Head clearly directed toward ground or feed bunk; neck in downward curve |
| Eating head up | Muzzle at or above shoulder height | Head elevated while at eating location | Body positioned at feed bunk area | Head raised above feed surface; distinct from standing by proximity to feed area |
| Lying | Torso in contact with ground surface | Body horizontal and resting on ground or bedding | Significant vertical gap absent between body and ground | Legs not in standing position; body clearly supported by ground |
| Standing | Legs in vertical weight-bearing position | Upright posture with torso elevated | Clear space visible between ventral body surface and ground | Four legs supporting body weight; stationary or minimal movement |
| Walking | At least one leg raised or in forward motion | Body in upright position with leg displacement | Forward movement trajectory evident | Leg position asymmetric or mid-stride; motion blur may be present |
| Method | Target Modules | Rank ( ) | Alpha ( ) | Trainable Params | % of Total |
|---|---|---|---|---|---|
| QLoRA | q_proj | 8 | 16 | 2.6M | 0.04% |
| QLoRA | q_proj | 16 | 32 | 5.2M | 0.08% |
| QLoRA | all-linear | 16 | 32 | 46.8M | 0.70% |
| QLoRA | all-linear | 64 | 128 | 183.0M | 2.72% |
| DoRA | q_proj | 8 | 16 | 2.8M | 0.04% |
| DoRA | q_proj | 16 | 32 | 5.4M | 0.08% |
| Method | Target | Rank | Trainable Params | Training Time | Test Acc. | Test F1 |
|---|---|---|---|---|---|---|
| ResNet-18 (scratch) | — | — | 11.2M (100%) | 16h 45m | 72.87% | 0.7526 |
| ViT-Small (scratch) | — | — | 21.7M (100%) | 18h 39m | 61.91% | 0.6600 |
| DINOv3 (frozen) | — | — | 4.7M (0.07%) | 17h 27m | 76.56% | 0.7691 |
| QLoRA | q_proj | 8 | 2.6M (0.04%) | 6h 32m | 77.17% | 0.7646 |
| QLoRA | q_proj | 16 | 5.2M (0.08%) | 7h 16m | 78.38% | 0.7753 |
| QLoRA | all-linear | 16 | 46.8M (0.70%) | 4h 43m | 80.40% | 0.8069 |
| Config | Target Modules | Rank | Alpha | Trainable Params | Test Acc. | Val–Test Gap |
|---|---|---|---|---|---|---|
| Q1 | q_proj | 16 | 32 | 5.2M (0.08%) | 78.38% | 12.18 pp |
| Q2 | q_proj | 8 | 16 | 2.6M (0.04%) | 77.17% | 13.39 pp |
| Q3 | all-linear | 16 | 32 | 46.8M (0.70%) | 80.40% | 9.97 pp |
| Q4 | all-linear | 64 | 128 | 183.0M (2.72%) | 83.16% | 8.14 pp |
| Config | Target Modules | Rank | Alpha | Trainable Params | Test Acc. | Val–Test Gap |
|---|---|---|---|---|---|---|
| D1 | q_proj | 16 | 32 | 5.4M (0.08%) | 81.03% | 10.64 pp |
| D2 | q_proj | 8 | 16 | 2.8M (0.04%) | 81.53% | 8.66 pp |
| D3 | all-linear | 16 | 32 | 48.4M (0.72%) | 81.23% | 9.33 pp |
| D4 | all-linear | 64 | 128 | 184.5M (2.75%) | 83.14% | 8.90 pp |
| Target | Rank | QLoRA Acc. | DoRA Acc. | QLoRA Time | DoRA Time | Ratio | |
|---|---|---|---|---|---|---|---|
| q_proj | 8 | 77.17% | 81.53% | +4.36 pp | 6h 32m | 11h 31m | 1.76 |
| q_proj | 16 | 78.38% | 81.03% | +2.65 pp | 7h 16m | 10h 27m | 1.44 |
| all-linear | 16 | 80.40% | 81.23% | +0.83 pp | 4h 43m | 11h 51m | 2.51 |
| all-linear | 64 | 83.16% | 83.14% | 0.02 pp | 5h 46m | 10h 59m | 1.90 |
| ResNet-18 | ViT-Small | DINOv3 (frozen) | QLoRA (best) | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Behavior | Support | P | R | F1 | P | R | F1 | P | R | F1 | P | R | F1 |
| Drinking | 3,011 | .35 | .69 | .47 | .24 | .62 | .35 | .44 | .71 | .54 | .42 | .79 | .55 |
| Eat. head down | 30,952 | .82 | .35 | .49 | .66 | .31 | .42 | .87 | .29 | .44 | .88 | .55 | .68 |
| Eat. head up | 18,783 | .60 | .43 | .50 | .46 | .43 | .45 | .51 | .55 | .53 | .75 | .58 | .66 |
| Lying | 83,509 | .94 | .98 | .96 | .89 | .87 | .88 | .96 | .99 | .97 | .99 | .99 | .99 |
| Standing | 69,807 | .79 | .70 | .74 | .74 | .52 | .61 | .78 | .78 | .78 | .79 | .85 | .82 |
| Method | Configuration | Train Time | Inference Time | Throughput | Latency |
|---|---|---|---|---|---|
| (img/s) | (ms/img) | ||||
| ResNet-18 | scratch | 16h 45m | 16,124.9s | 13.1 | 76.13 |
| ViT-Small | scratch | 18h 39m | 14,975.5s | 14.1 | 70.70 |
| DINOv3 | frozen | 17h 27m | 31,848.2s | 6.6 | 150.36 |
| QLoRA | q_proj, | 6h 32m | 34,264.3s | 6.2 | 161.77 |
| QLoRA | q_proj, | 7h 16m | 32,195.9s | 6.6 | 152.00 |
Appendix figures & tables17 assets
Supplementary material from the paper’s appendix.
Appendix
| Parameter | Q1 | Q2 | Q3 | Q4 |
|---|---|---|---|---|
| (q_proj, ) | (q_proj, ) | (all-linear, ) | (all-linear, ) | |
| Target modules | q_proj | q_proj | all-linear | all-linear |
| Rank ( ) | 16 | 8 | 16 | 64 |
| Alpha ( ) | 32 | 16 | 32 | 128 |
| LoRA dropout | 0.05 | 0.10 | 0.05 | 0.05 |
| Bias | none | none | none | none |
| Parameter | D1 | D2 | D3 | D4 |
|---|---|---|---|---|
| (q_proj, ) | (q_proj, ) | (all-linear, ) | (all-linear, ) | |
| Target modules | q_proj | q_proj | all-linear | all-linear |
| Rank ( ) | 16 | 8 | 16 | 64 |
| Alpha ( ) | 32 | 16 | 32 | 128 |
| use_dora | True | True | True | True |
| LoRA dropout | 0.05 | 0.05 | 0.05 | 0.05 |
| Parameter | ResNet-18 | ViT-Small | DINOv3 (frozen) |
|---|---|---|---|
| Architecture | ResNet-18 | ViT-Small (patch16) | DINOv3-ViT-Giant |
| Pre-trained weights | None | None | facebook/dinov3-vit7b16 |
| Total parameters | 11.2M | 21.7M | 6.7B |
| Trainable parameters | 11.2M (100%) | 21.7M (100%) | 4.7M (0.07%) |
| Feature dimension | 512 | 384 | 4096 |
| Classification head | Linear( ) | Linear( ) | MLP( ) |
| Q1 | Q2 | Q3 | Q4 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Behavior | Support | P | R | F1 | P | R | F1 | P | R | F1 | P | R | F1 |
| Drinking | 3,011 | .42 | .76 | .54 | .41 | .75 | .53 | .42 | .78 | .55 | .42 | .79 | .55 |
| Eat. h.d. | 30,952 | .87 | .38 | .53 | .86 | .35 | .50 | .88 | .48 | .62 | .88 | .55 | .68 |
| Eat. h.u. | 18,783 | .60 | .58 | .59 | .57 | .57 | .57 | .70 | .57 | .63 | .75 | .58 | .66 |
| Lying | 83,509 | .97 | .99 | .98 | .97 | .99 | .98 | .99 | .99 | .99 | .99 | .99 | .99 |
| Standing | 69,807 | .78 | .82 | .80 | .77 | .81 | .79 | .79 | .84 | .81 | .79 | .85 | .82 |
| D1 | D2 | D3 | D4 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Behavior | Support | P | R | F1 | P | R | F1 | P | R | F1 | P | R | F1 |
| Drinking | 3,011 | .43 | .77 | .55 | .43 | .77 | .55 | .43 | .77 | .55 | .43 | .77 | .55 |
| Eat. h.d. | 30,952 | .87 | .49 | .63 | .87 | .51 | .64 | .87 | .49 | .63 | .87 | .56 | .68 |
| Eat. h.u. | 18,783 | .72 | .57 | .64 | .74 | .56 | .64 | .73 | .56 | .63 | .77 | .56 | .65 |
| Lying | 83,509 | .98 | .99 | .99 | .98 | .99 | .99 | .98 | .99 | .99 | .98 | .99 | .99 |
| Standing | 69,807 | .78 | .84 | .81 | .79 | .84 | .81 | .78 | .84 | .81 | .77 | .86 | .81 |
| Category | Transform | Parameters | Probability |
| Geometric | HorizontalFlip | — | |
| Rotate | limit= | ||
| ShiftScaleRotate | shift=0.1, scale=(0.8, 1.2) | ||
| Perspective | scale=(0.05, 0.10) | ||
| Color (OneOf) | RandomBrightnessContrast | 0.2 | (group) |
| HueSaturationValue | hue=10, sat=20, val=20 |
| Behavior | Source | Train | Val | Test | Total |
|---|---|---|---|---|---|
| Drinking | MMCows | 240 | 60 | 3,011 | 3,311 |
| Eating head down | MMCows | 240 | 60 | 30,952 | 31,252 |
| Eating head up | MMCows | 240 | 60 | 18,783 | 19,083 |
| Lying | MMCows | 240 | 60 | 83,509 | 83,809 |
| Standing | MMCows | 240 | 60 | 69,807 | 70,107 |
| Walking | MMCows | 240 | 60 | 3,819 | 4,119 |
| Behavior | Test Samples | Percentage | Imbalance Ratio |
|---|---|---|---|
| Lying | 83,509 | 39.43% | 145.2 |
| Standing | 69,807 | 32.96% | 121.4 |
| Eating head down | 30,952 | 14.61% | 53.8 |
| Eating head up | 18,783 | 8.87% | 32.7 |
| Walking | 3,819 | 1.80% | 6.6 |
| Drinking | 3,011 | 1.42% | 5.2 |
| Layer | Input Dim | Output Dim | Activation | Dropout |
|---|---|---|---|---|
| Linear 1 | 4,096 | 1,024 | ReLU | 0.30 |
| Linear 2 | 1,024 | 512 | ReLU | 0.15 |
| Linear 3 (output) | 512 | 9 | — | — |
| Total parameters | 4,719,113 | |||
| Component | Specification |
|---|---|
| Hardware | |
| GPU | NVIDIA Tesla V100-PCIE-16GB |
| GPU Memory | 16 GB HBM2 |
| CPU | Intel Xeon (Azure Databricks) |
| System Memory | 56 GB |
| Software | |