🚀 kasrahabib/KM45L6V2OC
该模型是 sentence-transformers/all-MiniLM-L6-v2 的微调版本,用于在软件需求数据集(SWARD)上将软件需求分类为功能性(F)和非功能性(NF)类型。它在评估集上取得了以下结果:
- 训练损失:0.0107
- 验证损失:0.0404
- 轮数:14
- 最终宏 F1 分数:0.99
标签:
0 或 F -> 功能性;
1 或 NF -> 非功能性;
🚀 快速开始
✨ 主要特性
此模型基于预训练模型微调,能高效准确地将软件需求分类为功能性和非功能性类型,在评估集上有优异的表现。
📦 安装指南
若要在本地使用该模型,可按以下步骤操作:
- 克隆仓库:
git lfs install
git clone url_of_repo
- 找到下载目录的路径。
- 将路径链接写入
model_ckpt
变量。
💻 使用示例
基础用法
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}]
高级用法
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']
🔧 技术细节
训练超参数
训练期间使用了以下超参数:
- 优化器:{'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': 9030, '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}
- 训练精度:float32
框架版本
- Transformers 4.26.1
- TensorFlow 2.11.0
- Datasets 2.10.1
- Tokenizers 0.13.2
📄 许可证
本项目采用 Apache-2.0 许可证。