Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
2
3model = AutoModelForCausalLM.from_pretrained(
4 "oxdev/security-auditor-grpo",
5 use_cache=True, # Important: config has use_cache=False from training
6)
7tokenizer = AutoTokenizer.from_pretrained("oxdev/security-auditor-grpo")
8pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, device="cuda")
9
10messages = [
11 {"role": "system", "content": "You are an expert smart contract security auditor. Analyze the provided Solidity code for vulnerabilities."},
12 {"role": "user", "content": """Audit this contract:
13```solidity
14contract SimpleBank {
15 mapping(address => uint256) public balances;
16 function deposit() public payable { balances[msg.sender] += msg.value; }
17 function withdraw(uint256 amount) public {
18 require(balances[msg.sender] >= amount);
19 (bool success, ) = msg.sender.call{value: amount}("");
20 require(success);
21 balances[msg.sender] -= amount;
22 }
23}
24```"""},
25]
26
27result = pipe(messages, max_new_tokens=512, do_sample=False, return_full_text=False)
28output = result[0]["generated_text"]
29if isinstance(output, list):
30 output = output[-1]["content"]
31print(output)train_grpo_v2_colab.ipynb in Google Colab with a free T4 GPU| Category | Keywords |
|---|---|
| Reentrancy | reentrancy, reentrant, callback |
| Access Control | unauthorized, permission, onlyowner |
| Oracle Manipulation | price feed, chainlink, twap |
| Flash Loan | flash loan, flashloan |
| Overflow/Underflow | overflow, underflow, arithmetic |
| Front-running | front-run, sandwich, MEV |
| DoS | denial of service, gas limit, unbounded |
| Token Issues | fee-on-transfer, rebasing, ERC20 |
| Storage | storage collision, delegatecall, proxy |
| Cross-chain | bridge, relay, message passing |
| Liquidation | liquidation, collateral, health factor |
| Signature | ecrecover, replay, nonce, EIP712 |
| Initialization | uninitialized, constructor |
| Rounding | precision, truncation, decimal |
<|im_start|> / <|im_end|>)use_cache=True when loading for inference — the saved config has use_cache=False from training, which makes generation 10-20× slower| File | Description |
|---|---|
model.safetensors | V1 trained model weights (1.8GB) |
train_grpo_job.py | V1 training script |
train_grpo_v2.py | V2 training script (4 reward functions) |
train_grpo_v2_colab.ipynb | V2 Colab notebook (free T4 GPU) |
checkpoint-300/ | V1 training checkpoint |
checkpoint-326/ | V1 final checkpoint |
1@article{shao2024deepseekmath,
2 title = {{DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models}},
3 author = {Zhihong Shao and Peiyi Wang and Qihao Zhu and Runxin Xu and Junxiao Song and others},
4 year = 2024,
5 eprint = {arXiv:2402.03300},
6}