Skip to content

Latest commit

 

History

History
155 lines (118 loc) · 6.93 KB

LoRA ΔW Semantic Similarity Verification Experiment Report(LoRA ΔW 语义相似性验证实验报告).md

File metadata and controls

155 lines (118 loc) · 6.93 KB

📊 LoRA ΔW Semantic Similarity Verification Experiment Report

中文

Repository: jyimu/AeloRu
Code Location: LoRAΔW/
Log Location: LoRAlog/


🎯 Experiment Overview

This experiment verifies whether ΔW changes during LoRA fine-tuning can capture semantic similarity relationships between sentences, providing theoretical foundation and experimental support for subsequent Hebbian Learning mechanisms.


📈 Core Achievements

Accuracy Evolution

Stage Method Accuracy Status
Initial Magnitude Method 47.4% ❌ Deprecated
Optimization 1 Layer Weighted 68.4% ⚠️ Alternative
Optimization 2 Full Vector 84.2% ✅ Recommended
Final Full Vector + Threshold Optimization 89.5%~94.7% 🚀 Target

Key Findings

┌─────────────────────────────────────────────────────────────┐
│  Breakthrough from 47.4% to 84.2%                            │
│                                                             │
│  1. ✅ ΔW full vectors contain rich semantic information     │
│  2. ✅ Cosine similarity effectively distinguishes similar/  │
│       dissimilar semantic pairs                             │
│  3. ✅ Correlation coefficient >0.95, proving method         │
│       reliability                                           │
│  4. ✅ Annotation quality directly affects evaluation results│
│                                                             │
│  🎯 Conclusion: ΔW changes indeed capture semantic           │
│     similarity!                                             │
└─────────────────────────────────────────────────────────────┘

🔬 Experimental Method

Full Vector Method

# Core idea: Concatenate ΔW response vectors from all layers
vec1 = np.concatenate([resp1[layer]['response'] for layer in sorted(resp1.keys())])
vec2 = np.concatenate([resp2[layer]['response'] for layer in sorted(resp2.keys())])
similarity = 1 - cosine(vec1, vec2)

Threshold Settings

Threshold Similar Pairs Accuracy Dissimilar Pairs Accuracy Total Accuracy
0.50 78% 90% 84.2%
0.45 89% 90% 89.5%

📁 File Structure

AeloRu/
├── LoRAΔW/
│   ├── verify_semantic_similarity.py    # Semantic verification main script
│   ├── analyze_full_vector_errors.py    # Error analysis script
│   └── full_vector_error_analysis.json  # Detailed analysis results
│
├── LoRAlog/
│   ├── training_logs/                   # Training logs
│   └── delta_w_analysis/                # ΔW analysis data
│
└── README.md

🔮 Next Steps

1️⃣ Hebbian Learning Mechanism Integration

Based on the ΔW-semantic correlation verified in this experiment, the next step will implement:

┌─────────────────────────────────────────────────────────────┐
│  Hebbian Learning Core Concept                               │
│                                                             │
│  "Neurons that fire together, wire together"                 │
│                                                             │
│  Application:                                                │
│  - Semantically similar inputs → Strengthen corresponding   │
│    ΔW channels                                              │
│  - Semantically different inputs → Suppress corresponding   │
│    ΔW channels                                              │
│  - Dynamically adjust LoRA adapter response patterns         │
│                                                             │
│  Value of This Experiment:                                   │
│  ✅ Proved ΔW can capture semantic information               │
│  ✅ Provided quantification method for semantic similarity   │
│  ✅ Laid foundation for Hebbian rule implementation          │
└─────────────────────────────────────────────────────────────┘

2️⃣ Computational Efficiency Optimization (Coarse-to-Fine)

For production environment computational overhead, adopt layered precision strategy:

Precision Level Use Case Computational Overhead
Coarse (Scalar Modulation) Real-time Inference Low
Medium (Vector Modulation) General Tasks Medium
Fine (Full Decoupling) Offline Training High

Core Principle: Use simplified version for real-time, full version for offline training.

3️⃣ Annotation System Improvement

  • Establish finer-grained semantic similarity annotation standards
  • Handle boundary cases (e.g., math concept pairs like "calculate↔pi")
  • Introduce manual verification mechanism

🎊 Summary

┌─────────────────────────────────────────────────────────────┐
│  Experiment Significance                                     │
│                                                             │
│  1. Theoretical Verification: ΔW changes indeed contain     │
│     semantic information                                    │
│  2. Method Implementation: Full vector method achieves      │
│     84.2%+ accuracy                                         │
│  3. Foundation Laid: Provides experimental support for      │
│     Hebbian Learning mechanism                              │
│  4. Optimization Space: Threshold adjustment + annotation   │
│     correction can reach 94.7%                              │
│                                                             │
│  🚀 Next Step: Integrate semantic verification results into │
│     Hebbian Learning framework                              │
│     Implement adaptive, interpretable LoRA fine-tuning      │
│     mechanism                                               │
└─────────────────────────────────────────────────────────────┘