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
def check_tag(src_lang: str, tgt_lang: str) -> None
Validates language codes.
Raises: ValueError if language codes are invalid
add_tag
def add_tag(sentence: str, lang: str) -> str
Adds language tag to sentence.
Example:
add_tag("Good morning!", "EN")
# Returns: "[EN] Good morning!"
printEvaluationResults
def printEvaluationResults(results: dict) -> None
Prints formatted evaluation results to console.
logger Module
File: wimarka/utils/logger.py
setup_logger
def setup_logger() -> logging.Logger
Configures and returns logger instance.
Configuration:
Format:
[LEVEL] - messageHandler: Console (stdout)
Level: INFO
Usage:
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:
import torch
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
See Also
API Reference - Complete API reference
Task Modules - Task module documentation