tmmdev commited on
Commit
667bcfc
·
verified ·
1 Parent(s): 8e1d7a3

Update pattern_analyzer.py

Browse files
Files changed (1) hide show
  1. pattern_analyzer.py +12 -7
pattern_analyzer.py CHANGED
@@ -1,5 +1,5 @@
1
  import os
2
- os.environ['HF_HOME'] = '/tmp/huggingface'
3
  from transformers import AutoModelForCausalLM, AutoTokenizer
4
  import numpy as np
5
  import pandas as pd
@@ -9,12 +9,14 @@ from pattern_logic import PatternLogic
9
  class PatternAnalyzer:
10
  def __init__(self):
11
  self.model = AutoModelForCausalLM.from_pretrained(
12
- "http://localhost:5000/codellama-chart-model",
13
- load_in_8bit=True,
14
- device_map="auto",
15
- torch_dtype="auto"
16
  )
17
- self.tokenizer = AutoTokenizer.from_pretrained("http://localhost:5000/codellama-chart-model")
 
 
18
  self.basic_patterns = {
19
  'channel': {'min_points': 4, 'confidence_threshold': 0.7},
20
  'triangle': {'min_points': 3, 'confidence_threshold': 0.75},
@@ -26,7 +28,7 @@ class PatternAnalyzer:
26
  self.pattern_logic = PatternLogic()
27
 
28
  def analyze_data(self, ohlcv_data):
29
- data_prompt = f"""TASK: Identify high-confidence technical patterns only.
30
  Minimum confidence threshold: 0.8
31
  Required pattern criteria:
32
  1. Channel: Must have at least 3 touching points
@@ -56,6 +58,7 @@ class PatternAnalyzer:
56
 
57
  for pattern in analysis_data.get('patterns', []):
58
  pattern_type = pattern.get('type')
 
59
  if pattern_type in self.basic_patterns:
60
  threshold = self.basic_patterns[pattern_type]['confidence_threshold']
61
  if pattern.get('confidence', 0) >= threshold:
@@ -68,6 +71,8 @@ class PatternAnalyzer:
68
  'timestamp': pd.Timestamp.now().isoformat()
69
  }
70
  })
 
71
  return patterns
 
72
  except json.JSONDecodeError:
73
  return []
 
1
  import os
2
+ os.environ['TRANSFORMERS_CACHE'] = '/tmp/transformers_cache'
3
  from transformers import AutoModelForCausalLM, AutoTokenizer
4
  import numpy as np
5
  import pandas as pd
 
9
  class PatternAnalyzer:
10
  def __init__(self):
11
  self.model = AutoModelForCausalLM.from_pretrained(
12
+ "tmmdev/codellama-pattern-analysis",
13
+ load_in_8bit=True, # Enable 8-bit quantization
14
+ device_map="auto", # Optimize device usage
15
+ torch_dtype="auto" # Automatic precision selection
16
  )
17
+ self.tokenizer = AutoTokenizer.from_pretrained("tmmdev/codellama-pattern-analysis")
18
+
19
+
20
  self.basic_patterns = {
21
  'channel': {'min_points': 4, 'confidence_threshold': 0.7},
22
  'triangle': {'min_points': 3, 'confidence_threshold': 0.75},
 
28
  self.pattern_logic = PatternLogic()
29
 
30
  def analyze_data(self, ohlcv_data):
31
+ data_prompt = f"""TASK: Identify high-confidence technical patterns only.
32
  Minimum confidence threshold: 0.8
33
  Required pattern criteria:
34
  1. Channel: Must have at least 3 touching points
 
58
 
59
  for pattern in analysis_data.get('patterns', []):
60
  pattern_type = pattern.get('type')
61
+
62
  if pattern_type in self.basic_patterns:
63
  threshold = self.basic_patterns[pattern_type]['confidence_threshold']
64
  if pattern.get('confidence', 0) >= threshold:
 
71
  'timestamp': pd.Timestamp.now().isoformat()
72
  }
73
  })
74
+
75
  return patterns
76
+
77
  except json.JSONDecodeError:
78
  return []