Spaces:
Running
Running
Update src/aibom_generator/generator.py
Browse files
src/aibom_generator/generator.py
CHANGED
@@ -4,6 +4,7 @@ import datetime
|
|
4 |
from typing import Dict, Optional, Any
|
5 |
|
6 |
from huggingface_hub import HfApi, ModelCard
|
|
|
7 |
|
8 |
|
9 |
class AIBOMGenerator:
|
@@ -118,23 +119,16 @@ class AIBOMGenerator:
|
|
118 |
metadata["ai:task"] = metadata.get("pipeline_tag", "Text Generation")
|
119 |
metadata["ai:framework"] = "PyTorch" if "transformers" in metadata.get("library_name", "") else "Unknown"
|
120 |
|
121 |
-
if "DeepSeek-R1" in model_id:
|
122 |
-
metadata.update({
|
123 |
-
"ai:parameters": "672B total, 37B active per token",
|
124 |
-
"ai:training-data": "14.8 trillion tokens",
|
125 |
-
"ai:training-duration": "55 days",
|
126 |
-
"ai:training-cost": "$5.58 million",
|
127 |
-
"ai:hardware": "NVIDIA H800 GPUs"
|
128 |
-
})
|
129 |
|
130 |
-
return {k: v for k, v in metadata.items() if v is not None
|
131 |
|
132 |
def _extract_unstructured_metadata(self, model_card: ModelCard) -> Dict[str, Any]:
|
133 |
return {}
|
134 |
|
135 |
def _create_metadata_section(self, model_id: str, metadata: Dict[str, Any]) -> Dict[str, Any]:
|
136 |
-
|
137 |
-
|
|
|
138 |
timestamp = datetime.datetime.utcnow().isoformat() + "Z"
|
139 |
tools = [{
|
140 |
"vendor": "Aetheris AI",
|
@@ -162,7 +156,10 @@ class AIBOMGenerator:
|
|
162 |
value = json.dumps(value)
|
163 |
properties.append({"name": key, "value": str(value)})
|
164 |
|
165 |
-
|
|
|
|
|
|
|
166 |
|
167 |
metadata_section = {
|
168 |
"timestamp": timestamp,
|
|
|
4 |
from typing import Dict, Optional, Any
|
5 |
|
6 |
from huggingface_hub import HfApi, ModelCard
|
7 |
+
from utils import calculate_completeness_score
|
8 |
|
9 |
|
10 |
class AIBOMGenerator:
|
|
|
119 |
metadata["ai:task"] = metadata.get("pipeline_tag", "Text Generation")
|
120 |
metadata["ai:framework"] = "PyTorch" if "transformers" in metadata.get("library_name", "") else "Unknown"
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
+
return {k: v for k, v in metadata.items() if v is not None]
|
124 |
|
125 |
def _extract_unstructured_metadata(self, model_card: ModelCard) -> Dict[str, Any]:
|
126 |
return {}
|
127 |
|
128 |
def _create_metadata_section(self, model_id: str, metadata: Dict[str, Any]) -> Dict[str, Any]:
|
129 |
+
aibom_stub = {"metadata": metadata} # Build stub for scoring
|
130 |
+
score_report = calculate_completeness_score(aibom_stub)
|
131 |
+
|
132 |
timestamp = datetime.datetime.utcnow().isoformat() + "Z"
|
133 |
tools = [{
|
134 |
"vendor": "Aetheris AI",
|
|
|
156 |
value = json.dumps(value)
|
157 |
properties.append({"name": key, "value": str(value)})
|
158 |
|
159 |
+
# Add quality scoring results
|
160 |
+
properties.append({"name": "aibom:quality-score", "value": str(score_report["total_score"])})
|
161 |
+
properties.append({"name": "aibom:quality-breakdown", "value": json.dumps(score_report["section_scores"])})
|
162 |
+
properties.append({"name": "aibom:field-checklist", "value": json.dumps(score_report["field_checklist"])})
|
163 |
|
164 |
metadata_section = {
|
165 |
"timestamp": timestamp,
|