← retour aux outils back to tools

# Giskard

Framework Python open-source de test pour modèles ML et applications LLM/agentiques. Scanne automatiquement l'hallucination, l'injection de prompt, les biais et la divulgation d'informations. Open-source Python testing framework for ML models and LLM/agentic applications. Automatically scans for hallucination, prompt injection, bias, and information disclosure.

↗ https://github.com/Giskard-AI/giskard

## Overview

Giskard is an open-source Python framework for testing ML models and LLM/agentic applications. Point its `scan()` function at a wrapped model and it automatically probes for a broad set of issues — hallucination, prompt injection, harmful/toxic content generation, bias, and information/data disclosure — then produces a browsable vulnerability report you can turn into a regression test suite. It’s used both by ML engineers validating model quality and by red teamers assessing an LLM app’s safety surface before a release.

## Installation

    pip install "giskard[llm]"

Needed for LLM-assisted checks (hallucination/factuality detectors)

    export OPENAI_API_KEY="<api_key>"

## Wrapping a target and scanning

    import giskard as gsk

    def model_predict(df):
        # df has one column "question" — call your target LLM app per row
        return [call_target_llm(q, endpoint="<target_url>", model="<model_name>") for q in df["question"]]

    giskard_model = gsk.Model(
        model=model_predict,
        model_type="text_generation",
        name="target-chatbot",
        description="Customer support assistant for <product>",
        feature_names=["question"],
    )

    # Run the full automatic scan
    scan_results = gsk.scan(giskard_model)
    scan_results.to_html("giskard_report.html")

## Scanning a LangChain / agentic pipeline

    from langchain.chains import RetrievalQA

    def predict_fn(df):
        return [qa_chain.invoke({"query": q})["result"] for q in df["question"]]

    giskard_model = gsk.Model(
        model=predict_fn,
        model_type="text_generation",
        name="rag-agent",
        description="RAG agent answering from internal docs",
        feature_names=["question"],
    )

    scan_results = gsk.scan(giskard_model, only=["hallucination", "prompt_injection", "information_disclosure"])

## Turning findings into a regression test suite

    test_suite = scan_results.generate_test_suite("LLM safety regression suite")
    test_suite.run()   # re-run on every model/prompt change, e.g. in CI

## Tips

- Narrow scans with `only=[...]` (e.g. `"prompt_injection"`, `"hallucination"`) during iterative fixing — a full scan against a hosted API can be slow and token-expensive.
- `scan_results.to_html()` is a self-contained report — good to hand off to a client alongside a written pentest report.
- Giskard also has a hosted “Giskard Hub” for continuous LLM monitoring, but the open-source `giskard` package fully covers one-off red-team scans.

Help / Man page

    Key API (Python):

    giskard.Model(model, model_type, name, description, feature_names)
        # Wraps any callable target (function, LangChain chain, REST call) for scanning

    giskard.scan(giskard_model, only=None)
        # Runs automatic vulnerability detectors; `only` filters to specific categories:
        #   hallucination, harmfulness, prompt_injection, robustness,
        #   information_disclosure, sycophancy, bias, discrimination

    scan_results.to_html(path)          # Export a browsable HTML report
    scan_results.to_dataframe()          # Export raw findings as a DataFrame
    scan_results.generate_test_suite(name)   # Convert findings into a re-runnable test suite

    test_suite.run()                      # Execute the generated regression tests
    test_suite.save("path/")               # Persist suite for CI usage

## Vue d’ensemble

Giskard est un framework Python open-source pour tester des modèles ML et des applications LLM/agentiques. Il suffit de pointer sa fonction `scan()` vers un modèle encapsulé pour qu’il sonde automatiquement un large ensemble de problèmes : hallucination, injection de prompt, génération de contenu nuisible/toxique, biais, et divulgation d’informations/données. Il produit ensuite un rapport de vulnérabilités navigable que l’on peut transformer en suite de tests de non-régression. Il est utilisé aussi bien par des ingénieurs ML validant la qualité d’un modèle que par des red teamers évaluant la surface de sécurité d’une application LLM avant une mise en production.

## Installation

    pip install "giskard[llm]"

Nécessaire pour les vérifications assistées par LLM (détecteurs d’hallucination/factualité)

    export OPENAI_API_KEY="<api_key>"

## Encapsuler une cible et scanner

    import giskard as gsk

    def model_predict(df):
        # df a une colonne "question" : appeler l'application LLM cible pour chaque ligne
        return [call_target_llm(q, endpoint="<target_url>", model="<model_name>") for q in df["question"]]

    giskard_model = gsk.Model(
        model=model_predict,
        model_type="text_generation",
        name="target-chatbot",
        description="Assistant de support client pour <product>",
        feature_names=["question"],
    )

    # Lancer le scan automatique complet
    scan_results = gsk.scan(giskard_model)
    scan_results.to_html("giskard_report.html")

## Scanner un pipeline LangChain / agentique

    from langchain.chains import RetrievalQA

    def predict_fn(df):
        return [qa_chain.invoke({"query": q})["result"] for q in df["question"]]

    giskard_model = gsk.Model(
        model=predict_fn,
        model_type="text_generation",
        name="rag-agent",
        description="Agent RAG répondant à partir de docs internes",
        feature_names=["question"],
    )

    scan_results = gsk.scan(giskard_model, only=["hallucination", "prompt_injection", "information_disclosure"])

## Transformer les résultats en suite de tests de non-régression

    test_suite = scan_results.generate_test_suite("LLM safety regression suite")
    test_suite.run()   # à relancer à chaque changement de modèle/prompt, par exemple en CI

## Conseils

- Restreindre les scans avec `only=[...]` (par exemple `"prompt_injection"`, `"hallucination"`) pendant les itérations de correction : un scan complet contre une API hébergée peut être lent et coûteux en tokens.
- `scan_results.to_html()` est un rapport autonome : pratique à transmettre à un client en plus d’un rapport de pentest écrit.
- Giskard propose aussi un “Giskard Hub” hébergé pour la surveillance continue de LLM, mais le package open-source `giskard` couvre pleinement les scans red-team ponctuels.

Aide / Page de manuel

    Key API (Python):

    giskard.Model(model, model_type, name, description, feature_names)
        # Wraps any callable target (function, LangChain chain, REST call) for scanning

    giskard.scan(giskard_model, only=None)
        # Runs automatic vulnerability detectors; `only` filters to specific categories:
        #   hallucination, harmfulness, prompt_injection, robustness,
        #   information_disclosure, sycophancy, bias, discrimination

    scan_results.to_html(path)          # Export a browsable HTML report
    scan_results.to_dataframe()          # Export raw findings as a DataFrame
    scan_results.generate_test_suite(name)   # Convert findings into a re-runnable test suite

    test_suite.run()                      # Execute the generated regression tests
    test_suite.save("path/")               # Persist suite for CI usage