Text Generation
Transformers
Safetensors
English
llama
nvidia
math
conversational
text-generation-inference
Instructions to use nvidia/OpenMath2-Llama3.1-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/OpenMath2-Llama3.1-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nvidia/OpenMath2-Llama3.1-8B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nvidia/OpenMath2-Llama3.1-8B") model = AutoModelForCausalLM.from_pretrained("nvidia/OpenMath2-Llama3.1-8B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nvidia/OpenMath2-Llama3.1-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nvidia/OpenMath2-Llama3.1-8B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/OpenMath2-Llama3.1-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nvidia/OpenMath2-Llama3.1-8B
- SGLang
How to use nvidia/OpenMath2-Llama3.1-8B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "nvidia/OpenMath2-Llama3.1-8B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/OpenMath2-Llama3.1-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "nvidia/OpenMath2-Llama3.1-8B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/OpenMath2-Llama3.1-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nvidia/OpenMath2-Llama3.1-8B with Docker Model Runner:
docker model run hf.co/nvidia/OpenMath2-Llama3.1-8B
Add pipeline tag and link to OpenCodeReasoning paper
#3
by nielsr HF Staff - opened
README.md
CHANGED
|
@@ -1,22 +1,23 @@
|
|
| 1 |
---
|
| 2 |
-
license: llama3.1
|
| 3 |
base_model:
|
| 4 |
- meta-llama/Llama-3.1-8B
|
| 5 |
datasets:
|
| 6 |
- nvidia/OpenMathInstruct-2
|
| 7 |
language:
|
| 8 |
- en
|
|
|
|
|
|
|
|
|
|
| 9 |
tags:
|
| 10 |
- nvidia
|
| 11 |
- math
|
| 12 |
-
library_name: transformers
|
| 13 |
---
|
| 14 |
|
| 15 |
# OpenMath2-Llama3.1-8B
|
| 16 |
|
| 17 |
-
OpenMath2-Llama3.1-8B is obtained by finetuning [Llama3.1-8B-Base](https://huggingface.co/meta-llama/Llama-3.1-8B) with [OpenMathInstruct-2](https://huggingface.co/datasets/nvidia/OpenMathInstruct-2).
|
| 18 |
|
| 19 |
-
The model outperforms [Llama3.1-8B-Instruct](https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct) on all the popular math benchmarks we evaluate on, especially on [MATH](https://github.com/hendrycks/math) by 15.9%.
|
| 20 |
|
| 21 |
<!-- <p align="center">
|
| 22 |
<img src="scaling_plot.jpg" width="350"><img src="math_level_comp.jpg" width="350">
|
|
@@ -81,7 +82,9 @@ pipeline = transformers.pipeline(
|
|
| 81 |
messages = [
|
| 82 |
{
|
| 83 |
"role": "user",
|
| 84 |
-
"content": "Solve the following math problem. Make sure to put the answer (and only answer) inside \\boxed{}.
|
|
|
|
|
|
|
| 85 |
"What is the minimum value of $a^2+6a-7$?"},
|
| 86 |
]
|
| 87 |
|
|
|
|
| 1 |
---
|
|
|
|
| 2 |
base_model:
|
| 3 |
- meta-llama/Llama-3.1-8B
|
| 4 |
datasets:
|
| 5 |
- nvidia/OpenMathInstruct-2
|
| 6 |
language:
|
| 7 |
- en
|
| 8 |
+
library_name: transformers
|
| 9 |
+
license: llama3.1
|
| 10 |
+
pipeline_tag: text-generation
|
| 11 |
tags:
|
| 12 |
- nvidia
|
| 13 |
- math
|
|
|
|
| 14 |
---
|
| 15 |
|
| 16 |
# OpenMath2-Llama3.1-8B
|
| 17 |
|
| 18 |
+
OpenMath2-Llama3.1-8B is obtained by finetuning [Llama3.1-8B-Base](https://huggingface.co/meta-llama/Llama-3.1-8B) with [OpenMathInstruct-2](https://huggingface.co/datasets/nvidia/OpenMathInstruct-2). This model is described in the paper [OpenCodeReasoning: Advancing Data Distillation for Competitive Coding](https://huggingface.co/papers/2504.01943).
|
| 19 |
|
| 20 |
+
The model outperforms [Llama3.1-8B-Instruct](https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct) on all the popular math benchmarks we evaluate on, especially on [MATH](https://github.com/hendrycks/math) by 15.9%.
|
| 21 |
|
| 22 |
<!-- <p align="center">
|
| 23 |
<img src="scaling_plot.jpg" width="350"><img src="math_level_comp.jpg" width="350">
|
|
|
|
| 82 |
messages = [
|
| 83 |
{
|
| 84 |
"role": "user",
|
| 85 |
+
"content": "Solve the following math problem. Make sure to put the answer (and only answer) inside \\boxed{}.
|
| 86 |
+
|
| 87 |
+
" +
|
| 88 |
"What is the minimum value of $a^2+6a-7$?"},
|
| 89 |
]
|
| 90 |
|