Skip to content

fix(HuggingFace, v1.2): drop unused TensorFlow import in sentiment analysis codegen - #7315

Open
github-actions[bot] wants to merge 2 commits into
release/v1.2from
backport/6809-drop-unused-tensorflow-import-in-sentime-v1.2
Open

fix(HuggingFace, v1.2): drop unused TensorFlow import in sentiment analysis codegen#7315
github-actions[bot] wants to merge 2 commits into
release/v1.2from
backport/6809-drop-unused-tensorflow-import-in-sentime-v1.2

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Automated backport of #6809 to release/v1.2.

Source: 2ae9a97 · automation run

Any related issues, documentation, discussions?

Backport of #6809. Originally linked #6794.

How was this PR tested?

Release-branch CI runs on this branch once the build is fixed and this PR is marked ready for review.

Was this PR authored or co-authored using generative AI tooling?

No.

… codegen (#6809)

### What changes were proposed in this PR?

`HuggingFaceSentimentAnalysisOpDesc.generatePythonCode` emitted an
import for `TFAutoModelForSequenceClassification` that the generated
body never uses — the model is loaded through the PyTorch
`AutoModelForSequenceClassification`.

The symbol does not exist in the pinned `transformers`: the library
dropped its TensorFlow backend in 5.0, and
`amber/operator-requirements.txt` has been on 5.x since #5016 (5.5.0
today). So the import is not dead weight — it raises `ImportError` at
module load and takes the whole generated script down before any
inference runs, on every environment that installs the pinned
requirements.

Fix — remove the unused import:

```diff
 from transformers import pipeline
 from transformers import AutoModelForSequenceClassification
-from transformers import TFAutoModelForSequenceClassification
 from transformers import AutoTokenizer, AutoConfig
```

### Any related issues, documentation, discussions?

Closes #6794

### How was this PR tested?

Manually, per @Yicong-Huang's request: the existing spec asserts on the
emitted text and `py_compile` only parses it, so neither executes the
template.

The template was dumped from `generatePythonCode` (columns `text` →
`pos`/`neu`/`neg`) and run against the `pytexera` in
`amber/src/main/python`, in a virtualenv with the pinned `transformers`
5.5.0 and `numpy` 2.1.0. main's stops at line 4 with `ImportError:
cannot import name 'TFAutoModelForSequenceClassification' from
'transformers'`, before the class body is defined; this PR's loads
`cardiffnlp/twitter-roberta-base-sentiment-latest` and classifies all
three rows, each row's three columns summing to 1:

| text | pos | neu | neg |
| --- | --- | --- | --- |
| I love this new feature, it works beautifully! | 0.9884 | 0.007 |
0.0046 |
| The meeting is scheduled for 3pm in room 204. | 0.0433 | 0.9438 |
0.0129 |
| This is the worst release we have ever shipped. | 0.0066 | 0.0423 |
0.951 |

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 4.8)

---------

(backported from commit 2ae9a97)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: carloea2 <carloea2@uci.edu>
Co-authored-by: Yicong Huang <17627829+Yicong-Huang@users.noreply.github.com>
Co-authored-by: Xuan Gu <162244362+xuang7@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

The cherry-pick applied cleanly but the backported tree failed its pre-merge build. Fix the build on this branch, then mark this PR ready for review.

@xuang7
xuang7 enabled auto-merge August 5, 2026 06:30
@github-actions github-actions Bot added the common label Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @carloea2
    You can notify them by mentioning @carloea2 in a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants