Update README.md
Browse files
README.md
CHANGED
@@ -21,6 +21,61 @@ should probably proofread and complete it, then remove this comment. -->
|
|
21 |
this predicts the `ret` column of the training dataset, given the `text` column. Fine-tuned @ ctx 1024.
|
22 |
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
## Model description
|
25 |
|
26 |
This model is a fine-tuned version of [microsoft/deberta-v3-small](https://huggingface.co/microsoft/deberta-v3-small) on BEE-spoke-data/sp500-edgar-10k-markdown
|
@@ -30,8 +85,6 @@ It achieves the following results on the evaluation set:
|
|
30 |
- Mse: 0.0005
|
31 |
|
32 |
|
33 |
-
|
34 |
-
|
35 |
## Training procedure
|
36 |
|
37 |
### Training hyperparameters
|
|
|
21 |
this predicts the `ret` column of the training dataset, given the `text` column. Fine-tuned @ ctx 1024.
|
22 |
|
23 |
|
24 |
+
<details>
|
25 |
+
<summary>Click to expand code example</summary>
|
26 |
+
|
27 |
+
```py
|
28 |
+
import json
|
29 |
+
|
30 |
+
import numpy as np
|
31 |
+
import torch
|
32 |
+
from huggingface_hub import hf_hub_download
|
33 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
34 |
+
|
35 |
+
# Define the model repository on Hugging Face Hub
|
36 |
+
model_repo_name = "pszemraj/deberta-v3-small-sp500-edgar-10k"
|
37 |
+
|
38 |
+
# Download the regression_config.json file
|
39 |
+
regression_config_path = hf_hub_download(
|
40 |
+
repo_id=model_repo_name, filename="regression_config.json"
|
41 |
+
)
|
42 |
+
|
43 |
+
# Load regression configuration
|
44 |
+
with open(regression_config_path, "r") as f:
|
45 |
+
regression_config = json.load(f)
|
46 |
+
|
47 |
+
# Load the tokenizer and model
|
48 |
+
tokenizer = AutoTokenizer.from_pretrained(model_repo_name)
|
49 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_repo_name)
|
50 |
+
|
51 |
+
|
52 |
+
# Function to apply inverse scaling to a prediction
|
53 |
+
def inverse_scale(prediction, config):
|
54 |
+
min_value, max_value = config["min_value"], config["max_value"]
|
55 |
+
return prediction * (max_value - min_value) + min_value
|
56 |
+
|
57 |
+
|
58 |
+
# Example of using the model for inference
|
59 |
+
def predict(text, tokenizer, model, config, ndigits=4):
|
60 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
61 |
+
with torch.no_grad():
|
62 |
+
outputs = model(**inputs)
|
63 |
+
logits = outputs.logits
|
64 |
+
predictions = logits.numpy()
|
65 |
+
# Assuming regression task, apply inverse scaling
|
66 |
+
scaled_predictions = [inverse_scale(pred[0], config) for pred in predictions]
|
67 |
+
return round(scaled_predictions[0], ndigits)
|
68 |
+
|
69 |
+
|
70 |
+
# Example text
|
71 |
+
text = "This is an example text for regression prediction."
|
72 |
+
|
73 |
+
# Get predictions
|
74 |
+
predictions = predict(text, tokenizer, model, regression_config)
|
75 |
+
print("Predicted Value:", predictions)
|
76 |
+
```
|
77 |
+
<details>
|
78 |
+
|
79 |
## Model description
|
80 |
|
81 |
This model is a fine-tuned version of [microsoft/deberta-v3-small](https://huggingface.co/microsoft/deberta-v3-small) on BEE-spoke-data/sp500-edgar-10k-markdown
|
|
|
85 |
- Mse: 0.0005
|
86 |
|
87 |
|
|
|
|
|
88 |
## Training procedure
|
89 |
|
90 |
### Training hyperparameters
|