rubert-tiny2-onnx

ONNX version of cointegrated/rubert-tiny2, a compact Russian language model.

This repository contains the model exported to ONNX format for inference with ONNX Runtime. It can be used to extract contextual token representations and generate text embeddings through mean pooling.

Features

  • Russian language support
  • ONNX inference
  • Compatible with Hugging Face Transformers and Optimum
  • Mean pooling for sentence embeddings
  • ONNX opset 14

Installation

pip install torch transformers optimum onnxruntime

Usage

import torch
from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForFeatureExtraction

model_id = "KvaytG/rubert-tiny2-onnx"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = ORTModelForFeatureExtraction.from_pretrained(model_id)

texts = [
    "Привет, мир!",
    "Как дела?",
]

inputs = tokenizer(
    texts,
    padding=True,
    truncation=True,
    max_length=128,
    return_tensors="pt",
)

with torch.no_grad():
    outputs = model(**inputs)

hidden = outputs.last_hidden_state
mask = inputs["attention_mask"].unsqueeze(-1).float()

embeddings = (
    (hidden * mask).sum(dim=1) / mask.sum(dim=1).clamp(min=1e-9)
)

print(embeddings.shape)  # torch.Size([2, 312])

The resulting embeddings tensor contains one vector per input text.

Model Details

  • Base model: cointegrated/rubert-tiny2
  • Format: ONNX
  • ONNX opset: 14
  • Task: Feature extraction
  • Output: last_hidden_state
  • Pooling: Mean pooling with attention mask
  • Language: Russian

License

This model is distributed under the MIT license, following the license of the original model, cointegrated/rubert-tiny2.

References

Citation

@misc{kvaytg_rubert_tiny2_onnx,
  author       = {KvaytG},
  title        = {RuBERT-tiny2 ONNX},
  year         = {2026},
  publisher    = {Hugging Face},
  journal      = {Hugging Face Models},
  url          = {https://huggingface.co/KvaytG/rubert-tiny2-onnx},
  note         = {ONNX export of cointegrated/rubert-tiny2 for Russian text feature extraction and embeddings}
}
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for KvaytG/rubert-tiny2-onnx

Quantized
(6)
this model