File size: 2,539 Bytes
34d1bf1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---
language: en
tags:
- frame-semantics
- semantic-role-labeling
- token-classification
- roberta
license: apache-2.0
widget:
- text: "The cat sat on the mat"
  text_pair: "sat"
---

# nixie1981/sem_frames

## Model Description

This is a RoBERTa-based model fine-tuned for semantic frame detection using a Question-Answering approach.
Given a sentence and a target word, the model predicts the semantic frame that best describes the word's meaning in context.

The model is trained on FrameNet 1.7 data and can predict from 797 different semantic frames.

## Usage

### Using the model directly

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

# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("nixie1981/sem_frames")
model = AutoModelForSequenceClassification.from_pretrained("nixie1981/sem_frames")

# Example: Find frame for "sat" in "The cat sat on the mat"
sentence = "The cat sat on the mat"
target_word = "sat"

# Tokenize
inputs = tokenizer(sentence, target_word, return_tensors="pt")

# Predict
with torch.no_grad():
    outputs = model(**inputs)
    predicted_frame_id = torch.argmax(outputs.logits, dim=-1).item()
    predicted_frame = model.config.id2label[predicted_frame_id]

print(f"Frame for '{target_word}': {predicted_frame}")
```

### Using the inference script

```python
from frame_finder.inference_qa import FrameFinderQA

# Initialize
finder = FrameFinderQA(model_path="nixie1981/sem_frames")

# Analyze text
text = "The cat sat on the mat"
result = finder.predict_text(text)

for token, frame in zip(result['tokens'], result['frames']):
    print(f"{token}: {frame}")
```

## Training Data

The model was trained on FrameNet 1.7, which includes:
- Semantic frame annotations for English text
- 797 distinct semantic frames
- Thousands of annotated sentences

## Input Format

The model expects two inputs:
1. **Sentence**: The complete sentence containing the target word
2. **Target word**: The specific word to classify

Format: `[CLS] sentence [SEP] target_word [SEP]`

## Output

The model outputs one of 797 semantic frame labels, or '_' for words without frames.

## Performance



## Limitations

- Trained only on English text
- Limited to FrameNet 1.7 frame inventory
- Performance may vary on domain-specific text

## Citation

If you use this model, please cite:

```bibtex
@misc{frame-finder-qa,
  title={QA-based Semantic Frame Finder},
  author={Your Name},
  year={2024},
  publisher={HuggingFace}
}
```

## License

Apache 2.0