Text Generation
Transformers
Safetensors
English
phi3
trl
text-generation-inference
math
code
conversational
Instructions to use prithivMLmods/TOI-157-Phi-4-Reasoning-Mini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/TOI-157-Phi-4-Reasoning-Mini with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="prithivMLmods/TOI-157-Phi-4-Reasoning-Mini") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("prithivMLmods/TOI-157-Phi-4-Reasoning-Mini") model = AutoModelForCausalLM.from_pretrained("prithivMLmods/TOI-157-Phi-4-Reasoning-Mini", 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 prithivMLmods/TOI-157-Phi-4-Reasoning-Mini with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "prithivMLmods/TOI-157-Phi-4-Reasoning-Mini" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "prithivMLmods/TOI-157-Phi-4-Reasoning-Mini", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/prithivMLmods/TOI-157-Phi-4-Reasoning-Mini
- SGLang
How to use prithivMLmods/TOI-157-Phi-4-Reasoning-Mini 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 "prithivMLmods/TOI-157-Phi-4-Reasoning-Mini" \ --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": "prithivMLmods/TOI-157-Phi-4-Reasoning-Mini", "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 "prithivMLmods/TOI-157-Phi-4-Reasoning-Mini" \ --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": "prithivMLmods/TOI-157-Phi-4-Reasoning-Mini", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use prithivMLmods/TOI-157-Phi-4-Reasoning-Mini with Docker Model Runner:
docker model run hf.co/prithivMLmods/TOI-157-Phi-4-Reasoning-Mini
File size: 3,453 Bytes
a9c4730 e4afbb9 a9c4730 e4afbb9 e3abe48 e4afbb9 e3abe48 | 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 | ---
license: mit
base_model:
- microsoft/Phi-4-mini-reasoning
language:
- en
pipeline_tag: text-generation
library_name: transformers
tags:
- trl
- text-generation-inference
- math
- code
---

# **TOI-157-Phi-4-Reasoning-Mini**
> **TOI-157-Phi-4-Reasoning-Mini** is a reasoning-focused model fine-tuned on **Microsoft’s Phi-4-mini-reasoning** for **Edge-level Abliterated Reasoning** and optimized **polished token probabilities**, enhancing balanced **multilingual generation** across mathematics and general-purpose reasoning.
> It specializes in **event-driven logic**, **structured analysis**, and precise probabilistic modeling—making it an ideal tool for researchers, educators, and developers working with uncertainty and structured reasoning.
## **Key Features**
1. **Abliterated Reasoning**
Enhanced reasoning precision through polished token probability distributions in Phi-based models, ensuring balanced and context-aware outputs.
2. **Event Simulation & Logical Analysis**
Models random events, probability-driven reasoning, and logical decision-making with strong consistency.
3. **Multilingual Mathematical & General-Purpose Problem Solving**
Delivers robust performance in **math**, **probability**, and **structured multilingual tasks**, enabling wide applicability in global research and education.
4. **Hybrid Symbolic-Probabilistic Thinking**
Combines structured logic, probabilistic inference, and reasoning fluency, providing accuracy across uncertainty-driven tasks.
5. **Structured Output Mastery**
Generates well-structured outputs in **LaTeX**, **Markdown**, **JSON**, **CSV**, and **YAML**, supporting technical workflows and data-driven research.
6. **Optimized Lightweight Footprint**
Compact **mini parameter size**, deployable on **edge devices**, **offline clusters**, and **mid-range GPUs**, while maintaining reasoning quality.
## **Quickstart with Transformers**
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
torch.random.manual_seed(0)
model_id = "prithivMLmods/TOI-157-Phi-4-Reasoning-Mini"
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="cuda",
torch_dtype="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
messages = [{
"role": "user",
"content": "How to solve 3*x^2 + 4*x + 5 = 1?"
}]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_dict=True,
return_tensors="pt",
)
outputs = model.generate(
**inputs.to(model.device),
max_new_tokens=32768,
temperature=0.8,
top_p=0.95,
do_sample=True,
)
outputs = tokenizer.batch_decode(outputs[:, inputs["input_ids"].shape[-1]:])
print(outputs[0])
```
## **Intended Use**
* Balanced multilingual reasoning and probability modeling
* Event simulation, uncertainty analysis, and structured problem solving
* Educational and research-focused reasoning tasks
* Lightweight deployment in constrained environments
* Technical content and structured data generation
## **Limitations**
* Focused on reasoning and mathematics—less suited for creative writing
* Smaller size may limit depth on highly complex, multi-step tasks
* Prioritizes structured reasoning and probabilistic accuracy over conversational or emotional tone. |