from peft import PeftModelfrom transformers import AutoModelForCausalLM, AutoTokenizerimport torch base = AutoModelForCausalLM.from_pretrained( "Qwen/Qwen2.5-Coder-7B-Instruct", dtype=torch.bfloat16, device_map="auto")model = PeftModel.from_pretrained(base, "Offlin33er/qwen25-coder-7b-solidity-audit")tok = AutoTokenizer.from_pretrained("Offlin33er/qwen25-coder-7b-solidity-audit") messages = [ {"role": "system", "content": "You are a senior smart-contract security auditor. Audit the provided Solidity code. If a vulnerability is present, report it as '## Finding: <type>' followed by the functionality, a Description, and a Recommendation. If none is found, state that no vulnerability was identified and describe what the code does."}, {"role": "user", "content": "Audit the following Solidity code for security vulnerabilities.\n\n```solidity\n<YOUR CODE>\n```"},]inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)out = model.generate(**inputs, max_new_tokens=512)print(tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))