Utility Modules =============== Documentation for utility modules in ``wimarka/utils/`` that provide supporting functionality. Overview -------- Utility modules handle cross-cutting concerns: * **helper.py** - File I/O and language tag management * **logger.py** - Logging configuration * **model.py** - Model loading and caching * **cache.py** - Response caching * **torch.py** - PyTorch device management helper Module ------------- **File**: ``wimarka/utils/helper.py`` Functions ~~~~~~~~~ check_tag ^^^^^^^^^ .. code-block:: python def check_tag(src_lang: str, tgt_lang: str) -> None Validates language codes. **Raises**: ``ValueError`` if language codes are invalid add_tag ^^^^^^^ .. code-block:: python def add_tag(sentence: str, lang: str) -> str Adds language tag to sentence. **Example**: .. code-block:: python add_tag("Good morning!", "EN") # Returns: "[EN] Good morning!" printEvaluationResults ^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: python def printEvaluationResults(results: dict) -> None Prints formatted evaluation results to console. logger Module ------------- **File**: ``wimarka/utils/logger.py`` setup_logger ~~~~~~~~~~~~ .. code-block:: python def setup_logger() -> logging.Logger Configures and returns logger instance. **Configuration**: * Format: ``[LEVEL] - message`` * Handler: Console (stdout) * Level: INFO **Usage**: .. code-block:: python from wimarka.utils.logger import setup_logger logger = setup_logger() logger.info("Processing...") model Module ------------ **File**: ``wimarka/utils/model.py`` Model loading and management utilities. **Key Functions**: * Load models from HuggingFace Hub * Manage model cache * Handle model initialization cache Module ------------ **File**: ``wimarka/utils/cache.py`` Caching utilities for LLM responses. torch Module ------------ **File**: ``wimarka/utils/torch.py`` PyTorch device management. **Content**: .. code-block:: python import torch device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') See Also -------- * :doc:`api_reference` - Complete API reference * :doc:`tasks` - Task module documentation