import torchfrom safetensors.torch import load_filefrom transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizerfrom huggingface_hub import hf_hub_download # Load model (recommended: manual load for reliability)config = AutoConfig.from_pretrained("HuggingFaceTB/nanowhale-100m", trust_remote_code=True)model = AutoModelForCausalLM.from_config(config, trust_remote_code=True).float() # Download and load weightsweights_path = hf_hub_download("HuggingFaceTB/nanowhale-100m", "model.safetensors")state_dict = load_file(weights_path)model.load_state_dict(state_dict, strict=True)model = model.cuda().eval() tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/nanowhale-100m") # Chatmessages = [{"role": "user", "content": "What are 3 benefits of exercise?"}]prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)input_ids = tokenizer.encode(prompt, return_tensors="pt").cuda()output = model.generate(input_ids, max_new_tokens=200, temperature=0.7, top_p=0.9, pad_token_id=tokenizer.eos_token_id)print(tokenizer.decode(output[0][input_ids.shape[1]:], skip_special_tokens=True))