Text Generation
Transformers
Safetensors
Arabic
llama
arabic
reasoning
chain-of-thought
math
gsm8k
small-language-model
slm
sft
conversational
text-generation-inference
Instructions to use oddadmix/Nawah-Math-Reasoning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use oddadmix/Nawah-Math-Reasoning with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="oddadmix/Nawah-Math-Reasoning") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("oddadmix/Nawah-Math-Reasoning") model = AutoModelForCausalLM.from_pretrained("oddadmix/Nawah-Math-Reasoning", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use oddadmix/Nawah-Math-Reasoning with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "oddadmix/Nawah-Math-Reasoning" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "oddadmix/Nawah-Math-Reasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/oddadmix/Nawah-Math-Reasoning
- SGLang
How to use oddadmix/Nawah-Math-Reasoning 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 "oddadmix/Nawah-Math-Reasoning" \ --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": "oddadmix/Nawah-Math-Reasoning", "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 "oddadmix/Nawah-Math-Reasoning" \ --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": "oddadmix/Nawah-Math-Reasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use oddadmix/Nawah-Math-Reasoning with Docker Model Runner:
docker model run hf.co/oddadmix/Nawah-Math-Reasoning
File size: 3,295 Bytes
867d0f3 | 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 | """
Re-split the merged v6 synthetic corpus so v5 -> v6 stays a fair comparison.
build_synth_dataset.py shuffles with SEED=42 over whatever rows it is given. The v6 corpus has
20,139 more rows than the v5 one, so that shuffle lands differently and **1,955 of v5's 2,000
held-out synth rows fall into v6's train split**. Training on them and then reporting the synth
cell would be scoring memorisation.
So the eval split is not re-drawn, it is *pinned*: `data_synth_sft/eval.jsonl` (v5's rows, in v5's
order) is copied through verbatim, and every one of those instructions is removed from train. The
first 1,000 of them are the same rows v4 and v5 were scored on, so the cell stays comparable
across all three models.
A second held-out set, `eval_rel.jsonl`, is carved from the relational pool (task_id >= 1,000,000)
— the whole point of v6 is a capability v5 lacks, and none of the legacy eval rows test it.
Writes data_synth_v6_sft/{train,eval,eval_rel}.jsonl.
"""
import json
import random
from pathlib import Path
import pyarrow.parquet as pq
CORPUS = Path("out_merged_v6/arabic_math_reasoning_synth.parquet")
LEGACY = Path("data_synth_sft/eval.jsonl") # v5's held-out synth rows — pinned, not redrawn
OUT = Path("data_synth_v6_sft")
EVAL_REL = 400
REL_MIN_TASK_ID = 1_000_000
SEED = 42
FIELDS = ("instruction", "reasoning", "answer")
def sft(row, source="synth_math_ar"):
return {**{k: row[k] for k in FIELDS}, "source": source}
def main():
rows = pq.read_table(CORPUS).to_pylist()
by_instruction = {r["instruction"]: r for r in rows}
print(f"[*] corpus {len(rows):,} rows")
legacy = [json.loads(l) for l in open(LEGACY, encoding="utf-8")]
missing = [r for r in legacy if r["instruction"] not in by_instruction]
print(f"[*] pinned eval {len(legacy):,} rows, {len(missing)} no longer in the corpus")
held = {r["instruction"] for r in legacy}
# relational held-out: deterministic sample of the new pool, also excluded from train
rel = [r for r in rows if r["task_id"] >= REL_MIN_TASK_ID and r["instruction"] not in held]
rel.sort(key=lambda r: (r["task_id"], r["instruction"])) # parquet order is shuffled
eval_rel = random.Random(SEED).sample(rel, min(EVAL_REL, len(rel)))
held |= {r["instruction"] for r in eval_rel}
print(f"[*] relational rows {len(rel):,}, holding out {len(eval_rel):,}")
train = [r for r in rows if r["instruction"] not in held]
n_rel_train = sum(1 for r in train if r["task_id"] >= REL_MIN_TASK_ID)
OUT.mkdir(exist_ok=True)
for name, split in (("train", [sft(r) for r in train]),
("eval", legacy), # verbatim, v5's order
("eval_rel", [sft(r) for r in eval_rel])):
with open(OUT / f"{name}.jsonl", "w", encoding="utf-8") as fh:
for r in split:
fh.write(json.dumps(r, ensure_ascii=False) + "\n")
print(f"[+] {name}: {len(split):,} -> {OUT / f'{name}.jsonl'}")
print(f"[*] train carries {n_rel_train:,} relational rows ({n_rel_train/len(train):.1%})")
leak = sum(1 for r in train if r["instruction"] in held)
print(f"[{'+' if leak == 0 else '!'}] contamination check: {leak} held-out rows in train")
if __name__ == "__main__":
main()
|