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-base", 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-base", "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-base") # Generateinput_ids = tokenizer.encode("The meaning of life is", return_tensors="pt").cuda()output = model.generate(input_ids, max_new_tokens=100, temperature=0.7, top_p=0.9, pad_token_id=tokenizer.eos_token_id)print(tokenizer.decode(output[0], skip_special_tokens=True))