Update README.md
Browse files
README.md
CHANGED
|
@@ -12,95 +12,163 @@ pipeline_tag: text-classification
|
|
| 12 |
---
|
| 13 |
# Model Card for Model ID
|
| 14 |
|
| 15 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
| 16 |
-
|
| 17 |
-
This modelcard aims to be a base template for new models. It has been generated using [this raw template](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1).
|
| 18 |
-
|
| 19 |
## Model Details
|
| 20 |
|
|
|
|
|
|
|
| 21 |
### Model Description
|
| 22 |
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
|
| 27 |
- **Developed by:** [noobpk](https://github.com/noobpk/)
|
| 28 |
|
| 29 |
### Model Sources
|
| 30 |
|
| 31 |
-
<!-- Provide the basic links for the model. -->
|
| 32 |
-
|
| 33 |
- **Paper :** [Research and Development of a Smart Solution for Runtime Web Application Self-Protection](https://doi.org/10.1145/3628797.3628901)
|
| 34 |
|
| 35 |
## Uses
|
| 36 |
|
| 37 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 38 |
-
|
| 39 |
### Direct Use
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
[More Information Needed]
|
| 44 |
-
|
| 45 |
-
### Downstream Use [optional]
|
| 46 |
|
| 47 |
-
|
| 48 |
|
| 49 |
-
|
| 50 |
|
| 51 |
### Out-of-Scope Use
|
| 52 |
|
| 53 |
-
|
| 54 |
|
| 55 |
-
|
| 56 |
|
| 57 |
## Bias, Risks, and Limitations
|
| 58 |
|
| 59 |
-
|
| 60 |
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
### Recommendations
|
| 64 |
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
-
|
| 68 |
|
| 69 |
## How to Get Started with the Model
|
| 70 |
|
| 71 |
Use the code below to get started with the model.
|
| 72 |
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
## Training Details
|
| 76 |
|
| 77 |
### Training Data
|
| 78 |
|
| 79 |
-
|
| 80 |
|
| 81 |
-
|
| 82 |
|
| 83 |
-
|
| 84 |
|
| 85 |
-
|
| 86 |
|
| 87 |
-
|
| 88 |
|
| 89 |
-
|
| 90 |
|
|
|
|
| 91 |
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
-
-
|
| 95 |
-
learning_rate : 0.001
|
| 96 |
-
activation : relu
|
| 97 |
-
batch_size : 256
|
| 98 |
-
loss : binary_crossentropy
|
| 99 |
-
optimizer : Adam
|
| 100 |
-
Conv1D : 32 - 64 - 128 - 256 - 512
|
| 101 |
-
GRU : 32 - 64 - 128 - 256 - 512
|
| 102 |
-
|
| 103 |
-
|
| 104 |
|
| 105 |
#### Speeds, Sizes, Times [optional]
|
| 106 |
|
|
@@ -110,38 +178,34 @@ Use the code below to get started with the model.
|
|
| 110 |
|
| 111 |
## Evaluation
|
| 112 |
|
| 113 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 114 |
-
|
| 115 |
### Testing Data, Factors & Metrics
|
| 116 |
|
| 117 |
#### Testing Data
|
| 118 |
|
| 119 |
-
|
| 120 |
|
| 121 |
-
|
| 122 |
|
| 123 |
#### Factors
|
| 124 |
|
| 125 |
-
|
| 126 |
|
| 127 |
-
[More Information Needed]
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 132 |
|
|
|
|
| 133 |
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
### Results
|
| 137 |
|
| 138 |
-
[More Information Needed]
|
| 139 |
|
| 140 |
#### Summary
|
| 141 |
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
### Model Architecture and Objective
|
| 145 |
|
| 146 |

|
| 147 |
|
|
@@ -155,8 +219,6 @@ Use the code below to get started with the model.
|
|
| 155 |
|
| 156 |
## Citation
|
| 157 |
|
| 158 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 159 |
-
|
| 160 |
**BibTeX:**
|
| 161 |
|
| 162 |
@inproceedings{10.1145/3628797.3628901,
|
|
@@ -177,21 +239,10 @@ location = {Ho Chi Minh, Vietnam},
|
|
| 177 |
series = {SOICT '23}
|
| 178 |
}
|
| 179 |
|
|
|
|
| 180 |
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 184 |
-
|
| 185 |
-
[More Information Needed]
|
| 186 |
-
|
| 187 |
-
## More Information [optional]
|
| 188 |
-
|
| 189 |
-
[More Information Needed]
|
| 190 |
-
|
| 191 |
-
## Model Card Authors [optional]
|
| 192 |
-
|
| 193 |
-
[More Information Needed]
|
| 194 |
|
| 195 |
## Model Card Contact
|
| 196 |
|
| 197 |
-
[
|
|
|
|
| 12 |
---
|
| 13 |
# Model Card for Model ID
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
## Model Details
|
| 16 |
|
| 17 |
+

|
| 18 |
+
|
| 19 |
### Model Description
|
| 20 |
|
| 21 |
+
This model combines Convolutional Neural Networks (CNN) and Gated Recurrent Units (GRU), designed for sequence-based tasks like time series analysis, natural language processing (NLP), or anomaly detection.
|
| 22 |
+
|
| 23 |
+
### 1. Input Layer
|
| 24 |
+
- **Shape:** `(None, 384)` — Variable batch size, input dimension of 384.
|
| 25 |
+
- **Reshape:** Converts input to `(None, 384, 1)` to add a channel dimension for Conv1D layers.
|
| 26 |
+
|
| 27 |
+
### 2. Two Parallel Branches
|
| 28 |
+
|
| 29 |
+
#### a) CNN Branch
|
| 30 |
+
- **Conv1D Layers:**
|
| 31 |
+
- Filters: 32, 64, 128, 256 (increasing depth)
|
| 32 |
+
- Kernel size: (not shown, likely small like 3)
|
| 33 |
+
- **MaxPooling1D:** Applied after each Conv1D layer to reduce dimensionality.
|
| 34 |
+
- **GlobalMaxPooling1D:** Final pooling layer reducing output to shape `(None, 256)`.
|
| 35 |
+
|
| 36 |
+
#### b) GRU Branch
|
| 37 |
+
- **GRU Layers:**
|
| 38 |
+
- Units: 32, 64, 128, 256 (increasing capacity)
|
| 39 |
+
- Stacked for hierarchical feature extraction.
|
| 40 |
+
- Final GRU outputs shape `(None, 256)`.
|
| 41 |
+
|
| 42 |
+
### 3. Fusion Layer
|
| 43 |
+
- **Multiply:** Element-wise multiplication of outputs from CNN and GRU branches.
|
| 44 |
+
- **Shape:** `(None, 256)`
|
| 45 |
|
| 46 |
+
### 4. Dense Layers
|
| 47 |
+
- **Dropout:** Applied for regularization.
|
| 48 |
+
- **Fully Connected Layers:**
|
| 49 |
+
- 256 → 128 → 64 → 32 → 1
|
| 50 |
+
- Gradually reducing dimensions for feature compression.
|
| 51 |
+
- **Output:** A single value — suitable for regression or binary classification.
|
| 52 |
+
|
| 53 |
+
### 5. Likely Use Cases
|
| 54 |
+
- Web attack detection
|
| 55 |
+
- Sequence classification
|
| 56 |
+
- Anomaly detection in time series
|
| 57 |
+
|
| 58 |
+
This architecture captures both spatial features (CNN) and temporal dependencies (GRU), making it well-suited for complex sequential data. Let me know if you’d like help tweaking or interpreting this model! 🚀
|
| 59 |
|
| 60 |
|
| 61 |
- **Developed by:** [noobpk](https://github.com/noobpk/)
|
| 62 |
|
| 63 |
### Model Sources
|
| 64 |
|
|
|
|
|
|
|
| 65 |
- **Paper :** [Research and Development of a Smart Solution for Runtime Web Application Self-Protection](https://doi.org/10.1145/3628797.3628901)
|
| 66 |
|
| 67 |
## Uses
|
| 68 |
|
|
|
|
|
|
|
| 69 |
### Direct Use
|
| 70 |
|
| 71 |
+
- Intrusion Detection: Identify suspicious activity in network traffic data.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
+
- Sentiment Analysis: Analyze sequential text data to determine sentiment polarity.
|
| 74 |
|
| 75 |
+
- Time Series Forecasting: Predict future values based on historical data trends.
|
| 76 |
|
| 77 |
### Out-of-Scope Use
|
| 78 |
|
| 79 |
+
- Image classification: This model is not optimized for handling spatial features in images.
|
| 80 |
|
| 81 |
+
- Tabular data analysis: It’s designed for sequential data and may not capture non-temporal relationships well.
|
| 82 |
|
| 83 |
## Bias, Risks, and Limitations
|
| 84 |
|
| 85 |
+
- Data Bias: The model’s performance heavily depends on the quality and diversity of training data. Biased or imbalanced datasets could lead to unfair or inaccurate predictions.
|
| 86 |
|
| 87 |
+
- Overfitting: With its depth and complexity, the model may overfit smaller datasets, capturing noise rather than meaningful patterns.
|
| 88 |
+
|
| 89 |
+
- Interpretability: CNN-GRU models can be seen as black boxes, making it difficult to interpret why specific predictions are made.
|
| 90 |
+
|
| 91 |
+
- Computational Costs: The parallel CNN-GRU architecture can demand significant resources during training and inference, potentially leading to longer processing times.
|
| 92 |
|
| 93 |
### Recommendations
|
| 94 |
|
| 95 |
+
- Balanced Dataset: Ensure training data represents diverse and balanced samples to mitigate bias.
|
| 96 |
+
|
| 97 |
+
- Regularization: Apply dropout and early stopping to prevent overfitting.
|
| 98 |
+
|
| 99 |
+
- Hyperparameter Tuning: Experiment with layer configurations, learning rates, and optimization techniques to enhance generalization.
|
| 100 |
+
|
| 101 |
+
- Explainability Tools: Use SHAP or LIME libraries to interpret model predictions and understand feature importance.
|
| 102 |
|
| 103 |
+
- Infrastructure: Deploy the model on systems with sufficient computational power, especially for real-time or large-scale applications.
|
| 104 |
|
| 105 |
## How to Get Started with the Model
|
| 106 |
|
| 107 |
Use the code below to get started with the model.
|
| 108 |
|
| 109 |
+
```
|
| 110 |
+
import os
|
| 111 |
+
os.environ["KERAS_BACKEND"] = "tensorflow"
|
| 112 |
+
|
| 113 |
+
from tensorflow.keras.models import load_model
|
| 114 |
+
from sentence_transformers import SentenceTransformer
|
| 115 |
+
from huggingface_hub import hf_hub_download
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def load_modeler():
|
| 119 |
+
local_model_path = hf_hub_download(
|
| 120 |
+
repo_id="noobpk/web-attack-detection",
|
| 121 |
+
filename="model.h5"
|
| 122 |
+
)
|
| 123 |
+
return load_model(local_model_path)
|
| 124 |
+
|
| 125 |
+
model = load_modeler()
|
| 126 |
+
|
| 127 |
+
def load_encoder():
|
| 128 |
+
model_name_or_path = os.environ.get("model_name_or_path", "sentence-transformers/all-MiniLM-L6-v2")
|
| 129 |
+
return SentenceTransformer(model_name_or_path)
|
| 130 |
+
|
| 131 |
+
encoder = load_encoder()
|
| 132 |
+
|
| 133 |
+
if __name__ == "__main__":
|
| 134 |
+
payload = input("Enter payload: ")
|
| 135 |
+
print("Processing...")
|
| 136 |
+
|
| 137 |
+
embeddings = encoder.encode(payload).reshape((1, 384))
|
| 138 |
+
prediction = model.predict(embeddings)
|
| 139 |
+
accuracy = float(prediction[0][0] * 100)
|
| 140 |
+
print(f"Accuracy: {accuracy}")
|
| 141 |
+
```
|
| 142 |
|
| 143 |
## Training Details
|
| 144 |
|
| 145 |
### Training Data
|
| 146 |
|
| 147 |
+
Dataset: https://huggingface.co/datasets/noobpk/web-attack-detection
|
| 148 |
|
| 149 |
+
- Using 70% for training data
|
| 150 |
|
| 151 |
+
#### Training Hyperparameters
|
| 152 |
|
| 153 |
+
- Optimizer: Adam with initial learning rate 0.001
|
| 154 |
|
| 155 |
+
- Learning Rate Schedule: InverseTimeDecay with decay steps of 1000 and decay rate of 0.1
|
| 156 |
|
| 157 |
+
- Batch Size: 256
|
| 158 |
|
| 159 |
+
- Epochs: Configurable, with early stopping after 3 epochs of no improvement
|
| 160 |
|
| 161 |
+
- Dropout Rates:
|
| 162 |
+
|
| 163 |
+
- - 0.1 after CNN and GRU branches
|
| 164 |
+
|
| 165 |
+
- - 0.3 after feature fusion
|
| 166 |
+
|
| 167 |
+
- Cross-Validation: K-Fold cross-validation with k=5 (or configurable)
|
| 168 |
+
|
| 169 |
+
- Loss Function: Binary cross-entropy
|
| 170 |
|
| 171 |
+
- Metrics: Accuracy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
#### Speeds, Sizes, Times [optional]
|
| 174 |
|
|
|
|
| 178 |
|
| 179 |
## Evaluation
|
| 180 |
|
|
|
|
|
|
|
| 181 |
### Testing Data, Factors & Metrics
|
| 182 |
|
| 183 |
#### Testing Data
|
| 184 |
|
| 185 |
+
Dataset: https://huggingface.co/datasets/noobpk/web-attack-detection
|
| 186 |
|
| 187 |
+
- Using 30% for testing data
|
| 188 |
|
| 189 |
#### Factors
|
| 190 |
|
| 191 |
+

|
| 192 |
|
|
|
|
| 193 |
|
| 194 |
+

|
|
|
|
|
|
|
| 195 |
|
| 196 |
+
#### Metrics
|
| 197 |
|
| 198 |
+
- precision
|
| 199 |
+
- f1-score
|
| 200 |
+
- recall
|
| 201 |
+
- accuracy
|
| 202 |
|
| 203 |
### Results
|
| 204 |
|
|
|
|
| 205 |
|
| 206 |
#### Summary
|
| 207 |
|
| 208 |
+
### Model Architecture and Objective: Hybrid CNN-GRU
|
|
|
|
|
|
|
| 209 |
|
| 210 |

|
| 211 |
|
|
|
|
| 219 |
|
| 220 |
## Citation
|
| 221 |
|
|
|
|
|
|
|
| 222 |
**BibTeX:**
|
| 223 |
|
| 224 |
@inproceedings{10.1145/3628797.3628901,
|
|
|
|
| 239 |
series = {SOICT '23}
|
| 240 |
}
|
| 241 |
|
| 242 |
+
## Model Card Authors
|
| 243 |
|
| 244 |
+
[noobpk](https://github.com/noobpk/)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
|
| 246 |
## Model Card Contact
|
| 247 |
|
| 248 |
+
[noobpk](t.me/noobpk)
|