Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google example API call fails with "RECITATION" #518

Closed
johann-petrak opened this issue Sep 11, 2024 · 3 comments
Closed

Google example API call fails with "RECITATION" #518

johann-petrak opened this issue Sep 11, 2024 · 3 comments
Assignees
Labels
component:demos Update demos type:bug Something isn't working

Comments

@johann-petrak
Copy link

Description of the bug:

This page gives the code for testing a newly established API key quickly: https://aistudio.google.com/app/apikey

curl \
  -H 'Content-Type: application/json' \
  -d '{"contents":[{"parts":[{"text":"Explain how AI works"}]}]}' \
  -X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=YOUR_API_KEY'

One would expect this to return a generated answer. Instead it returns:

{
  "candidates": [
    {
      "finishReason": "RECITATION",
      "index": 0
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 4,
    "totalTokenCount": 4
  }
}

Actual vs expected behavior:

See above

Any other information you'd like to share?

It is pretty werid and embarrassing that the very example given to test if invoking gemini works fails.

@johann-petrak johann-petrak added the type:bug Something isn't working label Sep 11, 2024
@gmKeshari gmKeshari added status:triaged Issue/PR triaged to the corresponding sub-team component:demos Update demos labels Sep 18, 2024
@gmKeshari gmKeshari self-assigned this Sep 19, 2024
@gmKeshari
Copy link

Hi @johann-petrak. Sometimes, We see finish Reason as RECITATION because model will be generating copyright text from the training data. So, I would suggest to run the code again or modify the prompt a bit.

@vishal-dharm
Copy link

vishal-dharm commented Sep 24, 2024

Hey @johann-petrak - are you still able to reproduce this? I've been trying to no avail on my end (ran the prompt 20ish times).

curl \
  -H 'Content-Type: application/json' \
  -d '{"contents":[{"parts":[{"text":"Explain how AI works"}]}]}' \
  -X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=<REDACTED>'
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "## How AI Works: A Simplified Explanation\n\nAI, or Artificial Intelligence, is a broad field that aims to create machines that can \"think\" and \"learn\" like humans. But how does it actually work? Here's a simplified explanation:\n\n**1. Data is the Fuel:** AI systems learn from vast amounts of data, like images, text, audio, and more. This data acts as a \"training set\" to teach the AI about the world.\n\n**2. Algorithms are the Tools:**  AI systems use complex algorithms, which are sets of instructions, to analyze and understand this data. There are different types of algorithms, but some common ones are:\n\n    * **Machine Learning:**  Algorithms that enable computers to learn from data without explicit programming. They identify patterns and make predictions based on that data.\n    * **Deep Learning:** A subset of machine learning that utilizes artificial neural networks, inspired by the structure of the human brain, to process information and make predictions.\n\n**3. Models are the Result:** By training on data using algorithms, AI systems build models that represent the relationships and patterns found in that data. These models are then used to perform tasks like:\n\n    * **Image recognition:** Identifying objects in images.\n    * **Natural language processing:** Understanding and generating human language.\n    * **Predictive analytics:** Forecasting future outcomes based on past data.\n\n**4. Continuous Learning:** AI systems are constantly being improved through ongoing training and refinement. As they encounter new data and feedback, their models become more accurate and sophisticated over time.\n\n**Example:** Imagine you want to teach an AI to recognize cats. You feed it thousands of images of cats and dogs. The algorithm analyzes these images and identifies patterns specific to cats (whiskers, pointy ears, etc.). It then builds a model that can distinguish between cats and dogs based on these patterns. \n\n**Key Points to Remember:**\n\n* **AI is not magic:** It relies on data, algorithms, and computational power.\n* **AI is constantly evolving:** New algorithms and techniques are being developed all the time.\n* **AI has the potential to be incredibly powerful:** It can automate tasks, solve complex problems, and improve our lives in many ways.\n\n**This is a very basic explanation, but hopefully it gives you a starting point to understand how AI works.** There are many different approaches and techniques used within AI, and it's a constantly developing field. \n"
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP",
      "index": 0,
      "safetyRatings": [
        {
          "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
          "probability": "NEGLIGIBLE"
        },
        {
          "category": "HARM_CATEGORY_HATE_SPEECH",
          "probability": "NEGLIGIBLE"
        },
        {
          "category": "HARM_CATEGORY_HARASSMENT",
          "probability": "NEGLIGIBLE"
        },
        {
          "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
          "probability": "NEGLIGIBLE"
        }
      ]
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 4,
    "candidatesTokenCount": 504,
    "totalTokenCount": 508
  }
}

@johann-petrak
Copy link
Author

I just retried and it works now.

@github-actions github-actions bot removed the status:triaged Issue/PR triaged to the corresponding sub-team label Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:demos Update demos type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants