guardrails-ai / competitor_check

Guardrails AI: Competitor Check - Validates that LLM-generated text is not naming any competitors from a given list
Apache License 2.0
1 stars 3 forks source link

Always control casing when iterating over competitors #17

Closed CalebCourier closed 2 months ago

CalebCourier commented 2 months ago

There are multiple places where we iterate over the competitors argument in this validator. When we do, we should be ignoring the case by lowering or uppering both the standard and the basis.

Take this example:

guard = Guard().use(CompetitorCheck(competitors=["Apple"], use_local=True, on_fail="fix"))
resp = guard.validate(llm_output='Fun fact about Apple is that apple is both a fruit and company.  Apples come in many different colors and flavors.  What if apple is a tech company that makes phones, computers, and tablets?  Apple is headquartered in Cupertino, California.')

The model correctly identifies the first uppercase Apple, the second lowercase apple (as in What if apple is a tech company), and the third uppercase Apple as entities within the text. However, since we are not controlling for case, only the uppercase entities are filtered in the output.

aaravnavani commented 2 months ago

addressed in #18