🚀 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}
}