GenAI – What Is Adapters In LLM ?

Table Of Contents:

  1. What Is An Adapter ?
  2. Why To Use Adapters ?
  3. How Adapters Works ?
  4. Why Use Adapters ?

(1) What Is An Adapter ?

(2) Why To Use Adapter ?

(3) How Adapter Works ?

(4) Why Use Adapters ?

(5) List Of Adapters Available ?

(6) List Of Adapters Methods Available ?

  1. Bottleneck Adapters.
  2. Language Adapters – Invertible Adapters.
  3. Prefix Tuning.
  4. Compacter.
  5. LoRA.
  6. IA3.
  7. Vera.
  8. Prompt Tuning.
  9. ReFT.

(7) Example with Hugging Face’s PEFT (LoRA Adapters)

from transformers import AutoModelForCausalLM
from peft import get_peft_model, LoraConfig

model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-hf")

lora_config = LoraConfig(
    r=8,
    lora_alpha=16,
    target_modules=["q_proj", "v_proj"],
    lora_dropout=0.1,
    task_type="CAUSAL_LM"
)

model = get_peft_model(model, lora_config)

(8) Summary

Leave a Reply

Your email address will not be published. Required fields are marked *