Text Classification
Keras
English
Azerbaijani
prompt-injection
security
llm-security
document-security
retvec
cnn
tensorflow
fastapi
Eval Results (legacy)
Instructions to use MegrurNiftiyev/MyGuard-Prompt-Injection-Detector with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use MegrurNiftiyev/MyGuard-Prompt-Injection-Detector with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://MegrurNiftiyev/MyGuard-Prompt-Injection-Detector") - Notebooks
- Google Colab
- Kaggle
Download tests/test_model_registry.py from MegrurNiftiyev/MyGuard-Prompt-Injection-Detector: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/MegrurNiftiyev/MyGuard-Prompt-Injection-Detector/resolve/main/tests/test_model_registry.py
- Command line
-
hf download hf://MegrurNiftiyev/MyGuard-Prompt-Injection-Detector/tests/test_model_registry.py
-
curl -L -o test_model_registry.py https://huggingface.co/MegrurNiftiyev/MyGuard-Prompt-Injection-Detector/resolve/main/tests/test_model_registry.py
1.09 kB
| """ | |
| Tests for the model registry module. | |
| """ | |
| import pytest | |
| from app.ml.serving.registry import ( | |
| DummyModel, | |
| serialize_model, | |
| deserialize_model, | |
| ) | |
| class TestDummyModel: | |
| """Verify the DummyModel stub works as expected.""" | |
| def test_predict_returns_tuple(self): | |
| model = DummyModel() | |
| result = model.predict("some text") | |
| assert isinstance(result, tuple) | |
| assert len(result) == 2 | |
| def test_predict_label(self): | |
| model = DummyModel() | |
| label, confidence = model.predict("anything") | |
| assert label == "safe" | |
| assert isinstance(confidence, float) | |
| class TestSerialization: | |
| """Verify model serialize/deserialize round-trips correctly.""" | |
| def test_round_trip(self): | |
| original = DummyModel() | |
| blob = serialize_model(original) | |
| assert isinstance(blob, bytes) | |
| restored = deserialize_model(blob) | |
| assert isinstance(restored, DummyModel) | |
| # Verify the restored model still works | |
| label, confidence = restored.predict("test") | |
| assert label == "safe" | |