pszemraj commited on
Commit
f899167
1 Parent(s): 307cdfe

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +7 -3
README.md CHANGED
@@ -33,6 +33,7 @@ from huggingface_hub import hf_hub_download
33
 
34
  model_repo_name = "pszemraj/deberta-v3-small-sp500-edgar-10k"
35
  pipe = pipeline("text-classification", model=model_repo_name)
 
36
 
37
  # Download the regression_config.json file
38
  regression_config_path = hf_hub_download(
@@ -41,23 +42,26 @@ regression_config_path = hf_hub_download(
41
  with open(regression_config_path, "r") as f:
42
  regression_config = json.load(f)
43
 
 
44
  def inverse_scale(prediction, config):
45
  """apply inverse scaling to a prediction"""
46
  min_value, max_value = config["min_value"], config["max_value"]
47
  return prediction * (max_value - min_value) + min_value
48
 
 
49
  def predict_with_pipeline(text, pipe, config, ndigits=4):
50
- result = pipe(text)[0] # Get the first (and likely only) result
51
- score = result['score'] if result['label'] == 'LABEL_1' else 1 - result['score']
52
  # Apply inverse scaling
53
  scaled_score = inverse_scale(score, config)
54
  return round(scaled_score, ndigits)
55
 
 
56
  text = "This is an example text for regression prediction."
57
 
58
  # Get predictions
59
  predictions = predict_with_pipeline(text, pipe, regression_config)
60
- print("Predicted Value:", predictions)
61
  ```
62
 
63
  </details>
 
33
 
34
  model_repo_name = "pszemraj/deberta-v3-small-sp500-edgar-10k"
35
  pipe = pipeline("text-classification", model=model_repo_name)
36
+ pipe.tokenizer.model_max_length = 1024
37
 
38
  # Download the regression_config.json file
39
  regression_config_path = hf_hub_download(
 
42
  with open(regression_config_path, "r") as f:
43
  regression_config = json.load(f)
44
 
45
+
46
  def inverse_scale(prediction, config):
47
  """apply inverse scaling to a prediction"""
48
  min_value, max_value = config["min_value"], config["max_value"]
49
  return prediction * (max_value - min_value) + min_value
50
 
51
+
52
  def predict_with_pipeline(text, pipe, config, ndigits=4):
53
+ result = pipe(text, truncation=True)[0] # Get the first (and likely only) result
54
+ score = result["score"] if result["label"] == "LABEL_1" else 1 - result["score"]
55
  # Apply inverse scaling
56
  scaled_score = inverse_scale(score, config)
57
  return round(scaled_score, ndigits)
58
 
59
+
60
  text = "This is an example text for regression prediction."
61
 
62
  # Get predictions
63
  predictions = predict_with_pipeline(text, pipe, regression_config)
64
+ print("Predicted returns (frec):", predictions)
65
  ```
66
 
67
  </details>