🚀 Emollama-7b:情感分析大语言模型
Emollama-7b是EmoLLMs项目的一部分,该项目是首个具备指令跟随能力、用于全面情感分析的开源大语言模型(LLM)系列。此模型基于Meta LLaMA2 - 7B基础模型和完整的AAID指令调优数据进行微调。该模型可用于情感分类任务(如情感极性或分类情感)和回归任务(如情感强度或情绪强度)。
🚀 快速开始
你可以在Python项目中使用Hugging Face Transformers库来使用Emollama - 7b模型。以下是一个简单的加载模型示例:
from transformers import LlamaTokenizer, LlamaForCausalLM
tokenizer = LlamaTokenizer.from_pretrained('lzw1008/Emollama-7b')
model = LlamaForCausalLM.from_pretrained('lzw1008/Emollama-7b', device_map='auto')
在这个示例中,LlamaTokenizer
用于加载分词器,LlamaForCausalLM
用于加载模型。device_map='auto'
参数用于在可用时自动使用GPU。
✨ 主要特性
EmoLLMs中的模型
EmoLLMs包含一系列模型,包括Emollama - 7b、Emollama - chat - 7b、Emollama - chat - 13b、Emoopt - 13b、Emobloom - 7b、Emot5 - large、Emobart - large。
- Emollama - 7b:基于LLaMA2 - 7B微调。
- Emollama - chat - 7b:基于LLaMA2 - chat - 7B微调。
- Emollama - chat - 13b:基于LLaMA2 - chat - 13B微调。
- Emoopt - 13b:基于OPT - 13B微调。
- Emobloom - 7b:基于Bloomz - 7b1 - mt微调。
- Emot5 - large:基于T5 - large微调。
- Emobart - large:基于bart - large微调。
所有模型均在完整的AAID指令调优数据上进行训练。
使用示例
基础用法
以下是加载Emollama - 7b模型的基础代码示例:
from transformers import LlamaTokenizer, LlamaForCausalLM
tokenizer = LlamaTokenizer.from_pretrained('lzw1008/Emollama-7b')
model = LlamaForCausalLM.from_pretrained('lzw1008/Emollama-7b', device_map='auto')
高级用法
以下是不同任务的使用示例:
情绪强度
Human:
Task: Assign a numerical value between 0 (least E) and 1 (most E) to represent the intensity of emotion E expressed in the text.
Text: @CScheiwiller can't stop smiling 😆😆😆
Emotion: joy
Intensity Score:
Assistant:
>>0.896
情感强度
Human:
Task: Evaluate the valence intensity of the writer's mental state based on the text, assigning it a real-valued score from 0 (most negative) to 1 (most positive).
Text: Happy Birthday shorty. Stay fine stay breezy stay wavy @daviistuart 😘
Intensity Score:
Assistant:
>>0.879
情感分类
Human:
Task: Categorize the text into an ordinal class that best characterizes the writer's mental state, considering various degrees of positive and negative sentiment intensity. 3: very positive mental state can be inferred. 2: moderately positive mental state can be inferred. 1: slightly positive mental state can be inferred. 0: neutral or mixed mental state can be inferred. -1: slightly negative mental state can be inferred. -2: moderately negative mental state can be inferred. -3: very negative mental state can be inferred
Text: Beyoncé resentment gets me in my feelings every time. 😩
Intensity Class:
Assistant:
>>-3: very negative emotional state can be inferred
情绪分类
Human:
Task: Categorize the text's emotional tone as either 'neutral or no emotion' or identify the presence of one or more of the given emotions (anger, anticipation, disgust, fear, joy, love, optimism, pessimism, sadness, surprise, trust).
Text: Whatever you decide to do make sure it makes you #happy.
This text contains emotions:
Assistant:
>>joy, love, optimism
任务描述可根据具体任务进行调整。
📚 详细文档
伦理考量
近期研究表明,大语言模型可能会引入一些潜在偏差,如性别差距。同时,一些错误的预测结果和过度泛化也表明当前大语言模型存在潜在风险。因此,将该模型应用于实际场景的情感分析系统仍面临诸多挑战。
📄 许可证
EmoLLMs系列采用MIT许可证。更多详情请参阅MIT文件。
📚 引用
如果您在工作中使用了EmoLLMs系列,请引用我们的论文:
@article{liu2024emollms,
title={EmoLLMs: A Series of Emotional Large Language Models and Annotation Tools for Comprehensive Affective Analysis},
author={Liu, Zhiwei and Yang, Kailai and Zhang, Tianlin and Xie, Qianqian and Yu, Zeping and Ananiadou, Sophia},
journal={arXiv preprint arXiv:2401.08508},
year={2024}
}