Update README.md
Browse files12 unmodified lines131415161718192021222 unmodified lines2526272829303132333435363716 unmodified lines54555657585912 unmodified lines- R1- CoT---SmolThink model is a Continued Supervised Fine-Tuned version of [SmolLM2-360M](https://huggingface.co/HuggingFaceTB/SmolLM2-360M-Instruct) on Deepseek R1 distilled dataset.The model was trained on a mixture of small Chain of Thoughts (CoT) and some long CoT dataset. Small CoT was used as the model is small and it is was reported that small models struggle to produce long reasoning chain [ref](https://arxiv.org/abs/2502.12143).The SFT dataset had been created from the following data mixtures:2 unmodified lines* [GeneralReasoning/GeneralThought-195K](https://huggingface.co/datasets/GeneralReasoning/GeneralThought-195K)* [open-r1/codeforces-cots](https://huggingface.co/datasets/open-r1/codeforces-cots)* [XeTute/Open-Coding-Thoughts (currently unavailable)](https://huggingface.co/datasets/XeTute/Open-Coding-Thoughts)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.Use the following code to load the model```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizerimport torch16 unmodified linesmessages = [{"role": "user", "content": "What is the capital of France."}]input_text=tokenizer.apply_chat_template(messages, tokenize=False)print(input_text)inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)print(tokenizer.decode(outputs[0]))12 unmodified lines1314151617181920212223242526272 unmodified lines30313233343536373839404142434445464748495016 unmodified lines67686970717273747576777879808182838485868788899091929394959697989910010110210310410512 unmodified lines- R1- CoT---# SmolThink: A Small Model That Tries to Think**SmolThink** model is a Continued Supervised Fine-Tuned version of [SmolLM2-360M](https://huggingface.co/HuggingFaceTB/SmolLM2-360M-Instruct) on **Deepseek-R1** distilled dataset.Training code and a portion of dataset can be found [QuwsarOhi/SmolThink](https://github.com/QuwsarOhi/SmolThink)## Trainin ProcessThe 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](https://arxiv.org/abs/2502.12143).The SFT dataset had been created from the following data mixtures:2 unmodified lines* [GeneralReasoning/GeneralThought-195K](https://huggingface.co/datasets/GeneralReasoning/GeneralThought-195K)* [open-r1/codeforces-cots](https://huggingface.co/datasets/open-r1/codeforces-cots)* [XeTute/Open-Coding-Thoughts (currently unavailable)](https://huggingface.co/datasets/XeTute/Open-Coding-Thoughts)* Custom tool calling and websearch summarizing dataset generated using **Phi-3.5**, **Qwen2: deepseek-r1:7b**. Data generation pipeline is described [here](#)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 was supervised fine-tuned in two phases:* The model was initially trained with a rolling context length of `832` with a token stride of `832/8`. Dataset snapshot is available as [merged_dataset_phase1](#).* The model was again trained with a rolling context length of `3072` with a token stride of `768`. Dataset snapshot is available as [merged_dataset_phase2](#)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.## Usage### General UsageUse the following code to load and use the model```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizerimport torch16 unmodified linesmessages = [{"role": "user", "content": "What is the capital of France."}]input_text=tokenizer.apply_chat_template(messages, tokenize=False)print(input_text)inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)print(tokenizer.decode(outputs[0]))```### WebSearch Tool IntegrationThe 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.```pythonwebtool_def = {"type": "function","function": {"name": "web_search","description": "Can search the web for infomation which are doubtful/unknown/recent.","parameters": {"type": "object","properties": {"search_str": {"type": "string","description": "The whole question you want to ask.","required": True,}},},},}base_prompt = tokenizer.apply_chat_template([{"role": "user", "content": "What is the current stock price of Apple?"}], tools=[webtool_def], tokenize=False, add_generation_prompt=True)print(base_prompt)inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)print(tokenizer.decode(outputs[0]))
README.md+49-3