File size: 5,540 Bytes
9298c95
 
 
 
 
d10eb4f
9298c95
6140784
 
 
 
 
 
 
9298c95
 
 
 
 
d10eb4f
c9ef523
cffe9e9
743678c
 
 
98c694d
9298c95
9c7c0e7
891b1e4
9c7c0e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
891b1e4
 
 
 
 
 
 
 
d10eb4f
891b1e4
 
 
9c7c0e7
 
 
 
 
891b1e4
 
9c7c0e7
 
 
891b1e4
 
 
 
 
 
 
 
d10eb4f
891b1e4
 
 
9c7c0e7
 
 
 
891b1e4
 
 
 
 
 
 
 
 
 
9c7c0e7
891b1e4
 
 
 
 
 
 
 
 
 
93515fd
 
891b1e4
 
 
 
 
 
d10eb4f
891b1e4
 
 
9c7c0e7
 
 
 
891b1e4
 
 
 
 
 
 
 
 
9298c95
 
 
 
 
 
 
 
 
 
 
 
 
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---
license: apache-2.0
tags:
- generated_from_keras_callback
model-index:
- name: kasrahabib/KM35NCDF
  results: []
widget:
- text: "Application needs to keep track of subtasks in a task."
  example_title: "Requirment 1"
- text: "The system shall allow users to enter time in several different formats."
  example_title: "Requirment 2"
- text: "The system shall allow users who hold any of the ORES/ORELSE/PROVIDER keys to be viewed as a clinical user and has full access privileges to all problem list options."
  example_title: "Requirment 3"
---

<!-- This model card has been generated automatically according to the information Keras had access to. You should
probably proofread and complete it, then remove this comment. -->

# kasrahabib/KM35NCDF

This model is a fine-tuned version of [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) on Software Requirements Dataset (SWARD) for classifying 19 Non-functional requirements. Note that based on literature, two out of 19 classes are Data and Behavior, belong to types of Functional software requirements. It achieves the following results on the evaluation set:
- Train Loss: 0.1691
- Validation Loss: 0.7548
- Epoch: 14
- Final Macro F1-score: 0.79


<b>Labels</b>: 
0 or A -> Availability;
1 or AC -> Access Control;
2 or AU -> Audit;
3 or B -> Behaviour;
4 or D -> Data;
5 or FT -> Fault Tolerance;
6 or I -> Interface/Interoperability;
7 or LE -> Legal;
8 or LF -> Look and Feel;
9 or MN -> Maintainability;
10 or O -> Operational;
11 or PE -> Performance;
12 or PO -> Portability;
13 or RL -> Reliability;
14 or SA -> Safety;
15 or SC -> Scalability;
16 or SE -> Security;
17 or ST -> Stability;
18 or US -> Usability;


## Usage Pipeline
```python
from transformers import pipeline

frame_work = 'tf'
task = 'text-classification'
model_ckpt = 'kasrahabib/KM35NCDF '

software_requirment_cls = pipeline(task = task, model = model_ckpt, framework = frame_work)

example_1_US = 'Application needs to keep track of subtasks in a task.'
example_2_PE = 'The system shall allow users to enter time in several different formats.'
example_3_AC = 'The system shall allow users who hold any of the ORES/ORELSE/PROVIDER keys to be viewed as a clinical user and has full access privileges to all problem list options.'

software_requirment_cls([example_1_US, example_2_PE, example_3_AC])
```
```
[{'label': 'US', 'score': 0.9712953567504883},
 {'label': 'PE', 'score': 0.9457865953445435},
 {'label': 'AC', 'score': 0.9639136791229248}]
```

## Model Inference:
```python

import numpy as np
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification

model_ckpt = 'kasrahabib/KM35NCDF '
tokenizer = AutoTokenizer.from_pretrained(model_ckpt)
model = TFAutoModelForSequenceClassification.from_pretrained(model_ckpt)

example_1_US = 'Application needs to keep track of subtasks in a task.'
example_2_PE = 'The system shall allow users to enter time in several different formats.'
example_3_AC = 'The system shall allow users who hold any of the ORES/ORELSE/PROVIDER keys to be viewed as a clinical user and has full access privileges to all problem list options.'
requirements = [example_1_US, example_2_PE, example_3_AC]

encoded_requirements = tokenizer(requirements, return_tensors = 'np', padding = 'longest')

y_pred = model(encoded_requirements).logits
classifications = np.argmax(y_pred, axis = 1)

classifications = [model.config.id2label[output] for output in classifications]
print(classifications)
```
```
['US', 'PE', 'AC']
```

## Usage Locally Downloaded (e.g., GitHub):


  1  - Clone the repository:
```shell
git lfs install
git clone url_of_repo
```
  2  - Locate the path to the downloaded directory <br>
  3  - Write the link to the path in the ```model_ckpt``` variable <br>
    
Then modify the code as below:
```python
import numpy as np
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification

model_ckpt =  'rest_of_the_path/KM35NCDF '
tokenizer = AutoTokenizer.from_pretrained(model_ckpt)
model = TFAutoModelForSequenceClassification.from_pretrained(model_ckpt)

example_1_US = 'Application needs to keep track of subtasks in a task.'
example_2_PE = 'The system shall allow users to enter time in several different formats.'
example_3_AC = 'The system shall allow users who hold any of the ORES/ORELSE/PROVIDER keys to be viewed as a clinical user and has full access privileges to all problem list options.'
requirements = [example_1_US, example_2_PE, example_3_AC]

encoded_requirements = tokenizer(requirements, return_tensors = 'np', padding = 'longest')

y_pred = model(encoded_requirements).logits
classifications = np.argmax(y_pred, axis = 1)

classifications = [model.config.id2label[output] for output in classifications]
print(classifications)
```

### Training hyperparameters

The following hyperparameters were used during training:
- optimizer: {'name': 'Adam', 'weight_decay': None, 'clipnorm': None, 'global_clipnorm': None, 'clipvalue': None, 'use_ema': False, 'ema_momentum': 0.99, 'ema_overwrite_frequency': None, 'jit_compile': True, 'is_legacy_optimizer': False, 'learning_rate': {'class_name': 'PolynomialDecay', 'config': {'initial_learning_rate': 2e-05, 'decay_steps': 6735, 'end_learning_rate': 0.0, 'power': 1.0, 'cycle': False, 'name': None}}, 'beta_1': 0.9, 'beta_2': 0.999, 'epsilon': 1e-08, 'amsgrad': False}
- training_precision: float32

### Framework versions

- Transformers 4.26.1
- TensorFlow 2.11.0
- Datasets 2.10.0
- Tokenizers 0.13.2