OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Models

Optipfair

Optipfair is an open-source Python library for analyzing and compressing large language models. It assesses layer importance, supports depth pruning that removes transformer layers and width pruning that reduces MLP neuron counts, and provides knowledge distillation to train a pruned student model against a teacher.

Independent OpenViST project profile, based on linked sources.

Optipfair — OpenViST project profile in AI Models.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use Optipfair when you want a Python workflow to analyze layer importance and experiment with depth or width pruning, optionally followed by distillation to recover performance.

Who it is for

  • Practitioners experimenting with structured compression of transformer language models.
  • Researchers comparing model structure and performance before and after pruning.
  • Developers seeking a composable Python workflow for pruning followed by knowledge distillation.

Documented uses

  • Estimate which model layers contribute least using a model and dataloader.
  • Remove selected transformer layers or reduce MLP neuron counts.
  • Fine-tune a pruned student model against a teacher with task and logits losses.
  • Explore fairness or bias analysis using the optional visualization dependencies.
Before you choose

Requirements & limits

The repository is public and identifies Optipfair as open source under the Apache-2.0 license. The README provides pip installation instructions.

  • Depth pruning removes complete layers; width pruning reduces neuron counts within MLP layers.
  • The project recommends knowledge distillation after aggressive pruning, but distillation is optional.
  • Layer analysis requires a model and dataloader; distillation requires a student model, teacher model and training dataloader.
  • The README reports benchmark results for a specific Qwen3.5-0.8B-Base experiment, which should not be treated as a prediction for other models or datasets.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Install Optipfair for pruning and distillation

Install the library, with the optional visualization dependency used for bias analysis.

Before you start

  • Python package installation with pip.

Steps

  1. Install the core package with the command below.

    Documented command
    pip install optipfair
  2. For visualization dependencies used in bias analysis, install the command below.

    Documented command
    pip install optipfair[viz]

Expected outcome

The Optipfair package is installed, with visualization dependencies included if the optional extra was selected.

Guide limitations

  • The installation instructions do not specify Python or dependency version requirements.
  • Installation alone does not perform model analysis, pruning or distillation.
Source-based practical guide

Analyze layer importance and prune a model

Use layer-importance scores to select layers for depth pruning.

Before you start

  • A model and dataloader to pass to analyze_layer_importance.
  • Optipfair installed and imported as optipfair.

Steps

  1. Call optipfair.analyze_layer_importance(model, dataloader) to obtain layer-importance scores.

  2. Sort the returned scores and select the indices of the least important layers.

  3. Pass the selected indices to optipfair.prune_model with pruning_type="DEPTH".

Expected outcome

A model with the selected transformer layers removed; the README example also requests pruning statistics.

Guide limitations

  • The README does not define a universal layer-selection threshold or guarantee the resulting model’s performance.
  • The recipe covers depth pruning; it does not include distillation or deployment.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
14 October 2026
Original website title
peremartra/optipfair · Official homepage title · retained in its source language