pub struct FamilyRegistry { /* private fields */ }Expand description
Registry of known model families for detection.
Implementations§
Source§impl FamilyRegistry
impl FamilyRegistry
Sourcepub fn new() -> FamilyRegistry
pub fn new() -> FamilyRegistry
Create an empty registry
Sourcepub fn register(&mut self, family: Box<dyn ModelFamily>)
pub fn register(&mut self, family: Box<dyn ModelFamily>)
Register a model family
Sourcepub fn register_alias(
&mut self,
hf_pattern: &str,
parent_family: &str,
) -> Result<(), String>
pub fn register_alias( &mut self, hf_pattern: &str, parent_family: &str, ) -> Result<(), String>
Register an HF repo pattern as an alias for an existing family.
Used to unblock derived models that share the parent family’s
architecture but have different vocab/repo patterns. e.g.,
register_alias("codellama/*", "llama") lets codellama checkpoints
dispatch through the llama loader.
The pattern is a simple glob with * as suffix wildcard. Returns
Err if the parent family is not registered.
Sourcepub fn resolve_alias(&self, hf_repo: &str) -> Option<&str>
pub fn resolve_alias(&self, hf_repo: &str) -> Option<&str>
Resolve an HF repo identifier through registered aliases. Returns the parent family for the first matching alias, or None.
Sourcepub fn alias_count(&self) -> usize
pub fn alias_count(&self) -> usize
Number of registered aliases.
Sourcepub fn family_names(&self) -> Vec<&str>
pub fn family_names(&self) -> Vec<&str>
Get all registered family names
Sourcepub fn get(&self, family_name: &str) -> Option<&dyn ModelFamily>
pub fn get(&self, family_name: &str) -> Option<&dyn ModelFamily>
Look up a family by name
Sourcepub fn detect_family(&self, tensor_names: &[&str]) -> Option<&dyn ModelFamily>
pub fn detect_family(&self, tensor_names: &[&str]) -> Option<&dyn ModelFamily>
Detect model family from tensor names using best-match scoring.
Scores each family by counting how many of its expected tensor patterns (embedding + per-layer for layer 0) match the given tensor names. Returns the family with the highest score, which disambiguates families with overlapping naming conventions (e.g., Qwen2’s bias tensors distinguish it from LLaMA/DeepSeek/Mistral which share the same base naming but lack bias patterns).
Sourcepub fn detect_from_model_type(
&self,
model_type: &str,
) -> Option<&dyn ModelFamily>
pub fn detect_from_model_type( &self, model_type: &str, ) -> Option<&dyn ModelFamily>
Detect model family from HuggingFace model_type string.
Sourcepub fn detect_from_config_str(body: &str) -> Option<&'static str>
pub fn detect_from_config_str(body: &str) -> Option<&'static str>
Detect model family from a raw HF config.json body string.
Uses discriminator-field-based dispatch in priority order, mirroring
the apr-cookbook architecture-demos detector recipe. Falls through
to LlamaForCausalLM as the catch-all for transformer configs that
don’t match anything more specific.
Returns the family name (e.g. “llama”, “qwen2”, “phi”) if a
discriminator matches, or None if the config is unrecognized.
Use get(name) to obtain the registered family object after detection.
This is the high-level entry point most callers want — detect_family
requires already-parsed tensor names; detect_from_config_str works
directly off the JSON body and surfaces all 18 supported families.
Sourcepub fn supported_families() -> Vec<&'static str>
pub fn supported_families() -> Vec<&'static str>
All 18 supported family names tracked by the detector dispatch.
Trait Implementations§
Source§impl Debug for FamilyRegistry
impl Debug for FamilyRegistry
Source§impl Default for FamilyRegistry
impl Default for FamilyRegistry
Source§fn default() -> FamilyRegistry
fn default() -> FamilyRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for FamilyRegistry
impl !UnwindSafe for FamilyRegistry
impl Freeze for FamilyRegistry
impl Send for FamilyRegistry
impl Sync for FamilyRegistry
impl Unpin for FamilyRegistry
impl UnsafeUnpin for FamilyRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more