You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by "mawiesne (via GitHub)" <gi...@apache.org> on 2026/09/16 06:28:25 UTC
Re: [PR] OPENNLP-1937: Expose text embeddings as a generic SPI interface (opennlp)
mawiesne commented on code in PR #1290:
URL: https://github.com/apache/opennlp/pull/1290#discussion_r4023107044
##########
opennlp-api/src/main/java/opennlp/tools/embeddings/TextEmbedderProviders.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package opennlp.tools.embeddings;
+
+import java.util.ServiceConfigurationError;
+import java.util.ServiceLoader;
+
+/**
+ * Discovers embedding factories without opening models. Providers register through
+ * {@link ServiceLoader}; their constructors must not load models or initialize native runtimes.
+ * No provider or model instances are cached globally.
+ *
+ * @since 3.0.0
+ */
+public final class TextEmbedderProviders {
+
+ /** The provider selected by {@link #getDefault()}. */
+ public static final String DEFAULT_PROVIDER = "onnx";
+
+ private TextEmbedderProviders() {
+ }
+
+ /**
+ * Selects the default ONNX provider using the thread context class loader.
+ *
+ * @return The provider. Never {@code null}.
+ * @throws IllegalArgumentException Thrown if the default provider is not installed.
+ * @throws IllegalStateException Thrown if multiple providers use the default identifier.
+ * @throws ServiceConfigurationError Thrown if a service registration is invalid.
+ */
+ public static TextEmbedderProvider getDefault() {
Review Comment:
Do we need this method and related constant (`DEFAULT_PROVIDER = "onnx"`) here??
Shouldn't this be _per component_, that is defined in `OnnxTextEmbbedderProvider` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opennlp.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org