Text Generation
Transformers
Safetensors
English
qwen3
stablecoin
payments
compliance
x402
eip-3009
eip-712
disputes
refunds
agents
agentkit
trl
web3
usdc
fraud-detection
financial-risk
qwen
mcp
ai-agents
prompt-injection
agentic-payments
payment-security
risk-assessment
ofac
conversational
Eval Results (legacy)
Eval Results
text-generation-inference
Instructions to use sriram1983007/SRA-RiskGate-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sriram1983007/SRA-RiskGate-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sriram1983007/SRA-RiskGate-4B") 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("sriram1983007/SRA-RiskGate-4B") model = AutoModelForCausalLM.from_pretrained("sriram1983007/SRA-RiskGate-4B", 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 sriram1983007/SRA-RiskGate-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sriram1983007/SRA-RiskGate-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sriram1983007/SRA-RiskGate-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sriram1983007/SRA-RiskGate-4B
- SGLang
How to use sriram1983007/SRA-RiskGate-4B 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 "sriram1983007/SRA-RiskGate-4B" \ --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": "sriram1983007/SRA-RiskGate-4B", "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 "sriram1983007/SRA-RiskGate-4B" \ --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": "sriram1983007/SRA-RiskGate-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use sriram1983007/SRA-RiskGate-4B with Docker Model Runner:
docker model run hf.co/sriram1983007/SRA-RiskGate-4B
Update README.md
Browse files
README.md
CHANGED
|
@@ -19,6 +19,7 @@ tags:
|
|
| 19 |
- disputes
|
| 20 |
- refunds
|
| 21 |
- agents
|
|
|
|
| 22 |
- trl
|
| 23 |
- web3
|
| 24 |
- usdc
|
|
@@ -29,10 +30,10 @@ tags:
|
|
| 29 |
- text-generation
|
| 30 |
---
|
| 31 |
|
| 32 |
-
# ๐ก๏ธ SRA-RiskGate-4B
|
| 33 |
|
| 34 |
[](https://pypi.org/project/sra-riskgate/)
|
| 35 |
-
[](https://sriram1983007-sra-riskgate-demo.static.hf.space/index.html)
|
| 37 |
[](https://huggingface.co/datasets/sriram1983007/sra-stablecoin-risk-bench)
|
| 38 |
[](https://huggingface.co/sriram1983007/SRA-RiskGate-4B-Q4_K_M-GGUF)
|
|
@@ -47,6 +48,57 @@ It is engineered for both ends of a stablecoin payment's operational lifecycle:
|
|
| 47 |
|
| 48 |
---
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
## ๐ Transformers Quickstart
|
| 51 |
|
| 52 |
The model expects the standard ChatML template and outputs strict JSON conforming to the [sra-stablecoin-risk-bench](https://huggingface.co/datasets/sriram1983007/sra-stablecoin-risk-bench) schema:
|
|
@@ -163,6 +215,7 @@ with torch.no_grad():
|
|
| 163 |
|
| 164 |
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
| 165 |
print(json.dumps(json.loads(response), indent=2))
|
|
|
|
| 166 |
```
|
| 167 |
|
| 168 |
### Output Schema (`risk_gate`)
|
|
@@ -181,6 +234,7 @@ print(json.dumps(json.loads(response), indent=2))
|
|
| 181 |
"obtain_attestation_from_trusted_attester"
|
| 182 |
]
|
| 183 |
}
|
|
|
|
| 184 |
```
|
| 185 |
|
| 186 |
---
|
|
@@ -191,6 +245,7 @@ The `sra-riskgate` SDK provides zero-latency deterministic pre-filtering rules (
|
|
| 191 |
|
| 192 |
```bash
|
| 193 |
pip install --upgrade sra-riskgate
|
|
|
|
| 194 |
```
|
| 195 |
|
| 196 |
```python
|
|
@@ -208,11 +263,12 @@ tx = TransactionPayload(
|
|
| 208 |
)
|
| 209 |
|
| 210 |
verdict = gate.inspect(tx)
|
| 211 |
-
print("Decision:
|
| 212 |
-
print("Risk Score:
|
| 213 |
-
print("Flags:
|
| 214 |
-
print("Required Actions:", verdict.required_actions)
|
| 215 |
-
print("Explanation:
|
|
|
|
| 216 |
```
|
| 217 |
|
| 218 |
---
|
|
@@ -223,11 +279,13 @@ Run locally via Ollama with greedy sampling (`temperature 0.0`) to ensure valid
|
|
| 223 |
|
| 224 |
```bash
|
| 225 |
ollama run sriram1983007/sra-riskgate
|
|
|
|
| 226 |
```
|
| 227 |
|
| 228 |
*Note: Ensure `temperature 0.0` is configured in your `Modelfile`.*
|
| 229 |
|
| 230 |
---
|
|
|
|
| 231 |
## ๐ Benchmark Evaluation (Held-Out Test Split)
|
| 232 |
|
| 233 |
Evaluated against the 2,000-case test set in [`sra-stablecoin-risk-bench`](https://huggingface.co/datasets/sriram1983007/sra-stablecoin-risk-bench) using `score.py`:
|
|
@@ -252,4 +310,4 @@ Evaluated against the 2,000-case test set in [`sra-stablecoin-risk-bench`](https
|
|
| 252 |
|
| 253 |
## โ๏ธ License
|
| 254 |
|
| 255 |
-
Distributed under the Apache 2.0 License.
|
|
|
|
| 19 |
- disputes
|
| 20 |
- refunds
|
| 21 |
- agents
|
| 22 |
+
- agentkit
|
| 23 |
- trl
|
| 24 |
- web3
|
| 25 |
- usdc
|
|
|
|
| 30 |
- text-generation
|
| 31 |
---
|
| 32 |
|
| 33 |
+
# ๐ก๏ธ๏ธ SRA-RiskGate-4B
|
| 34 |
|
| 35 |
[](https://pypi.org/project/sra-riskgate/)
|
| 36 |
+
[](https://pypi.org/project/sra-riskgate/)
|
| 37 |
[](https://sriram1983007-sra-riskgate-demo.static.hf.space/index.html)
|
| 38 |
[](https://huggingface.co/datasets/sriram1983007/sra-stablecoin-risk-bench)
|
| 39 |
[](https://huggingface.co/sriram1983007/SRA-RiskGate-4B-Q4_K_M-GGUF)
|
|
|
|
| 48 |
|
| 49 |
---
|
| 50 |
|
| 51 |
+
## ๐ค Autonomous Agent Firewall (Coinbase AgentKit Integration)
|
| 52 |
+
|
| 53 |
+
Autonomous on-chain agents can hallucinate payment transfers, sign malformed calldata, or trigger catastrophic transactions during market depegs.
|
| 54 |
+
|
| 55 |
+
The deterministic pre-filter and policy firewall is available directly as a plug-and-play **Action Provider** for the [Coinbase AgentKit](https://github.com/coinbase/agentkit) framework:
|
| 56 |
+
|
| 57 |
+
```bash
|
| 58 |
+
pip install "sra-riskgate[agentkit]>=0.3.3"
|
| 59 |
+
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
### Drop-in Agent Firewall Example
|
| 63 |
+
|
| 64 |
+
Add `RiskGateActionProvider` to intercept and gate transaction attempts before wallet signing:
|
| 65 |
+
|
| 66 |
+
```python
|
| 67 |
+
from coinbase_agentkit import AgentKit, CdpWalletProvider, CdpWalletProviderConfig
|
| 68 |
+
from sra_riskgate.integrations.agentkit import RiskGateActionProvider
|
| 69 |
+
|
| 70 |
+
# 1. Initialize your wallet provider
|
| 71 |
+
wallet_provider = CdpWalletProvider(CdpWalletProviderConfig())
|
| 72 |
+
|
| 73 |
+
# 2. Wrap agent execution with the deterministic RiskGate firewall
|
| 74 |
+
agentkit = AgentKit(
|
| 75 |
+
ActionProviderOptions(
|
| 76 |
+
wallet_provider=wallet_provider,
|
| 77 |
+
action_providers=[
|
| 78 |
+
RiskGateActionProvider(
|
| 79 |
+
max_amount=1000.0, # Ceiling per transaction (USDC)
|
| 80 |
+
depeg_hold_pct=1.0, # Triggers manual review if depeg >= 1%
|
| 81 |
+
depeg_reject_pct=5.0 # Hard aborts execution if depeg >= 5%
|
| 82 |
+
)
|
| 83 |
+
]
|
| 84 |
+
)
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
### Deterministic Risk Enforcement
|
| 90 |
+
|
| 91 |
+
Every payment action triggered by the LLM is intercepted and validated against strict financial safety boundaries:
|
| 92 |
+
|
| 93 |
+
| Check | Action Taken | Why It Matters |
|
| 94 |
+
| --- | --- | --- |
|
| 95 |
+
| **Invalid / Zero Address** | Hard Reject | Aborts `0x0...0` burner or malformed hex executions |
|
| 96 |
+
| **Self-Transfer** | Hard Reject | Blocks recursive/hallucinated self-loops draining gas |
|
| 97 |
+
| **Exceeds Amount Ceiling** | Paused (HOLD) | Intercepts rogue agent spending beyond allocated policy |
|
| 98 |
+
| **Severe Depeg ($\ge 5\%$)** | Critical Abort | Prevents clearing payments in collapsing or compromised assets |
|
| 99 |
+
|
| 100 |
+
---
|
| 101 |
+
|
| 102 |
## ๐ Transformers Quickstart
|
| 103 |
|
| 104 |
The model expects the standard ChatML template and outputs strict JSON conforming to the [sra-stablecoin-risk-bench](https://huggingface.co/datasets/sriram1983007/sra-stablecoin-risk-bench) schema:
|
|
|
|
| 215 |
|
| 216 |
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
| 217 |
print(json.dumps(json.loads(response), indent=2))
|
| 218 |
+
|
| 219 |
```
|
| 220 |
|
| 221 |
### Output Schema (`risk_gate`)
|
|
|
|
| 234 |
"obtain_attestation_from_trusted_attester"
|
| 235 |
]
|
| 236 |
}
|
| 237 |
+
|
| 238 |
```
|
| 239 |
|
| 240 |
---
|
|
|
|
| 245 |
|
| 246 |
```bash
|
| 247 |
pip install --upgrade sra-riskgate
|
| 248 |
+
|
| 249 |
```
|
| 250 |
|
| 251 |
```python
|
|
|
|
| 263 |
)
|
| 264 |
|
| 265 |
verdict = gate.inspect(tx)
|
| 266 |
+
print("Decision: ", verdict.decision.value) # hold
|
| 267 |
+
print("Risk Score: ", verdict.risk_score) # 0.65
|
| 268 |
+
print("Flags: ", verdict.flags) # ['MODERATE_DEPEG']
|
| 269 |
+
print("Required Actions:", verdict.required_actions) # ['manual_review']
|
| 270 |
+
print("Explanation: ", verdict.explanation)
|
| 271 |
+
|
| 272 |
```
|
| 273 |
|
| 274 |
---
|
|
|
|
| 279 |
|
| 280 |
```bash
|
| 281 |
ollama run sriram1983007/sra-riskgate
|
| 282 |
+
|
| 283 |
```
|
| 284 |
|
| 285 |
*Note: Ensure `temperature 0.0` is configured in your `Modelfile`.*
|
| 286 |
|
| 287 |
---
|
| 288 |
+
|
| 289 |
## ๐ Benchmark Evaluation (Held-Out Test Split)
|
| 290 |
|
| 291 |
Evaluated against the 2,000-case test set in [`sra-stablecoin-risk-bench`](https://huggingface.co/datasets/sriram1983007/sra-stablecoin-risk-bench) using `score.py`:
|
|
|
|
| 310 |
|
| 311 |
## โ๏ธ License
|
| 312 |
|
| 313 |
+
Distributed under the Apache 2.0 License.
|