Skip to content

[Model] Add PP-Chart2Table Model Support#43767

Merged
vasqu merged 68 commits intohuggingface:mainfrom
XingweiDeng:feat/pp_chart2table
Mar 19, 2026
Merged

[Model] Add PP-Chart2Table Model Support#43767
vasqu merged 68 commits intohuggingface:mainfrom
XingweiDeng:feat/pp_chart2table

Conversation

@XingweiDeng
Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@XingweiDeng
Copy link
Copy Markdown
Contributor Author

Hi @molbap @vasqu @yonigozlan , PP-Chart2Table is a model contributed by our team. Could you please take a look and review it when you have a moment? Thanks a lot!

@zhang-prog
Copy link
Copy Markdown
Contributor

zhang-prog commented Mar 16, 2026

@vasqu This is PP-Chart2Table, one of the five models we plan to merge this week. PTAL.🤗

Copy link
Copy Markdown
Contributor

@vasqu vasqu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super solid! I only have a few smaller comments to align with a few smaller standards but overall nice job

model_path = "PaddlePaddle/PP-Chart2Table_safetensors"
model = AutoModelForImageTextToText.from_pretrained(
model_path,
dtype="float32",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dtype="float32",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

dtype="float32",
device_map="auto",
)
processor = AutoProcessor.from_pretrained(model_path, use_fast=True).to(model.device)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
processor = AutoProcessor.from_pretrained(model_path, use_fast=True).to(model.device)
processor = AutoProcessor.from_pretrained(model_path).to(model.device)

not sure but I don't think we need this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

image = Image.open(requests.get("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/chart_parsing_02.png", stream=True).raw)
inputs = processor(images=image)

generated_ids = model.generate(**inputs, use_cache=True, do_sample=False, max_new_tokens=256)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
generated_ids = model.generate(**inputs, use_cache=True, do_sample=False, max_new_tokens=256)
generated_ids = model.generate(**inputs, do_sample=False, max_new_tokens=256)

same here, shouldn't be needed I think

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

model_path = "PaddlePaddle/PP-Chart2Table_safetensors"
model = AutoModelForImageTextToText.from_pretrained(
model_path,
dtype="float32",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dtype="float32",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +160 to +166
## PPChart2TableVisionPreTrainedModel

[[autodoc]] PPChart2TableVisionPreTrainedModel

## PPChart2TablePreTrainedModel

[[autodoc]] PPChart2TablePreTrainedModel
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## PPChart2TableVisionPreTrainedModel
[[autodoc]] PPChart2TableVisionPreTrainedModel
## PPChart2TablePreTrainedModel
[[autodoc]] PPChart2TablePreTrainedModel

Nit: don't really need those exposed in the docs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +179 to +181
@unittest.skip(reason="PPChart2Table does not support this test.")
def test_model_is_small(self):
pass
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely shouldn't be skipped, let's shrink the model to make this pass. It's fairly important for our CI to run fast

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +167 to +177
@unittest.skip(
reason="PPChart2Table have reused the GotOcr2 model, which does not implement the latest logic for capturing attentions and hidden_states introduced in Transformers v5."
)
def test_get_image_features_attentions(self):
pass

@unittest.skip(
reason="PPChart2Table have reused the GotOcr2 model, which does not implement the latest logic for capturing attentions and hidden_states introduced in Transformers v5."
)
def test_get_image_features_hidden_states(self):
pass
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not skipped in got ocr2 so imo we should check what goes wrong

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

**inputs,
use_cache=True,
do_sample=False,
max_new_tokens=1024,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that we properly end early but we probably should reduce this nonetheless

Suggested change
max_new_tokens=1024,
max_new_tokens=32,

just a wild guess

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread utils/check_config_attributes.py Outdated
"BambaConfig": ["attn_layer_indices"],
"Dots1Config": ["max_window_layers"],
"JambaConfig": ["attn_layer_offset", "attn_layer_period", "expert_layer_offset", "expert_layer_period"],
"PPChart2TableConfig": ["tie_word_embeddings"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"PPChart2TableConfig": ["tie_word_embeddings"],

shouldn't be needed, we have excluded some common attributes with ATTRIBUTES_TO_ALLOW in the file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread utils/check_repo.py Outdated
Comment on lines +48 to +60
if images is None:
raise ValueError("At least one of `images` must be provided")
image_inputs = self.image_processor(images=images, **output_kwargs["images_kwargs"])

# Prepare input ids for batch
if text is None:
raise ValueError("At least one of `text` must be provided")

if not isinstance(text, list):
text = [text]

input_ids = self.tokenizer(text, **output_kwargs["text_kwargs"]).input_ids

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: except for errors, looks same as super().__call__. We can do

if text is None or images is None:
    raise ValueError("Both `images` and `text` must be provided")
return super().__call(images=images, text=text, **kwargs)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@vasqu
Copy link
Copy Markdown
Contributor

vasqu commented Mar 19, 2026

#43514 just got merged, we need to fixup the img processor a bit, let me know if I should step in

@XingweiDeng XingweiDeng reopened this Mar 19, 2026
Copy link
Copy Markdown
Member

@yonigozlan yonigozlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cc @vasqu changes needed after image proc refactor ;)

Comment thread tests/models/pp_chart2table/test_image_processing_pp_chart2table.py Outdated
Comment thread tests/models/pp_chart2table/test_image_processing_pp_chart2table.py Outdated
Comment thread tests/models/pp_chart2table/test_image_processing_pp_chart2table.py Outdated
@vasqu
Copy link
Copy Markdown
Contributor

vasqu commented Mar 19, 2026

run-slow: pp_chart2table

@github-actions
Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

This comment contains run-slow, running the specified jobs:

models: ["models/pp_chart2table"]
quantizations: []

@github-actions
Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN 3200c811 workflow commit (merge commit)
PR eb5c2a51 branch commit (from PR)
main e94695e5 base commit (on main)

Model CI Report

3 new failed tests from this PR 😭

  • pp_chart2table:
    tests/models/pp_chart2table/test_modeling_pp_chart2table.py::PPChart2TableIntegrationTest::test_small_model_integration_test_pp_chart2table (✅ ⟹ ❌)
    tests/models/pp_chart2table/test_modeling_pp_chart2table.py::PPChart2TableIntegrationTest::test_small_model_integration_test_pp_chart2table_batched (✅ ⟹ ❌)
    tests/models/pp_chart2table/test_processing_pp_chart2table.py::PPChart2TableProcessorTest::test_ocr_queries (✅ ⟹ ❌)

@vasqu
Copy link
Copy Markdown
Contributor

vasqu commented Mar 19, 2026

run-slow: pp_chart2table

@github-actions
Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, pp_chart2table

@github-actions
Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

This comment contains run-slow, running the specified jobs:

models: ["models/pp_chart2table"]
quantizations: []

@github-actions
Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN e8916c60 workflow commit (merge commit)
PR 081537cc branch commit (from PR)
main b96f8a98 base commit (on main)

✅ No failing test specific to this PR 🎉 👏 !

@vasqu vasqu enabled auto-merge March 19, 2026 18:50
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@vasqu vasqu added this pull request to the merge queue Mar 19, 2026
Merged via the queue into huggingface:main with commit aa1c36f Mar 19, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants