Metadata-Version: 2.4
Name: amagi-weights
Version: 0.1.0
Summary: Point it at a Hugging Face model ID or a local model folder and it tells you whether you can use the weights commercially: the real license (Llama, Gemma, Qwen, Mistral and other custom licenses included), user caps, attribution and naming rules, and what the base model's license imposes on a fine-tune.
Author-email: "AmagiLabs (Amagisolutionsgroup, Inc.)" <dev@amagisolutionsgroup.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/amagilabs/amagi-weights
Keywords: llm,license,hugging-face,open-weights,llama,gemma,qwen,model-license,compliance,cli
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Dynamic: license-file

# amagi-weights

Check an open-weights model's license before you ship it. Give it a Hugging Face model, a local model folder or a `.gguf` file. It reads the license text and follows the base-model chain, then tells you whether you can use it commercially, what user or revenue caps apply, what you have to credit and how you have to name it, and whether your fine-tune's label matches the license it inherited.

Built for indie devs and small agencies who ship products on Llama, Qwen, Gemma, Mistral and similar models and can't have a lawyer read every model card.

![demo](assets/demo.gif)

## Install

```bash
pipx install amagi-weights
```

Python 3.9 or newer. No dependencies.

## Usage

Point it at a model:

```bash
amagi-weights meta-llama/Llama-3.1-8B-Instruct
amagi-weights https://huggingface.co/Qwen/Qwen2.5-72B-Instruct
amagi-weights ./my-finetune            # a local folder: README.md front matter, adapter_config.json, LICENSE
amagi-weights ./model-Q4_K_M.gguf      # GGUF metadata (general.license, general.base_model.*)
```

### A fine-tune labelled with the wrong license

`examples/my-support-bot` is a LoRA adapter on Llama 3.1 8B Instruct whose model card says `license: apache-2.0`. That label is wrong, because the Llama license stays with derivatives. A real run:

```
$ amagi-weights examples/my-support-bot
my-support-bot  (local: examples/my-support-bot)
  label:    apache-2.0  (README.md front matter)
  license:  Apache License 2.0  (from label in README.md front matter)
  lineage:
    my-support-bot: Apache License 2.0 [yes]
    +- adapter on meta-llama/Llama-3.1-8B-Instruct: Llama 3.1 Community License [conditional]
       +- fine-tune of meta-llama/Llama-3.1-8B: Llama 3.1 Community License [conditional]

  Commercial use: YES, WITH CONDITIONS
    - Llama 3.1 Community License (meta-llama/Llama-3.1-8B-Instruct, meta-llama/Llama-3.1-8B):
      Commercial use allowed under Meta's terms, with a user cap, branding and naming rules.
  Caps:
    - Over 700 million monthly active users (on the Llama 3.1 release date) you need a separate
      license from Meta.
  You must:
    - Keep the LICENSE and any NOTICE file, and mark files you changed.
    - Prominently display "Built with Llama" on a related website, user interface, blog post,
      about page or product documentation.
    - Notice file text: "Llama 3.1 is licensed under the Llama 3.1 Community License, Copyright
      © Meta Platforms, Inc. All Rights Reserved."
    - Follow the Llama 3.1 Acceptable Use Policy.
    - Ship a copy of the agreement with any copy of the weights or a derivative you distribute.
    - Training another model on Llama 3.1 outputs triggers the "Llama" naming rule if you
      distribute that model.
  Naming:
    - FAIL: the Llama 3.1 Community License needs the name to start with "Llama";
      "my-support-bot" does not.
  Conflicts (1):
    ! This model is labelled Apache License 2.0, but its base meta-llama/Llama-3.1-8B-Instruct
      is under the Llama 3.1 Community License, which stays with derivatives. Relabel it
      `license: llama3.1` and ship that license text.

  Result: NOT CLEARED

Not legal advice. Rules checked against the license texts on 2026-10-24; read the license before you ship.
```

Exit code 1. Rename it to start with "Llama", relabel it `llama3.1`, ship the license text, and it clears.

### A model you can't use commercially

```
$ amagi-weights Qwen/Qwen2.5-3B-Instruct
Qwen2.5-3B-Instruct  (Hugging Face: Qwen/Qwen2.5-3B-Instruct)
  label:    other (qwen-research)  (model card)
  license:  Qwen Research License Agreement  (from license text (LICENSE))
  lineage:
    Qwen2.5-3B-Instruct: Qwen Research License Agreement [no]
    +- fine-tune of Qwen/Qwen2.5-3B: Qwen Research License Agreement [no]

  Commercial use: NO
    - Qwen Research License Agreement (this model, Qwen/Qwen2.5-3B): Research and evaluation
      only. Commercial use needs a separate license from Alibaba Cloud.
  ...
  Result: NOT CLEARED
```

The 7B and 72B models from the same release use other licenses (Apache 2.0, and the Qwen License with a 100 million user cap). This card and the 72B card both say `license: other`; amagi-weights tells them apart by reading the LICENSE file.

### Check your numbers against the caps

```
$ amagi-weights Qwen/Qwen2.5-72B-Instruct --mau 150000000
  ...
  Commercial use: NO
    - Qwen License Agreement (this model, Qwen/Qwen2.5-72B): Commercial use allowed under
      Alibaba Cloud's terms, with a user cap and a "Built with Qwen" rule for derived models.
    - --mau 150,000,000 is over the 100,000,000 monthly active user cap in the Qwen License
      Agreement: you need a separate license.
  ...
  Result: NOT CLEARED
```

