Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Low-Rank Adapters injection into base models #312

Open
bilelomrani1 opened this issue Aug 28, 2023 · 3 comments
Open

Add Low-Rank Adapters injection into base models #312

bilelomrani1 opened this issue Aug 28, 2023 · 3 comments
Labels
feat/training Feature: Training/Fine-tuning type/feature Type: Feature
Milestone

Comments

@bilelomrani1
Copy link

bilelomrani1 commented Aug 28, 2023

Low-Rank Adaptation (LoRA) has become the de-facto parameter-efficient finetuning technique to adapt a base language model to a specific task. curated-transformers already supports dynamic quantization using bitsandbytes, hence adding some utilities to inject trainable adapters opens the door to using curated-transformers as a replacement to the HuggingFace transformers + peft stack. This could also enable a very nice finetuning integration into spaCy in the future.

For reference, I find this implementation in lit-gpt really readable.

Do you find this idea interesting?

If so, as for the user-facing API, drawing inspiration from HuggingFace peft it could look something like

# Load and quantize the base model
model = AutoGenerator.from_hf_hub(
    name="meta-llama/Llama-2-7b-chat-hf",
    device=torch.device("cuda", index=0),
    quantization_config=BitsAndBytesConfig.for_4bit(
        quantization_dtype=Dtype4Bit.FP4,
        compute_dtype=torch.bfloat16,
        double_quantization=True,
    ),
)

# Replace targeted linear layers by `LoRALayer` that wrap the original weights
model_with_adapters = inject_adapters(
    base_model=model,
    lora_config=LoraConfig(
        rank=64,
        alpha=16,
        dropout=0.1,
        bias=LoraBias.NONE,
        target_modules=[...]
    ),
)
@shadeMe
Copy link
Collaborator

shadeMe commented Aug 28, 2023

Thanks for the suggestion! Fine-tuning (and LoRA support) is already on our roadmap - We'll definitely be looking into this.

@shadeMe shadeMe added type/feature Type: Feature feat/training Feature: Training/Fine-tuning and removed type/feature Type: Feature labels Aug 28, 2023
@bilelomrani1
Copy link
Author

Thank you, that's great! Out of curiosity, is your roadmap public and visible somewhere?

@shadeMe
Copy link
Collaborator

shadeMe commented Aug 28, 2023

It's not publicly available at the moment.

@shadeMe shadeMe added the type/feature Type: Feature label Aug 28, 2023
@shadeMe shadeMe added this to the Undecided milestone Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat/training Feature: Training/Fine-tuning type/feature Type: Feature
Projects
None yet
Development

No branches or pull requests

2 participants