Skip to content

v.03

Latest
Compare
Choose a tag to compare
@Nkluge-correa Nkluge-correa released this 27 Dec 01:15
· 132 commits to master since this release

Teeny-Tiny Castle 🏰

DOI
made-with-python

python

AI Ethics and Safety are (relatively) new fields, and their tools (and how to handle them) are still not known to most of the development community. To address this problem, we created the Teeny-Tiny Castle, an open-source repository containing "Educational tools for AI Ethics and Safety Research." There, the developer can find many examples of how to use programming tools (functions, classes, libraries, etc.) to work with and deal with various problems raised in the literature (e.g., Algorithmic Discrimination, Model Opacity, etc.). At the moment, our repository has several examples of how to work ethically and safely with AI, using one of the most widely used languages in the community (Python). Our lines of focus are on issues related to "Accountability & Sutentability" "Interpretability" "Robustness/Adversarial" "Fairness" and "Cybersecurity", all being worked through examples that refer to some of the most common contemporary AI applications (e.g., Computer Vision, Natural language Processing, Synthetic Data Generation, Classification & Forecasting, etc.).

You can also find an introductory course on ML organized by the AIRES at PUCRS. To run the notebooks just open them in your Google Drive as a Colab Notebook, or as a Jupyter notebook. You can also follow our Python and VS Code installation tutorial if you want to run these notebooks on your own workstation. All requirements are specified in the requirements.txt file. Python version is 3.9.13.

If you would like to enable your GPU to follow our notebooks, you will need to install the drivers related to your NVIDIA/Cuda/TPU/GPU. If you use NVIDIA, you will also need the NVIDIA Toolkit and cudaDNN. You can find a comprehensive guide on how to configure your NVIDIA card in this tutorial (- by deeplizard -).

Join AIRES at PUCRS.

AI Ethics ⚖️🤖⚖️

  • Learn about the state-of-the-art in AI Ethics by browsing our Dash or Power BI dashboard;
  • Learn about the major organizations pushing AI R&D and their commitment to AI Safety research in this dasboard;
  • Track the current developments in the AI field with the AI Tracker tool, an online table that lists the largest (and most proficient) models ever created, along with an analysis of the potential risks associated with each model being tracked (developed by Gladstone AI);
  • Interested in AI regulation? On September 29, 2021, the Chamber of Deputies of the Federative Republic of Brazil approved Bill n. 21/2020, which establishes foundations and principles for the development and application of artificial intelligence (AI) in Brazil (together with Bills 5051/2019 and 872/2021). Here you can find a technical report (Portuguese only...sorry) structured from the main topics addressed in the three bills. This report was made by a collaboration between AIRES at PUCRS and the Post-Graduate Program in Law (PPGD), linked to the PUCRS School of Law.

