Teeny-Tiny Castle: Learning Resources for AI Ethics and Safety

AI Ethics and Safety are (relatively) new fields, and most of the development community is still unaware of their tools (and how to handle them). To address this problem, we created the Teeny-Tiny Castle, an open-source repository that contains “Educational tools for AI Ethics and Safety Research”. Here, the developer can find many examples of how to address various problems raised in the literature (e.g., algorithmic discrimination, model opacity).

The Teeny-Tiny Castle repository has several examples of how to work ethically and safely with AI, mainly focusing on issues related to Accountability & Sustainability, Interpretability, Robustness/Adversarial, and Fairness, all being worked through examples that refer to some of the most common contemporary AI applications (e.g., Computer Vision, Natural language Processing, Classification & Forecasting, etc.). In case you are new to the field, you will also find in the Teeny-Tiny Castle an introductory course on ML.

Machine Learning Introduction Course 📈

Whether you’re a beginner or looking to refresh your skills, this course covers a range of essential topics in machine learning. From setting up your own workstation with Visual Studio Code to deploying a forecasting model as an API with FastAPI, each tutorial provides hands-on experience and practical knowledge.

TutorialGitHubColab
Build your own workstation with Visual Studio CodeLINK👈
Introduction to PythonLINKOpen In Colab
Basic Pandas, Scikit-learn, and Numpy tutorialLINKOpen In Colab
Gradient Descent from scratchLINKOpen In Colab
Linear Regression with gradient descent from scratchLINKOpen In Colab
Multi-Layer Perceptron with NumPyLINKOpen In Colab
Feed-Forward Neural Network from scratch with NumPyLINKOpen In Colab
Introduction to Keras and TensorFlow using the Fashion-MNIST datasetLINKOpen In Colab
Introduction to PyTorch using the Digit-MNIST datasetLINKOpen In Colab
Hyperparameter optimization with KerasTunerLINKOpen In Colab
Dataset processing with TFDSLINKOpen In Colab
Experimentation tracking with TensorboardLINKOpen In Colab
Introduction to recommendation systemsLINKOpen In Colab
Introduction to time series forecasting and XGBoostLINKOpen In Colab
Text classification with TransformersLINKOpen In Colab
Sequence-to-sequence modeling with RNNs and TransformersLINKOpen In Colab
Text-generation with the GPT architectureLINKOpen In Colab
Introduction to Reinforcement LearningLINKOpen In Colab
Creating ML apps with GradioLINKOpen In Colab
Deploying a forcasting model as an API with FastAPILINKOpen In Colab

Accountability and Sustainability ♻️

Learn how to generate model cards for transparent model reporting, explore the environmental impact of your models with CO2 emission reports from CodeCarbon, and navigate the accuracy-versus-sustainability dilemma.

TutorialGitHubColab
Accountability through Model ReportingLINKOpen In Colab
Tracking carbon emissions and power consumption with CodeCarbonLINKOpen In Colab
Architectural choices in computer vision and their impact on energy consumptionLINKOpen In Colab

Interpretability with CV 🖼️

Understanding and interpreting the decisions made by machine learning models is essential for building trust and making informed decisions. In this course, we explore various techniques for interpretability in computer vision. From introducing convolutional neural networks with CIFAR-10 to exploring feature visualization, maximum activation manipulation, saliency mapping, and using LIME for interpretation, each tutorial provides insights into the inner workings of CV models.

TutorialGitHubColab
Creating computer vision models for image classificationLINKOpen In Colab
Activation Maximization in CNNsLINKOpen In Colab
Introduction to saliency mapping with CNNsLINKOpen In Colab
Applying LIME to CNNsLINKOpen In Colab

Interpretability with NLP 📚

Unravel the complexities of natural language processing models and gain insights into their decision-making processes. From sentiment analysis and applying LIME explanations to LSTMs to exploring integrated gradients, interpreting BERT models, word2vector models, and embedding models, each tutorial provides a deep dive into NLP interpretability.

TutorialGitHubColab
Creating language models for text-classificationLINKOpen In Colab
Applying LIME explanations to shallow languge modelsLINKOpen In Colab
Applying integrated gradients to Language ModelsLINKOpen In Colab
Explaining DistilBERT with integrated gradientsLINKOpen In Colab
Training and Exploring Word2Vec modelsLINKOpen In Colab
Exploring Language Model’s EmbeddingsLINKOpen In Colab
Text mining on text datasetsLINKOpen In Colab
Dissecting a GPT modelLINKOpen In Colab

Interpretability with Tabular Classifiers 📊

Gain a deeper understanding of classification and prediction models with tabular data through interpretability techniques. Explore how to apply explanation techniques to tabular classifiers to uncover insights into their decision-making processes.

TutorialGitHubColab
Applying model-agnostic explanations to classifiers with dalexLINKOpen In Colab
Exploring models trained on the COMPAS Recidivism Racial Bias datasetLINKOpen In Colab

Machine Learning Fairness ⚖️

Advancing the discourse on machine learning fairness, the following tutorials delve into diverse facets of this crucial domain. From applying fairness metrics on datasets like Credit Card and Adult Census to enforcing fairness using tools like AIF360, these tutorials guide you through the intricate landscape of addressing biases in machine learning models.

TutorialGitHubColab
Applying fairnes metrics on the Credit Cart DatasetLINKOpen In Colab
Applying fairnes metrics on the Adult Census DatasetLINKOpen In Colab
Enforcing fairnes with AIF360LINKOpen In Colab
Applying the principle of Ceteris paribusLINKOpen In Colab
Applying fairnes metrics on the CelebA datasetLINKOpen In Colab
Investigating biases on text generation modelsLINKOpen In Colab

Adversarial Machine Learning 🐱‍💻

Within these tutorials, we navigate the intricate landscape of thwarting adversarial attacks and understanding their nuances. Explore the dark arts of exploiting pickle serialization, create adversarial examples with SecML and Textattack, and apply the fast sign gradient method against convolutional neural networks.

TutorialGitHubColab
Exploiting pickle serializationLINK Open In Colab
Creating adversarial examples with SecMLLINK Open In Colab
Applying the fast sign gradient method against CNNsLINK Open In Colab
Creating adverarial examples with textattackLINK Open In Colab
Extraction attacks via model clonningLINK Open In Colab
Demonstrating poisoning attacksLINK Open In Colab
Adversarial training for computer vision modelsLINK Open In Colab
Adversarial training for language modelsLINK Open In Colab