binomial-shannon-2 / configuration_shannon2.py
ilayibrahimzadeh's picture
Publish binomial-shannon v2
c24924a verified
Raw
History Blame Contribute Delete
2.72 kB
"""Configuration class for binomial-shannon-2 (router + ticker + macro).
Ships with the model on HuggingFace Hub so
`AutoConfig.from_pretrained(repo, trust_remote_code=True)` works.
"""
from __future__ import annotations
from transformers.configuration_utils import PretrainedConfig
# Ticker mode (Shannon-1 schema)
EVENTS = (
"earnings", "guidance", "m_and_a", "regulatory_legal", "product",
"exec_change", "dividend_buyback", "analyst_rating", "macro_sector", "other",
)
CLAIM_TYPES = ("fact", "opinion", "rumor", "forecast")
# Macro mode
TOPICS = (
"monetary_policy", "fiscal_policy", "inflation", "growth", "labor",
"rates_fixed_income", "equities_markets", "fx_currency", "energy",
"commodities", "credit_banking", "crypto", "mergers_acquisitions",
"trade_policy", "geopolitics", "single_company", "technicals", "other",
)
SEVERITY_BUCKETS = ("noise", "minor", "notable", "major", "crisis")
NOVELTY_BUCKETS_MACRO = ("rehash", "commentary", "breaking")
CLAIM_TYPES_MACRO = ("fact", "opinion", "rumor", "forecast")
HAWKISH_DOVISH_BUCKETS = (
"dovish", "mildly_dovish", "neutral", "mildly_hawkish", "hawkish",
)
class Shannon2Config(PretrainedConfig):
"""Config for Shannon2MultiHead.
Shared encoder + 2-way router + ticker head bank (19 outputs, inherited
from shannon-1) + macro head bank (35 outputs). Mirrors shannon-1's hub
configuration approach.
"""
model_type = "shannon2"
def __init__(
self,
encoder_name_or_path: str = "answerdotai/ModernBERT-base",
max_position_embeddings: int = 4096,
head_h1: int = 512,
head_h2: int = 256,
dropout: float = 0.1,
events: tuple[str, ...] = EVENTS,
claim_types: tuple[str, ...] = CLAIM_TYPES,
topics: tuple[str, ...] = TOPICS,
severity_buckets: tuple[str, ...] = SEVERITY_BUCKETS,
novelty_buckets_macro: tuple[str, ...] = NOVELTY_BUCKETS_MACRO,
claim_types_macro: tuple[str, ...] = CLAIM_TYPES_MACRO,
hawkish_dovish_buckets: tuple[str, ...] = HAWKISH_DOVISH_BUCKETS,
**kwargs,
) -> None:
super().__init__(**kwargs)
self.encoder_name_or_path = encoder_name_or_path
self.max_position_embeddings = max_position_embeddings
self.head_h1 = head_h1
self.head_h2 = head_h2
self.dropout = dropout
self.events = list(events)
self.claim_types = list(claim_types)
self.topics = list(topics)
self.severity_buckets = list(severity_buckets)
self.novelty_buckets_macro = list(novelty_buckets_macro)
self.claim_types_macro = list(claim_types_macro)
self.hawkish_dovish_buckets = list(hawkish_dovish_buckets)