Sasidhar1826
commited on
Commit
•
9dd8097
1
Parent(s):
7c3ea24
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Fine-Tuned Metaphor Detection Model
|
2 |
+
|
3 |
+
This is a fine-tuned version of the model used for metaphor detection in text. It was trained on a custom dataset with sentences labeled as either metaphors or literals.
|
4 |
+
|
5 |
+
## Model Details
|
6 |
+
- **Model architecture**: BERT-based model
|
7 |
+
- **Number of labels**: 2 (Metaphor, Literal)
|
8 |
+
- **Training epochs**: 1
|
9 |
+
- **Batch size**: 8
|
10 |
+
- **Learning rate**: 1e-5
|
11 |
+
|
12 |
+
## How to use
|
13 |
+
You can use this model to predict whether a sentence contains a metaphor or not.
|
14 |
+
|
15 |
+
```python
|
16 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
17 |
+
import torch
|
18 |
+
|
19 |
+
# Load model and tokenizer
|
20 |
+
tokenizer = AutoTokenizer.from_pretrained("your-username/fine-tuned-metaphor-detection")
|
21 |
+
model = AutoModelForSequenceClassification.from_pretrained("your-username/fine-tuned-metaphor-detection")
|
22 |
+
|
23 |
+
# Example text
|
24 |
+
text = "Time is a thief."
|
25 |
+
|
26 |
+
# Tokenize input and get predictions
|
27 |
+
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
28 |
+
with torch.no_grad():
|
29 |
+
outputs = model(**inputs)
|
30 |
+
logits = outputs.logits
|
31 |
+
prediction = torch.argmax(logits, dim=-1)
|
32 |
+
|
33 |
+
print("Prediction:", "Metaphor" if prediction.item() == 1 else "Literal")
|