Update README.md
Browse files
README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
license: mit
|
| 3 |
---
|
| 4 |
---
|
|
|
|
| 5 |
language:
|
| 6 |
- en
|
| 7 |
tags:
|
|
@@ -11,20 +12,24 @@ tags:
|
|
| 11 |
- peft
|
| 12 |
- dpo
|
| 13 |
- reinforcement-learning
|
|
|
|
| 14 |
license: apache-2.0
|
| 15 |
datasets:
|
| 16 |
-
-
|
| 17 |
metrics:
|
| 18 |
- dpo-loss
|
|
|
|
|
|
|
|
|
|
| 19 |
library_name: unsloth
|
| 20 |
library_version: 0.5.0
|
| 21 |
base_model: meta-llama/Llama-2-7b
|
| 22 |
pipeline_tag: text-generation
|
| 23 |
---
|
| 24 |
|
| 25 |
-
# LoRA DPO LLaMa-7B
|
| 26 |
|
| 27 |
-
This repository contains LoRA (Low-Rank Adaptation) parameters for a fine-tuned version of LLaMa-7B using Direct Preference Optimization (DPO). The model is trained to better align with
|
| 28 |
|
| 29 |
## Model Details
|
| 30 |
|
|
@@ -32,11 +37,28 @@ This repository contains LoRA (Low-Rank Adaptation) parameters for a fine-tuned
|
|
| 32 |
- **Training Method**: Direct Preference Optimization (DPO)
|
| 33 |
- **LoRA Parameters**:
|
| 34 |
- Rank (r): 16
|
| 35 |
-
- Alpha: 16
|
| 36 |
- Target Modules: `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `down_proj`, `up_proj`
|
| 37 |
- **Training Framework**: Unsloth + TRL
|
| 38 |
- **Training Precision**: 4-bit Quantization
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
## Usage
|
| 41 |
|
| 42 |
To use this model, you'll need to load both the base model and the LoRA adapter:
|
|
@@ -86,33 +108,82 @@ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
|
| 86 |
|
| 87 |
## Training Dataset
|
| 88 |
|
| 89 |
-
The model was trained on
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
## Training Procedure
|
| 92 |
|
| 93 |
-
The model was trained using the DPO method which directly optimizes a language model to align with
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
-
|
|
|
|
|
|
|
| 96 |
- Learning rate: 1e-5
|
| 97 |
- Number of epochs: 3
|
| 98 |
- DPO beta: 0.1
|
| 99 |
-
- Loss type:
|
| 100 |
- Max sequence length: 2048
|
| 101 |
|
| 102 |
## Evaluation Results
|
| 103 |
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
## Limitations and Biases
|
| 110 |
|
| 111 |
This model inherits the limitations and biases from the base LLaMa model. Additionally:
|
| 112 |
|
| 113 |
-
- It's optimized for
|
| 114 |
-
- Performance
|
| 115 |
- The LoRA adaptation affects specific parameter matrices and may not fully transform the base model's capabilities
|
|
|
|
|
|
|
| 116 |
|
| 117 |
## Ethical Considerations
|
| 118 |
|
|
@@ -142,4 +213,4 @@ When using this model, consider:
|
|
| 142 |
archivePrefix={arXiv},
|
| 143 |
primaryClass={cs.CL}
|
| 144 |
}
|
| 145 |
-
```
|
|
|
|
| 2 |
license: mit
|
| 3 |
---
|
| 4 |
---
|
| 5 |
+
---
|
| 6 |
language:
|
| 7 |
- en
|
| 8 |
tags:
|
|
|
|
| 12 |
- peft
|
| 13 |
- dpo
|
| 14 |
- reinforcement-learning
|
| 15 |
+
- autonomous-driving
|
| 16 |
license: apache-2.0
|
| 17 |
datasets:
|
| 18 |
+
- prefdrive-preference-dataset
|
| 19 |
metrics:
|
| 20 |
- dpo-loss
|
| 21 |
+
- route-completion
|
| 22 |
+
- traffic-light-violations
|
| 23 |
+
- layout-collisions
|
| 24 |
library_name: unsloth
|
| 25 |
library_version: 0.5.0
|
| 26 |
base_model: meta-llama/Llama-2-7b
|
| 27 |
pipeline_tag: text-generation
|
| 28 |
---
|
| 29 |
|
| 30 |
+
# PrefDrive: LoRA DPO LLaMa-7B for Autonomous Driving
|
| 31 |
|
| 32 |
+
This repository contains LoRA (Low-Rank Adaptation) parameters for a fine-tuned version of LLaMa-7B using Direct Preference Optimization (DPO). The model is trained to better align with specific driving behaviors and operational requirements through preference learning, significantly improving autonomous driving performance.
|
| 33 |
|
| 34 |
## Model Details
|
| 35 |
|
|
|
|
| 37 |
- **Training Method**: Direct Preference Optimization (DPO)
|
| 38 |
- **LoRA Parameters**:
|
| 39 |
- Rank (r): 16
|
| 40 |
+
- Alpha (α): 16
|
| 41 |
- Target Modules: `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `down_proj`, `up_proj`
|
| 42 |
- **Training Framework**: Unsloth + TRL
|
| 43 |
- **Training Precision**: 4-bit Quantization
|
| 44 |
|
| 45 |
+
### Training Configuration
|
| 46 |
+
|
| 47 |
+
| Parameter | Value |
|
| 48 |
+
|-----------|-------|
|
| 49 |
+
| Base Model | LLaMA2-7B |
|
| 50 |
+
| Training Strategy | LoRA |
|
| 51 |
+
| Learning Rate | 1e-5 |
|
| 52 |
+
| Batch Size | 4 |
|
| 53 |
+
| Gradient Accumulation Steps | 2 |
|
| 54 |
+
| Training Epochs | 3 |
|
| 55 |
+
| Maximum Sequence Length | 2,048 |
|
| 56 |
+
| Warmup Ratio | 0.1 |
|
| 57 |
+
| Max Gradient Norm | 0.3 |
|
| 58 |
+
| DPO Beta (β) | 0.1 |
|
| 59 |
+
| Loss Type | Sigmoid |
|
| 60 |
+
| Training Data | Chosen & Rejected action pairs |
|
| 61 |
+
|
| 62 |
## Usage
|
| 63 |
|
| 64 |
To use this model, you'll need to load both the base model and the LoRA adapter:
|
|
|
|
| 108 |
|
| 109 |
## Training Dataset
|
| 110 |
|
| 111 |
+
The model was trained on the PrefDrive dataset, a comprehensive collection of 74,040 driving sequences carefully annotated with driving preferences and driving decisions. Each entry in the dataset consists of:
|
| 112 |
+
|
| 113 |
+
- A driving scenario description (s)
|
| 114 |
+
- A preferred/chosen driving action with its reasoning and resulting waypoint (a_p)
|
| 115 |
+
- A rejected driving action with its reasoning and resulting waypoint (a_r)
|
| 116 |
+
|
| 117 |
+
This dataset captures various autonomous driving scenarios with emphasis on proper distance maintenance, trajectory smoothness, traffic rule compliance, and route adherence.
|
| 118 |
|
| 119 |
## Training Procedure
|
| 120 |
|
| 121 |
+
The model was trained using the DPO method which directly optimizes a language model to align with driving preferences without requiring a reward model. The training process uses pairwise comparisons between preferred and rejected driving actions to update model parameters.
|
| 122 |
+
|
| 123 |
+
### Methodology
|
| 124 |
+
|
| 125 |
+
The PrefDrive methodology for autonomous driving is formulated as:
|
| 126 |
+
|
| 127 |
+
$\mathcal{L}_{DPO} = -\mathbb{E}_{(s,a_p,a_r)\sim\mathcal{D}}\Big[\log\sigma\Big(\beta\log\frac{\pi_\theta(a_p|s)}{\pi_{ref}(a_p|s)} - \beta\log\frac{\pi_\theta(a_r|s)}{\pi_{ref}(a_r|s)}\Big)\Big]$
|
| 128 |
+
|
| 129 |
+
where:
|
| 130 |
+
- $\mathcal{D}$ represents our driving preference dataset
|
| 131 |
+
- $s$ denotes the current driving scenario description
|
| 132 |
+
- $a_p$ represents the preferred (chosen) driving action with its reasoning and resulting waypoint
|
| 133 |
+
- $a_r$ represents the rejected driving action with its reasoning and resulting waypoint
|
| 134 |
+
- $\pi_\theta$ is the policy model being trained
|
| 135 |
+
- $\pi_{ref}$ is the initial reference model
|
| 136 |
+
- $\beta$ controls the preference learning sensitivity (set to 0.1)
|
| 137 |
+
- $\sigma$ represents the sigmoid function
|
| 138 |
|
| 139 |
+
This formulation explicitly shows how our model learns to favor chosen driving actions over rejected ones while maintaining reasonable deviation from the reference model's behavior.
|
| 140 |
+
|
| 141 |
+
### Key Training Parameters
|
| 142 |
- Learning rate: 1e-5
|
| 143 |
- Number of epochs: 3
|
| 144 |
- DPO beta: 0.1
|
| 145 |
+
- Loss type: Sigmoid
|
| 146 |
- Max sequence length: 2048
|
| 147 |
|
| 148 |
## Evaluation Results
|
| 149 |
|
| 150 |
+
The model was evaluated in the CARLA simulator across different town environments. Here are the performance metrics:
|
| 151 |
+
|
| 152 |
+
### Town 01 Performance
|
| 153 |
+
|
| 154 |
+
| Metric | LMDrive (baseline) | PrefDrive (Ours) | Improvement |
|
| 155 |
+
|--------|-------------------|-----------------|-------------|
|
| 156 |
+
| Composite Score | 53.00 | 56.12 | +5.9% |
|
| 157 |
+
| Penalty Score | 0.86 | 0.88 | +1.5% |
|
| 158 |
+
| Route Completion | 59.10 | 64.15 | +8.5% |
|
| 159 |
+
| Layout Collisions | 0.73 | 0.27 | -63.5% |
|
| 160 |
+
| Traffic Light Violations | 0.22 | 0.16 | -28.1% |
|
| 161 |
+
| Route Deviation | 1.32 | 1.36 | +3.0% |
|
| 162 |
+
| Vehicle Blocked | 0.11 | 0.00 | -100.0% |
|
| 163 |
+
|
| 164 |
+
### Town 04 Performance
|
| 165 |
+
|
| 166 |
+
| Metric | LMDrive (baseline) | PrefDrive (Ours) | Improvement |
|
| 167 |
+
|--------|-------------------|-----------------|-------------|
|
| 168 |
+
| Composite Score | 60.11 | 65.93 | +9.7% |
|
| 169 |
+
| Penalty Score | 0.93 | 0.96 | +3.2% |
|
| 170 |
+
| Route Completion | 65.25 | 69.93 | +7.2% |
|
| 171 |
+
| Layout Collisions | 0.00 | 0.00 | 0.0% |
|
| 172 |
+
| Traffic Light Violations | 0.24 | 0.00 | -100.0% |
|
| 173 |
+
| Route Deviation | 1.86 | 1.77 | -4.8% |
|
| 174 |
+
| Vehicle Blocked | 0.00 | 0.00 | 0.0% |
|
| 175 |
+
|
| 176 |
+
The results demonstrate significant improvements in crucial metrics, particularly in reducing traffic light violations and layout collisions while improving route completion.
|
| 177 |
|
| 178 |
## Limitations and Biases
|
| 179 |
|
| 180 |
This model inherits the limitations and biases from the base LLaMa model. Additionally:
|
| 181 |
|
| 182 |
+
- It's optimized specifically for autonomous driving tasks and may not perform well in unrelated domains
|
| 183 |
+
- Performance may vary in driving environments that differ significantly from the training data
|
| 184 |
- The LoRA adaptation affects specific parameter matrices and may not fully transform the base model's capabilities
|
| 185 |
+
- While the model shows improved performance in simulated environments (CARLA), its behavior in real-world driving scenarios would require further validation and safety testing
|
| 186 |
+
- The model is designed to work with a specific autonomous driving stack and may require adaptation for different setups
|
| 187 |
|
| 188 |
## Ethical Considerations
|
| 189 |
|
|
|
|
| 213 |
archivePrefix={arXiv},
|
| 214 |
primaryClass={cs.CL}
|
| 215 |
}
|
| 216 |
+
```
|