S
Beginner30 min

Getting Started with LLaMA 3

Learn how to set up and run LLaMA 3 models locally on your machine

Last updated: 2025-01-15

Prerequisites

  • Basic Python knowledge
  • GPU with 8GB+ VRAM
  • Linux or macOS

1. Install Dependencies

First, install the required Python packages and dependencies.

pip install transformers torch accelerate

2. Download the Model

Download LLaMA 3 from Hugging Face.

from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("meta-llama/Meta-Llama-3-8B")
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B")

3. Run Inference

Generate text using the model.

inputs = tokenizer("Hello, how are you?", return_tensors="pt")
outputs = model.generate(**inputs, max_length=100)
print(tokenizer.decode(outputs[0]))

Next Steps

Continue your learning journey with these related tutorials: