google-gemini / generative-ai-python

The official Python library for the Google Gemini API
https://pypi.org/project/google-generativeai/
Apache License 2.0
1.39k stars 270 forks source link

block_reason: OTHER #276

Open dipakmeher opened 5 months ago

dipakmeher commented 5 months ago

Description of the bug:

Hi, I'm using gemini-pro to generate user preferences based on user reviews. However, I encountered an issue when my prompt was flagged and blocked due to the reason: other. Upon reviewing the content, I noticed it was a movie review that contained words such as "rapped," "toilet humor," etc. I'm currently unable to proceed further from this point. How can I resolve this issue?

Thank you.

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

Andy963 commented 5 months ago

did you try this safety setting:

safety_settings = [ {"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_NONE"}, {"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_NONE"}, {"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "BLOCK_NONE"}, {"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_NONE"}, ]

dipakmeher commented 5 months ago

Yes I did. Still I am getting the block_reason:OTHER output. Let me give you the specific user review for which I am getting this output:

This will probably end up as a cult classic, but it's pure trash. It is based on a clever idea (making a documentary in America for the benefit of Kasakhstan) and the Borat character is charming, but there is too much toilet humor here. There are several jokes about rape, which is not the least bit funny, especially for anyone who has ever been raped. It's a vulgar movie that should be "X" rated. It tries to be funny, but it tries too hard and goes to the gutter too often for laughs. Probably immature 16-years old guys will find this movie a real hoot. I thought it was a stupid movie with not much to redeem it. It could have really been a great movie as the premise was good (not understanding cultural differences between two countries and the sticky situations that come about as a result). Unfortunately, it just doesn't work. There are some moments that should be funny, such as when Borat invites a chubby black prostitute to a totally white high society dinner party. I did laugh when Borat goes to buy a pet for protection and ends up with a bear. Don't waste your time. There are lots funnier movies, but maybe this was not intended to be a comedy. It's certainly not a serious movie

Any assistance in resolving this issue would be appreciated.

ArunJRK commented 5 months ago

Yes I did. Still I am getting the block_reason:OTHER output.

Same issue for me

pribadihcr commented 4 months ago

I have same issue. Any workaround? Thanks

anomous123 commented 4 months ago

When utilizing gemini-pro-vision to deal with domainnet/sketch/toe/sketch_314_000022.jpg (an image from Domainnet dataset), I met the same issue. How can I solve this? Thanks!

tawsifkamal commented 4 months ago

Any updates on this??

Extremely annoying and I have no idea how to resolve this!

caliburn420 commented 4 months ago

Yeah This is so annoying, it's like Google enforcing it's agenda despite everything is set to NONE

MarkDaoust commented 4 months ago

Hi, sorry there are some filters that we just can't turn off, these all go into the "OTHER" finish reason.

For example: one of the non-configurable filters is child safety, which is a legal requirement.

@dipakmeher - your example seems to be flagged because it includes both "rape" and "16-years-old".

dipakmeher commented 4 months ago

@MarkDaoust, thank you for addressing this issue. I am using Gemini Pro to generate user preferences based on their movie reviews. Is there a way to proceed with such tasks and reviews since they are genuine reviews on the movies?

caliburn420 commented 4 months ago

Wow, then why give users the illusion of choice. Looks like turning Block Reason to none is next to useless.

MarkDaoust commented 4 months ago

@dipakmeher - I sent that to the owners as an example of a false positive. Thanks for reporting.

MaKTaiL commented 4 months ago

This issue is happening with me. I'm using Gemini to translate subtitles and a simple "How is my baby girl doing?" (Dad asking about his daughter) is triggering a block. Replacing it with "How is my daughter doing?" fixes the issue, but it is not the first time I get this and I have to make changes. There is simply no reason to flag this as "child safety".

notV3NOM commented 3 months ago

Facing similar issues. I'm using it for captioning images and normal images (E.g. of a child with sea shells ) is getting blocked

YepJin commented 2 months ago

Same issues... Modified: I used public available videos and didn't find anything inappropriate even for a 6-year-old child. Don't know which type of restriction Google is using

augusto-rehfeldt commented 2 months ago

Same issues here. I'm summarizing a book and it throws this issue when some sexually explicit act happens. I have everything set to block none and use the Dev API.

The content filter is too strict.

luisiacc commented 1 month ago

I'm trying to use gemini to help in law assistance, but every time something about a gun killing other people shows up, it gives this reason as well. Just some feedback.

luisiacc commented 1 month ago

To reproduce you can put this prompt, it's in spanish though, it will trigger the blockReason OTHER situation, I'm pretty sure this is a false positive

Estos son documentos de las resoluciones de las cortes.
<document type="Resolucion" title="Tribunal de Apelación de Sentencia Penal II Circuito Judicial de San José expediente # 220007500053PE" id="sen-1-0034-1177998">
Redactado por: Kathya Jiménez Fernández
los hechos indicó que ese día llegó un muchacho (que había visto antes allí) y gritaba improperios a su hijo y tuvieron una pelea por lo que [Nombre 009] le dijo a [Nombre 011] y a ella que se metieran porque "esto se iba a poner feo" y cuando se regresó a su casa minutos después escuchó unos disparos (de los que resultó muerto su hijo y herido [Nombre 011]), se asomó y vio a un sujeto de "sueta oscura", jeans azul y no recuerda color de las tennis, contextura gruesa, y que todas las personas decían que había sido "[Nombre 026]" (sic), el mismo sujeto con el que había tenido el problema minutos antes (cfr. informe No. 28-SH/IP-2022, fls. 8 vllto-9). En el debate, solicitó justicia por la muerte de su hijo y respecto de los hechos manifestó, en esencia, que sabía todo lo que ocurrió. Relató que esto sucedió el 18 de junio de 2022; que eran las 5:45 de la mañana y escuchó un ruido en el corredor de su casa (ubicada en Hatillo 4, y explica que contiguo vivía su hijo [Nombre 009]), por lo que fue a ver qué ocurría, enfocó a su hijo y le dijo que no hiciera bulla, que al devolverse este muchacho ([Nombre 006]) la alcanza y se metió a su casa por lo que se dio un enfrentamiento entre [Nombre 009] y el acusado, y que allí estaba [Nombre 011]. Que cuando [Nombre 006] se fue le gritó a su hijo "[Nombre 015], usted hoy se muere", por lo que [Nombre 009] le indicó "que esto se iba a poner feo". Ella se puso a hacer el café y en segundos escuchó la balacera, cuando pararon de tirar bala se asomó y vio a su hijo sobre el suelo, ya agonizando. [Nombre 011] se vino y se sentó en las graditas que dan hacia la casa mía, echando sangre de la pierna, ella se dirigió hacia donde [Nombre 009] y le manifestó "que no me hablara, estese tranquilo, póngase en paz con Dios, váyase tranquilo, yo voy a estar bien, pídale perdón a Dios, quédese en paz, y fue cuando mi hijo se me quedó".
 Continuó diciendo: "Yo sé que fue [Nombre 006] porque le dijo que se las iba a pagar, que lo iba a matar. Después de la amenaza [Nombre 006] se va, se sube al carro de él, creo que Toyota negra, carro grande. Lo vi cuando se montó en el carro y se fue, después de eso mi hijo se metió en la casa. Las detonaciones fueron como a las cinco y cuarenta y cinco. Entre la amenaza y las detonaciones fueron unos (sic) cuarenta y cinco minutos, todo sucedió tan rápido. No escuché gente, era tantas balas, detonaciones sonaban y sonaban (...) Al salir no había nadie más además de [Nombre 011] y mi hijo (...) Cuando yo salgo [Nombre 011] estaba sentado en la primera gradita, se vino jalándose, jalándose (sic). [Nombre 011] me dijo que había sido [Nombre 006].

La mamá me ha buscado, el 14 de setiembre del año pasado. Cuando cruzo la calle, al salir de mi casa, la señora viene saliendo del súper, pero yo no sabía que era la mamá de ese muchacho. Me dijo cómo llueve y, le dije sí señora. Me preguntó si tengo nietos, le dije que no, le dije que tenía un hijo pero que estaba muerto. Me preguntó qué le pasó, me preguntó cómo pasó, yo seguí caminando, me dijo que me iba a acompañar. Entro a la fotocopiadora, entra conmigo, me cobran cuatrocientos pesos, me dijo que me iba a dar cien pesos, le dije que no. Cuando salgo y me voy, ella coge para el mismo lado mío, sigue caminando y como a los cien metros, me dice señora, usted sabe quién soy yo, le digo que no, me dijo que era la mamá de [Nombre 006], le dije cuál, me dijo la mamá del muchacho que mató a su hijo. (...) Después de eso, ella llamó a la señora de [Nombre 006] y le dijo que estaba hablando conmigo. Me puso en el teléfono a la muchacha, me preguntó que si yo iba a ir al juicio, le dije que sí, le dije lo mismo. Me alcanzó y me dijo que la muchacha le dijo que le diera el número de teléfono, le dije que no (...) Sí hice un reconocimiento en el Organismo. Pude reconocer. Sí está en la sala, es él, el de camisa blanca (señaló al imputado) (...) No vi a [Nombre 006] disparando porque estoy encerrada en la casa. ( ...) No vi a [Nombre 006] matar a mi hijo, pero sabía por la amenaza que le hizo. (...) Antes de acostarme no vi más gente con mi hijo.
 A [Nombre 011] lo vi en la mañana después de que mi hijo sacara al muchacho de la casa. Creo que venía llegando cuando estaban los golpes. [Nombre 011] vio que empezó el pleito, se agarraron y llegó a defender a mi hijo, agarró a golpes al muchacho también. Es correcto, [Nombre 011] me dijo que había sido [Nombre 006], después de que se recuperó. Una vez que me llamó del hospital. La mamá me llamó y me lo puso a él, hablamos poquito (...). » Por su parte, el oficial Mario José Ruíz Torres manifestó ante el tribunal de instancia que el 18 de junio de 2022 se encontraba disponible, era un fin de semana y al ser las 6:30 horas, recibió un reporte del sistema 9-1-1 sobre una persona fallecida en Hatillo 3, sobre la acera principal de la vía pública, por lo que, en compañía de Miguel Gamboa, se desplazó al sitio para iniciar las labores del caso. Encontraron una persona sobre la acera y les explicaron que estaba allí porque intentaron auxiliarla, pero no dio tiempo. Describe que lo que la madre del ofendido le indicó acerca de los hechos (primero sobre los ruidos, la golpiza y la amenaza de muerte que [Nombre 006] le hizo a su hijo al salir y que este se fue en carro tipo Rav4, marca Toyota; que transcurren unos minutos y escucha una secuencia de disparos frente a la casa de ella, que no observa quién lo hizo, pero encuentra a su hijo muriendo y ve solo a una persona con casco de motocicleta y ropa oscura que se aleja caminando). 
Explica el testigo que hicieron un rastreo en la zona para ubicar cámaras con resultado positivo, pero que en algunas de ellas solo logran divisar una persona a bordo de un cuadraciclo color amarillo, ingresó a toda velocidad, se detuvo, ingresó caminando sobre la alameda, segundos después se observa dónde sale corriendo, aborda nuevamente el cuadraciclo y se retira a gran velocidad con dirección al norte; en otras se observa a una persona caminando con un casco color anaranjado, bastante llamativo, sweater oscuro, camisa oscura y pantalón tipo jeans, pasa por la alameda y segundos después se devuelve. A un costado de la casa del fallecido, había cámaras de vigilancia que lograron recopilar y observó al sospechoso acercándose hacia la vivienda, por la espalda, bordeando la vivienda, como realizando un efecto sorpresa. Respecto de la intervención de [Nombre 011] manifestó: "Posteriormente, fuimos al hospital donde nos presentamos y dialogamos con [Nombre 011], que era el testigo herido en sus dos rodillas con arma de fuego. Inmediatamente llegamos, nos relató lo sucedido.
</document>

Actua como si la informacion anterior es parte de tu conocimiento, responde la siguiente pregunta:

<question>Pedro esta en un baile de una fiesta patronal y esta ebrio, en un momento dado saca una pistola y dispara 2 veces al aire, con tan mala suerte que una bala rebota en una columna del techo e impacta en la cabeza a una de las personas que estaban en el baile provocándole la muerte. que responsabilidad penal tendría Pedro?</question>

If I translate the text into english and prompt it to gemini, then it does not rise any blockReason, this is the text translated by Claude Sonnet:

These are documents of court resolutions.
<document type="Resolution" title="Court of Appeal for Criminal Sentences II Judicial Circuit of San José file # 220007500053PE" id="sen-1-0034-1177998">
Written by: Kathya Jiménez Fernández
The facts indicated that on that day a young man arrived (whom she had seen there before) and was shouting insults at her son and they had a fight, so [Name 009] told [Name 011] and her to get inside because "this was going to get ugly" and when she returned to her house minutes later she heard some shots (from which her son died and [Name 011] was wounded), she looked out and saw a subject in a "dark sweatshirt", blue jeans and doesn't remember the color of the sneakers, thick build, and that all the people were saying it had been "[Name 026]" (sic), the same subject with whom he had had the problem minutes before (cf. report No. 28-SH/IP-2022, fls. 8 back-9). In the debate, she requested justice for her son's death and regarding the facts, she essentially stated that she knew everything that happened. She related that this happened on June 18, 2022; that it was 5:45 in the morning and she heard a noise in the hallway of her house (located in Hatillo 4, and explains that her son [Name 009] lived next door), so she went to see what was happening, focused on her son and told him not to make noise, that when returning this boy ([Name 006]) reached her and entered her house which led to a confrontation between [Name 009] and the accused, and that [Name 011] was there. That when [Name 006] left he shouted at her son "[Name 015], you're going to die today", so [Name 009] indicated "that this was going to get ugly". She started making coffee and in seconds heard the shooting, when they stopped firing she looked out and saw her son on the ground, already dying. [Name 011] came and sat on the small steps leading to my house, bleeding from the leg, she went to where [Name 009] was and told him "don't talk to me, stay calm, make peace with God, go peacefully, I'm going to be fine, ask God for forgiveness, stay in peace, and that's when my son stayed with me".
She continued saying: "I know it was [Name 006] because he told him he was going to pay for it, that he was going to kill him. After the threat [Name 006] leaves, gets into his car, I think a black Toyota, big car. I saw him when he got in the car and left, after that my son went into the house. The detonations were around five forty-five. Between the threat and the detonations were about (sic) forty-five minutes, everything happened so fast. I didn't hear people, it was so many bullets, detonations sounded and sounded (...) When I went out there was no one else besides [Name 011] and my son (...) When I come out [Name 011] was sitting on the first small step, he came dragging himself, dragging himself (sic). [Name 011] told me it had been [Name 006].
The mother has sought me out, on September 14 of last year. When I cross the street, leaving my house, the lady is coming out of the supermarket, but I didn't know she was that boy's mother. She said how it's raining and, I said yes ma'am. She asked me if I have grandchildren, I said no, I said I had a son but he was dead. She asked me what happened to him, she asked me how it happened, I kept walking, she said she was going to accompany me. I enter the copy shop, she enters with me, they charge me four hundred pesos, she said she was going to give me one hundred pesos, I said no. When I leave and go, she goes the same way as me, keeps walking and about a hundred meters later, she says ma'am, do you know who I am, I say no, she told me she was [Name 006]'s mother, I said which one, she said the mother of the boy who killed your son. (...) After that, she called [Name 006]'s wife and told her she was talking to me. She put the girl on the phone with me, she asked me if I was going to go to the trial, I said yes, I told her the same. She caught up with me and told me that the girl told her to give her the phone number, I said no (...) Yes, I did a recognition at the Agency. I could recognize. Yes, he's in the room, it's him, the one in the white shirt (she pointed to the accused) (...) I didn't see [Name 006] shooting because I'm locked in the house. (...) I didn't see [Name 006] kill my son, but I knew from the threat he made. (...) Before going to bed I didn't see more people with my son.
I saw [Name 011] in the morning after my son took the boy out of the house. I think he was arriving when the blows were happening. [Name 011] saw that the fight started, they grabbed each other and he came to defend my son, he also beat up the boy. That's correct, [Name 011] told me it had been [Name 006], after he recovered. Once he called me from the hospital. The mother called me and put him on, we talked a little (...). » For his part, officer Mario José Ruíz Torres stated before the court of instance that on June 18, 2022, he was available, it was a weekend and at 6:30 hours, he received a report from the 9-1-1 system about a deceased person in Hatillo 3, on the main sidewalk of the public road, so, in the company of Miguel Gamboa, he moved to the site to begin the work on the case. They found a person on the sidewalk and were told that he was there because they tried to help him, but there wasn't time. He describes what the victim's mother told him about the events (first about the noises, the beating and the death threat that [Name 006] made to her son when leaving and that he left in a Rav4 type car, Toyota brand; that a few minutes pass and she hears a sequence of shots in front of her house, that she doesn't observe who did it, but finds her son dying and sees only a person with a motorcycle helmet and dark clothes walking away).
The witness explains that they did a search in the area to locate cameras with positive results, but that in some of them they only manage to see a person on board a yellow four-wheeler, entered at full speed, stopped, entered walking on the mall, seconds later it is observed where he leaves running, boards the four-wheeler again and leaves at high speed heading north; in others a person is seen walking with a rather striking orange helmet, dark sweater, dark shirt and jeans-type pants, passes through the mall and seconds later returns. On one side of the deceased's house, there were surveillance cameras that they managed to collect and observed the suspect approaching the house, from behind, bordering the house, as if making a surprise effect. Regarding the intervention of [Name 011] he stated: "Later, we went to the hospital where we presented ourselves and talked with [Name 011], who was the witness wounded in both knees with a firearm. As soon as we arrived, he told us what happened.
</document>
Act as if the above information is part of your knowledge, answer the following question:
<question>Pedro is at a dance at a patron saint festival and is drunk, at one point he pulls out a gun and fires 2 shots into the air, with such bad luck that a bullet ricochets off a ceiling column and impacts the head of one of the people who were at the dance causing their death. What criminal responsibility would Pedro have?</question>
luisiacc commented 1 month ago

I don't know if this will be useful or not, but I found this, this text does NOT causes gemini to give a block reason:

Estos son documentos de las resoluciones de las cortes.

<document type=\"Resolucion\" title=\"Tribunal de Apelación de Sentencia Penal II Circuito Judicial de San José expediente # 220007500053PE\" id=\"sen-1-0034-1177998\">

 Redactado por: Kathya Jiménez Fernández
los hechos indicó que ese día llegó un muchacho (que había visto antes allí) y gritaba improperios a su hijo y tuvieron una pelea por lo que [Nombre 009] le dijo a [Nombre 011] y a ella que se metieran porque \"esto se iba a poner feo\" y cuando se regresó a su casa minutos después escuchó unos disparos (de los que resultó muerto su hijo y herido [Nombre 011]), se asomó y vio a un sujeto de \"sueta oscura\", jeans azul y no recuerda color de las tennis, contextura gruesa, y que todas las personas decían que había sido \"[Nombre 026]\" (sic), el mismo sujeto con el que había tenido el problema minutos antes (cfr. informe No. 28-SH/IP-2022, fls. 8 vllto-9). En el debate, solicitó justicia por la muerte de su hijo y respecto de los hechos manifestó, en esencia, que sabía todo lo que ocurrió. Relató que esto sucedió el 18 de junio de 2022; que eran las 5:45 de la mañana y escuchó un ruido en el corredor de su casa (ubicada en Hatillo 4, y explica que contiguo vivía su hijo [Nombre 009]), por lo que fue a ver qué ocurría, enfocó a su hijo y le dijo que no hiciera bulla, que al devolverse este muchacho ([Nombre 006]) la alcanza y se metió a su casa por lo que se dio un enfrentamiento entre [Nombre 009] y el acusado, y que allí estaba [Nombre 011]. Que cuando [Nombre 006] se fue le gritó a su hijo \"[Nombre 015], usted hoy se muere\", por lo que [Nombre 009] le indicó \"que esto se iba a poner feo\". Ella se puso a hacer el café y en segundos escuchó la balacera, cuando pararon de tirar bala se asomó y vio a su hijo sobre el suelo, ya agonizando. [Nombre 011] se vino y se sentó en las graditas que dan hacia la casa mía, echando sangre de la pierna, ella se dirigió hacia donde [Nombre 009] y le manifestó \"que no me hablara, estese tranquilo, póngase en paz con Dios, váyase tranquilo, yo voy a estar bien, pídale perdón a Dios, quédese en paz, y fue cuando mi hijo se me quedó\". Continuó diciendo: \"Yo sé que fue [Nombre 006] porque le dijo que se las iba a pagar, que lo iba a matar. Después de la amenaza [Nombre 006] se va, se sube al carro de él, creo que Toyota negra, carro grande. Lo vi cuando se montó en el carro y se fue, después de eso mi hijo se metió en la casa. Las detonaciones fueron como a las cinco y cuarenta y cinco. Entre la amenaza y las detonaciones fueron unos (sic) cuarenta y cinco minutos, todo sucedió tan rápido. No escuché gente, era tantas balas, detonaciones sonaban y sonaban (...) Al salir no había nadie más además de [Nombre 011] y mi hijo (...) Cuando yo salgo [Nombre 011] estaba sentado en la primera gradita, se vino jalándose, jalándose (sic). [Nombre 011] me dijo que había sido [Nombre 006].

La mamá me ha buscado, el 14 de setiembre del año pasado. Cuando cruzo la calle, al salir de mi casa, la señora viene saliendo del súper, pero yo no sabía que era la mamá de ese muchacho. Me dijo cómo llueve y, le dije sí señora. Me preguntó si tengo nietos, le dije que no, le dije que tenía un hijo pero que estaba muerto. Me preguntó qué le pasó, me preguntó cómo pasó, yo seguí caminando, me dijo que me iba a acompañar. Entro a la fotocopiadora, entra conmigo, me cobran cuatrocientos pesos, me dijo que me iba a dar cien pesos, le dije que no. Cuando salgo y me voy, ella coge para el mismo lado mío, sigue caminando y como a los cien metros, me dice señora, usted sabe quién soy yo, le digo que no, me dijo que era la mamá de [Nombre 006], le dije cuál, me dijo la mamá del muchacho que mató a su hijo. (...) Después de eso, ella llamó a la señora de [Nombre 006] y le dijo que estaba hablando conmigo. Me puso en el teléfono a la muchacha, me preguntó que si yo iba a ir al juicio, le dije que sí, le dije lo mismo.
Me alcanzó y me dijo que la muchacha le dijo que le diera el número de teléfono
</document>

Actua como si la informacion anterior es parte de tu conocimiento, responde la siguiente pregunta:

<question>Pedro esta en un baile de una fiesta patronal y esta ebrio, en un momento dado saca una pistola y dispara 2 veces al aire, con tan mala suerte que una bala rebota en una columna del techo e impacta en la cabeza a una de las personas que estaban en el baile provocándole la muerte. que responsabilidad penal tendría Pedro?</question>

However if I just add the text ", le dije que no" before the end of the </document > in a way that the last line says:

Me alcanzó y me dijo que la muchacha le dijo que le diera el número de teléfono, le dije que no

Then it gives the blockReason OTHER.

MarkDaoust commented 1 month ago

Hi,

I think we may start supporting more block reasons soon, this will give you more information in cases where it's blocked by something other than the (settable) safety filters.

MaKTaiL commented 1 month ago

The reason itself isn't the problem though. These hidden filters (which we currently cannot customize) are flagging false positives when they shouldn't. Let us adjust the settings for them as well.

Brook2610 commented 5 days ago

I had the same issue when trying to summarize a book. I solved it by adding this to the prompt " Becareful to not include any unsafe or too sexual content".