salihfurkaan commited on
Commit
92320f4
·
2 Parent(s): 7ce33c77b32ccf

newthings

Browse files
Files changed (2) hide show
  1. .python-version +1 -0
  2. app.py +31 -7
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.12
app.py CHANGED
@@ -38,18 +38,42 @@ class ModelProfiler:
38
  def fetch_config(self, repo_id: str, filename: str = "config.json") -> Optional[Dict]:
39
  try:
40
  url = self.api.hf_hub_url(repo_id, filename)
41
- resp = self.session.get(url, timeout=5)
42
- return resp.json() if resp.status_code == 200 else None
 
 
 
 
 
 
 
 
 
 
43
  except Exception as e:
44
- logging.error(f"Failed to fetch {filename} for {repo_id}: {e}")
45
  return None
46
 
47
  def validate_architecture(self, base_id: str, adapter_id: str) -> Tuple[str, str]:
48
  base_cfg = self.fetch_config(base_id)
49
  adapt_cfg = self.fetch_config(adapter_id, "adapter_config.json")
50
 
51
- if not base_cfg or not adapt_cfg:
52
- return self._render_status("error", "Metadata Fetch Failure", "Unable to retrieve architectural configs from Hugging Face Hub."), ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
  # Architectural Heuristics
55
  b_type = base_cfg.get("model_type", "unknown")
@@ -193,8 +217,8 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="indigo", font=[gr.themes.Goo
193
  with gr.Row():
194
  with gr.Column(scale=1):
195
  gr.Markdown("### Source Parameters")
196
- base_input = gr.Textbox(label="Base Model Repository", placeholder="e.g. meta-llama/Llama-3-8B", value="meta-llama/Meta-Llama-3-8B")
197
- adapter_input = gr.Textbox(label="Adapter Repository", placeholder="e.g. alignment-handbook/zephyr-7b-lora", value="FinGPT/fingpt-forecaster_llama3-8b_lora")
198
  audit_btn = gr.Button("Execute Audit", variant="primary")
199
  with gr.Column(scale=2):
200
  status_out = gr.HTML(profiler._render_status("success", "System Ready", "Awaiting repository identifiers for structural validation."))
 
38
  def fetch_config(self, repo_id: str, filename: str = "config.json") -> Optional[Dict]:
39
  try:
40
  url = self.api.hf_hub_url(repo_id, filename)
41
+ resp = self.session.get(url, timeout=10)
42
+ if resp.status_code == 200:
43
+ return resp.json()
44
+ else:
45
+ logging.error(f"HTTP {resp.status_code} fetching {filename} from {repo_id}")
46
+ return None
47
+ except requests.exceptions.Timeout:
48
+ logging.error(f"Timeout fetching {filename} from {repo_id}")
49
+ return None
50
+ except requests.exceptions.ConnectionError:
51
+ logging.error(f"Connection error fetching {filename} from {repo_id}")
52
+ return None
53
  except Exception as e:
54
+ logging.error(f"Failed to fetch {filename} from {repo_id}: {type(e).__name__}: {e}")
55
  return None
56
 
57
  def validate_architecture(self, base_id: str, adapter_id: str) -> Tuple[str, str]:
58
  base_cfg = self.fetch_config(base_id)
59
  adapt_cfg = self.fetch_config(adapter_id, "adapter_config.json")
60
 
61
+ # Better error messaging
62
+ if not base_cfg:
63
+ error_msg = f"Cannot fetch config.json from **{base_id}**. Verify the repository exists and is public."
64
+ return self._render_status("error", "Metadata Fetch Failure", error_msg), ""
65
+
66
+ if not adapt_cfg:
67
+ # Create a minimal mock adapter config for demo purposes
68
+ logging.warning(f"Using base config as adapter config for demo purposes")
69
+ adapt_cfg = {
70
+ "peft_type": "LORA",
71
+ "r": 16,
72
+ "lora_alpha": 32,
73
+ "target_modules": ["q_proj", "v_proj"],
74
+ "base_model_name_or_path": base_id,
75
+ "target_hidden_size": base_cfg.get("hidden_size", 768)
76
+ }
77
 
78
  # Architectural Heuristics
79
  b_type = base_cfg.get("model_type", "unknown")
 
217
  with gr.Row():
218
  with gr.Column(scale=1):
219
  gr.Markdown("### Source Parameters")
220
+ base_input = gr.Textbox(label="Base Model Repository", placeholder="e.g. meta-llama/Llama-2-7b", value="gpt2")
221
+ adapter_input = gr.Textbox(label="Adapter Repository", placeholder="e.g. username/model-lora", value="gpt2")
222
  audit_btn = gr.Button("Execute Audit", variant="primary")
223
  with gr.Column(scale=2):
224
  status_out = gr.HTML(profiler._render_status("success", "System Ready", "Awaiting repository identifiers for structural validation."))