Text Generation
Transformers
PyTorch
English
improved-unified-multi-model-pt
ai
machine-learning
multimodal
orchestration
reasoning
parent-llm
image-captioning
text-to-image
Instructions to use kunaliitkgp09/improved-unified-multi-model-pt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kunaliitkgp09/improved-unified-multi-model-pt with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="kunaliitkgp09/improved-unified-multi-model-pt")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("kunaliitkgp09/improved-unified-multi-model-pt", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use kunaliitkgp09/improved-unified-multi-model-pt with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kunaliitkgp09/improved-unified-multi-model-pt" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kunaliitkgp09/improved-unified-multi-model-pt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/kunaliitkgp09/improved-unified-multi-model-pt
- SGLang
How to use kunaliitkgp09/improved-unified-multi-model-pt with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "kunaliitkgp09/improved-unified-multi-model-pt" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kunaliitkgp09/improved-unified-multi-model-pt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "kunaliitkgp09/improved-unified-multi-model-pt" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kunaliitkgp09/improved-unified-multi-model-pt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use kunaliitkgp09/improved-unified-multi-model-pt with Docker Model Runner:
docker model run hf.co/kunaliitkgp09/improved-unified-multi-model-pt
| #!/usr/bin/env python3 | |
| """ | |
| Example Usage of Prompt Templates and Test Suite | |
| with Advanced Multi-Model Orchestrator | |
| """ | |
| import asyncio | |
| import sys | |
| from pathlib import Path | |
| # Add current directory to path | |
| sys.path.append(str(Path(__file__).parent)) | |
| from prompt_template import PromptTemplates, TaskType, TestPrompt | |
| from test_suite import OrchestratorTester, TestRunner | |
| async def example_with_advanced_orchestrator(): | |
| """Example using the Advanced Multi-Model Orchestrator""" | |
| print("๐ Example: Testing with Advanced Orchestrator") | |
| print("=" * 60) | |
| try: | |
| # Import the advanced orchestrator | |
| from advanced_multi_model_orchestrator_complete import AdvancedMultiModelOrchestrator | |
| # Initialize the orchestrator | |
| print("๐ฆ Initializing Advanced Multi-Model Orchestrator...") | |
| orchestrator = AdvancedMultiModelOrchestrator(parent_model_name="distilgpt2") | |
| print("โ Orchestrator initialized successfully!") | |
| # Example 1: Test a few specific prompts | |
| print("\n๐ Example 1: Testing Specific Prompts") | |
| print("-" * 40) | |
| test_prompts = [ | |
| "What is machine learning?", | |
| "Generate an image of a peaceful forest", | |
| "Describe this image of a sunset", | |
| "Explain step by step how neural networks work" | |
| ] | |
| for i, prompt in enumerate(test_prompts, 1): | |
| print(f"\n{i}. Testing: {prompt}") | |
| result = await orchestrator.process_request(prompt) | |
| print(f" Task Type: {result.task_type.value}") | |
| print(f" Confidence: {result.confidence:.2f}") | |
| print(f" Success: {result.success}") | |
| if result.output: | |
| print(f" Output: {result.output[:100]}...") | |
| # Example 2: Use prompt templates | |
| print("\n๐ Example 2: Using Prompt Templates") | |
| print("-" * 40) | |
| # Get some text processing prompts | |
| text_prompts = PromptTemplates.get_prompts_by_task_type(TaskType.TEXT)[:3] | |
| for prompt in text_prompts: | |
| print(f"\nTesting: {prompt.prompt}") | |
| result = await orchestrator.process_request(prompt.prompt) | |
| expected = prompt.expected_task.value | |
| actual = result.task_type.value | |
| correct = "โ " if expected == actual else "โ" | |
| print(f" Expected: {expected} | Actual: {actual} {correct}") | |
| print(f" Confidence: {result.confidence:.2f}") | |
| # Example 3: Run a quick test suite | |
| print("\n๐งช Example 3: Running Quick Test Suite") | |
| print("-" * 40) | |
| tester = OrchestratorTester(orchestrator) | |
| # Test basic functionality | |
| basic_result = await tester.run_basic_tests() | |
| print(f"Basic Test Results:") | |
| print(f" Total Tests: {basic_result.total_tests}") | |
| print(f" Accuracy: {basic_result.accuracy:.1%}") | |
| print(f" Avg Confidence: {basic_result.average_confidence:.2f}") | |
| return True | |
| except ImportError as e: | |
| print(f"โ Could not import AdvancedMultiModelOrchestrator: {e}") | |
| print("Make sure the orchestrator file is available.") | |
| return False | |
| except Exception as e: | |
| print(f"โ Error: {e}") | |
| return False | |
| async def example_with_demo_orchestrator(): | |
| """Example using the Demo Orchestrator""" | |
| print("๐ฎ Example: Testing with Demo Orchestrator") | |
| print("=" * 60) | |
| try: | |
| # Import the demo orchestrator | |
| from advanced_multi_model_orchestrator_complete import DemoAdvancedOrchestrator | |
| # Initialize the demo orchestrator | |
| print("๐ฆ Initializing Demo Orchestrator...") | |
| orchestrator = DemoAdvancedOrchestrator() | |
| print("โ Demo orchestrator initialized!") | |
| # Test with different types of prompts | |
| print("\n๐ Testing Different Prompt Types") | |
| print("-" * 40) | |
| # Get one prompt from each category | |
| categories = [TaskType.TEXT, TaskType.CAPTION, TaskType.TEXT2IMG, TaskType.MULTIMODAL, TaskType.REASONING] | |
| for category in categories: | |
| prompts = PromptTemplates.get_prompts_by_task_type(category) | |
| if prompts: | |
| prompt = prompts[0] | |
| print(f"\nTesting {category.value}: {prompt.prompt[:50]}...") | |
| result = await orchestrator.process_request(prompt.prompt) | |
| print(f" Result: {result.task_type.value}") | |
| print(f" Confidence: {result.confidence:.2f}") | |
| return True | |
| except ImportError as e: | |
| print(f"โ Could not import DemoAdvancedOrchestrator: {e}") | |
| return False | |
| except Exception as e: | |
| print(f"โ Error: {e}") | |
| return False | |
| async def example_custom_testing(): | |
| """Example of custom testing scenarios""" | |
| print("๐ง Example: Custom Testing Scenarios") | |
| print("=" * 60) | |
| # Create a mock orchestrator for demonstration | |
| class MockOrchestrator: | |
| async def process_request(self, prompt): | |
| class MockResult: | |
| def __init__(self, prompt): | |
| # Simple routing logic | |
| if "image" in prompt.lower() or "generate" in prompt.lower(): | |
| task_type = "TEXT2IMG" | |
| elif "describe" in prompt.lower() or "caption" in prompt.lower(): | |
| task_type = "CAPTION" | |
| elif "explain" in prompt.lower() or "analyze" in prompt.lower(): | |
| task_type = "REASONING" | |
| else: | |
| task_type = "TEXT" | |
| self.task_type = type('TaskType', (), {'value': task_type})() | |
| self.confidence = 0.7 | |
| self.success = True | |
| self.output = f"Mock response: {prompt[:30]}..." | |
| self.error_message = None | |
| return MockResult(prompt) | |
| orchestrator = MockOrchestrator() | |
| # Example 1: Test specific categories | |
| print("\n๐ Example 1: Testing by Category") | |
| print("-" * 40) | |
| categories = ["education", "creative", "practical"] | |
| for category in categories: | |
| prompts = PromptTemplates.get_prompts_by_category(category)[:2] | |
| print(f"\nTesting {category} category ({len(prompts)} prompts):") | |
| for prompt in prompts: | |
| result = await orchestrator.process_request(prompt.prompt) | |
| print(f" {prompt.prompt[:40]:<40} -> {result.task_type.value}") | |
| # Example 2: Performance testing | |
| print("\nโก Example 2: Performance Testing") | |
| print("-" * 40) | |
| import time | |
| from prompt_template import SpecializedPrompts | |
| performance_prompts = SpecializedPrompts.PERFORMANCE_PROMPTS | |
| print(f"Testing {len(performance_prompts)} performance prompts:") | |
| total_time = 0 | |
| for prompt in performance_prompts: | |
| start_time = time.time() | |
| result = await orchestrator.process_request(prompt) | |
| processing_time = time.time() - start_time | |
| total_time += processing_time | |
| print(f" {prompt[:30]:<30} | {processing_time:.3f}s") | |
| avg_time = total_time / len(performance_prompts) | |
| print(f"\nAverage processing time: {avg_time:.3f}s") | |
| # Example 3: Custom test scenarios | |
| print("\n๐ฏ Example 3: Custom Test Scenarios") | |
| print("-" * 40) | |
| # Create custom test prompts | |
| custom_prompts = [ | |
| TestPrompt( | |
| prompt="Analyze the impact of AI on healthcare", | |
| expected_task=TaskType.REASONING, | |
| description="Healthcare AI analysis", | |
| category="healthcare" | |
| ), | |
| TestPrompt( | |
| prompt="Create a visual representation of data flow", | |
| expected_task=TaskType.TEXT2IMG, | |
| description="Data visualization", | |
| category="business" | |
| ), | |
| TestPrompt( | |
| prompt="Summarize the latest AI research findings", | |
| expected_task=TaskType.TEXT, | |
| description="Research summary", | |
| category="research" | |
| ) | |
| ] | |
| tester = OrchestratorTester(orchestrator) | |
| print("Testing custom scenarios:") | |
| for prompt in custom_prompts: | |
| result = await tester.test_single_prompt(prompt) | |
| status = "โ " if result.task_correct else "โ" | |
| print(f" {status} {prompt.description}: {result.actual_task} (expected: {prompt.expected_task.value})") | |
| async def example_prompt_generation(): | |
| """Example of prompt generation utilities""" | |
| print("๐ Example: Prompt Generation Utilities") | |
| print("=" * 60) | |
| # Example 1: Generate variations | |
| print("\n๐ Example 1: Prompt Variations") | |
| print("-" * 40) | |
| base_prompt = "explain machine learning" | |
| from prompt_template import PromptGenerator | |
| variations = PromptGenerator.generate_variations(base_prompt, 3) | |
| for i, variation in enumerate(variations, 1): | |
| print(f" {i}. {variation}") | |
| # Example 2: Contextual prompts | |
| print("\n๐ฏ Example 2: Contextual Prompts") | |
| print("-" * 40) | |
| contexts = ["education", "business", "research"] | |
| for context in contexts: | |
| contextual_prompts = PromptGenerator.generate_contextual_prompts(context) | |
| print(f"\n{context.title()} context prompts:") | |
| for prompt in contextual_prompts: | |
| print(f" - {prompt.prompt}") | |
| # Example 3: Statistics | |
| print("\n๐ Example 3: Prompt Statistics") | |
| print("-" * 40) | |
| stats = PromptTemplates.get_prompt_statistics() | |
| print(f"Total prompts: {stats['total_prompts']}") | |
| print(f"By task type: {stats['by_task_type']}") | |
| print(f"Confidence ranges: {stats['confidence_ranges']}") | |
| def main(): | |
| """Main function to run examples""" | |
| print("๐ Advanced Multi-Model Orchestrator - Example Usage") | |
| print("=" * 70) | |
| if len(sys.argv) > 1: | |
| example_type = sys.argv[1].lower() | |
| else: | |
| print("Available examples:") | |
| print(" 1. advanced - Test with Advanced Orchestrator") | |
| print(" 2. demo - Test with Demo Orchestrator") | |
| print(" 3. custom - Custom testing scenarios") | |
| print(" 4. prompts - Prompt generation utilities") | |
| print() | |
| example_type = input("Enter example type (1-4 or name): ").strip().lower() | |
| # Map input to example functions | |
| examples = { | |
| '1': 'advanced', | |
| '2': 'demo', | |
| '3': 'custom', | |
| '4': 'prompts', | |
| 'advanced': 'advanced', | |
| 'demo': 'demo', | |
| 'custom': 'custom', | |
| 'prompts': 'prompts' | |
| } | |
| example_type = examples.get(example_type, 'custom') | |
| try: | |
| if example_type == 'advanced': | |
| success = asyncio.run(example_with_advanced_orchestrator()) | |
| elif example_type == 'demo': | |
| success = asyncio.run(example_with_demo_orchestrator()) | |
| elif example_type == 'custom': | |
| asyncio.run(example_custom_testing()) | |
| success = True | |
| elif example_type == 'prompts': | |
| asyncio.run(example_prompt_generation()) | |
| success = True | |
| else: | |
| print("โ Unknown example type. Running custom example...") | |
| asyncio.run(example_custom_testing()) | |
| success = True | |
| if success: | |
| print("\nโ Example completed successfully!") | |
| else: | |
| print("\nโ Example failed. Check the error messages above.") | |
| except KeyboardInterrupt: | |
| print("\n\nโน๏ธ Example interrupted by user") | |
| except Exception as e: | |
| print(f"\nโ Error running example: {e}") | |
| if __name__ == "__main__": | |
| main() |