This commit is contained in:
157
packages/java/dev/kreuzberg/EmbeddingConfig.java
generated
Normal file
157
packages/java/dev/kreuzberg/EmbeddingConfig.java
generated
Normal file
@@ -0,0 +1,157 @@
|
||||
// This file is auto-generated by alef — DO NOT EDIT.
|
||||
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
|
||||
// To regenerate: alef generate
|
||||
// To verify freshness: alef verify --exit-code
|
||||
// Issues & docs: https://github.com/kreuzberg-dev/alef
|
||||
package dev.kreuzberg;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Embedding configuration for text chunks.
|
||||
*
|
||||
* Configures embedding generation using ONNX models via the vendored embedding engine.
|
||||
* Requires the {@code embeddings} feature to be enabled.
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_ABSENT)
|
||||
@JsonDeserialize(builder = EmbeddingConfig.Builder.class)
|
||||
public record EmbeddingConfig(
|
||||
/**
|
||||
* The embedding model to use (defaults to "balanced" preset if not specified)
|
||||
*/
|
||||
@Nullable @JsonProperty("model") EmbeddingModelType model,
|
||||
/**
|
||||
* Whether to normalize embedding vectors (recommended for cosine similarity)
|
||||
*/
|
||||
@Nullable @JsonProperty("normalize") Boolean normalize,
|
||||
/**
|
||||
* Batch size for embedding generation
|
||||
*/
|
||||
@Nullable @JsonProperty("batch_size") Long batchSize,
|
||||
/**
|
||||
* Show model download progress
|
||||
*/
|
||||
@Nullable @JsonProperty("show_download_progress") Boolean showDownloadProgress,
|
||||
/**
|
||||
* Custom cache directory for model files
|
||||
*
|
||||
* Defaults to {@code ~/.cache/kreuzberg/embeddings/} if not specified.
|
||||
* Allows full customization of model download location.
|
||||
*/
|
||||
@JsonProperty("cache_dir") java.nio.file.@Nullable Path cacheDir,
|
||||
/**
|
||||
* Hardware acceleration for the embedding ONNX model.
|
||||
*
|
||||
* When set, controls which execution provider (CPU, CUDA, CoreML, TensorRT)
|
||||
* is used for inference. Defaults to {@code None} (auto-select per platform).
|
||||
*/
|
||||
@Nullable @JsonProperty("acceleration") AccelerationConfig acceleration,
|
||||
/**
|
||||
* Maximum wall-clock duration (in seconds) for a single {@code embed()} call when
|
||||
* using EmbeddingModelType.Plugin.
|
||||
*
|
||||
* Applies only to the in-process plugin path — protects against hung
|
||||
* host-language backends (e.g. a Python callback deadlocked on the GIL,
|
||||
* a model stuck on CUDA OOM retries, etc.). On timeout, the dispatcher
|
||||
* returns {@code Plugin} instead of blocking forever.
|
||||
*
|
||||
* {@code None} disables the timeout. The default (60 seconds) is conservative
|
||||
* for common in-process inference; increase for large batches on slow
|
||||
* hardware.
|
||||
*/
|
||||
@Nullable @JsonProperty("max_embed_duration_secs") Long maxEmbedDurationSecs
|
||||
) {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
public EmbeddingConfig{
|
||||
if (batchSize == null) batchSize = 32L;
|
||||
}
|
||||
|
||||
// CPD-OFF
|
||||
@JsonPOJOBuilder(withPrefix = "with", buildMethodName = "build")
|
||||
public static final class Builder {
|
||||
|
||||
@Nullable private EmbeddingModelType model = null;
|
||||
private Boolean normalize = null;
|
||||
@JsonProperty("batch_size")
|
||||
private Long batchSize = null;
|
||||
@JsonProperty("show_download_progress")
|
||||
private Boolean showDownloadProgress = null;
|
||||
@JsonProperty("cache_dir")
|
||||
private java.nio.file.Path cacheDir = null;
|
||||
@Nullable private AccelerationConfig acceleration = null;
|
||||
@JsonProperty("max_embed_duration_secs")
|
||||
private Long maxEmbedDurationSecs = null;
|
||||
|
||||
/** Sets the model field. */
|
||||
@JsonProperty("model")
|
||||
public Builder withModel(final @Nullable EmbeddingModelType value) {
|
||||
this.model = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Sets the normalize field. */
|
||||
@JsonProperty("normalize")
|
||||
public Builder withNormalize(final @Nullable Boolean value) {
|
||||
this.normalize = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Sets the batchSize field. */
|
||||
@JsonProperty("batch_size")
|
||||
public Builder withBatchSize(final @Nullable Long value) {
|
||||
this.batchSize = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Sets the showDownloadProgress field. */
|
||||
@JsonProperty("show_download_progress")
|
||||
public Builder withShowDownloadProgress(final @Nullable Boolean value) {
|
||||
this.showDownloadProgress = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Sets the cacheDir field. */
|
||||
@JsonProperty("cache_dir")
|
||||
public Builder withCacheDir(final java.nio.file.@Nullable Path value) {
|
||||
this.cacheDir = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Sets the acceleration field. */
|
||||
@JsonProperty("acceleration")
|
||||
public Builder withAcceleration(final @Nullable AccelerationConfig value) {
|
||||
this.acceleration = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Sets the maxEmbedDurationSecs field. */
|
||||
@JsonProperty("max_embed_duration_secs")
|
||||
public Builder withMaxEmbedDurationSecs(final @Nullable Long value) {
|
||||
this.maxEmbedDurationSecs = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Builds the EmbeddingConfig instance. */
|
||||
public EmbeddingConfig build() {
|
||||
return new EmbeddingConfig(
|
||||
model,
|
||||
normalize,
|
||||
batchSize,
|
||||
showDownloadProgress,
|
||||
cacheDir,
|
||||
acceleration,
|
||||
maxEmbedDurationSecs
|
||||
);
|
||||
}
|
||||
}
|
||||
// CPD-ON
|
||||
public static EmbeddingConfig defaultInstance() {
|
||||
throw new UnsupportedOperationException("defaultInstance is not yet bridged via JNI; use the Builder instead.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user