Meta’s Llama 3.1 model is used for a variety of use cases, including question-answering, text generation, code generation, story writing, and much more. One use case also involves solving math word problems, but the model usually provides solutions in natural language rather than pure math expressions. We want to fine-tune the Llama 3.1 model to provide solutions to word problems in mathematical expressions.

We will use the openai/gsm8k dataset from Hugging Face for fine-tuning. GSM8K (Grade School Math 8K) is a dataset of 8.5K grade-school math word problems involving multi-step reasoning along with their solutions in pure maths expressions.

Let’s begin with the journey of fine-tuning Meta’s Llama 3.1 model on openai/gsm8k dataset using LoRA.

Install the dependencies

First, let’s install the libraries required for fine-tuning. We'll be installing the latest versions (at the time of writing) of the libraries.

Get hands-on with 1200+ tech skills courses.