输⼊⼀段⽂本, 模型可以给出对应的情感分类。分类为二分类,将情感分为积极(positive)和消极(egative)。 魔搭社区GPU环境 基于深度学习(LSTM)的情感分析(京东商城数据)jd_setimet_zh [PROMPT]Task: Setimet Classificatio \
Setece: 店家太不负责任了,衣服质量太差劲了,和图片上的不一样 \
Category: egative, positive \
Output: [OUTPUT]egative<|edoftext|> [PROMPT]Task: Setimet Classificatio \
Setece: 送国际友人挺好的,不错不错! \
Category: egative, positive \
Output: [OUTPUT]positive<|edoftext|> [PROMPT]Task: Setimet Classificatio \
Setece: 很好,装好一定很漂亮 \
Category: egative, positive \
Output: [OUTPUT]positive<|edoftext|> [PROMPT]Task: Setimet Classificatio \
Setece: 东西给你退回去了,你要黑我钱!!! \
Category: egative, positive \
Output: [OUTPUT] [PROMPT]Task: Setimet Classificatio \
Setece: 送货很快,书是正品,买书一直京东是首选! \
Category: egative, positive \
Output: [OUTPUT]positive<|edoftext|> [PROMPT]Task: Setimet Classificatio \
Setece: 口感相当的好 都想买第二次了 \
Category: egative, positive \
Output: [OUTPUT]positive<|edoftext|> [PROMPT]Task: Setimet Classificatio \
Setece: 硅胶味道太重,样子与图片差距太大 \
Category: egative, positive \
Output: [OUTPUT]egative<|edoftext|> [PROMPT]Task: Setimet Classificatio \
Setece: 很伤心,买了放到三星4尽然不能用,客服各种推 \
Category: egative, positive \
Output: [OUTPUT]egative<|edoftext|> [PROMPT]Task: Setimet Classificatio \
Setece: 质量不错,大小合适,应当是正品!但是我买的是黑灰,发来的却是纯黑,懒得换了,给个差评,希望以后改进! \
Category: egative, positive \
Output: [OUTPUT]positive<|edoftext|>
[INFO:swift] saveresultpath: /mt/workspace/output/qwe-18b/v0-20240126-230928/checkpoit-100/iferresult_20240126-231510.jsol情感分类模型(Emotio Classificatio Model)
简介
实验环境
训练方法
数据集
示例代码
# 设置pip全局镜像
pip cofig set global.idex-url https://mirrors.aliyu.com/pypi/simple/
# 安装ms-swift
git cloe https://github.com/modelscope/swift.git
cd swift
pip istall -e .[llm]
# It requires 5 miutes of traiig.
# Experimetal eviromet: A10
# 13GB GPU memory
import os
os.eviro['CUDA_VISIBLE_DEVICES'] = '0'
import torch
from swift.llm import (
DatasetName, IferArgumets, ModelType, SftArgumets,
ifer_mai, sft_mai, app_ui_mai, merge_lora_mai
)
model_type = ModelType.qwe_1_8b
# 超参数:
# https://github.com/modelscope/swift/blob/mai/docs/source/LLM/%E5%91%BD%E4%BB%A
# 4%E8%A1%8C%E5%8F%82%E6%95%B0.md
sft_args = SftArgumets(
model_type=model_type,
sft_type='lora',
trai_dataset_sample=2000,
dataset=[DatasetName.jd_setimet_zh],
output_dir='output')
result = sft_mai(sft_args)
# adapter的⼤⼩: 6.1MiB
best_model_checkpoit = result['best_model_checkpoit']
prit(f'best_model_checkpoit: {best_model_checkpoit}')
torch.cuda.empty_cache()
ifer_args = IferArgumets(
ckpt_dir=best_model_checkpoit,
load_dataset_cofig=True,
do_sample=False)
result = ifer_mai(ifer_args)
推理效果
positive<|edoftext|>
[LABELS]positive
[LABELS]egative
[LABELS]positive
[LABELS]positive
egative<|edoftext|>
[LABELS]egative
[LABELS]positive
[LABELS]positive
[LABELS]egative
[LABELS]egative
[LABELS]egative
点击空白处退出提示
评论