File size: 3,378 Bytes
fa440ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c4304be
 
fa440ed
 
c4304be
fa440ed
 
c4304be
fa440ed
 
 
 
 
c4304be
fa440ed
c4304be
fa440ed
c4304be
 
fa440ed
c4304be
fa440ed
 
 
 
c4304be
fa440ed
 
 
 
 
 
 
c4304be
fa440ed
 
 
 
c4304be
 
 
fa440ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c4304be
fa440ed
c4304be
fa440ed
 
c4304be
fa440ed
 
c4304be
3b1cdbc
 
 
 
fa440ed
 
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
---
license: apache-2.0  # Change if you have a different one; apache-2.0 is common for open models
base_model: meta-llama/Llama-3-8B  # ← IMPORTANT: Replace with your ACTUAL base model (e.g. mistralai/Mistral-7B-Instruct-v0.3, Qwen/Qwen2-7B-Instruct, google/gemma-2-9b-it, etc.)
tags:
  - peft
  - lora
  - text-generation
  - mathematics
  - math-reasoning
  - mathematical-olympiad
  - transformers
library_name: peft
pipeline_tag: text-generation
inference: false  # Set to true later if you deploy it
---

# ShineMath: Mathematical Olympiad Language Model

ShineMath is a custom-trained **LoRA adapter** designed to assist with mathematical olympiad problems, reasoning, step-by-step solution generation, and proof writing.  
It was fine-tuned for challenging math tasks using efficient PEFT methods.

**Author:** Shine Gupta (@shine_gupta17)  
**Repository:** [Shinegupta/ShineMath](https://huggingface.co/Shinegupta/ShineMath)

### Model Details
- **Type:** PEFT LoRA adapter (not a full model – load on top of a base LLM)
- **Files included:** adapter_model.safetensors, adapter_config.json, tokenizer files, chat_template.jinja, generation_config.json
- **Size:** ~82.5 MB (lightweight and easy to share/load)
- **Intended use:** Solving/generating IMO-style problems, AMC/AIME prep, mathematical reasoning, explanations

### Usage (with PEFT + Transformers)

Since this is a LoRA adapter, load it **on top of the base model**:

```python
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

base_model_name = "meta-llama/Llama-3-8B"  # ← Replace with your actual base model!
adapter_name = "Shinegupta/ShineMath"

tokenizer = AutoTokenizer.from_pretrained(adapter_name)
model = AutoModelForCausalLM.from_pretrained(
    base_model_name,
    torch_dtype=torch.bfloat16,  # or "auto"
    device_map="auto"
)
model = PeftModel.from_pretrained(model, adapter_name)

# Example
prompt = "Solve: Let x² + y² = 1. Find the maximum value of x + y under the constraint x, y ≥ 0."
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```

Simpler with pipeline (auto-handles adapter):

```python
from transformers import pipeline

pipe = pipeline(
    "text-generation",
    model=base_model_name,
    peft_model=adapter_name,  # Loads the LoRA automatically
    device_map="auto"
)

result = pipe("Prove by induction that the sum of the first n natural numbers is n(n+1)/2.")
print(result[0]["generated_text"])
```

Tip: Use the chat_template.jinja for chat/instruct formats if your base model supports it (e.g., apply_chat_template).

### Applications
- Solving and generating mathematical olympiad problems (IMO, AIME, AMC, etc.)
- Step-by-step solution explanations
- Mathematical reasoning, theorem proving, and algebraic manipulations

### License
See the LICENSE file or specify here (e.g., Apache-2.0 for open use).

### Citation
If you use ShineMath in research or projects, please cite:  

  author = Shine Gupta,
  title = ShineMath: Mathematical Olympiad Language Model,
  publisher = Hugging Face,
  howpublished = https://huggingface.co/Shinegupta/ShineMath

For questions, collaborations, or issues — open a discussion on the model page! Happy math solving!