Timm ❤️ Transformers: Use any timm model with transformers
TimmWrapper lets any timm vision model load through Hugging Face transformers' Auto classes and pipeline API. That makes architectures with no native transformers implementation, like MobileNetV4, usable with the standard tooling. Code examples cover pipeline inference, a Gradio demo, 8-bit quantization with bitsandbytes (346 MB to 88 MB, about 75% smaller, with near-identical predictions), Trainer-based fine-tuning and LoRA via PEFT (0.77% of parameters trainable), and torch.compile benchmarking. Fine-tuned models round-trip back into timm via the Hub with timm.create_model.
Related posts
- Quanto: a PyTorch quantization backend for Optimum
Hugging Face mediumAdeptQuanto is a PyTorch quantization backend for Optimum that works in eager mode on any device (CPU, CUDA, MPS), supports int2/int4/int8/float8 weights and int8/float8 activations, and accelerates int8-int8, fp16-int4, bf16-int8 and bf16-int4 matmuls on CUDA. The workflow runs from dynamic quantization through optional activation calibration and quantization-aware training to freezing integer weights, then serializing with safetensors plus a quantization map for reloading via requantize. It integrates with transformers through QuantoConfig, works across modalities such as Whisper, and is torch.compile-friendly when activations are left unquantized.
- Accelerate your models with 🤗 Optimum Intel and OpenVINO
Hugging Face mediumAdeptOptimum Intel now integrates OpenVINO, letting Transformers models run on OpenVINO Runtime across Intel processors and be quantized with the Neural Network Compression Framework (NNCF). A walkthrough applies post-training static quantization to a ViT image classifier fine-tuned on food101, using 300 calibration samples, then exports to OpenVINO IR and loads the result via OVModelForImageClassification pipelines. The quantized model shrinks 3.8x (344MB to 90MB) and cuts per-sample latency 2.4x (98ms to 41ms) with no measurable accuracy loss (87.6). Warm up the model before benchmarking, because compilation happens on the first inference. Encoder-decoder quantization is not yet supported.
- Gemma 3n fully available in the open-source ecosystem!
Hugging Face mediumAdeptGemma 3n, Google's natively multimodal on-device model accepting text, image, audio and video, now runs in transformers, timm, MLX, llama.cpp (text only), Transformers.js/ONNX and Ollama. The E2B and E4B variants have 5B and 8B real parameters but need only about 2GB and 3GB of GPU memory. Per-Layer Embeddings offload embeddings to the CPU, and a nested MatFormer design trains E2B as a sub-model of E4B so layers can be mixed and matched to a memory budget. Vision uses a new MobileNet-V5-300 encoder, audio uses a USM-based encoder over 160ms chunks, and code snippets plus free Colab notebooks cover inference and fine-tuning.
- Total noob’s intro to Hugging Face Transformers
Hugging Face easyNoviceA beginner-oriented walkthrough of running Microsoft's Phi-2 language model with the Hugging Face Transformers library inside a JupyterLab notebook hosted on a Hugging Face Space with an NVIDIA A10G GPU. It explains foundational concepts along the way (libraries, the Hub, Spaces, classes, methods, tokenizers, instruction-tuned vs base models) and shows the minimal code: install torch and transformers, load the model and tokenizer with from_pretrained, tokenize a prompt, call generate with max_new_tokens, and decode the output. Because Phi-2 is a base model, its output reads like autocomplete rather than a chat reply.
- Parameter-Efficient Fine-Tuning using 🤗 PEFT
Hugging Face mediumAdeptHugging Face's PEFT library brings parameter-efficient fine-tuning methods (LoRA, Prefix Tuning, Prompt Tuning, P-Tuning) to Transformers and Accelerate. Most pretrained weights stay frozen and only a small set of extra parameters is trained, which gives performance comparable to full fine-tuning at a fraction of the compute and storage cost. A LoRA config on mt0-large trains about 0.19% of the parameters, and the saved adapters are only a few MB (19MB for T0_3B) instead of 40GB per-task checkpoints. Example use cases include tuning T0_3B on 11GB consumer GPUs with DeepSpeed offload, INT8 tuning of OPT-6.7b in Colab with bitsandbytes, and Stable Diffusion Dreambooth, plus code for training, saving and loading adapters.