Downloads · 30 days
10
3% of all-time downloads
agentlans/e5-small-v2-nli
e5-small-v2-nli is a text classification model from agentlans. Use it when you need a label for a piece of text. It is set up for sentence-transformers. The card lists the license as mit.
- Base Model: intfloat/e5-small-v2 - Task: Natural Language Inference (NLI) - Framework: Hugging Face Transformers, Sentence Transformers
Downloads · 30 days
10
3% of all-time downloads
All-time downloads
358
Public
Parameters
33.4M
133 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors133 MB · 99%
From the Hugging Face model README
e5-small-v2-nli is a fine-tuned NLI model that classifies the relationship between pairs of sentences into three categories: entailment, neutral, and contradiction. It enhances the capabilities of intfloat/e5-small-v2 for improved performance on NLI tasks.
e5-small-v2-nli is ideal for applications requiring understanding of logical relationships between sentences, including:
e5-small-v2-nli was trained on the sentence-transformers/all-nli dataset, achieving competitive results in sentence pair classification.
Performance on the MNLI matched validation set:
Dataset:
Sampling:
Fine-tuning Process:
Hyperparameters:
To ensure reproducibility:
from sentence_transformers import CrossEncoder
model_name = "agentlans/e5-small-v2-nli"
model = CrossEncoder(model_name)
scores = model.predict(
[
("A man is eating pizza", "A man eats something"),
(
"A black race car starts up in front of a crowd of people.",
"A man is driving down a lonely road.",
),
]
)
label_mapping = ["entailment", "neutral", "contradiction"]
labels = [label_mapping[score_max] for score_max in scores.argmax(axis=1)]
print(labels)
# Output: ['entailment', 'contradiction']
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "agentlans/e5-small-v2-nli"
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
features = tokenizer(
[
"A man is eating pizza",
"A black race car starts up in front of a crowd of people.",
],
["A man eats something", "A man is driving down a lonely road."],
padding=True,
truncation=True,
return_tensors="pt",
)
model.eval()
with torch.no_grad():
scores = model(**features).logits
label_mapping = ["entailment", "neutral", "contradiction"]
labels = [label_mapping[score_max] for score_max in scores.argmax(dim=1)]
print(labels)
# Output: ['entailment', 'contradiction']
e5-small-v2-nli may reflect biases present in the training data. Users should evaluate its performance in specific contexts to ensure fairness and accuracy.
e5-small-v2-nli offers a robust solution for NLI tasks, enhancing intfloat/e5-small-v2's capabilities with straightforward integration into existing frameworks. It aids developers in building intelligent applications that require nuanced language understanding.