File size: 1,847 Bytes
dcfbea4
 
4614566
dcfbea4
4614566
 
 
 
 
dcfbea4
4614566
 
 
 
 
 
 
 
 
 
 
 
6416543
4614566
6416543
 
dcfbea4
 
9dd8097
 
dcfbea4
 
 
9dd8097
 
 
 
 
 
 
dcfbea4
 
9dd8097
 
dcfbea4
9dd8097
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4614566
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
59
60
61
62
63
64
65
---
language: en
license: apache-2.0
tags:
- metaphor-detection
- bert
- text-classification
- nlp
- transformer
model-index:
- name: Fine-Tuned Metaphor Detection Model
  results:
  - task:
      name: text-classification
      type: text-classification
    metrics:
    - name: Accuracy
      value: 72
      type: accuracy
metrics:
- accuracy
base_model:
- Sasidhar1826/common_metaphors_detection
pipeline_tag: text-classification
datasets:
- Sasidhar1826/manual_data_on_metaphors
---

# Fine-Tuned Metaphor Detection Model

This is the extention of my previously trained model.

This is a fine-tuned version of a BERT-based model used for metaphor detection in text. The model was trained on a custom dataset with sentences labeled as either metaphors or literals.

## Model Details
- **Model architecture**: BERT-based model
- **Number of labels**: 2 (Metaphor, Literal)
- **Training epochs**: 1
- **Batch size**: 8
- **Learning rate**: 1e-5
- **Evaluation metric**: Accuracy
- **Accuracy**: 72%

## How to use
You can use this model to predict whether a sentence contains a metaphor or not. Below is an example of how to load the model and use it for inference:

```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("your-username/fine-tuned-metaphor-detection")
model = AutoModelForSequenceClassification.from_pretrained("your-username/fine-tuned-metaphor-detection")

# Example text
text = "Time is a thief."

# Tokenize input and get predictions
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
with torch.no_grad():
    outputs = model(**inputs)
    logits = outputs.logits
    prediction = torch.argmax(logits, dim=-1)

print("Prediction:", "Metaphor" if prediction.item() == 1 else "Literal")