from transformers import AutoModelForCausalLM, AutoTokenizerimport torch model_name = "techwithsergiu/Qwen3.5-text-4B" tokenizer = AutoTokenizer.from_pretrained(model_name)model = AutoModelForCausalLM.from_pretrained( model_name, dtype=torch.bfloat16, device_map="auto",) messages = [{"role": "user", "content": "What is the capital of Romania?"}] # Thinking OFF — direct answertext = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True, enable_thinking=False,)inputs = tokenizer(text, return_tensors="pt").to(model.device)outputs = model.generate(**inputs, max_new_tokens=256)response = tokenizer.decode( outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True,)print(response) # Thinking ON — chain-of-thought before the answertext = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True, enable_thinking=True,)inputs = tokenizer(text, return_tensors="pt").to(model.device)outputs = model.generate(**inputs, max_new_tokens=1024)response = tokenizer.decode( outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True,)print(response)