HCAE-21M-v1.1-Base is a specialized text embedding model utilizing a Hybrid Convolutional-Attention Encoder architecture. This iteration optimizes the trade-off between local contextual feature extraction and global dependency modeling through a symmetric block configuration. By integrating Depthwise Separable Convolutions with Multi-head Self-Attention, HCAE achieves high representational fidelity at a compact scale of 21 million parameters.
The HCAE series is engineered to address the parameter-inefficiency of standard Transformers at small scales. Version 1.1-Base provides the foundation for general-purpose semantic similarity, leveraging refinements in normalization and non-linear mapping (LayerScale & SwiGLU) to ensure better convergence and downstream task performance.
1from transformers import AutoModel, AutoTokenizer
2import torch
3
4model_name = "HeavensHackDev/HCAE-21M-v1.1-Base"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModel.from_pretrained(model_name, trust_remote_code=True)
7
8sentences = ["HCAE-Base provides robust text embeddings.", "The model uses a hybrid architecture."]
9inputs = tokenizer(sentences, padding=True, truncation=True, return_tensors="pt")
10
11with torch.no_grad():
12 embeddings = model(**inputs)
The model is also available in ONNX format for efficient edge deployment and cross-platform compatibility.
1import onnxruntime as ort
2import numpy as np
3
4# Load the session (ensure model.onnx and model.onnx.data are in the same directory)
5session = ort.InferenceSession("model.onnx")
6
7# Inputs should be numpy arrays (int64)
8inputs = {
9 "input_ids": np.random.randint(0, 30522, (1, 128), dtype=np.int64),
10 "attention_mask": np.ones((1, 128), dtype=np.int64)
11}
12
13outputs = session.run(None, inputs)
14embeddings = outputs[0]
The HCAE architecture utilizes 1D Depthwise Separable Convolutions to capture local context efficiently, followed by Self-Attention blocks for global dependency modeling. The model incorporates LayerScale and SwiGLU activation functions for improved training stability and representational capacity.
This model is licensed under the Apache License 2.0.