generated_from_keras_callback

<!-- 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/KM45L6V2OC

This model is a fine-tuned version of sentence-transformers/all-MiniLM-L6-v2, for classifying softwrae requirments into functional (F) and Non-functional (NF) types, on Software Requirements Dataset (SWARD). It achieves the following results on the evaluation set:

<b>Labels</b>: 0 or F -> Functional; 1 or NF -> Non-functional;

Usage Pipeline

from transformers import pipeline

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

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

example_1_f = 'The START NEW PROJECT function shall allow the user to create a new project.'
example_2_nf = 'The email string consists of x@x.x and is less than 31 characters in length and is not empty.'
software_requirment_cls([example_1_f, example_2_nf])
[{'label': 'F', 'score': 0.9998922348022461},
 {'label': 'NF', 'score': 0.999846339225769}]

Model Inference:


import numpy as np
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification

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

example_1_f = 'The START NEW PROJECT function shall allow the user to create a new project.'
example_2_nf = 'The email string consists of x@x.x and is less than 31 characters in length and is not empty.'
requirements = [example_1_f, example_2_nf]

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)
['F', 'NF']

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

1 - Clone the repository:

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:

import numpy as np
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification

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

example_1_f = 'The START NEW PROJECT function shall allow the user to create a new project.'
example_2_nf = 'The email string consists of x@x.x and is less than 31 characters in length and is not empty.'
requirements = [example_1_f, example_2_nf]

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)
[{'label': 'F', 'score': 0.9998922348022461},
 {'label': 'NF', 'score': 0.999846339225769}]

Training hyperparameters

The following hyperparameters were used during training:

Framework versions