Method: Vecsearch::GTETiny#encode
- Defined in:
- lib/vecsearch/gte_tiny.rb
#encode(sentence, n_threads: 1) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/vecsearch/gte_tiny.rb', line 45 def encode(sentence, n_threads: 1) # Encode the sentence into token embeddings = encode_batch([sentence], n_threads: 1) # Pool the token embeddings into a sentence embedding # For simplicity, we'll use an attention mask of all ones attention_mask = Array.new(.first.length, 1) # sentence_embedding = mean_pooling(token_embeddings, attention_mask) # sentence_embedding end |