saladday1's picture
code: sync from git
ff88a82 verified
Raw History Blame Contribute Delete
4.38 kB
"""MiniMax language models: Text-01, VL-01, M1, M2, M2.1, M2.5, M2.7, M3, M3.1-Flash.
Facts these rules rely on (checked 2026-11-20 against the official config.json files):
- Four layouts. Text-01 and M1 share one (model_type minimax_text_01 / minimax_m1, both
`minimax` in the transformers port; hidden 6144, 80 layers, 32 experts); VL-01 wraps it
(minimax_vl_01). M2, M2.1, M2.5 and M2.7 share minimax_m2 (hidden 3072, 62 layers, 256
experts). M3 and M3.1-Flash share minimax_m3_vl (hidden 6144, 60 layers, 128 experts).
GGUF headers call them minimax-m2 / minimax-m3.
- So the layout says which line a repo is built on, not which release: within a line it is
the declared base_model, the GGUF header (general.name / base_model), the repo name, the
card and the creation date (a repo cannot be built on a release that came out after it).
- Pruning experts (REAP) keeps the hidden size, so it stays a derivative; toy test models
reuse the architecture at a different hidden size and are left out, as are models
distilled from our outputs into another architecture (their config names that one).
- The Hub tags every repo with its model_type, so the architecture tags find derivatives
whatever they are called.
"""
import re
from ..family import Arch, Family, Member
ORG = "MiniMaxAI/"
END = r"(?![._]?\d)" # "M2" is not "M2.5" or "M25"
# lineage, official repos, how the release is written in names (after "MiniMax" in cards)
RELEASES = [
("Text-01", ["MiniMax-Text-01", "MiniMax-Text-01-hf"], r"text[-_ ]?0?1|0?1[-_ ]?text"),
("VL-01", ["MiniMax-VL-01"], r"vl[-_ ]?0?1"),
("M1", ["MiniMax-M1-80k", "MiniMax-M1-40k", "MiniMax-M1-80k-hf", "MiniMax-M1-40k-hf"], r"m1"),
("M2", ["MiniMax-M2"], r"m2(?!-[157](?!\d))"), # "M2-5" is M2.5
("M2.1", ["MiniMax-M2.1"], r"m2[-._]1"),
("M2.5", ["MiniMax-M2.5"], r"m2[-._]5"),
("M2.7", ["MiniMax-M2.7"], r"m2[-._]7"),
("M3", ["MiniMax-M3", "MiniMax-M3-MXFP8"], r"m3(?![-_ ]?flash|-1(?!\d))"),
("M3.1-Flash", ["MiniMax-M3.1-Flash"], r"m3(?:[-._]1)?[-_ ]?flash|m3[-._]1"),
]
def in_name(tok):
"""The release on its own in a repo name, also glued to the family ("MiniMaxM2")."""
return re.compile(rf"(?:(?<![a-z0-9])|(?<=minimax))(?:{tok}){END}", re.I)
def in_text(tok):
"""The release in prose or a GGUF header: only with "MiniMax" in front ("runs on an M3 Max")."""
return re.compile(rf"minimax[-_ ]?(?:{tok}){END}", re.I)
ADD_ON = re.compile(r"eagle|specul|aurora[-_ ]?spec|dspark|dflash|draft|\bmtp\b|mmproj|vision|control[-_ ]?vectors?", re.I)
FAMILY_TEXT = re.compile(r"minimax[-_ ]?(?:m[123]|text[-_ ]?0?1|0?1[-_ ]?text|vl[-_ ]?0?1)", re.I)
FAMILY = Family(
key="m",
title="MiniMax 语言模型",
members=[Member(lin, ORG + repos[0], "text", in_name(tok), also=tuple(ORG + r for r in repos[1:]))
for lin, repos, tok in RELEASES],
default_member=None, # "MiniMax" alone does not say which release
name_queries=["minimax"],
fulltext_queries=[], # benchmark tables everywhere mention M2 / M3; tags and names suffice
tag_filters=["minimax_m2", "minimax_m3_vl", "minimax_m1", "minimax_text_01", "minimax_vl_01"],
family_text=FAMILY_TEXT,
name_hint=FAMILY_TEXT,
own_llm=True,
archs=[
Arch(("M2", "M2.1", "M2.5", "M2.7"), re.compile(r"minimax[-_]?m2", re.I), 3072),
Arch(("M3", "M3.1-Flash"), re.compile(r"minimax[-_]?m3", re.I), 6144),
Arch(("VL-01",), re.compile(r"minimax[-_]?vl[-_]?0?1", re.I), 6144),
Arch(("M1",), re.compile(r"minimax[-_]?m1", re.I), 6144),
Arch(("Text-01",), re.compile(r"minimax[-_]?(?:text[-_]?)?0?1", re.I), 6144),
# the transformers port calls both "minimax"
Arch(("Text-01", "M1"), re.compile(r"\bminimax\b(?![-_])|MiniMaxForCausalLM", re.I), 6144),
],
# parts made for a release rather than from its weights: draft models for speculative decoding,
# the vision tower and its GGUF projector, control vectors
text_component=ADD_ON,
text_component_why="是给它配套的草稿模型(投机解码)",
component_names=ADD_ON,
card_rules=[(in_text(tok), lin, 1, f"模型卡提到 MiniMax-{lin}", False) for lin, _, tok in RELEASES],
header_rules=[(in_text(tok), lin, f"GGUF 文件头写明转自 MiniMax-{lin}") for lin, _, tok in RELEASES],
)