PDF text increases prompt usage but not count_tokens on gemini-4-hydrogen
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- google-cloud, python
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Start with the attached pdf_token_repro.py reproduction and compare the SDK's count_tokens request and response with generate_content usage for the two PDF inputs. The report does not isolate whether the discrepancy comes from the SDK or Gemini backend, so first check whether raw REST reproduces it and review the earlier linked report. Done means identifying the responsible layer and documenting or fixing how PDF text is accounted for.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Adding embedded text to a 10-page PDF substantially increases gemini-4-hydrogen's reported input usage, but its count_tokens estimate is unchanged. The comparison below uses a blank PDF with the same page count and dimensions as a control.
Observed through google-genai; I have not isolated whether the cause is in the SDK or backend, or tested raw REST. Please redirect me if another tracker is more appropriate.
Environment details
- Python 3.12.13
- macOS 26.5.2 (arm64)
google-genai==3.3.0, Gemini Developer APIthinking_level=LOW; no system instruction, tools, or response schema
Steps to reproduce
- Extract the attached pdf-token-repro.zip.
- Set
GEMINI_API_KEY, then run:
pip install google-genai==3.3.0
python pdf_token_repro.py --pages 10
The script generates both synthetic PDFs and calls count_tokens and generate_content with identical contents for each model. No real documents or sensitive data are included.
Actual result
One run on 2026-11-16:
| Model | count_tokens | prompt_token_count | TEXT | |
|---|---|---|---|---|
| text.pdf | gemini-3.8-flash | 5,609 | 5,329 | 9 |
| text.pdf | gemini-4-hydrogen | 5,638 | 14,642 | 9,322 |
| blank.pdf | gemini-3.8-flash | 5,609 | 5,329 | 9 |
| blank.pdf | gemini-4-hydrogen | 5,638 | 5,704 | 384 |
All four requests report 5,320 IMAGE tokens. On Hydrogen, adding PDF text increases reported usage by 8,938 TEXT tokens without changing the estimate.
Expected behavior
count_tokens should account for PDF text included in prompt usage, or document the difference and provide a supported way to estimate input usage before generation.
Earlier report with additional Gemini API and Vertex AI observations.
- Ngôn ngữ chính
- Python
- Star
- 4.1k
- Fork
- 1.1k
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 97
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/python-genai
-
Interactions retries ignore the documented `initial_delay` and `max_delay` defaultsCó thể đã có người làm @Venkaiahbabuneelam đã nhận 8 ngày trước. Đang mởpriority: p2 status:awaiting user response type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
googleapis/python-genai#3317 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Test import module that doesn't existCó thể đã có người làm @Venkaiahbabuneelam đã nhận 34 ngày trước. Đang mởpriority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
googleapis/python-genai#3122 · 6 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Curated history keeps half a user turn when the model turn is invalidCó thể đã có người làm @Venkaiahbabuneelam đã nhận 43 ngày trước. Đang mởpriority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
googleapis/python-genai#3051 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFCCó thể đã có người làm @Venkaiahbabuneelam đã nhận 43 ngày trước. Đang mởpriority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
googleapis/python-genai#3044 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Structured-output continuation merge raises AttributeError: __pydantic_generic_metadata__ when a hop has parsed JSONCó thể đã có người làm @Venkaiahbabuneelam đã nhận 6 ngày trước. Đang mởpriority: p2 type: bug
googleapis/python-genai#3350 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của googleapis/python-genai
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
readthedocs/readthedocs-builder#73 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: ci bug good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
hffgzktbcc-blip/ounce-core#484 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
vllm-project/vllm-torchtpu#3395 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Hermes plugin: MITM-domain discovery misses the model: block (provider/base_url nested under model:) — traffic blind-tunnels silently, zero compressionCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
ranxianglei/billion-context#7063 ·
Maintainer thường phản hồi trong vòng 1 ngày