user
commited on
Commit
·
c1260e9
1
Parent(s):
9f61df5
Improve README
Browse files- README.md +177 -19
- Sentiment.svg +578 -0
README.md
CHANGED
|
@@ -1,34 +1,192 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
tags:
|
| 5 |
-
-
|
| 6 |
-
|
| 7 |
-
- name: multilingual-e5-small-aligned-sentiment-20241214-new
|
| 8 |
-
results: []
|
| 9 |
---
|
| 10 |
|
| 11 |
-
|
| 12 |
-
should probably proofread and complete it, then remove this comment. -->
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
| 17 |
-
It achieves the following results on the evaluation set:
|
| 18 |
-
- Loss: 0.1455
|
| 19 |
-
- Mse: 0.1455
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
|
|
|
|
|
|
| 28 |
|
| 29 |
-
##
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
## Training procedure
|
| 34 |
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- multilingual
|
| 5 |
+
- af
|
| 6 |
+
- am
|
| 7 |
+
- ar
|
| 8 |
+
- as
|
| 9 |
+
- az
|
| 10 |
+
- be
|
| 11 |
+
- bg
|
| 12 |
+
- bn
|
| 13 |
+
- br
|
| 14 |
+
- bs
|
| 15 |
+
- ca
|
| 16 |
+
- cs
|
| 17 |
+
- cy
|
| 18 |
+
- da
|
| 19 |
+
- de
|
| 20 |
+
- el
|
| 21 |
+
- en
|
| 22 |
+
- eo
|
| 23 |
+
- es
|
| 24 |
+
- et
|
| 25 |
+
- eu
|
| 26 |
+
- fa
|
| 27 |
+
- fi
|
| 28 |
+
- fr
|
| 29 |
+
- fy
|
| 30 |
+
- ga
|
| 31 |
+
- gd
|
| 32 |
+
- gl
|
| 33 |
+
- gu
|
| 34 |
+
- ha
|
| 35 |
+
- he
|
| 36 |
+
- hi
|
| 37 |
+
- hr
|
| 38 |
+
- hu
|
| 39 |
+
- hy
|
| 40 |
+
- id
|
| 41 |
+
- is
|
| 42 |
+
- it
|
| 43 |
+
- ja
|
| 44 |
+
- jv
|
| 45 |
+
- ka
|
| 46 |
+
- kk
|
| 47 |
+
- km
|
| 48 |
+
- kn
|
| 49 |
+
- ko
|
| 50 |
+
- ku
|
| 51 |
+
- ky
|
| 52 |
+
- la
|
| 53 |
+
- lo
|
| 54 |
+
- lt
|
| 55 |
+
- lv
|
| 56 |
+
- mg
|
| 57 |
+
- mk
|
| 58 |
+
- ml
|
| 59 |
+
- mn
|
| 60 |
+
- mr
|
| 61 |
+
- ms
|
| 62 |
+
- my
|
| 63 |
+
- ne
|
| 64 |
+
- nl
|
| 65 |
+
- 'no'
|
| 66 |
+
- om
|
| 67 |
+
- or
|
| 68 |
+
- pa
|
| 69 |
+
- pl
|
| 70 |
+
- ps
|
| 71 |
+
- pt
|
| 72 |
+
- ro
|
| 73 |
+
- ru
|
| 74 |
+
- sa
|
| 75 |
+
- sd
|
| 76 |
+
- si
|
| 77 |
+
- sk
|
| 78 |
+
- sl
|
| 79 |
+
- so
|
| 80 |
+
- sq
|
| 81 |
+
- sr
|
| 82 |
+
- su
|
| 83 |
+
- sv
|
| 84 |
+
- sw
|
| 85 |
+
- ta
|
| 86 |
+
- te
|
| 87 |
+
- th
|
| 88 |
+
- tl
|
| 89 |
+
- tr
|
| 90 |
+
- ug
|
| 91 |
+
- uk
|
| 92 |
+
- ur
|
| 93 |
+
- uz
|
| 94 |
+
- vi
|
| 95 |
+
- xh
|
| 96 |
+
- yi
|
| 97 |
+
- zh
|
| 98 |
+
datasets:
|
| 99 |
+
- agentlans/en-translations
|
| 100 |
+
base_model:
|
| 101 |
+
- agentlans/multilingual-e5-small-aligned
|
| 102 |
+
pipeline_tag: text-classification
|
| 103 |
tags:
|
| 104 |
+
- multilingual
|
| 105 |
+
- sentiment-assessment
|
|
|
|
|
|
|
| 106 |
---
|
| 107 |
|
| 108 |
+
# multilingual-e5-small-aligned-sentiment
|
|
|
|
| 109 |
|
| 110 |
+
This model is a fine-tuned version of [agentlans/multilingual-e5-small-aligned](https://huggingface.co/agentlans/multilingual-e5-small-aligned) designed for assessing text sentiment across multiple languages.
|
| 111 |
|
| 112 |
+
## Key Features
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
+
- Multilingual support
|
| 115 |
+
- Sentiment assessment for text
|
| 116 |
+
- Based on E5 small model architecture
|
| 117 |
|
| 118 |
+
## Intended Uses & Limitations
|
| 119 |
|
| 120 |
+
This model is intended for:
|
| 121 |
+
- Assessing the sentiment of multilingual text
|
| 122 |
+
- Filtering multilingual content
|
| 123 |
+
- Comparative analysis of corpus text sentiment across different languages
|
| 124 |
|
| 125 |
+
Limitations:
|
| 126 |
+
- Performance may vary for languages not well-represented in the training data
|
| 127 |
+
- Should not be used as the sole criterion for sentiment assessment
|
| 128 |
|
| 129 |
+
## Usage Example
|
| 130 |
|
| 131 |
+
```python
|
| 132 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 133 |
+
import torch
|
| 134 |
+
|
| 135 |
+
model_name = "agentlans/multilingual-e5-small-aligned-sentiment"
|
| 136 |
+
|
| 137 |
+
# Initialize tokenizer and model
|
| 138 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 139 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 140 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 141 |
+
model = model.to(device)
|
| 142 |
+
|
| 143 |
+
def sentiment(text):
|
| 144 |
+
"""Assess the sentiment of the input text."""
|
| 145 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True).to(device)
|
| 146 |
+
with torch.no_grad():
|
| 147 |
+
logits = model(**inputs).logits.squeeze().cpu()
|
| 148 |
+
return logits.tolist()
|
| 149 |
+
|
| 150 |
+
# Example usage
|
| 151 |
+
score = sentiment("Your text here.")
|
| 152 |
+
print(f"Sentiment score: {score}")
|
| 153 |
+
```
|
| 154 |
+
|
| 155 |
+
## Performance Results
|
| 156 |
+
|
| 157 |
+
The model was evaluated on a diverse set of multilingual text samples:
|
| 158 |
+
|
| 159 |
+
- 10 English text samples of varying sentiment were translated into Arabic, Chinese, French, Russian, and Spanish.
|
| 160 |
+
- The model demonstrated consistent sentiment assessment across different languages for the same text.
|
| 161 |
+
|
| 162 |
+
<details>
|
| 163 |
+
<summary>Click here for the 10 original texts and their translations.</summary>
|
| 164 |
+
|
| 165 |
+
| **Text** | **English** | **French** | **Spanish** | **Chinese** | **Russian** | **Arabic** |
|
| 166 |
+
|---|---|---|---|---|---|---|
|
| 167 |
+
| A | Nothing seems to go right, and I'm constantly frustrated. | Rien ne semble aller bien et je suis constamment frustré. | Nada parece ir bien y me siento constantemente frustrado. | 一切似乎都不顺利,我总是感到很沮丧。 | Кажется, все идет не так, как надо, и я постоянно расстроен. | يبدو أن لا شيء يسير على ما يرام، وأنا أشعر بالإحباط باستمرار. |
|
| 168 |
+
| B | Everything is falling apart, and I can't see any way out. | Tout s’effondre et je ne vois aucune issue. | Todo se está desmoronando y no veo ninguna salida. | 一切都崩溃了,我看不到任何出路。 | Все рушится, и я не вижу выхода. | كل شيء ينهار، ولا أستطيع أن أرى أي مخرج. |
|
| 169 |
+
| C | I feel completely overwhelmed by the challenges I face. | Je me sens complètement dépassé par les défis auxquels je suis confronté. | Me siento completamente abrumado por los desafíos que enfrento. | 我感觉自己完全被所面临的挑战压垮了。 | Я чувствую себя совершенно подавленным из-за проблем, с которыми мне приходится сталкиваться. | أشعر بأنني غارق تمامًا في ��لتحديات التي أواجهها. |
|
| 170 |
+
| D | There are some minor improvements, but overall, things are still tough. | Il y a quelques améliorations mineures, mais dans l’ensemble, les choses restent difficiles. | Hay algunas mejoras menores, pero en general las cosas siguen siendo difíciles. | 虽然有一些小的改进,但是总的来说,事情仍然很艰难。 | Есть некоторые незначительные улучшения, но в целом ситуация по-прежнему сложная. | هناك بعض التحسينات الطفيفة، ولكن بشكل عام، لا تزال الأمور صعبة. |
|
| 171 |
+
| E | I can see a glimmer of hope amidst the difficulties I encounter. | Je vois une lueur d’espoir au milieu des difficultés que je rencontre. | Puedo ver un rayo de esperanza en medio de las dificultades que encuentro. | 我在遇到的困难中看到了一线希望。 | Среди трудностей, с которыми я сталкиваюсь, я вижу проблеск надежды. | أستطيع أن أرى بصيص أمل وسط الصعوبات التي أواجهها. |
|
| 172 |
+
| F | Things are starting to look up, and I'm cautiously optimistic. | Les choses commencent à s’améliorer et je suis prudemment optimiste. | Las cosas están empezando a mejorar y me siento cautelosamente optimista. | 事情开始好转,我持谨慎乐观的态度。 | Ситуация начинает улучшаться, и я настроен осторожно и оптимистично. | بدأت الأمور تتجه نحو التحسن، وأنا متفائل بحذر. |
|
| 173 |
+
| G | I'm feeling more positive about my situation than I have in a while. | Je me sens plus positif à propos de ma situation que je ne l’ai été depuis un certain temps. | Me siento más positivo sobre mi situación que en mucho tiempo. | 我对自己处境的感觉比以前更加乐观了。 | Я чувствую себя более позитивно относительно своей ситуации, чем когда-либо за последнее время. | أشعر بإيجابية أكبر تجاه وضعي مقارنة بأي وقت مضى. |
|
| 174 |
+
| H | There are many good things happening, and I appreciate them. | Il se passe beaucoup de bonnes choses et je les apprécie. | Están sucediendo muchas cosas buenas y las aprecio. | 有很多好事发生,我对此表示感谢。 | Происходит много хорошего, и я это ценю. | هناك الكثير من الأشياء الجيدة التي تحدث، وأنا أقدرها. |
|
| 175 |
+
| I | Every day brings new joy and possibilities; I feel truly blessed. | Chaque jour apporte de nouvelles joies et possibilités ; je me sens vraiment béni. | Cada día trae nueva alegría y posibilidades; me siento verdaderamente bendecida. | 每天都有新的快乐和可能性;我感到非常幸福。 | Каждый день приносит новую радость и возможности; я чувствую себя по-настоящему благословенной. | كل يوم يجلب فرحة وإمكانيات جديدة؛ أشعر بأنني محظوظة حقًا. |
|
| 176 |
+
| J | Life is full of opportunities, and I'm excited about the future. | La vie est pleine d’opportunités et je suis enthousiaste quant à l’avenir. | La vida está llena de oportunidades y estoy entusiasmado por el futuro. | 生活充满机遇,我对未来充满兴奋。 | Жизнь полна возможностей, и я с нетерпением жду будущего. | الحياة مليئة بالفرص، وأنا متحمس للمستقبل. |
|
| 177 |
+
|
| 178 |
+
</details>
|
| 179 |
+
|
| 180 |
+
<img src="Sentiment.svg" alt="Scatterplot of predicted sentiment scores grouped by text sample and language" width="100%"/>
|
| 181 |
+
|
| 182 |
+
## Training Data
|
| 183 |
+
|
| 184 |
+
The model was trained on the [Multilingual Parallel Sentences dataset](https://huggingface.co/datasets/agentlans/en-translations), which includes:
|
| 185 |
+
|
| 186 |
+
- Parallel sentences in English and various other languages
|
| 187 |
+
- Semantic similarity scores calculated using LaBSE
|
| 188 |
+
- Additional sentiment metrics
|
| 189 |
+
- Sources: JW300, Europarl, TED Talks, OPUS-100, Tatoeba, Global Voices, and News Commentary
|
| 190 |
|
| 191 |
## Training procedure
|
| 192 |
|
Sentiment.svg
ADDED
|
|