NEFTune  by neelsjain

Technique to improve instruction finetuning of LLMs

created 1 year ago
397 stars

Top 73.8% on sourcepulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

NEFTune introduces a simple yet effective method to enhance instruction fine-tuning for Large Language Models (LLMs) by adding random noise to embedding vectors during training. This technique, aimed at researchers and practitioners working with LLMs, significantly improves conversational quality and instruction-following capabilities without requiring additional compute or data.

How It Works

NEFTune injects noise into the embedding layer's output during the forward pass of fine-tuning. By adding uniformly distributed noise scaled by a factor noise_alpha, the method perturbs the embedding space. This perturbation is hypothesized to improve generalization and robustness, leading to substantial gains in downstream conversational tasks, as demonstrated by a significant jump in AlpacaEval performance. The noise is only applied during training, ensuring standard behavior during inference.

Quick Start & Requirements

  • Install: Integration is available in Huggingface's TRL and Ludwig.ai. For direct use, a custom forward pass for the embedding layer is required, as shown in the provided LLaMA example.
  • Dependencies: PyTorch, Huggingface libraries (TRL, Transformers), Ludwig.ai.
  • Resources: No specific hardware requirements beyond standard LLM fine-tuning setups are mentioned, but performance gains are demonstrated on LLaMA-2-7B.

Highlighted Details

  • Achieves a performance boost from 29.8% to 64.7% on AlpacaEval for LLaMA-2-7B fine-tuned with the Alpaca dataset.
  • Offers a "free lunch" for LLM fine-tuning, with no additional compute or data overhead.
  • Maintains performance on factual question-answering baselines while improving conversational quality.
  • The underlying mechanism of why NEFTune works is still under investigation.

Maintenance & Community

The project has seen integration into major libraries like Huggingface TRL and Ludwig.ai, indicating active development and adoption. Direct contact information for the author is available in the linked paper for feedback and inquiries.

Licensing & Compatibility

The repository does not explicitly state a license. However, its integration into Huggingface and Ludwig suggests a permissive approach, but users should verify licensing for commercial or closed-source applications.

Limitations & Caveats

The study's findings are primarily based on AlpacaEval, which relies on a single judge (GPT-4) and may have biases. Validation on larger LLM variants (70B+) and diverse datasets was limited due to computational constraints. The exact mechanism behind NEFTune's effectiveness remains an open research question.

Health Check
Last commit

1 year ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
2 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.