Rezaul Karim
commited on
Commit
•
725078e
1
Parent(s):
2ec2d86
Update README.md
Browse files
README.md
CHANGED
@@ -54,6 +54,7 @@ Use the code below to get started with the model.
|
|
54 |
|
55 |
### Training Data
|
56 |
|
|
|
57 |
from transformers import GPT2Tokenizer
|
58 |
|
59 |
dataset = load_dataset("FinGPT/fingpt-sentiment-train")
|
@@ -99,9 +100,11 @@ tokenized_datasets['train'] = train_test_split['train']
|
|
99 |
|
100 |
small_train_dataset = tokenized_datasets["train"].shuffle(seed=42).select(range(100))
|
101 |
small_eval_dataset = tokenized_datasets["test"].shuffle(seed=42).select(range(100))
|
|
|
102 |
|
103 |
### Fine-tune Procedure
|
104 |
|
|
|
105 |
from transformers import GPT2ForSequenceClassification
|
106 |
from transformers import TrainingArguments, Trainer
|
107 |
|
@@ -126,6 +129,7 @@ trainer = Trainer(
|
|
126 |
trainer.train()
|
127 |
trainer.evaluate()
|
128 |
trainer.save_model("fine_tuned_finsetiment_model")
|
|
|
129 |
|
130 |
#### Training Hyperparameters
|
131 |
|
@@ -139,6 +143,7 @@ trainer.save_model("fine_tuned_finsetiment_model")
|
|
139 |
|
140 |
## Evaluation
|
141 |
|
|
|
142 |
import evaluate
|
143 |
|
144 |
metric = evaluate.load("accuracy")
|
@@ -148,6 +153,7 @@ def compute_metrics(eval_pred):
|
|
148 |
predictions = np.argmax(logits, axis=-1)
|
149 |
|
150 |
return metric.compute(predictions=predictions, references=labels)
|
|
|
151 |
|
152 |
### Results
|
153 |
|
|
|
54 |
|
55 |
### Training Data
|
56 |
|
57 |
+
```
|
58 |
from transformers import GPT2Tokenizer
|
59 |
|
60 |
dataset = load_dataset("FinGPT/fingpt-sentiment-train")
|
|
|
100 |
|
101 |
small_train_dataset = tokenized_datasets["train"].shuffle(seed=42).select(range(100))
|
102 |
small_eval_dataset = tokenized_datasets["test"].shuffle(seed=42).select(range(100))
|
103 |
+
```
|
104 |
|
105 |
### Fine-tune Procedure
|
106 |
|
107 |
+
```
|
108 |
from transformers import GPT2ForSequenceClassification
|
109 |
from transformers import TrainingArguments, Trainer
|
110 |
|
|
|
129 |
trainer.train()
|
130 |
trainer.evaluate()
|
131 |
trainer.save_model("fine_tuned_finsetiment_model")
|
132 |
+
```
|
133 |
|
134 |
#### Training Hyperparameters
|
135 |
|
|
|
143 |
|
144 |
## Evaluation
|
145 |
|
146 |
+
```
|
147 |
import evaluate
|
148 |
|
149 |
metric = evaluate.load("accuracy")
|
|
|
153 |
predictions = np.argmax(logits, axis=-1)
|
154 |
|
155 |
return metric.compute(predictions=predictions, references=labels)
|
156 |
+
```
|
157 |
|
158 |
### Results
|
159 |
|