Gemini 2.5 Pro and Flash break when working with long tables

When generating markdown tables with expected long content, the AI will generate the dash line that signifies the header line. If this is very long, the AI gets stuck at generating the dashes and eventually starts returning random content. By removing the excessive dashes in previous messages (which are not necessary for MD display), the AI can continue to use this shorter pattern and run in a stable format.

Example:

| Parameter                                                     | Rationale / Notes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Specification / Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| :------------------------------------------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Anticipated Planning Horizon / Design Cycle for the EUC**   | The EUC serves a dynamic research and development environment within a startup. Design iterations and significant modifications are expected based on evolving research needs and resource availability. Therefore, defining a long-term fixed lifespan is unrealistic. A shorter planning horizon reflects the intended development cycle. A significant modification that impacts the safety concept would necessitate a re-evaluation of the risk assessment and potentially constitute a "new machine" from a conformity assessment perspective, resetting this horizon.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | The current design iteration and this risk assessment are based on an anticipated operational and development timeframe of approximately **2 years**. Future major redesigns or modifications will require a review and update of this risk assessment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

maybe the model can be finetuned to generate a maximum of 20 dashes

5 Likes

Yeah, I’m facing the same issue with Flash 2.0 also. I’ve tried lowering the temperature, but it did not improve the situation.

2 Likes

Hey folks, Thanks for flagging.

If you could provide the prompt if possible that will be helpful to repro the issue.

Getting this constantly. I notice you also picked Github Flavored Markdown. Even when I drop the requirement for GFM… any multi-page table just DESTROYs Gemini. MAX_TOKENS errors all day long no matter what the model is.

This is the main blocker to all my chunking work. Massive issue with Gemini.

Here:

You are an expert at extracting large tables from documents.
You will be given a document and you will need to extract all the large tables from the document.
You will need to create a table with appropriate headers and column names.
Then fill in the table 'cells' with the data from the document.
Only include tables that span more than one page.

Doesn’t matter if I use examples or not, doesn’t matter if the prompt is long and detailed or short and vague (like this one, above).

Doesn’t matter if it’s structured content or just text mime type response. Just cursed. Completely cursed. Amazed you don’t know about this. Must be thousands of people out there with this exact issue.

1 Like

Hey, did you happen to find a fix for this?

I’m still running into the same issue - tables fail to generate and the UI breaks when streaming with those endless dashes.

It seems to consistently happen when it’s the first table generated in a chat session - on the second request, everything works fine. I don’t think the issue is in my implementation, but I’m not discounting the possibility.

Just wondering if Google has resolved this on their end or if there’s a known workaround. Thanks!

1 Like

Found a fix.

Instead of asking for Markdown tables directly, write the instruction like this:

- Use Markdown for bold text and links.

- When information can be clearly structured, output it as a plain text table using the | character between columns,
but do not try to align or pad columns, and do not insert extra spaces for formatting.
Each row must be on a single line, exactly like:
Header 1 | Header 2 | Header 3
Value A | Value B | Value C

This is enough to detach the model from the behaviour of generating markdown tables, which had the problem of trying to estimate the width of a column before it wrote it.

It was hilariously getting stuck on adding spaces and would only stop after hitting the 2M token output limit.

I don’t understand how this has been happening for six months now without Google fixing it.

Been a recurring issue in my project where I get infinity dashes or spacing until token eventually ran out. One of the task I am working currently is to extract certain part of financial document as a markdown table. Embedded the image in the payload then send it to api url.
api_url = f"https://generativelanguage.googleapis.com/v1beta/models/{model_id}:{generate_content_api}?key={gemini_api_key}"

The configuration is as follows:
Model: “gemini-2.5-flash”
top_p: 0.95
top_k : 20
max_output_tokens: 65536
response_mime_type: str = “text/plain”

This is my prompt:

Task: Extract the Statement of Cash Flow from the image and format it as a Markdown table.

Preserve the exact structure, including the ‘GROUP’ and ‘COMPANY’ columns with their respective years.

Do not use excessive dashes.

For each column clearly indicate on table header which column is GROUP and which column is COMPANY, default to COMPANY if not shown.

Ensure all numbers, descriptions, text and formatting are transcribed as it is.

Do not add any explanation or commentary; only return the table. If no content found, return empty string `````.

Since I cannot attach any text file here (lenghtly output), provided the google drive share link: https://drive.google.com/file/d/1aZivhLL2GwMFy1ilx133lI3Gr2XU435p/view?usp=drive_link

Any insight on preventing it from happening other than reducing max_output_tokens?

Attached is the image (covered company name)


We came to a low tech solution by splitting tables with large rows into mutliple tables. We added a new prompt to split rows by ten and mitigates the issue in gemini 2.5 flash