SmolThink model is a Continued Supervised Fine-Tuned version of
SmolLM2-360M on
Deepseek-R1 distilled dataset.
Training code and a portion of dataset can be found
QuwsarOhi/SmolThink
The model was trained on a mixture of small Chain of Thoughts (CoT) and some long CoT dataset. Small CoT dataset mixture was used as the model is small and it is was reported that small models struggle to produce long reasoning chain
ref.
The datasets were filtered by removing the contents having CoT length more than 256 words. The model was trained to produce tool calls. As being a small language model, the model does not memorize certain things (example: how to bake cake). Rather, if used with web search, the model may produce good quality of answer regardless of the size.
The model is still under training and the whole training and dataset mixtures would be published soon. The model is trained on MacBook Air with 16GB unified memory.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4device = 'mps'
5
6tokenizer = AutoTokenizer.from_pretrained(
7 "quwsarohi/SmolThink"
8)
9
10model = AutoModelForCausalLM.from_pretrained(
11 "quwsarohi/SmolThink",
12 low_cpu_mem_usage=True,
13 torch_dtype=torch.bfloat16,
14 trust_remote_code=True,
15 use_cache=False,
16 tie_word_embeddings=True,
17).to(device)
18
19messages = [{"role": "user", "content": "What is the capital of France."}]
20input_text=tokenizer.apply_chat_template(messages, tokenize=False)
21print(input_text)
22inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
23outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
24print(tokenizer.decode(outputs[0]))
The model is further trained to do web search using a special websearch tool. The following code could be used to use the web searching capability.
1webtool_def = {
2 "type": "function",
3 "function": {
4 "name": "web_search",
5 "description": "Can search the web for infomation which are doubtful/unknown/recent.",
6 "parameters": {
7 "type": "object",
8 "properties": {
9 "search_str": {
10 "type": "string",
11 "description": "The whole question you want to ask.",
12 "required": True,
13 }
14 },
15 },
16 },
17}
18
19base_prompt = tokenizer.apply_chat_template([
20 {"role": "user", "content": "What is the current stock price of Apple?"}
21], tools=[webtool_def], tokenize=False, add_generation_prompt=True)
22print(base_prompt)
23
24inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
25outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
26print(tokenizer.decode(outputs[0]))