etechoptimist commited on
Commit
c10f136
·
1 Parent(s): 7e9cd65

using distilbert-base-uncased

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -19,10 +19,10 @@ def anomalies_detector(logs: str) -> list[tuple[int, str]]:
19
  Returns:
20
  list[tuple[int, str]]: List of tuples containing (line_number, anomalous_text)
21
  """
22
- # Initialize the text classification pipeline with a model specialized in text classification
23
  classifier = pipeline(
24
  "text-classification",
25
- model="distilbert-base-uncased-finetuned-sst-2-english", # Using a model fine-tuned for sentiment/classification
26
  top_k=2 # Get both normal and anomalous probabilities
27
  )
28
 
@@ -41,7 +41,7 @@ def anomalies_detector(logs: str) -> list[tuple[int, str]]:
41
  # Check if the line is classified as anomalous
42
  # The model returns probabilities for both classes
43
  for result in results:
44
- if result['label'] == 'NEGATIVE' and result['score'] > 0.7: # NEGATIVE indicates potential anomaly
45
  anomalies.append((line_num, line))
46
  break
47
 
@@ -53,7 +53,7 @@ demo = gr.Interface(
53
  inputs="textbox",
54
  outputs="text",
55
  title="Log Anomaly Detector",
56
- description="Enter log entries to detect anomalous patterns using AI. The system will identify unusual patterns, errors, and potential issues in your logs."
57
  )
58
 
59
  # Launch both the Gradio web interface and the MCP server
 
19
  Returns:
20
  list[tuple[int, str]]: List of tuples containing (line_number, anomalous_text)
21
  """
22
+ # Initialize the text classification pipeline with a smaller, more reliable model
23
  classifier = pipeline(
24
  "text-classification",
25
+ model="distilbert-base-uncased", # Using a smaller, more reliable model
26
  top_k=2 # Get both normal and anomalous probabilities
27
  )
28
 
 
41
  # Check if the line is classified as anomalous
42
  # The model returns probabilities for both classes
43
  for result in results:
44
+ if result['label'] == 'LABEL_1' and result['score'] > 0.7: # LABEL_1 indicates potential anomaly
45
  anomalies.append((line_num, line))
46
  break
47
 
 
53
  inputs="textbox",
54
  outputs="text",
55
  title="Log Anomaly Detector",
56
+ description="Enter log entries to detect anomalous patterns using BERT Model. The system will identify unusual patterns, errors, and potential issues in your logs."
57
  )
58
 
59
  # Launch both the Gradio web interface and the MCP server