Skip to content

[codex] Fix shared embeddings and string sparse validation#551

Draft
shenweichen wants to merge 4 commits intomasterfrom
codex/fix-shared-embedding-esmm
Draft

[codex] Fix shared embeddings and string sparse validation#551
shenweichen wants to merge 4 commits intomasterfrom
codex/fix-shared-embedding-esmm

Conversation

@shenweichen
Copy link
Copy Markdown
Owner

Summary

  • Reuse embedding layers by embedding_name for both SparseFeat and VarLenSparseFeat instead of recreating and overwriting duplicate entries.
  • Preserve sequence masking when a shared embedding is used by varlen sparse features.
  • Raise a clear ValueError when a string SparseFeat is configured without use_hash=True, so users do not hit TensorFlow's lower-level string-to-int embedding lookup failure.
  • Add regression coverage for shared embeddings and ESMM string sparse feature configuration.

Why

This addresses #419 by making shared embedding semantics explicit and avoiding repeated initialization for the same embedding_name. It also addresses #548 by clarifying the supported path for string sparse features in ESMM and other models: use use_hash=True, or pre-encode values to integer ids before passing them to DeepCTR.

Validation

  • git diff --check
  • python -m compileall -q deepctr tests
  • python -m pytest -q tests/feature_test.py tests/models/MTL_test.py was attempted locally, but this environment does not have TensorFlow installed (ModuleNotFoundError: No module named 'tensorflow').

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

❌ Patch coverage is 93.75000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.23%. Comparing base (b6a623a) to head (28035a0).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
deepctr/feature_column.py 77.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #551      +/-   ##
==========================================
+ Coverage   78.11%   78.23%   +0.11%     
==========================================
  Files          61       61              
  Lines        3304     3331      +27     
==========================================
+ Hits         2581     2606      +25     
- Misses        723      725       +2     
Flag Coverage Δ
pytest 78.23% <93.75%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant