Skip to main content

Collection of utilities for AI/ML model analysis and processing

Project description

dolphin-utils

A collection of utilities for AI/ML model analysis and processing.

dolphin-summarize

This tool analyzes safetensors model files to generate a condensed summary of the model's architecture. It groups similar parameter names using range notation (e.g., model.layers.[0-39].mlp.down_proj.weight) and displays the shape and data type (precision) for each parameter group.

Key Features:

  • Remote Processing: Analyze Hugging Face models without downloading the full model files (downloads only headers - KB instead of GB)
  • Local Processing: Works with locally stored model directories
  • Efficient: Uses HTTP range requests and streaming to minimize data transfer
  • Reliable: Multiple fallback strategies ensure 100% compatibility

Dependencies

  • Python 3
  • huggingface_hub and requests (Required for remote processing):
    pip install huggingface_hub requests
    
  • safetensors (Optional, but recommended for full shape extraction capabilities):
    pip install safetensors
    

Or install all dependencies:

pip install -r requirements.txt

Usage

After installing the package:

pip install dolphin-utils

You can use the tool in two ways:

Via CLI command:

dolphin-summarize [MODEL_PATH_OR_REPO_ID] [OPTIONS]

Via Python module:

python -m dolphin_summarize [MODEL_PATH_OR_REPO_ID] [OPTIONS]

Arguments:

  • MODEL_PATH_OR_REPO_ID:
    • Local path: Directory containing safetensors files (e.g., ~/models/my_llama_model)
    • Hugging Face repo ID: Repository identifier (e.g., microsoft/DialoGPT-medium)
    • Defaults to current directory (.) if not provided

Options:

  • --output OUTPUT, -o OUTPUT: Path to an output file where the summary will be written (optional).
  • --verbose, -v: Show verbose output during processing (optional).

Examples

Remote Processing (Hugging Face Hub):

# Process a model directly from Hugging Face without downloading
python -m dolphin_summarize microsoft/DialoGPT-medium --verbose

# Large models work too - only headers are downloaded
python -m dolphin_summarize meta-llama/Llama-2-70b-hf --verbose

Local Processing:

# Process a local model directory
python -m dolphin_summarize ~/models/my_llama_model --verbose

# Process current directory
python -m dolphin_summarize . --verbose

Output Format

The script prints the summary to the console (and optionally to a file). Each line represents a parameter or a group of parameters with a similar structure:

parameter_name,[shape],dtype

Example Output Lines:

lm_head.weight,[131072,5120],BF16
model.embed_tokens.weight,[131072,5120],BF16
model.layers.[0-39].input_layernorm.weight,[5120],BF16
model.layers.[0-39].mlp.down_proj.weight,[5120,13824],BF16
model.layers.[0-39].mlp.gate_proj.weight,[13824,5120],BF16
model.layers.[0-39].mlp.up_proj.weight,[13824,5120],BF16
model.layers.[0-39].post_attention_layernorm.weight,[5120],BF16
model.layers.[0-39].self_attn.k_proj.weight,[512,5120],BF16
model.layers.[0-39].self_attn.o_proj.weight,[5120,8192],BF16
model.layers.[0-39].self_attn.q_proj.weight,[8192,5120],BF16
model.layers.[0-39].self_attn.v_proj.weight,[512,5120],BF16
model.norm.weight,[5120],BF16

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dolphin_utils-0.4.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dolphin_utils-0.4.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file dolphin_utils-0.4.0.tar.gz.

File metadata

  • Download URL: dolphin_utils-0.4.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/8.5.0 pkginfo/1.12.1.2 requests/2.32.4 requests-toolbelt/1.0.0 tqdm/4.67.1 CPython/3.12.2

File hashes

Hashes for dolphin_utils-0.4.0.tar.gz
Algorithm Hash digest
SHA256 a63be7437ebb3caf651490aca119cdf97143b9142298c9d8457ba7d96bc0fabd
MD5 ec268b3b2dd92ad3713e611f9deeabaf
BLAKE2b-256 1183e09e15b5d886ed438154d01bd2a63fdcaebb13bc29347f66a8621bdb8229

See more details on using hashes here.

File details

Details for the file dolphin_utils-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: dolphin_utils-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/8.5.0 pkginfo/1.12.1.2 requests/2.32.4 requests-toolbelt/1.0.0 tqdm/4.67.1 CPython/3.12.2

File hashes

Hashes for dolphin_utils-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73a5af159c4c5fb1315270d01488de85b94f2a83753eaed0f4707ace77ecfd28
MD5 516a87194bfbdf00c44427999bf59e14
BLAKE2b-256 643fa97ba9deb8c47f3e5e3fc8f238390200216011ac99e97eb25ab8fae3e272

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page