Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,124 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# LIMO: Less Is More for Reasoning 🚀
|
| 2 |
+
|
| 3 |
+
This is the **updated version (v2)** of the LIMO model, corresponding to the latest paper version as of July 30, 2025.
|
| 4 |
+
|
| 5 |
+
## Model Information
|
| 6 |
+
|
| 7 |
+
| Model | Backbone | Size |
|
| 8 |
+
|-------|----------|------|
|
| 9 |
+
| LIMO-v2 | [Qwen2.5-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-32B-Instruct) | 32B |
|
| 10 |
+
|
| 11 |
+
## Previous Version
|
| 12 |
+
|
| 13 |
+
If you need the original LIMO model (corresponding to the initial paper version), you can access it at:
|
| 14 |
+
- **LIMO v1**: [`GAIR/LIMO`](https://huggingface.co/GAIR/LIMO)
|
| 15 |
+
|
| 16 |
+
## Quick Start
|
| 17 |
+
|
| 18 |
+
Our model is fine-tuned on [Qwen2.5-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-32B-Instruct) and is compatible with most mainstream frameworks like [HF Transformers](https://github.com/huggingface/transformers), [VLLM](https://github.com/vllm-project/vllm), [TensorRT-LLM](https://github.com/NVIDIA/TensorRT-LLM) and etc.
|
| 19 |
+
|
| 20 |
+
### Using HF Transformers
|
| 21 |
+
|
| 22 |
+
```python
|
| 23 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 24 |
+
import torch
|
| 25 |
+
|
| 26 |
+
# Initialize model and tokenizer
|
| 27 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 28 |
+
"GAIR/LIMO-v2",
|
| 29 |
+
torch_dtype="auto",
|
| 30 |
+
trust_remote_code=True,
|
| 31 |
+
device_map="auto"
|
| 32 |
+
)
|
| 33 |
+
tokenizer = AutoTokenizer.from_pretrained("GAIR/LIMO-v2", trust_remote_code=True)
|
| 34 |
+
|
| 35 |
+
# Prepare input messages
|
| 36 |
+
messages = [
|
| 37 |
+
{"role": "system", "content": "Please reason step by step, and put your final answer within \\boxed{}."},
|
| 38 |
+
{"role": "user", "content": "What is the result of 1+1?"}
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
# Format input using chat template
|
| 42 |
+
text = tokenizer.apply_chat_template(
|
| 43 |
+
messages,
|
| 44 |
+
tokenize=False,
|
| 45 |
+
add_generation_prompt=True
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
# Tokenize input
|
| 49 |
+
inputs = tokenizer(text, return_tensors="pt").to(model.device)
|
| 50 |
+
|
| 51 |
+
# Generate response
|
| 52 |
+
outputs = model.generate(
|
| 53 |
+
**inputs,
|
| 54 |
+
max_new_tokens=32768,
|
| 55 |
+
temperature=0.7,
|
| 56 |
+
top_p=0.95,
|
| 57 |
+
do_sample=True
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
# Decode and print response
|
| 61 |
+
response = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
|
| 62 |
+
print(response)
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
### Using VLLM
|
| 66 |
+
|
| 67 |
+
```python
|
| 68 |
+
from vllm import LLM, SamplingParams
|
| 69 |
+
from transformers import AutoTokenizer
|
| 70 |
+
|
| 71 |
+
# Initialize the model
|
| 72 |
+
llm = LLM(
|
| 73 |
+
model="GAIR/LIMO-v2",
|
| 74 |
+
tensor_parallel_size=4, # adjust based on available GPUs
|
| 75 |
+
trust_remote_code=True,
|
| 76 |
+
swap_space=60,
|
| 77 |
+
gpu_memory_utilization=0.96,
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
# Prepare input messages
|
| 81 |
+
messages = [
|
| 82 |
+
{"role": "system", "content": "Please reason step by step, and put your final answer within \\boxed{}."},
|
| 83 |
+
{"role": "user", "content": "What is the result of 1+1?"}
|
| 84 |
+
]
|
| 85 |
+
|
| 86 |
+
# Setup tokenizer
|
| 87 |
+
tokenizer = AutoTokenizer.from_pretrained("GAIR/LIMO-v2", trust_remote_code=True)
|
| 88 |
+
text = tokenizer.apply_chat_template(
|
| 89 |
+
messages,
|
| 90 |
+
tokenize=False,
|
| 91 |
+
add_generation_prompt=True
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
# Configure generation parameters
|
| 95 |
+
sampling_params = SamplingParams(
|
| 96 |
+
temperature=0.7,
|
| 97 |
+
max_tokens=32768,
|
| 98 |
+
top_p=0.95,
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
# Generate response
|
| 102 |
+
output = llm.generate(text, sampling_params)
|
| 103 |
+
print(output[0].outputs[0].text)
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
## License
|
| 107 |
+
|
| 108 |
+
This project is licensed under the MIT License.
|
| 109 |
+
|
| 110 |
+
## Citation
|
| 111 |
+
|
| 112 |
+
```bibtex
|
| 113 |
+
@misc{ye2025limoreasoning,
|
| 114 |
+
title={LIMO: Less is More for Reasoning},
|
| 115 |
+
author={Yixin Ye and Zhen Huang and Yang Xiao and Ethan Chern and Shijie Xia and Pengfei Liu},
|
| 116 |
+
year={2025},
|
| 117 |
+
eprint={2502.03387},
|
| 118 |
+
archivePrefix={arXiv},
|
| 119 |
+
primaryClass={cs.CL},
|
| 120 |
+
url={https://arxiv.org/abs/2502.03387},
|
| 121 |
+
}
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
For more details and training code, please visit our [GitHub repository](https://github.com/GAIR-NLP/LIMO).
|