Class: Candle::EmbeddingModel
- Inherits:
-
Object
- Object
- Candle::EmbeddingModel
- Defined in:
- lib/candle/embedding_model.rb
Constant Summary collapse
- DEFAULT_MODEL_PATH =
Default model path for Jina BERT embedding model
"jinaai/jina-embeddings-v2-base-en"
- DEFAULT_TOKENIZER_PATH =
Default tokenizer path that works well with the default model
"sentence-transformers/all-MiniLM-L6-v2"
- DEFAULT_EMBEDDING_MODEL_TYPE =
Default embedding model type
"jina_bert"
Class Method Summary collapse
-
.new(model_path: DEFAULT_MODEL_PATH, tokenizer_path: DEFAULT_TOKENIZER_PATH, device: nil, model_type: DEFAULT_EMBEDDING_MODEL_TYPE, embedding_size: nil) ⇒ Object
Constructor for creating a new EmbeddingModel with optional parameters.
Instance Method Summary collapse
-
#embedding(str, pooling_method: "pooled_normalized") ⇒ Object
Returns the embedding for a string using the specified pooling method.
Class Method Details
.new(model_path: DEFAULT_MODEL_PATH, tokenizer_path: DEFAULT_TOKENIZER_PATH, device: nil, model_type: DEFAULT_EMBEDDING_MODEL_TYPE, embedding_size: nil) ⇒ Object
Constructor for creating a new EmbeddingModel with optional parameters
18 19 20 21 22 23 24 |
# File 'lib/candle/embedding_model.rb', line 18 def self.new(model_path: DEFAULT_MODEL_PATH, tokenizer_path: DEFAULT_TOKENIZER_PATH, device: nil, model_type: DEFAULT_EMBEDDING_MODEL_TYPE, embedding_size: nil) _create(model_path, tokenizer_path, device, model_type, ) end |
Instance Method Details
#embedding(str, pooling_method: "pooled_normalized") ⇒ Object
Returns the embedding for a string using the specified pooling method.
28 29 30 |
# File 'lib/candle/embedding_model.rb', line 28 def (str, pooling_method: "pooled_normalized") (str, pooling_method) end |