情感分析(作业)

我要开发同款
匿名用户2024年07月31日
37阅读

技术信息

开源地址
https://modelscope.cn/models/Woodpecker/Sentiment_analysis_Homework
授权协议
Apache License 2.0

作品详情

Traiig procedure

Framework versios

  • SWIFT 1.5.3

Base model iformatio

  • BaseModel Class QWeLMHeadModel

情感分析(作业)

SetimetaalysisHomework

  • 简介:

  • 情感分析模型,以问答形式对用户输入内容的情感倾向进行二分类

  • 实验环境:

  • Ubutu22.04-cuda12.1.0-py310-torch2.1.2-tf2.14.0-1.11.0

  • 8核32G A10 24G显存

  • 训练方法:

  • 模型:qwe1_8b

  • 数据集:jdsetimetzh

  • 超参数:

  sft_type='lora',
  trai_dataset_sample=2000,
  • 示例代码:
  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
  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)
  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)
  • 推理效果:
  Setece: 擦玻璃很好、就是太小了
  Category: egative, positive
  Output:[OUTPUT]positive<|edoftext|>

  [LABELS]positive
  --------------------------------------------------
  [PROMPT]Task: Setimet Classificatio
  Setece: 店家太不负责任了,衣服质量太差劲了,和图片上的不一样
  Category: egative, positive
  Output:[OUTPUT]egative<|edoftext|>

  [LABELS]egative
  --------------------------------------------------
  [PROMPT]Task: Setimet Classificatio
  Setece: 送国际友人挺好的,不错不错!
  Category: egative, positive
  Output:[OUTPUT]positive<|edoftext|>

  [LABELS]positive
  --------------------------------------------------
  [PROMPT]Task: Setimet Classificatio
  Setece: 很好,装好一定很漂亮
  Category: egative, positive
  Output:[OUTPUT]positive<|edoftext|>

  [LABELS]positive
  --------------------------------------------------
  [PROMPT]Task: Setimet Classificatio
  Setece: 东西给你退回去了,你要黑我钱!!!
  Category: egative, positive
  Output:[OUTPUT]egative<|edoftext|>

  [LABELS]egative
  --------------------------------------------------
  [PROMPT]Task: Setimet Classificatio
  Setece: 送货很快,书是正品,买书一直京东是首选!
  Category: egative, positive
  Output:[OUTPUT]positive<|edoftext|>

  [LABELS]positive
  --------------------------------------------------
  [PROMPT]Task: Setimet Classificatio
  Setece: 口感相当的好 都想买第二次了
  Category: egative, positive
  Output:[OUTPUT]positive<|edoftext|>

  [LABELS]positive
  --------------------------------------------------
  [PROMPT]Task: Setimet Classificatio
  Setece: 硅胶味道太重,样子与图片差距太大
  Category: egative, positive
  Output:[OUTPUT]egative<|edoftext|>

  [LABELS]egative
  --------------------------------------------------
  [PROMPT]Task: Setimet Classificatio
  Setece: 很伤心,买了放到三星4尽然不能用,客服各种推
  Category: egative, positive
  Output:[OUTPUT]egative<|edoftext|>

  [LABELS]egative
  --------------------------------------------------
  [PROMPT]Task: Setimet Classificatio
  Setece: 质量不错,大小合适,应当是正品!但是我买的是黑灰,发来的却是纯黑,懒得换了,给个差评,希望以后改进!
  Category: egative, positive
  Output:[OUTPUT]positive<|edoftext|>

  [LABELS]egative

功能介绍

Training procedure Framework versions SWIFT 1.5.3 Base model information BaseModel Class QWenLMHe

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论