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 app/api/routes/train.py from MegrurNiftiyev/MyGuard-Prompt-Injection-Detector: direct link, hf CLI and curl.
- Browser
- Download file 2.26 kB
-
https://huggingface.co/MegrurNiftiyev/MyGuard-Prompt-Injection-Detector/resolve/main/app/api/routes/train.py
- Command line
-
hf download hf://MegrurNiftiyev/MyGuard-Prompt-Injection-Detector/app/api/routes/train.py
-
curl -L -o train.py https://huggingface.co/MegrurNiftiyev/MyGuard-Prompt-Injection-Detector/resolve/main/app/api/routes/train.py
2.26 kB
| """ | |
| Training endpoints. | |
| POST /train — trigger a background training job | |
| GET /train/status/{job_id} — check training job status | |
| """ | |
| import uuid | |
| from datetime import datetime, timezone | |
| from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException | |
| from app.api.dependencies import verify_internal_service | |
| from app.models.schemas import TrainingJobResponse, ErrorResponse | |
| from app.core.firebase import get_firestore_db | |
| from app.jobs.training_job import run_training_job | |
| router = APIRouter(prefix="/train", tags=["Training"]) | |
| async def start_training(background_tasks: BackgroundTasks): | |
| """Start a new training job in the background.""" | |
| db = get_firestore_db() | |
| job_id = str(uuid.uuid4()) | |
| # Create job record in Firestore (survives service restarts) | |
| if db is not None: | |
| try: | |
| db.collection("training_jobs").document(job_id).set( | |
| { | |
| "jobId": job_id, | |
| "status": "queued", | |
| "createdAt": datetime.now(timezone.utc), | |
| } | |
| ) | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=f"Failed to create job in Firestore: {str(e)}") | |
| # Launch training as a background task | |
| background_tasks.add_task(run_training_job, job_id) | |
| return {"jobId": job_id, "status": "queued"} | |