Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.ai.embedding

public Class EmbeddingModelMetadataService

extends Object
Class Inheritance
Annotations
@NullMarked
Imports
java.io.IOException, java.net.URI, .URISyntaxException, java.util.Collection, .List, .Locale, .Map, .Optional, .OptionalInt, .OptionalLong, .Set, java.util.concurrent.ConcurrentHashMap, org.jabref.logic.ai.preferences.AiPreferences, org.jabref.logic.importer.FetcherException, org.jabref.logic.net.URLDownload, org.jabref.logic.util.strings.StringUtil, ai.djl.repository.Artifact, ai.djl.repository.MRL, ai.djl.repository.zoo.ModelLoader, ai.djl.repository.zoo.ModelZoo, com.google.gson.JsonArray, .JsonElement, .JsonObject, .JsonParseException, .JsonParser, org.jspecify.annotations.NullMarked, org.slf4j.Logger, .LoggerFactory

Service for discovering available AI embedding models and querying their download size and maximum snippet (token / sequence) limit dynamically at runtime from DJL and Hugging Face.

Field Summary

Modifier and TypeField and Description
private final AiPreferences
private static final Set<String>
public static final String
private static final Logger
private final Map<String, EmbeddingModelMetadata>

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
private OptionalInt
extractMaxTokensFromArtifact(ai.djl.repository.Artifact artifact)

private OptionalLong
extractSizeFromArtifact(ai.djl.repository.Artifact artifact)

private OptionalInt
private OptionalInt
private OptionalLong
public List<String>
getAvailableModels()

Returns the list of available embedding models discovered from the DJL HuggingFace Model Zoo.

public Optional<EmbeddingModelMetadata>
getMetadata(String modelName)

Queries metadata (download size in bytes and maximum snippet length in tokens) for the given embedding model from DJL ModelZoo, falling back to the Hugging Face Hub REST API.

private boolean
private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

aiPreferencesback to summary
private final AiPreferences aiPreferences
CONFIG_AND_TOKENIZER_FILESback to summary
private static final Set<String> CONFIG_AND_TOKENIZER_FILES
DJL_PYTORCH_GROUP_IDback to summary
public static final String DJL_PYTORCH_GROUP_ID
LOGGERback to summary
private static final Logger LOGGER
metadataCacheback to summary
private final Map<String, EmbeddingModelMetadata> metadataCache

Constructor Detail

EmbeddingModelMetadataServiceback to summary
public EmbeddingModelMetadataService(AiPreferences aiPreferences)
EmbeddingModelMetadataServiceback to summary
public EmbeddingModelMetadataService()

Method Detail

extractMaxTokensFromArtifactback to summary
private OptionalInt extractMaxTokensFromArtifact(ai.djl.repository.Artifact artifact)
extractSizeFromArtifactback to summary
private OptionalLong extractSizeFromArtifact(ai.djl.repository.Artifact artifact)
fetchIntFieldFromJsonback to summary
private OptionalInt fetchIntFieldFromJson(String url, String fieldName)
fetchMaxTokensFromHuggingFaceback to summary
private OptionalInt fetchMaxTokensFromHuggingFace(String modelName)
fetchSizeFromHuggingFaceback to summary
private OptionalLong fetchSizeFromHuggingFace(String modelName)
getAvailableModelsback to summary
public List<String> getAvailableModels()

Returns the list of available embedding models discovered from the DJL HuggingFace Model Zoo.

getMetadataback to summary
public Optional<EmbeddingModelMetadata> getMetadata(String modelName)

Queries metadata (download size in bytes and maximum snippet length in tokens) for the given embedding model from DJL ModelZoo, falling back to the Hugging Face Hub REST API.

isAiEnabledback to summary
private boolean isAiEnabled()
isTokenizerOrConfigFileback to summary
private boolean isTokenizerOrConfigFile(String path)