How dnchkw/toxic-text-detection works
Main Components
• Frontend: Located in the “frontend” directory. This includes the index.html, script.js, and style.css which collectively deliver the UI that users interact with in their browser.
• Backend: The “backend” folder holds app.py, indicating the server-side logic, likely handling API requests between the UI and the ML model.
• Entry Point: The main.py file in the root is the central orchestrator that likely ties together the backend and ML model serving.
• Machine Learning Model: The “model” directory containing model_pipeline.joblib represents the trained toxic text detection pipeline.
• Data Sources and Utilities:
– The “data” directory holds data.csv, which might have been used for model training or evaluation.
– The “tokenizer.py” and the “utils” folder (with nltk_download.py) indicate that text preprocessing (tokenization and any necessary NLTK downloads) is an important part of the workflow.
• Experimentation/Prototyping: The “notebooks” directory (Notebook.ipynb) shows that prototype experiments or EDA were performed to fine-tune model behavior.
Relationships and Interactions
• User Interaction Flow: Users open a browser and navigate to localhost:8000 (as mentioned in the README). The request is handled by the backend server (backend/app.py or main.py invoking it).
• Data Flow: The front end sends user input (text) as an API call to the backend. The backend then communicates with the ML model (model_pipeline.joblib) — potentially via a call encapsulated in main.py — and returns a prediction (toxic or not toxic).
• Preprocessing: The tokenizer (tokenizer.py) and any initialization utilities (in utils/nltk_download.py) are used during either model loading or in the prediction workflow to ensure proper text preprocessing.
• Model Metrics: Screenshots show evaluation metrics (Precision-Recall curve), suggesting that model performance has been graphically documented. This can be noted as an additional monitoring component if desired.
• Separation of Concerns: Frontend/UI, Backend server, ML Model, and Data/Preprocessing utilities are clearly separated.
• Layered Approach: The web layer (frontend) communicates with an application layer (backend) which, in turn, integrates with model prediction services.
• Modular Design: Dedicated directories for model artifacts, utilities, and experiments support modularity and future extensibility.
Technologies and Frameworks
• Python is used extensively (Python version specified in .python-version and required by the project).
• uv (mentioned in the README and uv.lock) suggests a lightweight environment or a particular web runner setup.
• Standard web technologies for the frontend (HTML, CSS, JavaScript) and possibly a web framework in the backend (such as Flask or FastAPI, even if not explicitly stated) are in use.
• Joblib is used for the ML pipeline persistence in the model folder.