InfR aims to advance AI systems by improving reasoning, reducing adoption barriers, and addressing privacy concerns through smaller model sizes.
For optimal performance, we recommend using PyTorch 2.0+ and CUDA 11.8+.
1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3# Define messages in chat format
4messages = [
5 {"role": "system", "content": "You are a helpful assistant."},
6 {"role": "user", "content": "A new program had 60 downloads in the first month. The number of downloads in the second month was three times as many as the downloads in the first month, but then reduced by 30% in the third month. How many downloads did the program have total over the three months? Think step by step."},
7]
8
9# Load model and tokenizer
10tokenizer = AutoTokenizer.from_pretrained("InfiX-ai/InfiR-1B-Instruct")
11model = AutoModelForCausalLM.from_pretrained("InfiX-ai/InfiR-1B-Instruct")
12
13# Apply chat template and generate
14raw_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
15inputs = tokenizer(raw_prompt, return_tensors="pt")
16outputs = model.generate(inputs["input_ids"], max_new_tokens=2048)
17print(tokenizer.decode(outputs[0], skip_special_tokens=True))
1# Mathematical problem solving with chat format
2messages = [
3 {"role": "system", "content": "You are a helpful assistant."},
4 {"role": "user", "content": "If a rectangle has a length of 8 units and a width of 6 units, what is its area and perimeter? Solve this step by step."},
5]
6
7raw_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
8inputs = tokenizer(raw_prompt, return_tensors="pt")
9outputs = model.generate(
10 inputs["input_ids"],
11 max_new_tokens=512,
12 temperature=0.1,
13 do_sample=True
14)
15print(tokenizer.decode(outputs[0], skip_special_tokens=True))
1# Code generation example with chat format
2messages = [
3 {"role": "system", "content": "You are a helpful assistant."},
4 {"role": "user", "content": "Write a Python function to calculate the factorial of a number."},
5]
6
7raw_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
8inputs = tokenizer(raw_prompt, return_tensors="pt")
9outputs = model.generate(
10 inputs["input_ids"],
11 max_new_tokens=256,
12 temperature=0.2,
13 do_sample=True
14)
15print(tokenizer.decode(outputs[0], skip_special_tokens=True))
1# Chain-of-thought reasoning with chat format
2messages = [
3 {"role": "system", "content": "You are a helpful assistant."},
4 {"role": "user", "content": "A train travels 120 km in 2 hours. What is its speed in km/h? Let's approach this step by step."},
5]
6
7raw_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
8inputs = tokenizer(raw_prompt, return_tensors="pt")
9outputs = model.generate(
10 inputs["input_ids"],
11 max_new_tokens=300,
12 temperature=0.3,
13 do_sample=True
14)
15print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Data cleaning: heuristic filters, MinHash de-duplication, 10-gram benchmark decontamination, reward-model rejection sampling.
1@misc{xie2025infir,
2 title={InfiR: Crafting Effective Small Language Models and Multimodal Small Language Models in Reasoning},
3 author={Xie, Congkai and Cai, Shuo and Wang, Wenjun and others},
4 year={2025},
5 eprint={2502.11573},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}
Xie, C., Cai, S., Wang, W., et al. (2025). InfiR: Crafting Effective Small Language Models and Multimodal Small Language Models in Reasoning. arXiv:2502.11573.