DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to serve several task adapters from one base model with Peft

Save one small adapter per task and load or switch between them on a single base model.

Short answer: Load a trained adapter for inference with PeftModel.from_pretrained on top of the base model; then with a Transformers model, add adapters with add_adapter and load trained ones with load_adapter; Switch between them with set_adapter, for example to lora_2. All steps.

Who it is forA team with separate fine-tunes for support replies, summaries and tagging who cannot host three full models.

The problemKeeping a full copy of a model for every task wastes storage and GPU memory.

The outcomeOne base model in memory with small adapters you load and switch per request.

What you need first

  • Python with PyTorch and Transformers
  • A GPU with enough memory for the base model (the README shows a 3B model on far less memory with LoRA)
  • A dataset for your task

Steps

  1. Load a trained adapter for inference with PeftModel.from_pretrained on top of the base model
  2. With a Transformers model, add adapters with add_adapter and load trained ones with load_adapter
  3. Switch between them with set_adapter, for example to lora_2
  4. Keep each adapter as its own small checkpoint per task or dataset

Prompt for your agent

Using huggingface/peft, load base model <model> once and attach adapters <adapter A> and <adapter B> with load_adapter. Write a function that switches adapters with set_adapter per request and test each on <prompt>.

Caveat. The Transformers integration does not include every PEFT feature, such as merging the adapter into the base model.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for huggingface/peft and "Serve several task adapters from one base model"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer