Based on
google/mobilebert-uncased
(MobileBERT is a thin version of BERT_LARGE, while equipped with bottleneck structures and a carefully designed balance between self-attentions and feed-forward networks). This model detects SQLInjection attacks in the input string (check How To Below). This is a very very light model (100mb) and can be used for edge computing use cases. Used dataset from
Kaggle
called
SQl_Injection
.
Please test the model before deploying into any environment
.
Contact us for more info:
support@cloudsummary.com
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()
defpredict(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 username = 'admin' AND password = 'password';"#text = "select * from users where username = 'admin' and password = 'password';"#text = "SELECT * from USERS where id = '1' or @ @1 = 1 union select 1,version ( ) -- 1'"#text = "select * from data where id = '1' or @"
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("Prediction: SQL Injection Detected")
else:
print("Prediction: No SQL Injection Detected")
print(f"Confidence: {confidence:.2f}")
# OUTPUT# Prediction: SQL Injection Detected# Confidence: 1.00
Uses
[More Information Needed]
Direct Use
Could used in application where natural language is to be converted into SQL queries.
[More Information Needed]
Out-of-Scope Use
[More Information Needed]
Bias, Risks, and Limitations
[More Information Needed]
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
mobilebert-sql-injection-detect huggingface.co is an AI model on huggingface.co that provides mobilebert-sql-injection-detect's model effect (), which can be used instantly with this cssupport mobilebert-sql-injection-detect model. huggingface.co supports a free trial of the mobilebert-sql-injection-detect model, and also provides paid use of the mobilebert-sql-injection-detect. Support call mobilebert-sql-injection-detect model through api, including Node.js, Python, http.
mobilebert-sql-injection-detect huggingface.co is an online trial and call api platform, which integrates mobilebert-sql-injection-detect's modeling effects, including api services, and provides a free online trial of mobilebert-sql-injection-detect, you can try mobilebert-sql-injection-detect online for free by clicking the link below.
cssupport mobilebert-sql-injection-detect online free url in huggingface.co:
mobilebert-sql-injection-detect is an open source model from GitHub that offers a free installation service, and any user can find mobilebert-sql-injection-detect on GitHub to install. At the same time, huggingface.co provides the effect of mobilebert-sql-injection-detect install, users can directly use mobilebert-sql-injection-detect installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
mobilebert-sql-injection-detect install url in huggingface.co: