Class OnnxEmbeddingModel
java.lang.Object
dev.langchain4j.model.embedding.DimensionAwareEmbeddingModel
dev.langchain4j.model.embedding.onnx.AbstractInProcessEmbeddingModel
dev.langchain4j.model.embedding.onnx.OnnxEmbeddingModel
- All Implemented Interfaces:
dev.langchain4j.model.embedding.EmbeddingModel
,dev.langchain4j.model.embedding.TokenCountEstimator
An embedding model that runs within your Java application's process
using ONNX runtime.
Many models (e.g., from HuggingFace) can be used, as long as they are in the ONNX format.
Information on how to convert models into ONNX format can be found here.
Many models already converted to ONNX format are available here.
Many models (e.g., from HuggingFace) can be used, as long as they are in the ONNX format.
Information on how to convert models into ONNX format can be found here.
Many models already converted to ONNX format are available here.
-
Field Summary
Fields inherited from class dev.langchain4j.model.embedding.DimensionAwareEmbeddingModel
dimension
-
Constructor Summary
ConstructorsConstructorDescriptionOnnxEmbeddingModel
(String pathToModel) Deprecated.OnnxEmbeddingModel
(String pathToModel, String pathToTokenizer, PoolingMode poolingMode) OnnxEmbeddingModel
(String pathToModel, String pathToTokenizer, PoolingMode poolingMode, Executor executor) OnnxEmbeddingModel
(Path pathToModel) Deprecated.OnnxEmbeddingModel
(Path pathToModel, Path pathToTokenizer, PoolingMode poolingMode) OnnxEmbeddingModel
(Path pathToModel, Path pathToTokenizer, PoolingMode poolingMode, Executor executor) -
Method Summary
Methods inherited from class dev.langchain4j.model.embedding.onnx.AbstractInProcessEmbeddingModel
embedAll, estimateTokenCount, loadFromJar
Methods inherited from class dev.langchain4j.model.embedding.DimensionAwareEmbeddingModel
dimension, knownDimension
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.langchain4j.model.embedding.EmbeddingModel
embed, embed
Methods inherited from interface dev.langchain4j.model.embedding.TokenCountEstimator
estimateTokenCount, estimateTokenCount
-
Constructor Details
-
OnnxEmbeddingModel
- Parameters:
pathToModel
- The path to the modelPath file (e.g., "/path/to/model.onnx")pathToTokenizer
- The path to the tokenizer file (e.g., "/path/to/tokenizer.json")poolingMode
- The pooling model to use. Can be found in the ".../1_Pooling/config.json" file on HuggingFace. Here is an example."pooling_mode_mean_tokens": true
means thatPoolingMode.MEAN
should be used.
-
OnnxEmbeddingModel
public OnnxEmbeddingModel(Path pathToModel, Path pathToTokenizer, PoolingMode poolingMode, Executor executor) - Parameters:
pathToModel
- The path to the modelPath file (e.g., "/path/to/model.onnx")pathToTokenizer
- The path to the tokenizer file (e.g., "/path/to/tokenizer.json")poolingMode
- The pooling model to use. Can be found in the ".../1_Pooling/config.json" file on HuggingFace. Here is an example."pooling_mode_mean_tokens": true
means thatPoolingMode.MEAN
should be used.executor
- The executor to use to parallelize the embedding process.
-
OnnxEmbeddingModel
- Parameters:
pathToModel
- The path to the model file (e.g., "/home/me/model.onnx")pathToTokenizer
- The path to the tokenizer file (e.g., "/path/to/tokenizer.json")poolingMode
- The pooling model to use. Can be found in the ".../1_Pooling/config.json" file on HuggingFace. Here is an example."pooling_mode_mean_tokens": true
means thatPoolingMode.MEAN
should be used.
-
OnnxEmbeddingModel
public OnnxEmbeddingModel(String pathToModel, String pathToTokenizer, PoolingMode poolingMode, Executor executor) - Parameters:
pathToModel
- The path to the model file (e.g., "/home/me/model.onnx")pathToTokenizer
- The path to the tokenizer file (e.g., "/path/to/tokenizer.json")poolingMode
- The pooling model to use. Can be found in the ".../1_Pooling/config.json" file on HuggingFace. Here is an example."pooling_mode_mean_tokens": true
means thatPoolingMode.MEAN
should be used.executor
- The executor to use to parallelize the embedding process.
-
OnnxEmbeddingModel
Deprecated.- Parameters:
pathToModel
- The path to the modelPath file (e.g., "/path/to/model.onnx")
-
OnnxEmbeddingModel
Deprecated.- Parameters:
pathToModel
- The path to the modelPath file (e.g., "/path/to/model.onnx")
-
-
Method Details
-
model
- Specified by:
model
in classAbstractInProcessEmbeddingModel
-
OnnxEmbeddingModel(Path, Path, PoolingMode)
orOnnxEmbeddingModel(String, String, PoolingMode)
instead.