Skip to main content

FamilyRegistry

Struct FamilyRegistry 

Source
pub struct FamilyRegistry { /* private fields */ }
Expand description

Registry of known model families for detection.

Implementations§

Source§

impl FamilyRegistry

Source

pub fn new() -> FamilyRegistry

Create an empty registry

Source

pub fn register(&mut self, family: Box<dyn ModelFamily>)

Register a model family

Source

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.

Source

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.

Source

pub fn alias_count(&self) -> usize

Number of registered aliases.

Source

pub fn family_names(&self) -> Vec<&str>

Get all registered family names

Source

pub fn get(&self, family_name: &str) -> Option<&dyn ModelFamily>

Look up a family by name

Source

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).

Source

pub fn detect_from_model_type( &self, model_type: &str, ) -> Option<&dyn ModelFamily>

Detect model family from HuggingFace model_type string.

Source

pub fn len(&self) -> usize

Number of registered families

Source

pub fn is_empty(&self) -> bool

Check if registry is empty

Source

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.

Source

pub fn supported_families() -> Vec<&'static str>

All 18 supported family names tracked by the detector dispatch.

Trait Implementations§

Source§

impl Debug for FamilyRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for FamilyRegistry

Source§

fn default() -> FamilyRegistry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,