Class AbstractEmbeddingFilter
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable,SelfConfiguring
- Direct Known Subclasses:
OpenAIEmbeddingFilter
The pipeline is:
- Read source text from
contentFieldin metadata - Chunk it with
MarkdownChunker - Call
to get vectors
invalid reference
#embed(List, InferenceConfig) - Serialize chunks + vectors as JSON into
outputField
The MarkdownChunker requires markdown-formatted content to split at
semantic boundaries (headings, paragraphs, etc.). The content handler type
must be set to MARKDOWN in the configuration. If the
TikaCoreProperties.TIKA_CONTENT_HANDLER_TYPE metadata field indicates
a different handler type, a warning is logged.
Subclasses implement embed(java.util.List<org.apache.tika.inference.Chunk>, org.apache.tika.inference.InferenceConfig, org.apache.tika.parser.ParseContext) for their specific API format.
Thread safety: instances are safe for concurrent MetadataFilter.filter(java.util.List<org.apache.tika.metadata.Metadata>, org.apache.tika.parser.ParseContext) calls once
fully constructed. Setters must not be called concurrently with
MetadataFilter.filter(java.util.List<org.apache.tika.metadata.Metadata>, org.apache.tika.parser.ParseContext).
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDeprecated.protectedDeprecated. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoFilter(List<Metadata> metadataList, ParseContext parseContext) Deprecated.Applies the filter in place.protected abstract voidembed(List<Chunk> chunks, InferenceConfig config, ParseContext parseContext) Deprecated.Call the embeddings endpoint to fill in vectors on each chunk.Deprecated.Deprecated.protected abstract StringDeprecated.The@TikaComponentname this filter's per-request JSON config is keyed by in parse-context (e.g.Deprecated.Deprecated.intDeprecated.intDeprecated.intDeprecated.getModel()Deprecated.Deprecated.intDeprecated.longDeprecated.booleanDeprecated.booleanDeprecated.voidDeprecated.voidsetBaseUrl(String baseUrl) Deprecated.voidsetClearContentAfterChunking(boolean clearContentAfterChunking) Deprecated.voidsetContentField(String contentField) Deprecated.voidsetMaxBatchSize(int maxBatchSize) Deprecated.voidsetMaxChunkChars(int maxChunkChars) Deprecated.voidsetMaxChunks(int maxChunks) Deprecated.voidDeprecated.voidsetOutputField(String outputField) Deprecated.voidsetOverlapChars(int overlapChars) Deprecated.voidsetSkipEmbedding(boolean skipEmbedding) Deprecated.voidsetTimeoutMillis(long timeoutMillis) Deprecated.Methods inherited from class org.apache.tika.metadata.filter.MetadataFilter
close, filter, filter
-
Constructor Details
-
AbstractEmbeddingFilter
protected AbstractEmbeddingFilter()Deprecated. -
AbstractEmbeddingFilter
Deprecated.
-
-
Method Details
-
embed
protected abstract void embed(List<Chunk> chunks, InferenceConfig config, ParseContext parseContext) throws IOException, TikaException Deprecated.Call the embeddings endpoint to fill in vectors on each chunk. Implementations should setChunk.setVector(float[])on each chunk in the list.- Parameters:
chunks- the text chunks to embedconfig- the resolved config for this callparseContext- the task's ParseContext -- pass toTikaHttpClientcalls to bound the request by the task's remaining budget and checkpoint while waiting- Throws:
IOException- on HTTP errorsTikaException- on API-level errors
-
getComponentName
Deprecated.The@TikaComponentname this filter's per-request JSON config is keyed by in parse-context (e.g.{"openai-embedding-filter": {...}}). -
doFilter
protected void doFilter(List<Metadata> metadataList, ParseContext parseContext) throws TikaException Deprecated.Description copied from class:MetadataFilterApplies the filter in place. A filter that needs to write a reserved Tika-native (tk:) key by name (rather than via itsProperty) should callMetadata.addTrusted(java.lang.String, java.lang.String)/Metadata.setTrusted(java.lang.String, java.lang.String)explicitly at that write.- Specified by:
doFilterin classMetadataFilter- Parameters:
metadataList- the list to filter (must be mutable)parseContext- per-request context- Throws:
TikaException- if filtering fails
-
getDefaultConfig
Deprecated. -
getBaseUrl
Deprecated. -
setBaseUrl
Deprecated.- Throws:
TikaConfigException
-
getModel
Deprecated. -
setModel
Deprecated. -
getApiKey
Deprecated. -
setApiKey
Deprecated.- Throws:
TikaConfigException
-
getTimeoutMillis
public long getTimeoutMillis()Deprecated. -
setTimeoutMillis
public void setTimeoutMillis(long timeoutMillis) Deprecated. -
getMaxChunkChars
public int getMaxChunkChars()Deprecated. -
setMaxChunkChars
public void setMaxChunkChars(int maxChunkChars) Deprecated. -
getOverlapChars
public int getOverlapChars()Deprecated. -
setOverlapChars
public void setOverlapChars(int overlapChars) Deprecated. -
getContentField
Deprecated. -
setContentField
Deprecated. -
getOutputField
Deprecated. -
setOutputField
Deprecated. -
isSkipEmbedding
public boolean isSkipEmbedding()Deprecated. -
setSkipEmbedding
public void setSkipEmbedding(boolean skipEmbedding) Deprecated. -
isClearContentAfterChunking
public boolean isClearContentAfterChunking()Deprecated. -
setClearContentAfterChunking
public void setClearContentAfterChunking(boolean clearContentAfterChunking) Deprecated. -
getMaxBatchSize
public int getMaxBatchSize()Deprecated. -
setMaxBatchSize
public void setMaxBatchSize(int maxBatchSize) Deprecated. -
getMaxChunks
public int getMaxChunks()Deprecated. -
setMaxChunks
public void setMaxChunks(int maxChunks) Deprecated.
-
"engines"and bind it with aTEXT"inference"binding, which embeds the whole document tree in batched requests.