Instructions to use inference4j/all-MiniLM-L12-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use inference4j/all-MiniLM-L12-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("inference4j/all-MiniLM-L12-v2") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
all-MiniLM-L12-v2 โ ONNX
ONNX export of all-MiniLM-L12-v2, a sentence-transformers model that maps sentences to a 384-dimensional dense vector space. Deeper variant (12 layers) of MiniLM with slightly better quality at the cost of speed.
Mirrored for use with inference4j, an inference-only AI library for Java.
Original Source
- Repository: sentence-transformers
- License: apache-2.0
Usage with inference4j
try (SentenceTransformer model = SentenceTransformer.fromPretrained("models/all-MiniLM-L12-v2")) {
float[] embedding = model.encode("Hello, world!");
System.out.println("Dimension: " + embedding.length); // 384
}
Model Details
| Property | Value |
|---|---|
| Architecture | MiniLM-L12 (12 layers, 384 hidden) |
| Task | Sentence embeddings / semantic similarity |
| Output dimension | 384 |
| Max sequence length | 256 |
| Training data | 1B+ sentence pairs |
| Original framework | PyTorch (sentence-transformers) |
License
This model is licensed under the Apache License 2.0. Original model by sentence-transformers.