Update README.md
Browse files
README.md
CHANGED
@@ -29,3 +29,44 @@ configs:
|
|
29 |
[zeroshot/twitter-financial-news-sentiment](https://huggingface.co/datasets/zeroshot/twitter-financial-news-sentiment) prepared for LLM fine-tuning
|
30 |
by adding an `instruction` column and mapping the label from numeric to string (`{0:"negative", 1:'positive', 2:'neutral'}`).
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
[zeroshot/twitter-financial-news-sentiment](https://huggingface.co/datasets/zeroshot/twitter-financial-news-sentiment) prepared for LLM fine-tuning
|
30 |
by adding an `instruction` column and mapping the label from numeric to string (`{0:"negative", 1:'positive', 2:'neutral'}`).
|
31 |
|
32 |
+
[Source](https://github.com/AI4Finance-Foundation/FinGPT/blob/master/fingpt/FinGPT-v3/data/making_data.ipynb)
|
33 |
+
```python
|
34 |
+
from datasets import load_dataset
|
35 |
+
import datasets
|
36 |
+
|
37 |
+
from huggingface_hub import notebook_login
|
38 |
+
notebook_login()
|
39 |
+
|
40 |
+
ds = load_dataset('zeroshot/twitter-financial-news-sentiment')
|
41 |
+
|
42 |
+
num_to_label = {
|
43 |
+
0: 'negative',
|
44 |
+
1: 'positive',
|
45 |
+
2: 'neutral',
|
46 |
+
}
|
47 |
+
|
48 |
+
instruction = 'What is the sentiment of this tweet? Please choose an answer from {negative/neutral/positive}.'
|
49 |
+
|
50 |
+
# Training split
|
51 |
+
|
52 |
+
ds_train = ds['train']
|
53 |
+
ds_train = ds_train.to_pandas()
|
54 |
+
ds_train['label'] = ds_train['label'].apply(num_to_label.get)
|
55 |
+
ds_train['instruction'] = instruction
|
56 |
+
ds_train.columns = ['input', 'output', 'instruction']
|
57 |
+
ds_train = datasets.Dataset.from_pandas(ds_train)
|
58 |
+
|
59 |
+
ds_train.push_to_hub("twitter-financial-news-sentiment")
|
60 |
+
|
61 |
+
# Validation split
|
62 |
+
|
63 |
+
ds_valid = ds['validation']
|
64 |
+
ds_valid = ds_valid.to_pandas()
|
65 |
+
ds_valid['label'] = ds_valid['label'].apply(num_to_label.get)
|
66 |
+
ds_valid['instruction'] = instruction
|
67 |
+
ds_valid.columns = ['input', 'output', 'instruction']
|
68 |
+
ds_valid = datasets.Dataset.from_pandas(ds_valid, split='validation')
|
69 |
+
|
70 |
+
ds_valid.push_to_hub("twitter-financial-news-sentiment", split='validation')
|
71 |
+
```
|
72 |
+
|