---
title: "Comparing the Performance of LLMs: A Deep Dive into Roberta, Llama 2, and Mistral for Disaster Tweets Analysis with Lora"
description: "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."
url: "https://swe.quest/articles/comparing-the-performance-of-llms-a-deep-dive-into-roberta-llama-2-and-mistral-312ca793200aefd9"
canonical: "https://huggingface.co/blog/Lora-for-sequence-classification-with-Roberta-Llama-Mistral"
source: "Hugging Face"
published: "2023-11-07"
difficulty: "medium"
kind: "How-to"
reading_minutes: 15
tags: ["model-training","llms","python"]
---

# Comparing the Performance of LLMs: A Deep Dive into Roberta, Llama 2, and Mistral for Disaster Tweets Analysis with Lora

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2023-11-07, 15 min read, How-to. Original: [https://huggingface.co/blog/Lora-for-sequence-classification-with-Roberta-Llama-Mistral](https://huggingface.co/blog/Lora-for-sequence-classification-with-Roberta-Llama-Mistral)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Transformer language models
- PyTorch basics
- Hugging Face transformers

## Keywords

LoRA, PEFT, RoBERTa, Llama 2, Mistral 7B, Hugging Face Transformers, Weights & Biases

## Related posts

- [StackLLaMA: A hands-on guide to train LLaMA with RLHF](https://swe.quest/articles/stackllama-a-hands-on-guide-to-train-llama-with-rlhf-9d42cc2a0ae4620b.md): Hugging Face · 2023-04-05 · Hard · 14 min read · Model training, LLMs, Machine learning, Python
  A 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.
- [Welcome Llama 3 - Meta's new open LLM](https://swe.quest/articles/welcome-llama-3-meta-s-new-open-llm-76a74164d4c8a37c.md): Hugging Face · 2024-04-18 · Medium · 11 min read · LLMs, Inference & serving, Model training, Python
  Meta'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.
- [Make LLM Fine-tuning 2x faster with Unsloth and 🤗 TRL](https://swe.quest/articles/make-llm-fine-tuning-2x-faster-with-unsloth-and-trl-5db8c0b6a40cf74e.md): Hugging Face · 2024-01-10 · Medium · 5 min read · Model training, LLMs, Performance engineering, Python
  Unsloth speeds up QLoRA fine-tuning of Llama and Mistral-family models by rewriting PyTorch modules as Triton kernels with manually derived backpropagation.
- [Llama 2 is here - get it on Hugging Face](https://swe.quest/articles/llama-2-is-here-get-it-on-hugging-face-c56eec059476bd0f.md): Hugging Face · 2023-07-18 · Medium · 9 min read · LLMs, Inference & serving, Model training, Python
  Meta'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.
- [Productizing Large Language Models](https://swe.quest/articles/productizing-large-language-models-5be0923873af50a1.md): Replit · 2022-09-21 · Medium · 6 min read · Inference & serving, LLMs, AI for coding, Evaluation, Kubernetes
  Replit 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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
