Text Generation
PEFT
Safetensors
English
llama
math
code
lora
adapter
autoscientist
adaption
conversational
Instructions to use flamiinngo/adaption_math_word_problems_solutions with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use flamiinngo/adaption_math_word_problems_solutions with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("togethercomputer/Meta-Llama-3.3-70B-Instruct-Reference") model = PeftModel.from_pretrained(base_model, "flamiinngo/adaption_math_word_problems_solutions") - Notebooks
- Google Colab
- Kaggle
File size: 5,176 Bytes
fadcd3a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | ---
license: llama3.3
base_model: meta-llama/Llama-3.3-70B-Instruct
datasets:
- flamiinngo/math-code-qa-v2
tags:
- math
- code
- lora
- peft
- adapter
- autoscientist
- adaption
language:
- en
pipeline_tag: text-generation
library_name: peft
---
# Math & Code β Llama-3.3-70B LoRA
A LoRA adapter for **Llama-3.3-70B-Instruct**, fine-tuned to solve mathematical
problems β arithmetic word problems through algebra, geometry and combinatorics β
and answer short coding questions.
Trained with **Adaption Labs' AutoScientist** for the AutoScientist Challenge
(Math & Code category).
## Result
| Evaluation | Base | Adapted |
|---|---|---|
| Math category | 28 | **72** |
| In-distribution test set | 52 | 48 |
Wins in a paired comparison, not accuracy percentages.
The rows disagree, which is worth explaining. On the narrow in-distribution set a
judge slightly prefers the base model's phrasing. Across the wider category β
including problems well outside the training distribution β the adapted model wins
decisively. The mathematical substance generalised further than the answer style.
## What produced the 12-point gain
An earlier version of this model scored **60β28** on the same category evaluation.
The difference was a single filter in the training data.
v1 capped every solution at 18β75 words. In the upstream corpus, MATH-level
solutions have a **median length of 121β156 words**, while grade-school word
problems sit at 89β101. The cap therefore kept only the shortest, easiest examples
from the hard sources β the model trained almost entirely on arithmetic and was
then evaluated across the full difficulty range.
Setting the word budget per source (30β150 for algebra and geometry, 18β80 for
word problems) raised solution p90 from 77 words to 133, and the category win rate
from 60 to 72.
## Usage
The adapter is stored unpacked and loads directly.
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
BASE = "meta-llama/Llama-3.3-70B-Instruct"
ADAPTER = "flamiinngo/adaption_math_word_problems_solutions"
tokenizer = AutoTokenizer.from_pretrained(BASE)
model = AutoModelForCausalLM.from_pretrained(
BASE, torch_dtype=torch.bfloat16, device_map="auto"
)
model = PeftModel.from_pretrained(model, ADAPTER)
model.eval()
messages = [{"role": "user", "content":
"Mrs Thompson has 7 Harry Potter books, 6 Twilight books and 5 Hunger Games "
"books. Each series must stay together on the shelf. How many orderings are "
"there?"}]
inputs = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
out = model.generate(inputs, max_new_tokens=400, do_sample=False)
print(tokenizer.decode(out[0][inputs.shape[-1]:], skip_special_tokens=True))
```
**Hardware:** the 70B base needs roughly 140 GB in bf16, or about 40 GB with 4-bit
quantisation. The adapter is 3.3 GB.
**Output style:** brief worked steps, then the result stated explicitly as
"The answer is X."
**Note on the base model name.** `adapter_config.json` records
`togethercomputer/Meta-Llama-3.3-70B-Instruct-Reference`, the base as served during
training. Same architecture β load against `meta-llama/Llama-3.3-70B-Instruct`.
## Training
| Parameter | Value |
|---|---|
| Base | `meta-llama/Llama-3.3-70B-Instruct` |
| Rank (`r`) | 64 |
| `lora_alpha` | 128 |
| Target modules | all-linear |
| Epochs | 3 |
| Peak learning rate | 1e-4, cosine |
## Dataset
[**flamiinngo/math-code-qa-v2**](https://huggingface.co/datasets/flamiinngo/math-code-qa-v2)
β 5,297 rows (4,197 math, 1,100 code), every math answer ending in a result
verified against the upstream `expected_answer` column. Derived from
[nvidia/OpenMathInstruct-2](https://huggingface.co/datasets/nvidia/OpenMathInstruct-2)
and [sahil2801/CodeAlpaca-20k](https://huggingface.co/datasets/sahil2801/CodeAlpaca-20k),
both CC-BY-4.0.
Also on Kaggle:
[model](https://www.kaggle.com/models/flamiinngo/adaption_math-41946c32-256d-4d24-a1ee-6effb91b690c) Β·
[dataset](https://www.kaggle.com/datasets/flamiinngo/math-code-qa-v2)
## Limitations
- **It can produce confident wrong reasoning.** The training solutions are
model-generated upstream; only their final answers were verified. Errors in
algebraic reasoning exist in the data and this model reproduces that style of
mistake. Check any result that matters.
- **Not a calculator.** Fine-tuning improved the working, not arithmetic guarantees.
- **Scope is school through early-undergraduate.** Not olympiad or research
mathematics.
- **Code output is untested.** The code training data was filtered for length,
not executed. Treat generated code as a draft.
- **Win rate is not accuracy.** It measures preference against one base model on
one evaluation.
- **English only.**
## License
The adapter is a derivative of Llama-3.3-70B-Instruct and is subject to the
**Llama 3.3 Community License**. The training data is CC-BY-4.0.
## Acknowledgements
- **Adaption Labs** β AutoScientist platform and the challenge
- **NVIDIA** and **sahil2801** β upstream open datasets
- **Meta** β Llama 3.3 base model
|