java.lang.Object
org.nasdanika.ai.ChunkingEmbeddings<T>
- Type Parameters:
T- a container of tokens, e.g. int[] or char[] or List<Integer>
- All Implemented Interfaces:
Coordinates,Embeddings,Model
- Direct Known Subclasses:
CharChunkingEmbeddings,EncodingChunkingEmbeddings
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.nasdanika.ai.Embeddings
Embeddings.Requirement -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedChunkingEmbeddings(Embeddings target, int chunkSize, int overlap) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract StringDecodes a string from an array of tokensprotected abstract TEncodes a string into tokensGenerates embeddings for a single stringgenerateAsync(String input) Asynchronously generates embeddings for a single stringintintgetName()Model nameProvider name - OpenAI, Ollama, ...booleanprotected abstract intprotected abstract TMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nasdanika.ai.Embeddings
generate, generateAsync
-
Constructor Details
-
ChunkingEmbeddings
- Parameters:
target-chunkSize- Chunk size, if non-positive, then target max input tokens is used as chunk sizeoverlap-
-
-
Method Details
-
getProvider
Description copied from interface:CoordinatesProvider name - OpenAI, Ollama, ...- Specified by:
getProviderin interfaceCoordinates- Returns:
-
getName
Description copied from interface:CoordinatesModel name- Specified by:
getNamein interfaceCoordinates- Returns:
-
getVersion
- Specified by:
getVersionin interfaceCoordinates
-
getMaxInputTokens
- Specified by:
getMaxInputTokensin interfaceModel
-
isTooLong
- Specified by:
isTooLongin interfaceEmbeddings- Returns:
- true if the input is too long for a given model
-
getDimensions
- Specified by:
getDimensionsin interfaceEmbeddings- Returns:
- number of dimentions
-
chunk
-
generateAsync
Description copied from interface:EmbeddingsAsynchronously generates embeddings for a single string- Specified by:
generateAsyncin interfaceEmbeddings- Returns:
-
generate
Description copied from interface:EmbeddingsGenerates embeddings for a single string- Specified by:
generatein interfaceEmbeddings- Returns:
-
encode
Encodes a string into tokens- Parameters:
input-- Returns:
-
decode
Decodes a string from an array of tokens- Parameters:
tokens-- Returns:
-
size
-
slice
-