bert-log-anomaly-detection
74
license:apache-2.0
by
AungMoonLord
Other
OTHER
New
74 downloads
Early-stage
Edge AI:
Mobile
Laptop
Server
Unknown
Mobile
Laptop
Server
Quick Summary
AI model with specialized capabilities.
Code Examples
add tokenpython
def predict_log(log_text):
log_text = add_prefix_token(log_text)
inputs = tokenizer(
log_text,
return_tensors="pt",
truncation=True,
padding=True, # for cases when the inference contains more than 1 log, i.e., batch size > 1
max_length=128
)
with torch.no_grad():
logits = model(**inputs).logits
pred = torch.argmax(logits, dim=1).item()
prob = torch.softmax(logits, dim=-1).tolist()[0]
return "Normal" if pred == 1 else "Anomaly", probStep 4 (Samples of Inferences)python
# Example 1
text1 = "SELECT * FROM users WHERE id = 1 OR 1=1"
print(predict_log(text1))
# Example 2
text2 = "2025-01-06 14:23:45 | User: anonymous | IP: 203.154.89.102 | Duration: 0.05s SELECT * FROM users WHERE username = 'admin' OR '1'='1' -- ' AND password = 'x'"
print(predict_log(text2))
# Example 3
text3 = "3051-06-22T07:20:02.296945Z 3 Query select e3mJKDCCY from 7Q8SpG8LLEWhrfpe4s5 where ph4d = 'a1S9hQa92uC1EAyJf2Y';"
print(predict_log(text3))Deploy This Model
Production-ready deployment in minutes
Together.ai
Instant API access to this model
Production-ready inference API. Start free, scale to millions.
Try Free APIReplicate
One-click model deployment
Run models in the cloud with simple API. No DevOps required.
Deploy NowDisclosure: We may earn a commission from these partners. This helps keep LLMYourWay free.