Package: giskard
The testing framework dedicated to ML models, from tabular to LLMsScan AI models to detect risks of biases, performance issues and errors. In 4 lines of code.Documentation•Blog•Website•Discord Community•AdvisorsInstall Giskard 🐢You can install the latest version of Giskard from PyPi using pip :pipinstallgiskard-UWe officially support Python 3.9, 3.10 and 3.11.Try in Colab 📙Open Colab notebookGiskard is a Python library that automaticallydetects vulnerabilitiesin AI models, from tabular models to LLM, including performance biases, data leakage, spurious correlation, hallucination, toxicity, security issues and many more.It's a powerful tool that helps data scientistssave time and effortdrilling down on model issues, and produce morereliable and trustworthy models.Instantaneously generate test suites for your models ⤵️Giskard works with any model, in any environment and integrates seamlessly with your favorite tools ⤵️Contents🤸‍♀️Quickstart⭐️Premium features❓FAQ👋Community🤸‍♀️ Quickstart1. 🔎 Scan your modelHere's an example of a Giskard scan on the famous Titanic survival prediction dataset:importgiskard# Replace this with your own data & model creation.df=giskard.demo.titanic_df()demo_data_processing_function,demo_sklearn_model=giskard.demo.titanic_pipeline()# Wrap your Pandas DataFrame with Giskard.Dataset (test set, a golden dataset, etc.).giskard_dataset=giskard.Dataset(df=df,# A pandas.DataFrame that contains the raw data (before all the pre-processing steps) and the actual ground truth variable (target).target="Survived",# Ground truth variablename="Titanic dataset",# Optionalcat_columns=['Pclass','Sex',"SibSp","Parch","Embarked"]# List of categorical columns. Optional, but is a MUST if available. Inferred automatically if not.)# Wrap your model with Giskard.Model. Check the dedicated doc page: https://docs.giskard.ai/en/latest/guides/wrap_model/index.html# you can use any tabular, text or LLM models (PyTorch, HuggingFace, LangChain, etc.),# for classification, regression & text generation.defprediction_function(df):# The pre-processor can be a pipeline of one-hot encoding, imputer, scaler, etc.preprocessed_df=demo_data_processing_function(df)returndemo_sklearn_model.predict_proba(preprocessed_df)giskard_model=giskard.Model(model=prediction_function,# A prediction function that encapsulates all the data pre-processing steps and that could be executed with the dataset used by the scan.model_type="classification",# Either regression, classification or text_generation.name="Titanic model",# Optionalclassification_labels=demo_sklearn_model.classes_,# Their order MUST be identical to the prediction_function's output orderfeature_names=['PassengerId','Pclass','Name','Sex','Age','SibSp','Parch','Fare','Embarked'],# Default: all columns of your dataset)✨✨✨Then run Giskard's magical scan✨✨✨scan_results=giskard.scan(giskard_model,giskard_dataset)Once the scan completes, you can display the results directly in your notebook:display(scan_results)If you're facing issues, check out our wrappingmodel&datasetdocs for more information.2. 🪄 Automatically generate a test suiteIf the scan found potential issues in your model, you can automatically generate atest suitebased on the vulnerabilities found:test_suite=scan_results.generate_test_suite("My first test suite")You can then run the test suite locally to verify that it reproduces the issues:test_suite.run()Test suites are reusable objects that provide a way to apply consistent checks on your models. To drill down on failing tests and get even more out of the Giskard library, we recommend heading over to the Giskard hub ⤵️⭐️ Premium FeaturesThe Giskard hub is Giskard's premium offering. It provides a number of additional capabilities that are not available in the open-source version of Giskard, including:Advanced test generation: This includes the ability to diagnose failing tests, debug your models and create more domain-specific tests.Model comparison: This includes the ability to compare models to decide which one to promote.Test hub: This includes a place to gather all of your team's tests in one place to collaborate more efficiently.Business feedback: This includes the ability to share your results and collect business feedback from your team.If you are interested in learning more about Giskard's premium offering, pleasecontact us.1. Start the Giskard hubTo start theGiskard hub, run the following command:pipinstall"giskard[hub]"-U
giskardhubstart🚀 That's it! Access it athttp://localhost:190002. Upload your test suite to the Giskard hubYou can thenupload the test suitecreated using thegiskardPython library to the Giskard hub. This will enable you to:Compare the quality of different models to decide which one to promoteDebug your tests to diagnose identified vulnerabilitiesCreate more domain-specific tests relevant to your use caseShare results, and collaborate with your team to integrate business feedbackFirst, make sure the Giskard hub is installedHow to check if the Giskard hub is runningcheck ifhttp://localhost:19000is runningor usegiskard hub statusThen, execute the ML worker in your notebook:!giskardworkerstart-d-kYOUR_KEYFinally, upload your test suite to the Giskard hub using the following code:key="API_KEY"# Find it in Settings in the Giskard hubclient=giskard.GiskardClient(url="http://localhost:19000",key=key# URL of your Giskard instance)my_project=client.create_project("my_project","PROJECT_NAME","DESCRIPTION")# Upload to the current projecttest_suite.upload(client,"my_project")The Giskard hub is installed on your infrastructure.Giskard as a company does not have access to your datasets and models, so you can keep everything private.❓ Where can I get more help?What is a ML worker?Giskard executes your model using a worker that runs the model directly in your Python environment containing all the dependencies required by your model. You can execute the ML worker either from a local notebook, a Colab notebook or a terminal.How to get the API keyAccess the API key in the Settings tab of the Giskard hub.If Giskard hub/ML worker is not installedGo to theInstall the Giskard Hubpage.If Giskard hub is installed on an external server!giskardworkerstart-d-kYOUR_KEY-uhttp://ec2-13-50-XXXX.compute.amazonaws.com:19000/For more information on uploading to your local Giskard hubGo to theUpload an object to the Giskard hubpage.For any other questions and doubts, head over to ourDiscord.👋 CommunityWe welcome contributions from the Machine Learning community! Read thisguideto get started.Join our thriving community on our Discord server:join Discord server🌟Leave us a star, it helps the project to get discovered by others and keeps us motivated to build awesome open-source tools! 🌟❤️ You can alsosponsor uson GitHub. With a monthly sponsor subscription, you can get a sponsor badge and get your bug reports prioritized. We also offer one-time sponsoring if you want us to get involved in a consulting project, run a workshop, or give a talk at your company.