text-bison safety filter returning lots of false positives

Hi everybody,

I'm working on a project that uses medical recipes extracted from an OCR scan to extract some information. These recipes are in spanish. It was working totally fine but two days ago text-bison started blocking lots of answers claiming toxicity presence. These medical recipes does not contains anything close to toxicity or harmful data, it's clearly a false positive, but I'm having issues on bypassing the security filter.

My current code initializes text-bison as suggested in the "view code" snippet in Generative AI Studio:

########################################

import vertexai
from vertexai.language_models import TextGenerationModel

vertexai.init(project="#####", location="us-central1")
parameters = {
"candidate_count": 1,
"max_output_tokens": 1024,
"temperature": 0.0,
"top_p": 0.8,
"top_k": 1
}
model = TextGenerationModel.from_pretrained("text-bison")

model.predict(prompt, **parameters)

########################################

Here is a list of things I already tried:

- Tried rephrasing the prompt with no luck

- Tried using PaLM2 API passing safety_settigs to NONE as shown below

#########################################

import google.generativeai as palm

completion = palm.generate_text(

    model=model,

    prompt=prompt,

    safety_settings=[

        {

            "category": safety_types.HarmCategory.HARM_CATEGORY_DEROGATORY,

            "threshold": safety_types.HarmBlockThreshold.BLOCK_NONE,

        },

        {

            "category": safety_types.HarmCategory.HARM_CATEGORY_VIOLENCE,

            "threshold": safety_types.HarmBlockThreshold.BLOCK_NONE,

        },

        {

            "category": safety_types.HarmCategory.HARM_CATEGORY_TOXICITY,

            "threshold": safety_types.HarmBlockThreshold.BLOCK_NONE,

        },

    ]

)

#########################################

This not only didn’t worked but also returned errors as “400 The requested language is not supported by models/text-bison-001” (I’m using spanish text which is supported) or “None” answers with no additional explanation

- Tried using a plain request package to query the https API directly but I’m also getting blocked.

I’ve run out of ideas, I saw another discussion here suggesting the creation of a vertex.Client object but that doesn’t seem to work.

Open to any suggestion,  many thanks for reading!

1 REPLY 1

It sounds like you're dealing with quite a frustrating situation. Dealing with false positives from text filters can be challenging, especially when it affects your workflow. Let's try a few other potential solutions to bypass this issue:

Check Data Formatting: Ensure that the format of your input data aligns with the expected format for Text-Bison. Sometimes, minor formatting issues can trigger false positives in filters.

Explore Different APIs or Models: Consider utilizing other language models or APIs that might have different filtering mechanisms. Services like Google's Perspective API or custom-trained models might offer more flexibility in adjusting or bypassing filters.

Language Translation: If possible, translate the Spanish text to English and then process it through the API. This might help bypass the filter, as the filter could be more lenient with English text.

Context Adjustment: Try altering the context of your queries. Sometimes, subtle changes in the way the prompt is structured or the way questions are phrased can bypass the filter.

Custom Filtering: If allowed by the service, try creating a custom filtering mechanism based on the false positive triggers you're encountering. This might involve pre-processing the text or incorporating additional checks before sending it through the API.

Regarding the error messages you received when attempting to use the PaLM2 API, the "requested language not supported" and "None" responses might indicate issues with the API integration or the data format. It could also signify that the language model doesn't support the specific features or configurations you're attempting to use.

Exploring these different avenues might help you bypass the filter and continue working with your medical recipes effectively.

Remember to document any changes or attempts you make in case you need to refer back or share the information with the support team. If the issue persists, contacting the support might yield more tailored solutions.