You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@opennlp.apache.org by "Richard Zowalla (Jira)" <ji...@apache.org> on 2026/09/18 12:03:00 UTC

[jira] [Created] (OPENNLP-1977) SentenceVectorsDL returns the [CLS] hidden state instead of the pooled sentence embedding

Richard Zowalla created OPENNLP-1977:
----------------------------------------

             Summary: SentenceVectorsDL returns the [CLS] hidden state instead of the pooled sentence embedding
                 Key: OPENNLP-1977
                 URL: https://issues.apache.org/jira/browse/OPENNLP-1977
             Project: OpenNLP
          Issue Type: Bug
            Reporter: Richard Zowalla
             Fix For: 3.0.0


{{SentenceVectorsDL.getVectors}} returns {{v\[0\]\[0\]}}, the raw last hidden state of the first \(\[CLS\]\) token. The class targets sentence\-transformers models converted to ONNX, and {{SentenceVectorsDLEval}} uses all\-MiniLM\-L6\-v2, whose {{1\_Pooling/config.json}} sets {{pooling\_mode\_mean\_tokens: true}} and {{pooling\_mode\_cls\_token: false}}, followed by a Normalize module. So the returned vector is not the embedding the model was trained to produce, and similarity scores differ from sentence\-transformers.

Suggested fix: read the pooling mode and normalization from the model's sentence\-transformers metadata \({{1\_Pooling/config.json}}, {{modules.json}}\) when present, otherwise require it as an option; mean pooling must exclude padding positions. Since the 3.0.0 release note already states that vectors change, the default should be settled before 3.0.0.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)