Comparing the Performance of LLMs: A Deep Dive into Roberta, Llama 2, and Mistral for Disaster Tweets Analysis with Lora
RoBERTa-large (355M parameters), Mistral-7B and Llama-2-7B are fine-tuned with LoRA for binary classification of disaster tweets on a single 48GB A6000 GPU, using Hugging Face transformers, peft and datasets, with Weights & Biases for hyperparameter sweeps. The walkthrough covers the full pipeline: splitting and tokenizing the dataset, setting pad tokens to EOS for the decoder models, and computing class weights for a weighted-loss custom Trainer. It also covers LoRA configuration for each model. With rank 2 and alpha 16, LoRA trains only about 0.64% of RoBERTa's parameters.
Related posts
- StackLLaMA: A hands-on guide to train LLaMA with RLHF
Hugging Face hardMasterA 7B LLaMA model is trained to answer Stack Exchange questions with the full RLHF pipeline: supervised fine-tuning on packed Stack Exchange text, a pairwise reward model trained on upvote-derived preference scores, and PPO with a KL penalty against a frozen reference model. Memory is kept manageable by loading the model in 8-bit and training only LoRA adapters via peft, which needs roughly 1.2-1.4GB per billion parameters. The same frozen base serves as both policy and reference model, and data parallelism through accelerate or torchrun speeds up training. The reward model reaches 67% accuracy, and the RL run takes about 20 hours on 24 A100s. The post closes with practical notes on reward hacking and training instabilities.
- Welcome Llama 3 - Meta's new open LLM
Hugging Face mediumAdeptMeta's Llama 3 ships in 8B and 70B sizes, each with base and instruct variants, plus Llama Guard 2, a safety classifier fine-tuned on Llama 3 8B. Key changes from Llama 2 are a 128K-token vocabulary that encodes text more efficiently but enlarges the embedding matrices, Grouped-Query Attention in the 8B model, an 8K context, and pretraining on 15T tokens. Instruct tuning combined SFT, rejection sampling, PPO and DPO. The post gives the instruct prompt format, Transformers 4.40 usage with bf16 or 4-bit loading (about 16 GB vs 7 GB), deployment via TGI, Vertex AI or SageMaker, and a QLoRA fine-tune with the TRL CLI that takes about 4 hours on a single A10G.
- Make LLM Fine-tuning 2x faster with Unsloth and 🤗 TRL
Hugging Face mediumAdeptUnsloth speeds up QLoRA fine-tuning of Llama and Mistral-family models by rewriting PyTorch modules as Triton kernels with manually derived backpropagation. Because no approximations are made, it claims 0% accuracy loss relative to standard QLoRA. Across 59 benchmark runs on A100 and T4 GPUs, it ran 1.5–3.9x faster than Hugging Face transformers and used up to 74% less VRAM. Code examples show loading pre-quantized 4-bit models with FastLanguageModel, attaching LoRA adapters, and training with TRL's SFTTrainer or DPOTrainer.
- Llama 2 is here - get it on Hugging Face
Hugging Face mediumAdeptMeta's Llama 2 family (7B, 13B, 70B base and RLHF-tuned chat models) is released under a commercially usable license, trained on 40% more tokens than Llama 1 with 4k context and grouped-query attention for the 70B model, and is integrated across the Hugging Face ecosystem. Inference runs through transformers 4.31 or Text Generation Inference and Inference Endpoints, with recommended GPU sizes per model (A10G for 7B, A100 for 13B, 2-4x A100 for 70B). The 7B model can be fine-tuned on a single 16GB T4 using QLoRA and trl's SFTTrainer. The chat prompt format uses [INST] and <<SYS>> delimiters, and prompts must match the training template exactly for system prompts and multi-turn conversations to work.
- Productizing Large Language Models
Replit mediumAdeptReplit runs transformer models from ~100M parameters (search, spam) through 1-10B (GhostWriter code autocomplete) to 100B+ in production, and shares lessons on making them usable. Nonsense and repetition loops are handled with temperature and frequency penalty tuning, cycle detection, multi-temperature sampling, reranking with a second model, and fine-tuning on user feedback. Quality is tracked with HumanEval, loop and nonsense rates, and A/B tests. Inference cost is cut with FasterTransformer, distillation and quantization, and GPUs are run at 70-80% utilization on Kubernetes so request queues stay bounded while autoscaling has headroom.