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

Difference in Output Between PDF and DOC File Upload Methods #233

Open
anusonawane opened this issue Jul 8, 2024 · 4 comments
Open

Difference in Output Between PDF and DOC File Upload Methods #233

anusonawane opened this issue Jul 8, 2024 · 4 comments
Labels
component:other Issues unrelated to examples/quickstarts status:awaiting response Awaiting a response from the author status:stale Issue/PR is marked for closure due to inactivity type:bug Something isn't working

Comments

@anusonawane
Copy link

Description of the bug:

I'm trying two methods for file uploads:

PDF File Upload:
DOC File Upload:

Despite both files containing the same content, I'm noticing differences in the output. Specifically, the output response from the DOC file upload method lacks a lot of information and steps, while the PDF method works great.

Actual vs expected behavior:

Here's what I'm doing for each method:

1. PDF File Upload:

Since there is no support for direct PDF file upload, I'm converting each PDF page to an image, extracting text from the PDF, and then doing the following:
`files.append(genai.upload_file(img))

for page, (text, image) in enumerate(zip(texts, files)):
instruction = f"{instruction}\nPage {page+1}\n------------\n{text}\n{image}"

chat_session = model.start_chat(
history=[
{"role": "user", "parts": [instruction]},
]
)
response = chat_session.send_message(prompt)
print(response.text)
`

2. DOC File Upload:

For the DOC file, I'm uploading it directly to Gemini:

files.append(genai.upload_file("test.docx")) instruction = f"Usage document:\n{file}" chat_session = model.start_chat( history=[ {"role": "user", "parts": [instruction]}, ] ) response = chat_session.send_message(prompt) print(response.text)

Any other information you'd like to share?

Can anyone help me understand why there is a difference in the output between these two methods? The content in both files is the same, but the response from the DOC file upload lacks information and steps compared to the PDF method. Any insights would be appreciated!

@singhniraj08
Copy link
Contributor

@anusonawane
Thank you reporting this issue.
This repository is for issues related to Gemini cookbook Examples/Quickstarts bugs or improvements. For Issues/Questions related to Gemini API, we would suggest you to use "Send Feedback" option in Gemini docs. Ref: Screenshot below.
You can also post this issue on Google AI forum.

image

@singhniraj08 singhniraj08 added type:bug Something isn't working status:awaiting response Awaiting a response from the author component:other Issues unrelated to examples/quickstarts labels Jul 11, 2024
Copy link

Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.

@github-actions github-actions bot added the status:stale Issue/PR is marked for closure due to inactivity label Aug 16, 2024
@fati459
Copy link

fati459 commented Aug 20, 2024

It sounds like you're encountering a discrepancy in the output when uploading PDF and DOC files, even though the content is identical. Here are a few potential reasons for the differences and some suggestions for troubleshooting:

Possible Reasons for Output Differences

  1. File Parsing Differences:

    • The libraries or methods used to extract text from PDFs and DOC files might handle formatting and content extraction differently. PDFs can often contain more complex layouts, which might be better processed when converted to images.
  2. Content Extraction Method:

    • In your PDF method, you're converting pages to images and explicitly extracting text, which may allow for better control over what information gets included in the final output. The DOC upload might not be extracting all the necessary details due to how the content is structured.
  3. Input Structure:

    • The way you structure your input for the chat session might affect how the model interprets the content. Ensure that the instruction format is consistent between both methods.
  4. Model Limitations:

    • The model might have different capabilities or settings when processing different file types. It could be optimized for one format over another.

Suggestions for Troubleshooting

  1. Check the Extraction Process:

    • Verify that the text extraction from the DOC file is capturing all relevant content. You could print the extracted text before sending it to the chat session to compare it with the PDF output.
  2. Standardize Input Format:

    • Make sure that the instruction format is as similar as possible between the two methods. This includes how you concatenate instructions and how you present the files.
  3. Debugging Output:

    • Print the responses from both methods at each step to identify where the information starts to differ. This can help pinpoint if the issue lies in the extraction or the chat session.
  4. Consult Documentation:

    • Look into the documentation for the libraries or APIs you are using to see if there are any notes on limitations or differences in handling various file types.
  5. Experiment with Different Formats:

    • If possible, try different formats for the DOC upload (like DOCX vs. DOC) or use different libraries for text extraction to see if that changes the output.

By following these steps, you should be able to identify the source of the discrepancy and potentially improve the output consistency between the two file upload methods. If the issue persists, consider reaching out to support for the specific tools or libraries you’re using for further assistance.

@github-actions github-actions bot removed the status:stale Issue/PR is marked for closure due to inactivity label Dec 2, 2024
Copy link

Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.

@github-actions github-actions bot added the status:stale Issue/PR is marked for closure due to inactivity label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:other Issues unrelated to examples/quickstarts status:awaiting response Awaiting a response from the author status:stale Issue/PR is marked for closure due to inactivity type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants
@anusonawane @fati459 @singhniraj08 and others