Instructions to use QuantFactory/NuminaMath-7B-TIR-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use QuantFactory/NuminaMath-7B-TIR-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf QuantFactory/NuminaMath-7B-TIR-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf QuantFactory/NuminaMath-7B-TIR-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf QuantFactory/NuminaMath-7B-TIR-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf QuantFactory/NuminaMath-7B-TIR-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/NuminaMath-7B-TIR-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/NuminaMath-7B-TIR-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/NuminaMath-7B-TIR-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/NuminaMath-7B-TIR-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/NuminaMath-7B-TIR-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use QuantFactory/NuminaMath-7B-TIR-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "QuantFactory/NuminaMath-7B-TIR-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/NuminaMath-7B-TIR-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/QuantFactory/NuminaMath-7B-TIR-GGUF:Q4_K_M
- Ollama
How to use QuantFactory/NuminaMath-7B-TIR-GGUF with Ollama:
ollama run hf.co/QuantFactory/NuminaMath-7B-TIR-GGUF:Q4_K_M
- Unsloth Studio
How to use QuantFactory/NuminaMath-7B-TIR-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/NuminaMath-7B-TIR-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/NuminaMath-7B-TIR-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/NuminaMath-7B-TIR-GGUF to start chatting
- Docker Model Runner
How to use QuantFactory/NuminaMath-7B-TIR-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/NuminaMath-7B-TIR-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/NuminaMath-7B-TIR-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/NuminaMath-7B-TIR-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.NuminaMath-7B-TIR-GGUF-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: AI-MO/NuminaMath-7B-TIR
|
| 3 |
+
tags:
|
| 4 |
+
- alignment-handbook
|
| 5 |
+
- generated_from_trainer
|
| 6 |
+
widget:
|
| 7 |
+
- example_title: Math problem
|
| 8 |
+
messages:
|
| 9 |
+
- role: user
|
| 10 |
+
content: >-
|
| 11 |
+
For how many values of the constant $k$ will the polynomial
|
| 12 |
+
$x^{2}+kx+36$ have two distinct integer roots?
|
| 13 |
+
output:
|
| 14 |
+
text: >-
|
| 15 |
+
### Solution:
|
| 16 |
+
|
| 17 |
+
1- For the polynomial \\( x^2 + kx + 36 \\) to have two
|
| 18 |
+
distinct integer roots, let's denote these roots by \\( r_1 \\) and \\(
|
| 19 |
+
r_2 \\).
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
2- According to Vieta's formulas, the sum of the roots \\( r_1 + r_2 \\)
|
| 24 |
+
is equal to \\(-k\\), and the product of the roots \\( r_1 \\cdot r_2
|
| 25 |
+
\\) is equal to 36.
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
3- To find the distinct integer pairs \\((r_1, r_2)\\) whose product is
|
| 30 |
+
36, we need to determine all pairs of integers \\((r_1, r_2)\\) such
|
| 31 |
+
that \\( r_1 \\cdot r_2 = 36 \\) and \\( r_1 \\neq r_2 \\).
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
4- From the equation \\( r_1 + r_2 = -k \\), for each valid pair
|
| 36 |
+
\\((r_1, r_2)\\), we can compute the corresponding value of \\( k \\).
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
5- Finally, since we need the polynomial to have two distinct integer
|
| 41 |
+
roots, we need to ensure that \\( r_1 \\) and \\( r_2 \\) are distinct.
|
| 42 |
+
|
| 43 |
+
Let's start by finding all pairs \\((r_1, r_2)\\) such that \\( r_1
|
| 44 |
+
\\cdot r_2 = 36 \\). We'll then determine the values of \\( k \\) and
|
| 45 |
+
ensure the roots are distinct.
|
| 46 |
+
|
| 47 |
+
```python import itertools
|
| 48 |
+
|
| 49 |
+
# Find all pairs (r1, r2) such that r1 * r2 = 36 product_36 = 36
|
| 50 |
+
factor_pairs = []
|
| 51 |
+
|
| 52 |
+
for i in range(1, product_36 + 1):
|
| 53 |
+
if product_36 % i == 0:
|
| 54 |
+
pair = (i, product_36 // i)
|
| 55 |
+
if pair[0] != pair[1]: # Ensure distinct pairs
|
| 56 |
+
factor_pairs.append(pair)
|
| 57 |
+
|
| 58 |
+
# Calculate k for each pair and ensure distinct integer roots
|
| 59 |
+
valid_k_values = set()
|
| 60 |
+
for r1, r2 in factor_pairs:
|
| 61 |
+
if r1 != r2:
|
| 62 |
+
k = -(r1 + r2)
|
| 63 |
+
valid_k_values.add(k)
|
| 64 |
+
|
| 65 |
+
print((len(valid_k_values), sorted(valid_k_values)))
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
```output
|
| 69 |
+
(4, [-37, -20, -15,-13])
|
| 70 |
+
```
|
| 71 |
+
The distinct integer values of \\( k \\) that make the
|
| 72 |
+
polynomial \\( x^2 + kx + 36 \\) have two distinct integer roots are
|
| 73 |
+
\\(-37, -20, -15, \\text{and} -13\\).
|
| 74 |
+
|
| 75 |
+
Therefore, the number of such values of \\( k \\) is:
|
| 76 |
+
|
| 77 |
+
[ \\boxed{4} \\]
|
| 78 |
+
|
| 79 |
+
pipeline_tag: text-generation
|
| 80 |
+
model-index:
|
| 81 |
+
- name: NuminaMath-7B-TIR
|
| 82 |
+
results: []
|
| 83 |
+
license: apache-2.0
|
| 84 |
+
---
|
| 85 |
+
|
| 86 |
+
# QuantFactory/NuminaMath-7B-TIR-GGUF
|
| 87 |
+
This is quantized version of [AI-MO/NuminaMath-7B-TIR](https://huggingface.co/AI-MO/NuminaMath-7B-TIR) created using llama.cpp
|
| 88 |
+
|
| 89 |
+
# Model Card for NuminaMath 7B TIR
|
| 90 |
+
|
| 91 |
+
NuminaMath is a series of language models that are trained to solve math problems using tool-integrated reasoning (TIR). NuminaMath 7B TIR won the first progress prize of the [AI Math Olympiad (AIMO)](https://aimoprize.com), with a score of 29/50 on the public and private tests sets.
|
| 92 |
+
|
| 93 |
+

|
| 94 |
+
|
| 95 |
+
This model is a fine-tuned version of [deepseek-ai/deepseek-math-7b-base](https://huggingface.co/deepseek-ai/deepseek-math-7b-base) with two stages of supervised fine-tuning:
|
| 96 |
+
|
| 97 |
+
* **Stage 1:** fine-tune the base model on a large, diverse dataset of natural language math problems and solutions, where each solution is templated with Chain of Thought (CoT) to facilitate reasoning.
|
| 98 |
+
* **Stage 2:** fine-tune the model from Stage 1 on a synthetic dataset of tool-integrated reasoning, where each math problem is decomposed into a sequence of rationales, Python programs, and their outputs. Here we followed [Microsoft’s ToRA paper](https://arxiv.org/abs/2309.17452) and prompted GPT-4 to produce solutions in the ToRA format with code execution feedback. Fine-tuning on this data produces a reasoning agent that can solve mathematical problems via a mix of natural language reasoning and use of the Python REPL to compute intermediate results.
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
## Model description
|
| 103 |
+
|
| 104 |
+
- **Model type:** A 7B parameter math LLM fine-tuned in two stages of supervised fine-tuning, first on a dataset with math problem-solution pairs and then on a synthetic dataset with examples of multi-step generations using tool-integrated reasoning.
|
| 105 |
+
- **Language(s) (NLP):** Primarily English
|
| 106 |
+
- **License:** Apache 2.0
|
| 107 |
+
- **Finetuned from model:** [deepseek-ai/deepseek-math-7b-base](https://huggingface.co/deepseek-ai/deepseek-math-7b-base)
|
| 108 |
+
|
| 109 |
+
### Model Sources
|
| 110 |
+
|
| 111 |
+
<!-- Provide the basic links for the model. -->
|
| 112 |
+
|
| 113 |
+
- **Repository:** Coming soon!
|
| 114 |
+
- **Demo:** https://huggingface.co/spaces/AI-MO/math-olympiad-solver
|
| 115 |
+
|
| 116 |
+
## Intended uses & limitations
|
| 117 |
+
|
| 118 |
+
Here's how you can run the model using the `pipeline()` function from 🤗 Transformers:
|
| 119 |
+
|
| 120 |
+
```python
|
| 121 |
+
import re
|
| 122 |
+
import torch
|
| 123 |
+
from transformers import pipeline
|
| 124 |
+
|
| 125 |
+
pipe = pipeline("text-generation", model="AI-MO/NuminaMath-7B-TIR", torch_dtype=torch.bfloat16, device_map="auto")
|
| 126 |
+
|
| 127 |
+
messages = [
|
| 128 |
+
{"role": "user", "content": "For how many values of the constant $k$ will the polynomial $x^{2}+kx+36$ have two distinct integer roots?"},
|
| 129 |
+
]
|
| 130 |
+
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 131 |
+
|
| 132 |
+
gen_config = {
|
| 133 |
+
"max_new_tokens": 1024,
|
| 134 |
+
"do_sample": False,
|
| 135 |
+
"stop_strings": ["```output"], # Generate until Python code block is complete
|
| 136 |
+
"tokenizer": pipe.tokenizer,
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
outputs = pipe(prompt, **gen_config)
|
| 140 |
+
text = outputs[0]["generated_text"]
|
| 141 |
+
print(text)
|
| 142 |
+
|
| 143 |
+
# WARNING: This code will execute the python code in the string. We show this for eductional purposes only.
|
| 144 |
+
# Please refer to our full pipeline for a safer way to execute code.
|
| 145 |
+
python_code = re.findall(r"```python(.*?)```", text, re.DOTALL)[0]
|
| 146 |
+
exec(python_code)
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
The above executes a single step of Python code - for more complex problems, you will want to run the logic for several steps to obtain the final solution.
|
| 150 |
+
|
| 151 |
+
## Bias, Risks, and Limitations
|
| 152 |
+
|
| 153 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 154 |
+
|
| 155 |
+
NuminaMath 7B TIR was created to solve problems in the narrow domain of competition-level mathematics. As a result, the model should not be used for general chat applications. With greedy decoding, we find the model is capable of solving problems at the level of [AMC 12](https://artofproblemsolving.com/wiki/index.php/2023_AMC_12A_Problems), but often struggles generate a valid solution on harder problems at the AIME and Math Olympiad level. The model also struggles to solve geometry problems, likely due to it's limited capacity and lack of other modalities like vision.
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
## Training procedure
|
| 159 |
+
|
| 160 |
+
### Training hyperparameters
|
| 161 |
+
|
| 162 |
+
The following hyperparameters were used during training:
|
| 163 |
+
- learning_rate: 2e-05
|
| 164 |
+
- train_batch_size: 4
|
| 165 |
+
- eval_batch_size: 8
|
| 166 |
+
- seed: 42
|
| 167 |
+
- distributed_type: multi-GPU
|
| 168 |
+
- num_devices: 8
|
| 169 |
+
- total_train_batch_size: 32
|
| 170 |
+
- total_eval_batch_size: 64
|
| 171 |
+
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
| 172 |
+
- lr_scheduler_type: cosine
|
| 173 |
+
- lr_scheduler_warmup_ratio: 0.1
|
| 174 |
+
- num_epochs: 4.0
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
### Framework versions
|
| 178 |
+
|
| 179 |
+
- Transformers 4.40.1
|
| 180 |
+
- Pytorch 2.3.1
|
| 181 |
+
- Datasets 2.18.0
|
| 182 |
+
- Tokenizers 0.19.1
|
| 183 |
+
|
| 184 |
+
## Model Citation
|
| 185 |
+
|
| 186 |
+
If you find NuminaMath 7B TIR is useful in your work, please cite it with:
|
| 187 |
+
|
| 188 |
+
```
|
| 189 |
+
@misc{numina_math_7b,
|
| 190 |
+
author = {Edward Beeching and Shengyi Costa Huang and Albert Jiang and Jia Li and Benjamin Lipkin and Zihan Qina and Kashif Rasul and Ziju Shen and Roman Soletskyi and Lewis Tunstall},
|
| 191 |
+
title = {NuminaMath 7B TIR},
|
| 192 |
+
year = {2024},
|
| 193 |
+
publisher = {Numina & Hugging Face},
|
| 194 |
+
journal = {Hugging Face repository},
|
| 195 |
+
howpublished = {\url{https://huggingface.co/AI-MO/NuminaMath-7B-TIR}}
|
| 196 |
+
}
|
| 197 |
+
```
|