pip install guardrails-ai-bias-checkfrom guardrails import Guard
from guardrails_ai.bias_check import BiasCheck
guard = Guard().use(BiasCheck)
guard.validate("some text")This bias check format validator ensures textual outputs do not contain biased language towards specific demographics, such as race, gender, sex, religion, ethnicity.
This validator can be used to ensure fairness of model output across various demographic groups.
Dependencies:
Dev Dependencies:
Foundation model access keys:
pip install guardrails-ai-bias-check
This validator ships local models. After installing, run the post-install step to download them:
python -m guardrails_ai.bias_check.post_install
In this example, we apply the validator to a string output generated by an LLM.
# Import Guard and Validator
from guardrails_ai.bias_check import BiasCheck
from guardrails import Guard
# Setup Guard
guard = Guard().use(
BiasCheck(threshold=0.9, on_fail="exception")
)
guard.validate("The movie was great.") # Validator passes
guard.validate("Why do men think that movie was great?") # Validator fails
## License
MIT — © Guardrails AI.