Conversation
krickert
marked this pull request as ready for review
September 8, 2026 12:51
Contributor
|
This needs to wait after M6. |
rzo1
marked this pull request as draft
September 8, 2026 12:59
krickert
added a commit
to ai-pipestream/opennlp
that referenced
this pull request
Sep 9, 2026
OPENNLP-1937 (apache#1290) proposes this interface for opennlp-api without the experimental marker. This branch had an earlier copy that still used it, so the integration build hit an add/add conflict on the file and could resolve it either way. Take the upstream file as is. No behaviour changes: an annotation, an import, and a javadoc paragraph.
krickert
marked this pull request as ready for review
September 12, 2026 02:52
krickert
marked this pull request as draft
September 14, 2026 02:23
Contributor
Author
|
Putting this in draft. We should separate ONNX and CLI from the embedding library. ONNX can remain the default through an SPI, while downstream projects can exclude it and supply another implementation. Any native integration currently pulls in both unnecessarily. This would fix that concern. I’ll include the split in this ticket. It should be a focused packaging change that preserves the default runtime behavior and makes add-ons easier to use. It's not a lot of work to do. |
Select model factories by provider ID, retain ONNX as the default, and allow independently owned models through the closeable TextEmbedder API. Keep model initialization out of provider discovery and preserve the existing SentenceVectorsDL inference path. Tests cover multiple providers, missing and duplicate IDs, independent model lifetimes, and ONNX output parity. The root model-path regression first failed with NullPointerException; it now rejects the invalid path. The SPI tests initially failed to compile before the API was introduced. Validation: targeted Maven verify with dependencies, apache-rat:check, and final path-validation regression tests passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
opennlp.tools.embeddings.TextEmbedderto opennlp-api and makesSentenceVectorsDLimplement it.Core lacks a contract for "text in, vector out".
WordVectorTablelooks up a stored vector for one word, andSentenceVectorsDLexposes vectors only through the concrete class, so no API can accept an arbitrary embedder.The interface:
embed(CharSequence), a defaultedembedAll(List)for implementations that batch more efficiently, anddimension().In
SentenceVectorsDL:embedadaptsgetVectors, which now also rejects null input.embedAllbuckets inputs by token count and runs one session per bucket, so a batch has no padding and each result matches what the single-input path would produce.dimension()uses the model output metadata, falling back to a cached measurement when a model sets that value at run time.SentenceVectorsDLEmbedderTestexercises this through a real ONNX session. The bundled graph is 373 bytes and computesoutput[b][t] = float(input_ids[b][t]) * [0.5, -1, 2], so expected vectors follow directly from the ids. The generator script is committed alongside.rat-excludesand.gitignoregain entries for the binary, since*.onnxis ignored repo-wide and would drop the fixture with no warning.No experimental marker on the interface: it is a small contract over primitive arrays.
Motivation: a static embedding add-on is planned, and an add-on can only implement a contract present in a released core version. Otherwise add-ons each invent an embedder type and none interoperate.
Verification, offline, with checkstyle:
opennlp-api 387 tests, opennlp-dl 93 tests, no failures, no checkstyle violations.