Text Generation
Transformers
Safetensors
Portuguese
nanothink
thinking
reasoning
reason
think
lowparams
5m_params
thinkset-ptbr
gpt2
Instructions to use AxionLab-Co/NanoThink-5M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AxionLab-Co/NanoThink-5M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AxionLab-Co/NanoThink-5M")# pip install -U transformers accelerate # Load model directly from transformers import NanoThink model = NanoThink.from_pretrained("AxionLab-Co/NanoThink-5M", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AxionLab-Co/NanoThink-5M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AxionLab-Co/NanoThink-5M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AxionLab-Co/NanoThink-5M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/AxionLab-Co/NanoThink-5M
- SGLang
How to use AxionLab-Co/NanoThink-5M 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 "AxionLab-Co/NanoThink-5M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AxionLab-Co/NanoThink-5M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "AxionLab-Co/NanoThink-5M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AxionLab-Co/NanoThink-5M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use AxionLab-Co/NanoThink-5M with Docker Model Runner:
docker model run hf.co/AxionLab-Co/NanoThink-5M
Update README.md
Browse files123---license: mit---123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178---license: mitdatasets:- wikimedia/wikipedialanguage:- ptpipeline_tag: text-generationlibrary_name: transformers---# 🧠 NanoThink-5M> A 5M parameter language model trained from scratch on portuguese and thinking dataset to simulate structured reasoning.---## 🚀 Overview**NanoThink-5M** is an ultra-lightweight (~5M parameters) transformer model designed to explore the limits of **reasoning behavior in small-scale neural networks**.Built entirely from scratch, it runs efficiently on CPU and focuses on generating structured reasoning outputs in Portuguese.---## 💡 Key Idea> How far can a tiny model go in *simulating reasoning*?NanoThink-5M does not truly reason — instead, it learns to **imitate reasoning patterns** through structured training.---## 🧠 Capabilities* Generates step-by-step reasoning (`<THINK>`)* Produces structured answers (`<ANSWER>`)* Handles simple arithmetic and logic patterns* Fully CPU-compatible---## ⚙️ Model Details* Architecture: Causal Transformer (GPT-style)* Parameters: ~5M* Layers: 4* Heads: 4* Embedding size: 128* Context length: 256 tokens---## 🏗️ Training Pipeline### 1. TokenizerCustom tokenizer trained from scratch.### 2. Pretraining* Portuguese text corpus* Language modeling objective### 3. Fine-tuning* Synthetic reasoning dataset* Tasks include:* Arithmetic* Logical comparisons* Multi-step problemsStructured format:```text<USER> ... <\USER><THINK> ... <\THINK><ANSWER> ... <\ANSWER><END>```---## 📊 Example**Input:**```textJoão tem 3 maçãs e ganhou 2, quantas ele tem agora?```**Output:**```text<THINK>3 + 2 = 5</THINK><ANSWER>João has 5 apples.</ANSWER>```---## ⚠️ Limitations* Not reliable for precise mathematical reasoning* May generate inconsistent intermediate steps* Reasoning is **simulated, not grounded**> This model demonstrates *the appearance of reasoning*, not true reasoning.---## 🧪 Research InsightNanoThink-5M highlights an important phenomenon:> Small models can learn to **look intelligent before being intelligent**.This reinforces the distinction between:* Simulated reasoning* Actual reasoning---## 💻 Usage```pythonimport torchfrom safetensors.torch import load_filefrom model import NanoThinkfrom tokenizers import Tokenizertokenizer = Tokenizer.from_file("tokenizer.json")model = NanoThink(vocab_size=1229)state_dict = load_file("model.safetensors")model.load_state_dict(state_dict)model.eval()```---## 🔮 Future Work* Scaling to 10M–50M parameters* Improving dataset quality* Enhancing reasoning consistency* Multilingual support---## 🤝 ContributionsThis is an experimental project — contributions and ideas are welcome.---## 📜 LicenseMIT---## 🧠 AuthorAxionLab Co.Independent research project exploring the limits of small language models.---## ⭐ Final Thought> Intelligence can be mimicked at small scale — but not yet achieved.NanoThink-5M is a step toward understanding that boundary.
README.md+178-3