`--revenue` does the same for revenue caps, such as the Stability AI Community License's annual revenue limit.

## What it checks

- **The real license.** It identifies the license from the LICENSE file's text first and the model card's `license:` label second, and tells you when the two disagree. This catches custom licenses hidden behind `license: other` and cards whose label doesn't match the file.
- **The base-model chain.** It follows `base_model` from the Hub tags, the model card, `adapter_config.json`, GGUF metadata and `config.json`, up to 5 levels. The verdict is the strictest license anywhere in the chain.
- **Commercial use.** Yes, yes with conditions, no, or unknown.
- **Caps.** Monthly active users and revenue, with `--mau` and `--revenue` to check your own numbers.
- **What you must do.** Attribution lines, notice text, acceptable use policies, and rules about using outputs to train other models.
- **Naming rules.** Llama derivatives must start with "Llama". It checks your model's name.
- **Conflicts.** A fine-tune labelled MIT or Apache 2.0 on a Llama, Gemma or Qwen base, a share-alike base relabelled, or a RAIL base whose use restrictions were dropped.

`amagi-weights --licenses` lists the 31 licenses it knows, including Llama 2 through 4, Gemma, Qwen and Qwen Research, Mistral's MNPL and MRL, the Stability AI Community License, FLUX.1 [dev], DeepSeek, Falcon, NVIDIA Open Model, the OpenRAIL family and Creative Commons. Each one shows the date its rule was last checked against the license text.

## Options

```bash
amagi-weights MODEL [MODEL ...]           # several at once
amagi-weights MODEL --format json         # also: text (default), markdown; --json is short for json
amagi-weights MODEL --mau 50000           # your monthly active users
amagi-weights MODEL --revenue 2000000     # your annual revenue in USD
amagi-weights MODEL --strict              # also fail on conditional licenses and naming misses
amagi-weights MODEL --depth 2             # how far up the base-model chain to go (default 5)
amagi-weights MODEL --no-lineage          # only the model itself
amagi-weights ./folder --offline          # never contact Hugging Face
amagi-weights MODEL --rules mine.json     # add or override license rules
```

Gated Llama repos serve their LICENSE file without a token. Gemma repos ship no LICENSE file, so Gemma is identified from its `license: gemma` label. If a lookup says access is denied, set `HF_TOKEN` in your environment. The token is only sent to `huggingface.co` (or the host in `HF_ENDPOINT`).

## Use it in CI

Exit codes: 0 means cleared, 1 means not cleared (commercial use no or unknown, a license conflict, or a cap exceeded), 2 means a usage or lookup error. With `--strict`, conditional licenses and naming misses also exit 1.

```bash
amagi-weights ./model --mau 50000 --json > license-report.json
```

The JSON has one entry per model under `results`, each with `commercial`, `cleared`, `lineage`, `caps`, `attribution`, `conditions`, `naming`, `conflicts` and `notes`.

## Use it from Claude Code

This repo ships a skill at `.claude/skills/amagi-weights/SKILL.md`. Copy that folder into your own `.claude/skills/` and Claude Code can check a model before it suggests it, and tell you what to put in your model card.

## Limits

- It's not legal advice. It reads license texts and applies rules written from them, and it knows nothing about your contracts or how you use the model.
- The lineage is only as good as the metadata. `deepseek-ai/DeepSeek-R1-Distill-Llama-8B` is labelled MIT and lists no base model, so it comes back YES. Its model card says it is derived from Llama3.1-8B-Base, which is under the Llama 3.1 license. When a name mentions Llama, Qwen, Gemma, Mistral, Falcon or FLUX and the chain has no such model, it prints a note telling you to read the card.
- Some GGUF files carry no license. The official Qwen2.5 0.5B GGUF has no `general.license` key. Run it on the repo you downloaded it from instead.
- The built-in rules were checked against the license texts on 2026-10-24. Six rarely used ones (the BigCode, BigScience and BLOOM RAIL licenses, generic OpenRAIL, BSD 3-Clause and CC0) show "not re-checked". Licensors change terms, so read the current text before you ship.
- A license it doesn't recognise, or a tagged base model it can't fetch, makes the verdict unknown, never yes. A base named only in the card text that isn't on Hugging Face (a stale reference) is listed, left out of the verdict, and noted.

## If this saved you time

A star helps other people find it.

## More from AmagiLabs

- [amagilabs](https://github.com/amagilabs): other small open source dev tools from the same lab.
- [amagi-name-check](https://github.com/amagilabs/amagi-name-check): check a name for your next package or repo on PyPI, npm, crates.io, Homebrew, GitHub and six domain TLDs in one command.
- [amagi-env-check](https://github.com/amagilabs/amagi-env-check): compare `.env`, `.env.example` and the environment your app runs with on Vercel, Railway or Fly, without printing a value.
- [amagi-legal-review-skills](https://github.com/amagilabs/amagi-legal-review-skills): Claude Code skills for contract and lease review.

## License

MIT, see [LICENSE](LICENSE). Copyright (c) 2026 Amagisolutionsgroup, Inc. (AmagiLabs)
