Coder Social home page Coder Social logo

llm-earlyexit's Introduction

LLM Early Exit

An Early Exit strategy Analysis for LLMs

Usage

You can install the required dependencies with the following command:

conda env create -f environment.yml

Then activate the environment:

conda activate torch-main

Early Layer Visualization

run and follow the cells in the vis.ipynb file.

an Example visualization of the probability distribution of a wrong answer is:

  • Question: How many whiskers does a human have?
  • Correct Answer None
  • Model Generation: Two

An Example of Eatly Layer Distributions

Entropy Visualization

The entropy of layers based on correct and wrong answers on the TruthfulQA dataset shows potential bias (low entropy) in early layers.

The code can be found in the Entropy.ipynb file. Entropy Comparison

MLP Fact Detection

We train simple MLPs on the inner layer logits on the true-false dataset in the 'classifier.ipynb` file to try to detect unfactual generations.

Here are some results:

Experiment Train Loss Train Acc Test Acc
LM Next Token - 0.0 0.0
LM Token Prob. 0.50 0.53
MLP tap at layer 16 0.6228 0.56 0.65
MLP tap at layer 20 0.6283 0.56 0.63
MLP tap at layer 24 0.6263 0.55 0.61
MLP majority - 0.56 0.63

A Potential Solution

We use the DoLa decoding Method to generate new answers. Although the new generations seem better to humans. These automated metrics below seem to not agree. More information can be found at the Original DoLa Repository.

BLEU ROUGE BERTScore
Vanilla Decoding 0.244445 0.409804 0.900487
Dynamic-DOLA 0.16386 0.347001 0.891913

llm-earlyexit's People

Contributors

indirected avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.