Text Generation
Transformers
Safetensors
English
qwen2
solidity
smart-contracts
token-risk
lora
conversational
text-generation-inference
Instructions to use coronerai/coroner-coder-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use coronerai/coroner-coder-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="coronerai/coroner-coder-7b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("coronerai/coroner-coder-7b") model = AutoModelForCausalLM.from_pretrained("coronerai/coroner-coder-7b", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use coronerai/coroner-coder-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "coronerai/coroner-coder-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "coronerai/coroner-coder-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/coronerai/coroner-coder-7b
- SGLang
How to use coronerai/coroner-coder-7b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "coronerai/coroner-coder-7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "coronerai/coroner-coder-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "coronerai/coroner-coder-7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "coronerai/coroner-coder-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use coronerai/coroner-coder-7b with Docker Model Runner:
docker model run hf.co/coronerai/coroner-coder-7b
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,21 +1,48 @@
|
|
| 1 |
---
|
| 2 |
-
base_model: unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit
|
| 3 |
-
tags:
|
| 4 |
-
- text-generation-inference
|
| 5 |
-
- transformers
|
| 6 |
-
- unsloth
|
| 7 |
-
- qwen2
|
| 8 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
language:
|
| 10 |
-
- en
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
- **License:** apache-2.0
|
| 17 |
-
- **Finetuned from model :** unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
+
base_model: Qwen/Qwen2.5-Coder-7B-Instruct
|
| 4 |
+
library_name: transformers
|
| 5 |
+
pipeline_tag: text-generation
|
| 6 |
+
tags:
|
| 7 |
+
- solidity
|
| 8 |
+
- smart-contracts
|
| 9 |
+
- token-risk
|
| 10 |
+
- lora
|
| 11 |
language:
|
| 12 |
+
- en
|
| 13 |
---
|
| 14 |
|
| 15 |
+

|
| 16 |
+
|
| 17 |
+
# Coroner Coder 7B
|
| 18 |
+
|
| 19 |
+
A small model that fixes the patterns the Coroner scanner flags in an ERC-20 token contract: it takes a Solidity source plus the scanner's flags and returns a corrected contract and a short list of changes.
|
| 20 |
+
|
| 21 |
+
> Always compile and review the result yourself. A patch that compiles is not an audit. Not financial or security advice.
|
| 22 |
+
|
| 23 |
+
## What it fixes
|
| 24 |
+
The same patterns the Coroner pre-mortem scanner reports from source code:
|
| 25 |
+
`mint_with_live_owner`, `blacklist_function`, `pause_function`, `tax_changeable`, `risky_opcode` (selfdestruct, delegatecall, tx.origin) and `owner_privileges`.
|
| 26 |
+
|
| 27 |
+
## Training
|
| 28 |
+
- Base: Qwen2.5-Coder-7B-Instruct (Apache 2.0). Method: LoRA (rank 16) on 4-bit weights, one epoch (88 steps), then merged to 16-bit.
|
| 29 |
+
- Data: 1,400 synthetic examples. Each is a flawed token contract with its fix, generated from templates in two source layouts. **Every target is verified**: the corrected contract compiles with solc 0.8.24, keeps the ERC-20 interface and clears the flagged patterns. Generator and verifier: https://github.com/coroner-hash/ai/tree/main/coder
|
| 30 |
+
|
| 31 |
+
## Evaluation
|
| 32 |
+
A fix counts only if the patched contract compiles, keeps the ERC-20 interface, clears every flag and adds none. 40 held-out contracts in a third source layout the model never saw in training (greedy decoding):
|
| 33 |
+
|
| 34 |
+
| | Base model | Coroner Coder |
|
| 35 |
+
|---|---|---|
|
| 36 |
+
| Compiles | 1.00 | 0.925 |
|
| 37 |
+
| Flags cleared | 0.125 | 0.925 |
|
| 38 |
+
| Full fix (all checks) | 0.125 | 0.925 |
|
| 39 |
|
| 40 |
+
Returning the contract unchanged scores 0.05. In the layouts it was trained on the model scores 1.00, which mostly shows it learned the templates.
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
## Limits
|
| 43 |
+
- **Synthetic, narrow data.** All contracts are single-file ERC-20 variants without imports. Real contracts from a market will be messier; expect lower numbers. This is a first version.
|
| 44 |
+
- About 1 in 13 outputs did not compile in the held-out test. Always compile.
|
| 45 |
+
- It removes risky features; it does not find new bugs, and it can change behaviour. Review the diff.
|
| 46 |
+
- Only the scanner's six patterns. Not a general Solidity auditor.
|
| 47 |
|
| 48 |
+
Source, data generator and scorer: https://github.com/coroner-hash/ai
|