Download __init__.py from PowerMachine/CNN-BiGRU: direct link, hf CLI and curl.
- Browser
- Download file 6.74 kB
-
https://huggingface.co/PowerMachine/CNN-BiGRU/resolve/9f36e33eb4d0738c577cd3ca5efdfa0bce66c2ea/__init__.py
- Command line
-
hf download hf://PowerMachine/CNN-BiGRU@9f36e33eb4d0738c577cd3ca5efdfa0bce66c2ea/__init__.py
-
curl -L -o __init__.py https://huggingface.co/PowerMachine/CNN-BiGRU/resolve/9f36e33eb4d0738c577cd3ca5efdfa0bce66c2ea/__init__.py
6.74 kB
| """ | |
| CNN-BiGRU — Modelo Multimodal Cooperativo Autoaprendível (v2.0) | |
| Implementação completa de um LLM multimodal com arquitetura CNN-BiGRU cooperativa: | |
| - Núcleo dual-stream CNN-BiGRU com 3 níveis de pontes (cross-attention, gated cells, fusão) | |
| - Encoders multimodais (imagem + áudio) com fusão gated | |
| - Gerador + Verificador + Camada anti-alucinação (lógica fuzzy de Łukasiewicz) | |
| - Auto-aprendizado: ajuste dinâmico de LR, spectral norm, orthogonal init | |
| - Hipóteses ativadas por punições (Gumbel-Softmax diferenciável) | |
| - Synergy search (N tentativas de combinação de hiperparâmetros) | |
| - Múltiplas funções de perda: L_G, L_V, L_AH, L_reg, L_EWC | |
| NOVO v2.0: | |
| - EWC (Elastic Weight Consolidation) para aprendizado contínuo | |
| - Context Window com cache KV (sliding window + sink) | |
| - RoPE (Rotary Position Embeddings) | |
| - TransformerBlock (CausalSelfAttention + FFN) | |
| - Self-attention final layer verdadeira (CLS-token + multi-head) | |
| - Weight tying opcional | |
| - Inferência autoregressiva REAL via GeneratorCNNBiGRU | |
| """ | |
| from __future__ import annotations | |
| __version__ = "2.0.0" | |
| __author__ = "CNN-BiGRU Project" | |
| # Versão e metadados | |
| __all__ = [ | |
| "__version__", | |
| "__author__", | |
| # Tokenizer | |
| "BBPETokenizer", | |
| # Utils | |
| "MemoryOptimizer", | |
| "SemanticEmbedder", | |
| "EWCConfig", | |
| "EWCState", | |
| # Runtime | |
| "optimize_xeon_environment", | |
| "get_runtime_info", | |
| # Data | |
| "MultimodalStreamingDataset", | |
| "collate_multimodal", | |
| # Models | |
| "CooperativeCNNBiGRU", | |
| "MultimodalCNNBiGRU", | |
| "ImageEncoder", | |
| "AudioEncoder", | |
| "MultimodalFusion", | |
| "GeneratorCNNBiGRU", | |
| "VerifierCNNBiGRU", | |
| "AntiHallucinationLayer", | |
| "RotaryPositionEmbedding", | |
| "CausalSelfAttention", | |
| "TransformerBlock", | |
| "TransformerDecoderStack", | |
| "KVCache", | |
| "ContextWindowManager", | |
| "ContextWindowConfig", | |
| # Losses | |
| "LossConfig", | |
| "MultiLoss", | |
| # Training | |
| "TrainerConfig", | |
| "CooperativeTrainer", | |
| "AutoLearnConfig", | |
| "AutoLearner", | |
| "HypothesisConfig", | |
| "HypothesisController", | |
| "SynergySearcher", | |
| # Inference | |
| "generate_with_sampling", | |
| "evaluate_perplexity", | |
| ] | |
| # Lazy imports — apenas quando acessado | |
| def __getattr__(name: str): | |
| if name in ("BBPETokenizer",): | |
| from .tokenizer.bbpe_tokenizer import BBPETokenizer | |
| return BBPETokenizer | |
| if name in ("MemoryOptimizer",): | |
| from .utils.memory_optimizer import MemoryOptimizer | |
| return MemoryOptimizer | |
| if name in ("SemanticEmbedder",): | |
| from .utils.semantic_embeddings import SemanticEmbedder | |
| return SemanticEmbedder | |
| if name in ("EWCConfig", "EWCState"): | |
| from .utils.ewc import EWCConfig, EWCState | |
| if name == "EWCConfig": | |
| return EWCConfig | |
| return EWCState | |
| if name in ("optimize_xeon_environment", "get_runtime_info"): | |
| from .utils import xeon_runtime | |
| if name == "optimize_xeon_environment": | |
| return xeon_runtime.optimize_xeon_environment | |
| return xeon_runtime.get_runtime_info | |
| if name in ("MultimodalStreamingDataset", "collate_multimodal"): | |
| from .data.streaming_dataset import MultimodalStreamingDataset, collate_multimodal | |
| if name == "MultimodalStreamingDataset": | |
| return MultimodalStreamingDataset | |
| return collate_multimodal | |
| if name == "CooperativeCNNBiGRU": | |
| from .models.cooperative_bigru import CooperativeCNNBiGRU | |
| return CooperativeCNNBiGRU | |
| if name == "MultimodalCNNBiGRU": | |
| from .models.multimodal_model import MultimodalCNNBiGRU | |
| return MultimodalCNNBiGRU | |
| if name in ("ImageEncoder", "AudioEncoder", "MultimodalFusion"): | |
| from .models.multimodal_encoders import ImageEncoder, AudioEncoder, MultimodalFusion | |
| if name == "ImageEncoder": | |
| return ImageEncoder | |
| if name == "AudioEncoder": | |
| return AudioEncoder | |
| return MultimodalFusion | |
| if name in ("GeneratorCNNBiGRU", "VerifierCNNBiGRU", "AntiHallucinationLayer"): | |
| from .models.generator_verifier import ( | |
| GeneratorCNNBiGRU, | |
| VerifierCNNBiGRU, | |
| AntiHallucinationLayer, | |
| ) | |
| if name == "GeneratorCNNBiGRU": | |
| return GeneratorCNNBiGRU | |
| if name == "VerifierCNNBiGRU": | |
| return VerifierCNNBiGRU | |
| return AntiHallucinationLayer | |
| if name == "RotaryPositionEmbedding": | |
| from .models.rope import RotaryPositionEmbedding | |
| return RotaryPositionEmbedding | |
| if name in ("CausalSelfAttention", "TransformerBlock", "TransformerDecoderStack"): | |
| from .models.transformer_block import ( | |
| CausalSelfAttention, | |
| TransformerBlock, | |
| TransformerDecoderStack, | |
| ) | |
| if name == "CausalSelfAttention": | |
| return CausalSelfAttention | |
| if name == "TransformerBlock": | |
| return TransformerBlock | |
| return TransformerDecoderStack | |
| if name in ("KVCache", "ContextWindowManager", "ContextWindowConfig"): | |
| from .models.context_window import KVCache, ContextWindowManager, ContextWindowConfig | |
| if name == "KVCache": | |
| return KVCache | |
| if name == "ContextWindowManager": | |
| return ContextWindowManager | |
| return ContextWindowConfig | |
| if name in ("LossConfig", "MultiLoss"): | |
| from .losses.losses import LossConfig, MultiLoss | |
| if name == "LossConfig": | |
| return LossConfig | |
| return MultiLoss | |
| if name in ("TrainerConfig", "CooperativeTrainer"): | |
| from .training.trainer import TrainerConfig, CooperativeTrainer | |
| if name == "TrainerConfig": | |
| return TrainerConfig | |
| return CooperativeTrainer | |
| if name in ("AutoLearnConfig", "AutoLearner"): | |
| from .training.auto_learner import AutoLearnConfig, AutoLearner | |
| if name == "AutoLearnConfig": | |
| return AutoLearnConfig | |
| return AutoLearner | |
| if name in ("HypothesisConfig", "HypothesisController", "SynergySearcher"): | |
| from .training.hypothesis_controller import ( | |
| HypothesisConfig, | |
| HypothesisController, | |
| SynergySearcher, | |
| ) | |
| if name == "HypothesisConfig": | |
| return HypothesisConfig | |
| if name == "HypothesisController": | |
| return HypothesisController | |
| return SynergySearcher | |
| if name in ("generate_with_sampling", "evaluate_perplexity"): | |
| from .inference.inference import generate_with_sampling, evaluate_perplexity | |
| if name == "generate_with_sampling": | |
| return generate_with_sampling | |
| return evaluate_perplexity | |
| raise AttributeError(f"module {__name__!r} has no attribute {name!r}") | |