Introduction Course on ML 📈

  • If you want to learn how to build your own workstation, check this Python and VS Code installation guide;
  • Here you can find a Basic Python Tutorial to get you started on the language and syntax we are using in the available notebooks in this repository;
  • Some of the most utilized libraries in ML and Data Science (if you are a 🐍) are Pandas, Scikit-learn, and Numpy. Here you can find a brief tutorial on how to use some of the (many) features and functions of these libraries;
  • For many practitioners, the "Hello World" of Deep Learning is classifying one of the MNIST datasets. Here you can find a Basic Keras and Tensor Flow tutorial using the Digit-MNIST and Fashion-MNIST datasets;
  • But if you want to check the Pytorch implementation of the same algorithm we built in the last Keras/TensorFlow tutorial, go to this notebook;
  • One of the most famous problems in ML (- actually Neural Networks -) history is the XOR Problem. Here you can find an example of how to implement a Multi-Layer Perceptron using only NumPy to solve the XOR problem;
  • Here you can find a notebook showing how to implement a Feed-Forward Neural Network using NumPy. You will learn the inner workings of many of the pre-built functions available in libraries like TensorFlow and Pytorch;
  • One of the most basic ML models you can build is a Linear Regression (LR) model. Here you will find how to build an LR model from scratch, implementing the Gradient Descent algorithm using only NumPy;
  • Here you can find a visual representation of how the Gradient Descent algorithm works while trying to find the correct model that approximates a ∿ mystery function ∿;
  • Among the different techniques that we find within Machine Learning, Reinforcement Learning deserves some introduction. As much as this methodology is not yet mainstream, RL was the paradigm responsible for creating some of the most general and proficient agents of today. If you want to understand some of the basics behind RL, we have provided two notebooks where we trained an agent to deal with the [n-armed-bandit problem](- Among the different techniques that we find within Machine Learning, Reinforcement Learning deserves some introduction. As much as this methodology is not yet mainstream, RL was the paradigm responsible for creating some of the most general and proficient agents of today. If you want to understand some of the basics behind RL, we have provided two notebooks where we trained an agent to deal with the n-armed-bandit problem (a classic RL introduction problem), and OpenAI Gym's FrozenLake environment (a simple environment to learn the basics of $Q$-learning);
  • One of the most common applications of AI systems in industry is in creating recommendation systems. Learn how to build three different types of recommendation systems with this notebook;
  • Nowadays, (almost) everything is a transformer model, and one of the areas that have taken the most advantage of this is NLP (Natural Language Processing). Create your own encoder-transformer model to tackle a problem of text classification (more specifically, toxicity detection).
  • Learn how to work with sequence-to-sequence tasks using RNNs and the original (encoder-decoder) version of the transformer architecture.
  • Learn how to keep track of your experiments, and analyze your model training with TensorBoard;
  • Hyperparameter optimization is crucial for boosting the performance of deep learning models. Tune them right to improve accuracy, prevent overfitting, and get the most out of your model. Learn how to perform hyperparameter optimization using Hyperopt and Hyperas.
  • Get access to all the datasets you might need during the beginning of your ML journey by using the TensorFlow Datasets;
  • Training and testing ML models are only a part of the MLOps cycle. *earn to deploy simple AI applications using gradio;
  • One of the main operations computed during training and inference of an ML model is the dot product between vectors/matrices. Here you can find an explanation of what the doot product is and why it is a useful piece of linear algebra;
  • Tensor manipulation is a big part of what we do (- the algorithms and processors do -) in ML. Learn about tensors and tensor operations in this notebook using the Pytorch library;
  • If you are lost in the jargon, this glossary can help you get familiar with some of the main terms we use in ML;
  • To understand how gradient descent updates the parameters of an ML model using the opposite direction of the gradient of the loss function, understanding what is a derivative can help you a lot;
  • Here are all the requirements (and how to install them) needed for the notebooks in this repository.

Accountability & Sutentability ♻️

Interpretability with CV 🔎🖼️

  • If you want to create your own CNN to explore (using the below notebooks), you can use this simple CNN_model_maker for the CIFAR-10 dataset (this may take a while if you don't have a GPU. If you don't have GPU, limit your training phase to < 50 epochs);
  • Learn to explore and interpret the inner workings of a CNN by using feature visualization techniques;
  • Learn to interpret the output of CNN models by using saliency mapping techniques;
  • Learn to interpret the inner workings of a CNN using the LIME (Local Interpretable Model-Agnostic Explanations) library.
  • Diffusion models are one of the current paradigms in synthetic data generation (especially when it comes to photorealism). Learn how to interpret diffusion models with the diffusers-interpret library.

Interpretability with NLP 🔎📚

  • If you want to create your own NLP model to explore (using the below notebooks), you can use this simple NLP_model_maker (available in Portuguese and English) to create your own language model. We also provide a simple GUI interface, created using Dash and Flask to allow you to easily interact with your model;
  • Learn to explore and interpret the outputs of a Language Model using the LIME (Local Interpretable Model-Agnostic Explanations) library (available in Portuguese and English);
  • Learn to interpret the output of Keras NLP models (like RNNs) using the Integrated Gradients method (available in Portuguese and English);
  • Learn to explore text datasets using Text Mining. Here you will learn simple techniques to create visualization tools to interpret the distribution of patterns (e.g., sentiment, word recurrence) in a text corpus (available in Portuguese and English);
  • Ever wanted to build your own Open-AI-style-NLP playground? Here you can find a working dashboard that allows you to interact with LM and Report your findings. The GUI was created using Dash and Flask. You can download different models from the Hugging Face library and feed this Dashboard/Playground with the model you so choose (DistillGPT2 is a great choice for people without GPU access). This playground was specifically created for experiments involving prompt engineering (available in English). When running the my_app.py file, you will run this app on your browser (hosted on your local machine).

Interpretability in Classification & Prediction with Tabular Data 🔎📊

Machine Learning Fairness ⚖️

Cybersecurity 👾

  • Here you can find an example of a really bad PHP forum to practice XSS (and learn how not to build a PHP backend server, i.e., - without escaping your strings - ). Try to get to the users_passwords_dump file using only your browser! To be able to run and attack this page, you will need to host it on your own server (localhost). We recommend Wampserver for this job (YOU SHOULD NOT PERFORM XSS IN WEBSITES YOU DON'T HAVE EXPLICIT PERMISSION);
  • Learn a little bit about password security by cracking bad passwords encrypted whit unsafe hashes (YOU SHOULD NOT PERFORM PASSWORD CRACKING AGAINST HASHES YOU HAVE NO BUSINESS OWNING);
  • Learn how to use Deep Learning to classify/detect malware, among other techniques to explore and evaluate possibly malicious software (PE analysis, Reverse engineering, Automated Virus Scanning).

Adversarial Machine Learning 🐱‍💻

How to cite this repository 😊

@misc{teenytinycastle,
  doi = {10.5281/zenodo.7112065},
  url = {https://github.com/Nkluge-correa/teeny-tiny_castle},
  author = {Nicholas Kluge Corr{\^e}a},
  title = {Teeny-Tiny Castle},
  year = {2022},
  publisher = {GitHub},
  journal = {GitHub repository},
  note = {Last updated 27 December 2022},
}

This repository was built as part of the RAIES (Rede de Inteligência Artificial Ética e Segura) initiative, a project supported by FAPERGS - (Fundação de Amparo à Pesquisa do Estado do Rio Grande do Sul), Brazil.