isa-model 0.3.91__py3-none-any.whl ā 0.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- isa_model/client.py +732 -573
- isa_model/core/cache/redis_cache.py +401 -0
- isa_model/core/config/config_manager.py +53 -10
- isa_model/core/config.py +1 -1
- isa_model/core/database/__init__.py +1 -0
- isa_model/core/database/migrations.py +277 -0
- isa_model/core/database/supabase_client.py +123 -0
- isa_model/core/models/__init__.py +37 -0
- isa_model/core/models/model_billing_tracker.py +60 -88
- isa_model/core/models/model_manager.py +36 -18
- isa_model/core/models/model_repo.py +44 -38
- isa_model/core/models/model_statistics_tracker.py +234 -0
- isa_model/core/models/model_storage.py +0 -1
- isa_model/core/models/model_version_manager.py +959 -0
- isa_model/core/pricing_manager.py +2 -249
- isa_model/core/resilience/circuit_breaker.py +366 -0
- isa_model/core/security/secrets.py +358 -0
- isa_model/core/services/__init__.py +2 -4
- isa_model/core/services/intelligent_model_selector.py +101 -370
- isa_model/core/storage/hf_storage.py +1 -1
- isa_model/core/types.py +7 -0
- isa_model/deployment/cloud/modal/isa_audio_chatTTS_service.py +520 -0
- isa_model/deployment/cloud/modal/isa_audio_fish_service.py +0 -0
- isa_model/deployment/cloud/modal/isa_audio_openvoice_service.py +758 -0
- isa_model/deployment/cloud/modal/isa_audio_service_v2.py +1044 -0
- isa_model/deployment/cloud/modal/isa_embed_rerank_service.py +296 -0
- isa_model/deployment/cloud/modal/isa_video_hunyuan_service.py +423 -0
- isa_model/deployment/cloud/modal/isa_vision_ocr_service.py +519 -0
- isa_model/deployment/cloud/modal/isa_vision_qwen25_service.py +709 -0
- isa_model/deployment/cloud/modal/isa_vision_table_service.py +467 -323
- isa_model/deployment/cloud/modal/isa_vision_ui_service.py +607 -180
- isa_model/deployment/cloud/modal/isa_vision_ui_service_optimized.py +660 -0
- isa_model/deployment/core/deployment_manager.py +6 -4
- isa_model/deployment/services/auto_hf_modal_deployer.py +894 -0
- isa_model/eval/benchmarks/__init__.py +27 -0
- isa_model/eval/benchmarks/multimodal_datasets.py +460 -0
- isa_model/eval/benchmarks.py +244 -12
- isa_model/eval/evaluators/__init__.py +8 -2
- isa_model/eval/evaluators/audio_evaluator.py +727 -0
- isa_model/eval/evaluators/embedding_evaluator.py +742 -0
- isa_model/eval/evaluators/vision_evaluator.py +564 -0
- isa_model/eval/example_evaluation.py +395 -0
- isa_model/eval/factory.py +272 -5
- isa_model/eval/isa_benchmarks.py +700 -0
- isa_model/eval/isa_integration.py +582 -0
- isa_model/eval/metrics.py +159 -6
- isa_model/eval/tests/unit/test_basic.py +396 -0
- isa_model/inference/ai_factory.py +44 -8
- isa_model/inference/services/audio/__init__.py +21 -0
- isa_model/inference/services/audio/base_realtime_service.py +225 -0
- isa_model/inference/services/audio/isa_tts_service.py +0 -0
- isa_model/inference/services/audio/openai_realtime_service.py +320 -124
- isa_model/inference/services/audio/openai_stt_service.py +32 -6
- isa_model/inference/services/base_service.py +17 -1
- isa_model/inference/services/embedding/__init__.py +13 -0
- isa_model/inference/services/embedding/base_embed_service.py +111 -8
- isa_model/inference/services/embedding/isa_embed_service.py +305 -0
- isa_model/inference/services/embedding/openai_embed_service.py +2 -4
- isa_model/inference/services/embedding/tests/test_embedding.py +222 -0
- isa_model/inference/services/img/__init__.py +2 -2
- isa_model/inference/services/img/base_image_gen_service.py +24 -7
- isa_model/inference/services/img/replicate_image_gen_service.py +84 -422
- isa_model/inference/services/img/services/replicate_face_swap.py +193 -0
- isa_model/inference/services/img/services/replicate_flux.py +226 -0
- isa_model/inference/services/img/services/replicate_flux_kontext.py +219 -0
- isa_model/inference/services/img/services/replicate_sticker_maker.py +249 -0
- isa_model/inference/services/img/tests/test_img_client.py +297 -0
- isa_model/inference/services/llm/base_llm_service.py +30 -6
- isa_model/inference/services/llm/helpers/llm_adapter.py +63 -9
- isa_model/inference/services/llm/ollama_llm_service.py +2 -1
- isa_model/inference/services/llm/openai_llm_service.py +652 -55
- isa_model/inference/services/llm/yyds_llm_service.py +2 -1
- isa_model/inference/services/vision/__init__.py +5 -5
- isa_model/inference/services/vision/base_vision_service.py +118 -185
- isa_model/inference/services/vision/helpers/image_utils.py +11 -5
- isa_model/inference/services/vision/isa_vision_service.py +573 -0
- isa_model/inference/services/vision/tests/test_ocr_client.py +284 -0
- isa_model/serving/api/fastapi_server.py +88 -16
- isa_model/serving/api/middleware/auth.py +311 -0
- isa_model/serving/api/middleware/security.py +278 -0
- isa_model/serving/api/routes/analytics.py +486 -0
- isa_model/serving/api/routes/deployments.py +339 -0
- isa_model/serving/api/routes/evaluations.py +579 -0
- isa_model/serving/api/routes/logs.py +430 -0
- isa_model/serving/api/routes/settings.py +582 -0
- isa_model/serving/api/routes/unified.py +324 -165
- isa_model/serving/api/startup.py +304 -0
- isa_model/serving/modal_proxy_server.py +249 -0
- isa_model/training/__init__.py +100 -6
- isa_model/training/core/__init__.py +4 -1
- isa_model/training/examples/intelligent_training_example.py +281 -0
- isa_model/training/intelligent/__init__.py +25 -0
- isa_model/training/intelligent/decision_engine.py +643 -0
- isa_model/training/intelligent/intelligent_factory.py +888 -0
- isa_model/training/intelligent/knowledge_base.py +751 -0
- isa_model/training/intelligent/resource_optimizer.py +839 -0
- isa_model/training/intelligent/task_classifier.py +576 -0
- isa_model/training/storage/__init__.py +24 -0
- isa_model/training/storage/core_integration.py +439 -0
- isa_model/training/storage/training_repository.py +552 -0
- isa_model/training/storage/training_storage.py +628 -0
- {isa_model-0.3.91.dist-info ā isa_model-0.4.0.dist-info}/METADATA +13 -1
- isa_model-0.4.0.dist-info/RECORD +182 -0
- isa_model/deployment/cloud/modal/isa_vision_doc_service.py +0 -766
- isa_model/deployment/cloud/modal/register_models.py +0 -321
- isa_model/inference/adapter/unified_api.py +0 -248
- isa_model/inference/services/helpers/stacked_config.py +0 -148
- isa_model/inference/services/img/flux_professional_service.py +0 -603
- isa_model/inference/services/img/helpers/base_stacked_service.py +0 -274
- isa_model/inference/services/others/table_transformer_service.py +0 -61
- isa_model/inference/services/vision/doc_analysis_service.py +0 -640
- isa_model/inference/services/vision/helpers/base_stacked_service.py +0 -274
- isa_model/inference/services/vision/ui_analysis_service.py +0 -823
- isa_model/scripts/inference_tracker.py +0 -283
- isa_model/scripts/mlflow_manager.py +0 -379
- isa_model/scripts/model_registry.py +0 -465
- isa_model/scripts/register_models.py +0 -370
- isa_model/scripts/register_models_with_embeddings.py +0 -510
- isa_model/scripts/start_mlflow.py +0 -95
- isa_model/scripts/training_tracker.py +0 -257
- isa_model-0.3.91.dist-info/RECORD +0 -138
- {isa_model-0.3.91.dist-info ā isa_model-0.4.0.dist-info}/WHEEL +0 -0
- {isa_model-0.3.91.dist-info ā isa_model-0.4.0.dist-info}/top_level.txt +0 -0
@@ -8,7 +8,7 @@ This module provides the core training functionality:
|
|
8
8
|
"""
|
9
9
|
|
10
10
|
from .trainer import BaseTrainer, SFTTrainer
|
11
|
-
from .config import TrainingConfig, LoRAConfig, DatasetConfig
|
11
|
+
from .config import TrainingConfig, LoRAConfig, DatasetConfig, RunPodConfig, StorageConfig, JobConfig
|
12
12
|
from .dataset import DatasetManager
|
13
13
|
from .utils import TrainingUtils
|
14
14
|
|
@@ -18,6 +18,9 @@ __all__ = [
|
|
18
18
|
'TrainingConfig',
|
19
19
|
'LoRAConfig',
|
20
20
|
'DatasetConfig',
|
21
|
+
'RunPodConfig',
|
22
|
+
'StorageConfig',
|
23
|
+
'JobConfig',
|
21
24
|
'DatasetManager',
|
22
25
|
'TrainingUtils'
|
23
26
|
]
|
@@ -0,0 +1,281 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""
|
3
|
+
Intelligent Training System Example
|
4
|
+
|
5
|
+
This script demonstrates the capabilities of the intelligent training system:
|
6
|
+
- Natural language training request analysis
|
7
|
+
- Automatic model and resource selection
|
8
|
+
- Cost and performance optimization
|
9
|
+
- Training option comparison
|
10
|
+
- Best practices recommendations
|
11
|
+
|
12
|
+
Run this script to see the intelligent training system in action.
|
13
|
+
"""
|
14
|
+
|
15
|
+
import os
|
16
|
+
import sys
|
17
|
+
import json
|
18
|
+
from pathlib import Path
|
19
|
+
|
20
|
+
# Add the parent directory to path for imports
|
21
|
+
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent))
|
22
|
+
|
23
|
+
def main():
|
24
|
+
"""Demonstrate intelligent training capabilities."""
|
25
|
+
|
26
|
+
print("š§ Intelligent Training System Demo")
|
27
|
+
print("=" * 50)
|
28
|
+
|
29
|
+
try:
|
30
|
+
# Import intelligent training components
|
31
|
+
from isa_model.training import (
|
32
|
+
IntelligentTrainingFactory,
|
33
|
+
INTELLIGENT_AVAILABLE
|
34
|
+
)
|
35
|
+
|
36
|
+
if not INTELLIGENT_AVAILABLE:
|
37
|
+
print("ā Intelligent training features not available")
|
38
|
+
return
|
39
|
+
|
40
|
+
print("ā
Intelligent training system loaded successfully\n")
|
41
|
+
|
42
|
+
# Initialize intelligent factory
|
43
|
+
print("š§ Initializing intelligent training factory...")
|
44
|
+
factory = IntelligentTrainingFactory()
|
45
|
+
|
46
|
+
# Example 1: Natural Language Training Request
|
47
|
+
print("\n" + "="*50)
|
48
|
+
print("š EXAMPLE 1: Natural Language Analysis")
|
49
|
+
print("="*50)
|
50
|
+
|
51
|
+
description = "Train a customer service chatbot for a medical company that can answer patient questions about symptoms and treatments in Chinese"
|
52
|
+
dataset_path = "medical_qa_chinese.json" # Hypothetical dataset
|
53
|
+
|
54
|
+
print(f"Request: {description}")
|
55
|
+
print(f"Dataset: {dataset_path}")
|
56
|
+
|
57
|
+
try:
|
58
|
+
recommendation = factory.analyze_training_request(
|
59
|
+
description=description,
|
60
|
+
dataset_source=dataset_path,
|
61
|
+
quality_target="high",
|
62
|
+
budget_limit=300.0,
|
63
|
+
time_limit=12
|
64
|
+
)
|
65
|
+
|
66
|
+
print(f"\nā
Analysis completed successfully!")
|
67
|
+
print(f"š± Recommended Model: {recommendation.model_name}")
|
68
|
+
print(f"š„ļø Recommended GPU: {recommendation.recommended_gpu}")
|
69
|
+
print(f"š° Estimated Cost: ${recommendation.estimated_cost:.2f}")
|
70
|
+
print(f"ā±ļø Estimated Time: {recommendation.estimated_time:.1f} hours")
|
71
|
+
|
72
|
+
except Exception as e:
|
73
|
+
print(f"ā Analysis failed: {e}")
|
74
|
+
|
75
|
+
# Example 2: Training Options Comparison
|
76
|
+
print("\n" + "="*50)
|
77
|
+
print("š EXAMPLE 2: Training Options Comparison")
|
78
|
+
print("="*50)
|
79
|
+
|
80
|
+
description2 = "Fine-tune a code generation model for Python development"
|
81
|
+
dataset_path2 = "python_code_dataset.json"
|
82
|
+
|
83
|
+
print(f"Request: {description2}")
|
84
|
+
print(f"Comparing quality targets: fast, balanced, high")
|
85
|
+
|
86
|
+
try:
|
87
|
+
comparisons = factory.compare_training_options(
|
88
|
+
description=description2,
|
89
|
+
dataset_source=dataset_path2,
|
90
|
+
quality_targets=["fast", "balanced", "high"],
|
91
|
+
budget_limits=[50.0, 150.0, 300.0]
|
92
|
+
)
|
93
|
+
|
94
|
+
print(f"ā
Generated {len(comparisons)} training options for comparison")
|
95
|
+
|
96
|
+
except Exception as e:
|
97
|
+
print(f"ā Comparison failed: {e}")
|
98
|
+
|
99
|
+
# Example 3: Best Practices
|
100
|
+
print("\n" + "="*50)
|
101
|
+
print("š” EXAMPLE 3: Best Practices")
|
102
|
+
print("="*50)
|
103
|
+
|
104
|
+
task_types = ["chat", "classification", "generation"]
|
105
|
+
domains = ["medical", "legal", "general"]
|
106
|
+
|
107
|
+
for task_type in task_types:
|
108
|
+
for domain in domains:
|
109
|
+
try:
|
110
|
+
practices = factory.get_best_practices(task_type, domain)
|
111
|
+
if practices:
|
112
|
+
print(f"\nš {task_type.title()} + {domain.title()}:")
|
113
|
+
for practice in practices[:2]: # Show top 2
|
114
|
+
print(f" ⢠{practice}")
|
115
|
+
except Exception as e:
|
116
|
+
continue
|
117
|
+
|
118
|
+
# Example 4: System Capabilities
|
119
|
+
print("\n" + "="*50)
|
120
|
+
print("šÆ EXAMPLE 4: System Capabilities")
|
121
|
+
print("="*50)
|
122
|
+
|
123
|
+
try:
|
124
|
+
capabilities = factory.get_supported_capabilities()
|
125
|
+
|
126
|
+
print(f"š± Supported Models: {len(capabilities.get('task_types', []))} task types")
|
127
|
+
print(f"š Supported Domains: {len(capabilities.get('domains', []))} domains")
|
128
|
+
print(f"š„ļø Available GPUs: {len(capabilities.get('gpu_types', []))} types")
|
129
|
+
print(f"āļø Cloud Providers: {len(capabilities.get('cloud_providers', []))} providers")
|
130
|
+
|
131
|
+
print("\nTask Types:")
|
132
|
+
for task in capabilities.get('task_types', [])[:5]:
|
133
|
+
print(f" ⢠{task}")
|
134
|
+
|
135
|
+
print("\nDomains:")
|
136
|
+
for domain in capabilities.get('domains', [])[:5]:
|
137
|
+
print(f" ⢠{domain}")
|
138
|
+
|
139
|
+
print("\nGPU Types:")
|
140
|
+
for gpu in capabilities.get('gpu_types', [])[:5]:
|
141
|
+
print(f" ⢠{gpu}")
|
142
|
+
|
143
|
+
except Exception as e:
|
144
|
+
print(f"ā Failed to get capabilities: {e}")
|
145
|
+
|
146
|
+
# Example 5: Intelligence Statistics
|
147
|
+
print("\n" + "="*50)
|
148
|
+
print("š EXAMPLE 5: Intelligence Statistics")
|
149
|
+
print("="*50)
|
150
|
+
|
151
|
+
try:
|
152
|
+
stats = factory.get_intelligence_statistics()
|
153
|
+
|
154
|
+
if stats.get('intelligence_enabled'):
|
155
|
+
kb_stats = stats.get('knowledge_base', {})
|
156
|
+
print(f"š Knowledge Base:")
|
157
|
+
print(f" ⢠Models: {kb_stats.get('total_models', 0)}")
|
158
|
+
print(f" ⢠Best Practices: {kb_stats.get('best_practices', 0)}")
|
159
|
+
print(f" ⢠Benchmarks: {kb_stats.get('benchmarks', 0)}")
|
160
|
+
|
161
|
+
resource_stats = stats.get('resource_optimizer', {})
|
162
|
+
print(f"š„ļø Resource Optimizer:")
|
163
|
+
print(f" ⢠GPUs: {resource_stats.get('total_gpus', 0)}")
|
164
|
+
print(f" ⢠Providers: {resource_stats.get('total_providers', 0)}")
|
165
|
+
print(f" ⢠Avg Cost/Hour: ${resource_stats.get('avg_cost_per_hour', 0):.2f}")
|
166
|
+
|
167
|
+
except Exception as e:
|
168
|
+
print(f"ā Failed to get statistics: {e}")
|
169
|
+
|
170
|
+
# Example 6: Recommendation Scenarios
|
171
|
+
print("\n" + "="*50)
|
172
|
+
print("š EXAMPLE 6: Different Scenarios")
|
173
|
+
print("="*50)
|
174
|
+
|
175
|
+
scenarios = [
|
176
|
+
{
|
177
|
+
"name": "Budget-Conscious Student",
|
178
|
+
"description": "Create a simple English grammar checker",
|
179
|
+
"dataset": "grammar_corrections.json",
|
180
|
+
"budget": 25.0,
|
181
|
+
"time": 4,
|
182
|
+
"target": "fast"
|
183
|
+
},
|
184
|
+
{
|
185
|
+
"name": "Enterprise Company",
|
186
|
+
"description": "Advanced legal document analysis system",
|
187
|
+
"dataset": "legal_documents.json",
|
188
|
+
"budget": 1000.0,
|
189
|
+
"time": 24,
|
190
|
+
"target": "high"
|
191
|
+
},
|
192
|
+
{
|
193
|
+
"name": "Research Lab",
|
194
|
+
"description": "Multi-modal medical image description model",
|
195
|
+
"dataset": "medical_images_captions.json",
|
196
|
+
"budget": 500.0,
|
197
|
+
"time": 16,
|
198
|
+
"target": "balanced"
|
199
|
+
}
|
200
|
+
]
|
201
|
+
|
202
|
+
for scenario in scenarios:
|
203
|
+
print(f"\nš¤ {scenario['name']}:")
|
204
|
+
print(f" Request: {scenario['description']}")
|
205
|
+
print(f" Budget: ${scenario['budget']}, Time: {scenario['time']}h, Target: {scenario['target']}")
|
206
|
+
|
207
|
+
try:
|
208
|
+
rec = factory.analyze_training_request(
|
209
|
+
description=scenario['description'],
|
210
|
+
dataset_source=scenario['dataset'],
|
211
|
+
quality_target=scenario['target'],
|
212
|
+
budget_limit=scenario['budget'],
|
213
|
+
time_limit=scenario['time']
|
214
|
+
)
|
215
|
+
|
216
|
+
print(f" ā Model: {rec.model_name}")
|
217
|
+
print(f" ā GPU: {rec.recommended_gpu}")
|
218
|
+
print(f" ā Cost: ${rec.estimated_cost:.2f}")
|
219
|
+
print(f" ā Confidence: {rec.confidence_score:.1%}")
|
220
|
+
|
221
|
+
except Exception as e:
|
222
|
+
print(f" ā Failed: {e}")
|
223
|
+
|
224
|
+
# Summary
|
225
|
+
print("\n" + "="*50)
|
226
|
+
print("ā
DEMO COMPLETED SUCCESSFULLY")
|
227
|
+
print("="*50)
|
228
|
+
print("The intelligent training system is ready to use!")
|
229
|
+
print("\nNext steps:")
|
230
|
+
print("1. Prepare your dataset in JSON format")
|
231
|
+
print("2. Use analyze_training_request() for recommendations")
|
232
|
+
print("3. Use train_with_recommendation() to start training")
|
233
|
+
print("4. Monitor progress and collect results")
|
234
|
+
|
235
|
+
except ImportError as e:
|
236
|
+
print(f"ā Import error: {e}")
|
237
|
+
print("Make sure the isa_model package is properly installed")
|
238
|
+
except Exception as e:
|
239
|
+
print(f"ā Demo failed: {e}")
|
240
|
+
import traceback
|
241
|
+
traceback.print_exc()
|
242
|
+
|
243
|
+
|
244
|
+
def create_sample_dataset():
|
245
|
+
"""Create a sample dataset for testing."""
|
246
|
+
sample_data = [
|
247
|
+
{
|
248
|
+
"instruction": "What are the symptoms of the common cold?",
|
249
|
+
"input": "",
|
250
|
+
"output": "Common cold symptoms include runny nose, sneezing, coughing, sore throat, mild headache, and fatigue."
|
251
|
+
},
|
252
|
+
{
|
253
|
+
"instruction": "How can I prevent getting sick?",
|
254
|
+
"input": "",
|
255
|
+
"output": "To prevent illness, wash your hands frequently, maintain a healthy diet, get adequate sleep, exercise regularly, and avoid close contact with sick people."
|
256
|
+
},
|
257
|
+
{
|
258
|
+
"instruction": "When should I see a doctor?",
|
259
|
+
"input": "I have a fever and cough for 3 days",
|
260
|
+
"output": "You should see a doctor if you have a persistent fever and cough for more than 3 days, especially if symptoms are worsening or you have difficulty breathing."
|
261
|
+
}
|
262
|
+
]
|
263
|
+
|
264
|
+
# Create sample dataset file
|
265
|
+
os.makedirs("sample_data", exist_ok=True)
|
266
|
+
with open("sample_data/medical_qa_sample.json", "w") as f:
|
267
|
+
json.dump(sample_data, f, indent=2)
|
268
|
+
|
269
|
+
print("š Created sample dataset: sample_data/medical_qa_sample.json")
|
270
|
+
|
271
|
+
|
272
|
+
if __name__ == "__main__":
|
273
|
+
print("š Starting Intelligent Training System Demo\n")
|
274
|
+
|
275
|
+
# Create sample dataset
|
276
|
+
create_sample_dataset()
|
277
|
+
|
278
|
+
# Run main demo
|
279
|
+
main()
|
280
|
+
|
281
|
+
print("\nš Demo finished! Thank you for trying the intelligent training system.")
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"""
|
2
|
+
Intelligent Training Service Components
|
3
|
+
|
4
|
+
This module provides AI-powered training optimization and automation:
|
5
|
+
- Intelligent decision engine for configuration recommendations
|
6
|
+
- Task classification and model selection
|
7
|
+
- Resource optimization and cost estimation
|
8
|
+
- Natural language interface for training requests
|
9
|
+
"""
|
10
|
+
|
11
|
+
from .decision_engine import IntelligentDecisionEngine, TrainingRequest, TrainingRecommendation
|
12
|
+
from .task_classifier import TaskClassifier
|
13
|
+
from .knowledge_base import KnowledgeBase
|
14
|
+
from .resource_optimizer import ResourceOptimizer
|
15
|
+
from .intelligent_factory import IntelligentTrainingFactory
|
16
|
+
|
17
|
+
__all__ = [
|
18
|
+
'IntelligentDecisionEngine',
|
19
|
+
'TaskClassifier',
|
20
|
+
'KnowledgeBase',
|
21
|
+
'ResourceOptimizer',
|
22
|
+
'IntelligentTrainingFactory',
|
23
|
+
'TrainingRequest',
|
24
|
+
'TrainingRecommendation'
|
25
|
+
]
|