Text Generation
Transformers
PyTorch
chemistry
biology
finance
legal
music
art
code
climate
medical
text-generation-inference
Merge
Mixture of Experts
Instructions to use ZeppelinCorp/Charm_10 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ZeppelinCorp/Charm_10 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ZeppelinCorp/Charm_10")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ZeppelinCorp/Charm_10", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ZeppelinCorp/Charm_10 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ZeppelinCorp/Charm_10" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ZeppelinCorp/Charm_10", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ZeppelinCorp/Charm_10
- SGLang
How to use ZeppelinCorp/Charm_10 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 "ZeppelinCorp/Charm_10" \ --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": "ZeppelinCorp/Charm_10", "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 "ZeppelinCorp/Charm_10" \ --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": "ZeppelinCorp/Charm_10", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ZeppelinCorp/Charm_10 with Docker Model Runner:
docker model run hf.co/ZeppelinCorp/Charm_10
| import gc | |
| import psutil | |
| import numpy as np | |
| import torch | |
| import logging | |
| class MemoryManager: | |
| def __init__(self): | |
| self.allocated_memory = 0 | |
| self.max_memory_limit = psutil.virtual_memory().total * 0.8 # 80% of total RAM | |
| logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") | |
| def optimize_allocation(self): | |
| """Free up unused memory.""" | |
| gc.collect() | |
| if torch.cuda.is_available(): | |
| torch.cuda.empty_cache() | |
| logging.info("Memory optimization completed.") | |
| def allocate_memory(self, size, dtype=np.float32): | |
| """Allocate memory for a given size and data type.""" | |
| if self.allocated_memory + size > self.max_memory_limit: | |
| logging.warning("Memory limit exceeded. Optimizing memory...") | |
| self.optimize_allocation() | |
| self.allocated_memory += size | |
| logging.info(f"Allocated {size} bytes of memory. Total allocated: {self.allocated_memory} bytes.") | |
| return np.zeros(size, dtype=dtype) | |
| def deallocate_memory(self, obj): | |
| """Deallocate memory for a given object.""" | |
| del obj | |
| self.optimize_allocation() | |
| logging.info("Object deallocated and memory optimized.") | |
| def monitor_usage(self): | |
| """Monitor system memory usage and optimize if necessary.""" | |
| usage = psutil.virtual_memory().percent | |
| if usage > 85: | |
| logging.warning(f"High memory usage detected: {usage}%. Optimizing memory...") | |
| self.optimize_allocation() | |
| def adaptive_caching(self, model): | |
| """Disable gradients for large models to reduce memory usage.""" | |
| model_size = sum(p.numel() for p in model.parameters() if p.requires_grad) | |
| if model_size * 4 > self.max_memory_limit: # 4 bytes per float32 | |
| for param in model.parameters(): | |
| param.requires_grad = False | |
| logging.info("Adaptive caching applied: Gradients disabled for large model.") | |
| return model | |
| def __enter__(self): | |
| """Context manager entry point.""" | |
| return self | |
| def __exit__(self, exc_type, exc_val, exc_tb): | |
| """Context manager exit point.""" | |
| self.optimize_allocation() | |
| logging.info("MemoryManager context exited. Memory optimized.") | |
| # Example usage | |
| if __name__ == "__main__": | |
| memory_manager = MemoryManager() | |
| # Allocate memory | |
| array = memory_manager.allocate_memory(1000000) # 1 million elements | |
| print(array.shape) | |
| # Deallocate memory | |
| memory_manager.deallocate_memory(array) | |
| # Monitor usage | |
| memory_manager.monitor_usage() | |
| # Adaptive caching for a model | |
| model = torch.nn.Linear(1000, 1000) | |
| model = memory_manager.adaptive_caching(model) | |
| # Using context manager | |
| with MemoryManager() as mm: | |
| array = mm.allocate_memory(1000000) | |
| print(array.shape) |