File size: 1,250 Bytes
8486ab9 c65ed72 8486ab9 c65ed72 8486ab9 c65ed72 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
---
language: en
tags:
- bert
- regression
- biencoder
- similarity
pipeline_tag: text-similarity
---
# BiEncoder Regression Model
This model is a BiEncoder architecture that outputs similarity scores between text pairs.
## Model Details
- Base Model: bert-base-uncased
- Task: Regression
- Architecture: BiEncoder with cosine similarity
- Loss Function: mae
## Usage
```python
from transformers import AutoTokenizer, AutoModel
from modeling import BiEncoderModelRegression
# Load model components
tokenizer = AutoTokenizer.from_pretrained("minoosh/bert-reg-biencoder-mae")
base_model = AutoModel.from_pretrained("bert-base-uncased")
model = BiEncoderModelRegression(base_model, loss_fn="mae")
# Load weights
state_dict = torch.load("pytorch_model.bin")
model.load_state_dict(state_dict)
# Prepare inputs
texts1 = ["first text"]
texts2 = ["second text"]
inputs = tokenizer(
texts1, texts2,
padding=True,
truncation=True,
return_tensors="pt"
)
# Get similarity scores
outputs = model(**inputs)
similarity_scores = outputs["logits"]
```
## Metrics
The model was trained using mae loss and evaluated using:
- Mean Squared Error (MSE)
- Mean Absolute Error (MAE)
- Pearson Correlation
- Spearman Correlation
- Cosine Similarity
|