---
title: Customer_emotion_recognizer
canonical_url: "https://www.modelscope.cn/models/Meteoritehu/Customer_emotion_recognizer"
md_url: "https://www.modelscope.cn/models/Meteoritehu/Customer_emotion_recognizer.md"
repository: Meteoritehu/Customer_emotion_recognizer
chinese_name: "用户情感识别器"
last_updated: 2024-01-29
pipeline_tag: text-generation
tasks:
  - text-generation
library_name:
  - pytorch
frameworks:
  - pytorch
downloads: 84
stars: 4
---

# Customer_emotion_recognizer

> Customer_emotion_recognizer - Meteoritehu 在 ModelScope 开源的模型。给定一段文本，模型可以精确做到识别客户的情感

- **Repository**: Meteoritehu/Customer_emotion_recognizer
- **Tasks**: text-generation
- **Downloads**: 84
- **Stars**: 4
- **Last updated**: 2024-01-29

Source: https://www.modelscope.cn/models/Meteoritehu/Customer_emotion_recognizer

---

##模型介绍
- 名称：用户情感识别器
- 简介：随着互联网的不断发展，公司急需获取用户对其产品的反馈。然而，人类语言常常涉及讽刺、反语等复杂现象，这使得准确把握用户情感变得困难。该模型的设计目标是在尽可能有效地解读客户反馈的基础上，准确识别客户的情感。随着对用户见解的需求不断增加，该模型旨在通过处理语言的复杂性，提供对客户情感的细致理解，以弥补这一差距。

##实验环境：
- 8核 32GB 显存24G
- ubuntu22.04-cuda12.1.0-py310-torch2.1.2-tf2.14.0-1.11.0

## 训练方法：
- 数据集：jd-sentiment-zh
- 微调的模型：qwen-1_8b
- 超参数：sft_type='lora',  train_dataset_sample=2000

## 示例代码
```
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'

import torch

//train
from swift.llm import (
	DatasetName, InferArguments, ModelType, SftArguments,
	infer_main, sft_main, app_ui_main, merge_lora_main
	)
	
model_type = ModelType.qwen_1_8b

sft_args = SftArguments(
	model_type=model_type,
	sft_type='lora',
	train_dataset_sample=2000,
	dataset=[DatasetName.jd_sentiment_zh],output_dir='output')

result = sft_main(sft_args)

best_model_checkpoint = result['best_model_checkpoint']
print(f'best_model_checkpoint: {best_model_checkpoint}')



//infer
torch.cuda.empty_cache()
infer_args = InferArguments(
	ckpt_dir=best_model_checkpoint,
	load_dataset_config=True,
	do_sample=False)
	
result = infer_main(infer_args)
```

## 推理效果
```
{"response": "positive", "query": "Task: Sentiment Classification\nSentence: 擦玻璃很好、就是太小了\nCategory: negative, positive\nOutput: ", "label": "positive"}
{"response": "negative", "query": "Task: Sentiment Classification\nSentence: 店家太不负责任了，衣服质量太差劲了，和图片上的不一样\nCategory: negative, positive\nOutput: ", "label": "negative"}
{"response": "positive", "query": "Task: Sentiment Classification\nSentence: 送国际友人挺好的，不错不错！\nCategory: negative, positive\nOutput: ", "label": "positive"}
{"response": "positive", "query": "Task: Sentiment Classification\nSentence: 很好,装好一定很漂亮\nCategory: negative, positive\nOutput: ", "label": "positive"}
{"response": "negative", "query": "Task: Sentiment Classification\nSentence: 东西给你退回去了，你要黑我钱！！！\nCategory: negative, positive\nOutput: ", "label": "negative"}
{"response": "positive", "query": "Task: Sentiment Classification\nSentence: 送货很快，书是正品，买书一直京东是首选！\nCategory: negative, positive\nOutput: ", "label": "positive"}
{"response": "positive", "query": "Task: Sentiment Classification\nSentence: 口感相当的好 都想买第二次了\nCategory: negative, positive\nOutput: ", "label": "positive"}
{"response": "negative", "query": "Task: Sentiment Classification\nSentence: 硅胶味道太重，样子与图片差距太大\nCategory: negative, positive\nOutput: ", "label": "negative"}
{"response": "negative", "query": "Task: Sentiment Classification\nSentence: 很伤心，买了放到三星n4尽然不能用，客服各种推\nCategory: negative, positive\nOutput: ", "label": "negative"}
{"response": "positive", "query": "Task: Sentiment Classification\nSentence: 质量不错，大小合适，应当是正品！但是我买的是黑灰，发来的却是纯黑，懒得换了，给个差评，希望以后改进！\nCategory: negative, positive\nOutput: ", "label": "negative"}
```
