许可证:apache-2.0
语言:
模型卡片(Model ID)
基于google/mobilebert-uncased(MobileBERT是BERT_LARGE的轻量化版本,采用瓶颈结构并精心平衡了自注意力机制与前馈网络)。该模型用于检测输入字符串中的SQL注入攻击(使用方法见下文)。这是一个极其轻量的模型(100MB),适用于边缘计算场景。训练数据来自Kaggle的SQL_Injection数据集。
部署前请务必测试模型性能
联系我们获取更多信息:support@cloudsummary.com
代码仓库
项目代码详见:https://github.com/cssupport23/AI-Model---SQL-Injection-Attack-Detector
模型详情
模型描述
模型来源
模型来源请参考google/mobilebert-uncased。
快速开始
使用以下代码加载模型:
import torch
from transformers import MobileBertTokenizer, MobileBertForSequenceClassification
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
tokenizer = MobileBertTokenizer.from_pretrained('google/mobilebert-uncased')
model = MobileBertForSequenceClassification.from_pretrained('cssupport/mobilebert-sql-injection-detect')
model.to(device)
model.eval()
def predict(text):
inputs = tokenizer(text, padding=False, truncation=True, return_tensors='pt', max_length=512)
input_ids = inputs['input_ids'].to(device)
attention_mask = inputs['attention_mask'].to(device)
with torch.no_grad():
outputs = model(input_ids=input_ids, attention_mask=attention_mask)
logits = outputs.logits
probabilities = torch.softmax(logits, dim=1)
predicted_class = torch.argmax(probabilities, dim=1).item()
return predicted_class, probabilities[0][predicted_class].item()
text ="select * from users where id = 1 or 1#\"? = 1 or 1 = 1 -- 1"
predicted_class, confidence = predict(text)
if predicted_class > 0.7:
print("检测结果:发现SQL注入攻击")
else:
print("检测结果:未发现SQL注入")
print(f"置信度:{confidence:.2f}")
应用场景
[需补充更多信息]
直接应用
适用于需要将自然语言转换为SQL查询的应用场景。
[需补充更多信息]
非适用场景
[需补充更多信息]
偏差、风险与局限性
[需补充更多信息]
使用建议
应确保用户(包括直接使用者和下游用户)了解模型的潜在风险、偏差和局限性。需补充更多信息以提供进一步建议。
技术规格
模型架构与目标
google/mobilebert-uncased
计算基础设施
硬件
单块P6000 GPU
软件
PyTorch与HuggingFace
免责声明
仅限教育/研究用途
本模型仅用于教育和研究目的,禁止用于恶意活动或其他违法行为。
无担保条款
本模型按"原样"提供,不提供任何明示或默示担保。不保证其准确性、可靠性或性能,使用风险由用户自行承担。
责任限制
模型开发者、维护者及贡献者不对因使用本模型导致的任何直接/间接损失(包括但不限于数据丢失、业务中断等)承担责任,即使已被告知可能发生此类损害。
使用后果免责
对于因模型未能检测到SQL注入攻击或产生误报导致的任何后果,我们不承担任何责任。
用户责任
使用或下载本模型即表示您同意遵守所有适用法律法规。任何滥用行为(包括用于实施恶意活动)均由使用者承担全部责任。