giga-embeddings-mlx 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- giga_embeddings_mlx-0.1.0/.github/workflows/ci.yml +62 -0
- giga_embeddings_mlx-0.1.0/.github/workflows/publish-to-pypi.yml +61 -0
- giga_embeddings_mlx-0.1.0/.gitignore +18 -0
- giga_embeddings_mlx-0.1.0/CHANGELOG.md +30 -0
- giga_embeddings_mlx-0.1.0/CITATION.cff +34 -0
- giga_embeddings_mlx-0.1.0/CONTRIBUTING.md +45 -0
- giga_embeddings_mlx-0.1.0/LICENSE +22 -0
- giga_embeddings_mlx-0.1.0/PKG-INFO +279 -0
- giga_embeddings_mlx-0.1.0/README.md +230 -0
- giga_embeddings_mlx-0.1.0/README.ru.md +228 -0
- giga_embeddings_mlx-0.1.0/SECURITY.md +28 -0
- giga_embeddings_mlx-0.1.0/THIRD_PARTY_NOTICES.md +44 -0
- giga_embeddings_mlx-0.1.0/docs/EVALUATION.md +122 -0
- giga_embeddings_mlx-0.1.0/docs/benchmarks/0826-results.json +252 -0
- giga_embeddings_mlx-0.1.0/docs/benchmarks/0826-results.md +55 -0
- giga_embeddings_mlx-0.1.0/hf_cards/.gitattributes +4 -0
- giga_embeddings_mlx-0.1.0/hf_cards/10b-a1.8b-q8/README.md +86 -0
- giga_embeddings_mlx-0.1.0/hf_cards/10b-a1.8b-q8/README.ru.md +86 -0
- giga_embeddings_mlx-0.1.0/hf_cards/3b-q8/README.md +80 -0
- giga_embeddings_mlx-0.1.0/hf_cards/3b-q8/README.ru.md +79 -0
- giga_embeddings_mlx-0.1.0/hf_cards/480m-q8/README.md +80 -0
- giga_embeddings_mlx-0.1.0/hf_cards/480m-q8/README.ru.md +80 -0
- giga_embeddings_mlx-0.1.0/pyproject.toml +80 -0
- giga_embeddings_mlx-0.1.0/scripts/benchmark_load.py +67 -0
- giga_embeddings_mlx-0.1.0/scripts/benchmark_speed.py +148 -0
- giga_embeddings_mlx-0.1.0/scripts/build_parity_corpus.py +180 -0
- giga_embeddings_mlx-0.1.0/scripts/create_artifact_manifest.py +67 -0
- giga_embeddings_mlx-0.1.0/scripts/evaluate_backend_holdout.py +218 -0
- giga_embeddings_mlx-0.1.0/scripts/evaluate_downstream.py +176 -0
- giga_embeddings_mlx-0.1.0/scripts/evaluate_holdout.py +283 -0
- giga_embeddings_mlx-0.1.0/scripts/evaluate_parity.py +399 -0
- giga_embeddings_mlx-0.1.0/scripts/evaluate_revision3_acceptance.py +304 -0
- giga_embeddings_mlx-0.1.0/scripts/evaluate_vector_compression.py +230 -0
- giga_embeddings_mlx-0.1.0/scripts/quant_quality.py +176 -0
- giga_embeddings_mlx-0.1.0/scripts/router_trace.py +157 -0
- giga_embeddings_mlx-0.1.0/scripts/router_trace_reference.py +83 -0
- giga_embeddings_mlx-0.1.0/scripts/structural_check.py +66 -0
- giga_embeddings_mlx-0.1.0/src/giga_embeddings_mlx/__init__.py +15 -0
- giga_embeddings_mlx-0.1.0/src/giga_embeddings_mlx/_version.py +1 -0
- giga_embeddings_mlx-0.1.0/src/giga_embeddings_mlx/cli.py +122 -0
- giga_embeddings_mlx-0.1.0/src/giga_embeddings_mlx/conversion.py +75 -0
- giga_embeddings_mlx-0.1.0/src/giga_embeddings_mlx/deepseek_v3_bidirectional.py +200 -0
- giga_embeddings_mlx-0.1.0/src/giga_embeddings_mlx/dev_cli.py +40 -0
- giga_embeddings_mlx-0.1.0/src/giga_embeddings_mlx/loading.py +194 -0
- giga_embeddings_mlx-0.1.0/src/giga_embeddings_mlx/models.py +99 -0
- giga_embeddings_mlx-0.1.0/src/giga_embeddings_mlx/pooling.py +38 -0
- giga_embeddings_mlx-0.1.0/src/giga_embeddings_mlx/prompting.py +7 -0
- giga_embeddings_mlx-0.1.0/src/giga_embeddings_mlx/qwen3_bidirectional.py +85 -0
- giga_embeddings_mlx-0.1.0/src/giga_embeddings_mlx/server.py +111 -0
- giga_embeddings_mlx-0.1.0/tests/test_cli.py +25 -0
- giga_embeddings_mlx-0.1.0/tests/test_loading.py +75 -0
- giga_embeddings_mlx-0.1.0/tests/test_models.py +39 -0
- giga_embeddings_mlx-0.1.0/tests/test_server.py +76 -0
- giga_embeddings_mlx-0.1.0/tools/build_release_benchmarks.py +324 -0
- giga_embeddings_mlx-0.1.0/tools/prepare_hf_release.py +193 -0
- giga_embeddings_mlx-0.1.0/tools/verify_hf_staging.py +127 -0
- giga_embeddings_mlx-0.1.0/uv.lock +2239 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
behavior-and-package:
|
|
13
|
+
name: Python ${{ matrix.python-version }}
|
|
14
|
+
runs-on: macos-14
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
python-version: ["3.12", "3.13"]
|
|
19
|
+
steps:
|
|
20
|
+
- name: Check out source
|
|
21
|
+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
22
|
+
|
|
23
|
+
- name: Set up Python
|
|
24
|
+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
|
|
25
|
+
with:
|
|
26
|
+
python-version: ${{ matrix.python-version }}
|
|
27
|
+
cache: pip
|
|
28
|
+
|
|
29
|
+
- name: Install package, server, and release tooling
|
|
30
|
+
run: python -m pip install --disable-pip-version-check '.[dev,server]'
|
|
31
|
+
|
|
32
|
+
- name: Check formatting and lint
|
|
33
|
+
run: |
|
|
34
|
+
ruff format --check .
|
|
35
|
+
ruff check .
|
|
36
|
+
|
|
37
|
+
- name: Run behavior tests
|
|
38
|
+
run: pytest -q
|
|
39
|
+
|
|
40
|
+
- name: Build wheel and source distribution
|
|
41
|
+
run: python -m build
|
|
42
|
+
|
|
43
|
+
- name: Validate package metadata
|
|
44
|
+
run: python -m twine check dist/*
|
|
45
|
+
|
|
46
|
+
- name: Smoke-test CLI from the built wheel
|
|
47
|
+
run: |
|
|
48
|
+
python -m venv "$RUNNER_TEMP/wheel-smoke"
|
|
49
|
+
wheels=(dist/*.whl)
|
|
50
|
+
"$RUNNER_TEMP/wheel-smoke/bin/python" -m pip install "${wheels[0]}"
|
|
51
|
+
"$RUNNER_TEMP/wheel-smoke/bin/giga-embeddings-mlx" --version
|
|
52
|
+
"$RUNNER_TEMP/wheel-smoke/bin/giga-embeddings-mlx" --help
|
|
53
|
+
"$RUNNER_TEMP/wheel-smoke/bin/giga-embeddings-mlx" models
|
|
54
|
+
"$RUNNER_TEMP/wheel-smoke/bin/python" -c "import importlib.util; assert importlib.util.find_spec('fastapi') is None"
|
|
55
|
+
|
|
56
|
+
- name: Smoke-test optional server extra from the built wheel
|
|
57
|
+
run: |
|
|
58
|
+
python -m venv "$RUNNER_TEMP/server-smoke"
|
|
59
|
+
wheels=(dist/*.whl)
|
|
60
|
+
"$RUNNER_TEMP/server-smoke/bin/python" -m pip install "${wheels[0]}[server]"
|
|
61
|
+
"$RUNNER_TEMP/server-smoke/bin/python" -c "from giga_embeddings_mlx.server import create_app; assert create_app"
|
|
62
|
+
"$RUNNER_TEMP/server-smoke/bin/giga-embeddings-mlx" serve --help
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
if: startsWith(github.event.release.tag_name, 'v')
|
|
13
|
+
runs-on: macos-14
|
|
14
|
+
steps:
|
|
15
|
+
- name: Check out release tag
|
|
16
|
+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
17
|
+
with:
|
|
18
|
+
ref: ${{ github.event.release.tag_name }}
|
|
19
|
+
|
|
20
|
+
- name: Set up Python
|
|
21
|
+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
|
|
22
|
+
with:
|
|
23
|
+
python-version: "3.13"
|
|
24
|
+
|
|
25
|
+
- name: Verify release tag matches package version
|
|
26
|
+
run: |
|
|
27
|
+
PACKAGE_VERSION=$(python -c 'import runpy; print(runpy.run_path("src/giga_embeddings_mlx/_version.py")["__version__"])')
|
|
28
|
+
test "$GITHUB_REF_NAME" = "v$PACKAGE_VERSION"
|
|
29
|
+
|
|
30
|
+
- name: Build and validate distributions
|
|
31
|
+
run: |
|
|
32
|
+
python -m pip install --disable-pip-version-check 'build>=1.3,<2' 'twine>=7,<8'
|
|
33
|
+
python -m build
|
|
34
|
+
python -m twine check dist/*
|
|
35
|
+
|
|
36
|
+
- name: Upload immutable distributions
|
|
37
|
+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
38
|
+
with:
|
|
39
|
+
name: python-distributions
|
|
40
|
+
path: dist/
|
|
41
|
+
if-no-files-found: error
|
|
42
|
+
retention-days: 7
|
|
43
|
+
|
|
44
|
+
publish:
|
|
45
|
+
needs: build
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
environment:
|
|
48
|
+
name: pypi
|
|
49
|
+
url: https://pypi.org/project/giga-embeddings-mlx/
|
|
50
|
+
permissions:
|
|
51
|
+
contents: read
|
|
52
|
+
id-token: write
|
|
53
|
+
steps:
|
|
54
|
+
- name: Download distributions from build job
|
|
55
|
+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
|
|
56
|
+
with:
|
|
57
|
+
name: python-distributions
|
|
58
|
+
path: dist/
|
|
59
|
+
|
|
60
|
+
- name: Publish with PyPI Trusted Publishing
|
|
61
|
+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes follow [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
4
|
+
and releases use [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
|
+
|
|
6
|
+
## [0.1.0] - 2026-08-26
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- Native MLX inference for the exact Giga Embeddings `0826` 480M, 3B, and
|
|
11
|
+
10B-A1.8B revisions.
|
|
12
|
+
- Full-sequence bidirectional Qwen3 and DeepSeek-V3 MoE execution without
|
|
13
|
+
running checkpoint Python during normal inference.
|
|
14
|
+
- Three immutable upstream BF16 profiles and three accepted Q8 profiles, with
|
|
15
|
+
`3b-q8` as the disclosed balanced default; every profile resolves by an
|
|
16
|
+
exact verified Hugging Face commit SHA.
|
|
17
|
+
- Explicit query/document APIs, CLI encoding, local OpenAI-compatible
|
|
18
|
+
`/v1/embeddings`, offline/cache support, and conservative memory preflight.
|
|
19
|
+
- Reproducible public benchmark JSON and tables for quality, artifact size,
|
|
20
|
+
process RSS, Metal peak, load time, median/p95 latency, documents/s, and
|
|
21
|
+
tokens/s.
|
|
22
|
+
- Python 3.12/3.13 macOS CI, package smoke checks, and PyPI Trusted Publishing
|
|
23
|
+
workflow.
|
|
24
|
+
|
|
25
|
+
### Not released
|
|
26
|
+
|
|
27
|
+
- Q4, Q6, uniform 3B Q8, and dominated experimental policies.
|
|
28
|
+
- Automatic embedding-dimension truncation or output-vector compression.
|
|
29
|
+
|
|
30
|
+
[0.1.0]: https://github.com/ai-babai/giga-embeddings-mlx/releases/tag/v0.1.0
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this MLX port, cite this software and the exact upstream Giga Embeddings model repository."
|
|
3
|
+
title: "Giga Embeddings MLX"
|
|
4
|
+
type: software
|
|
5
|
+
authors:
|
|
6
|
+
- family-names: Popkov
|
|
7
|
+
given-names: Maksim
|
|
8
|
+
version: 0.1.0
|
|
9
|
+
date-released: 2026-08-26
|
|
10
|
+
license: MIT
|
|
11
|
+
repository-code: "https://github.com/ai-babai/giga-embeddings-mlx"
|
|
12
|
+
url: "https://huggingface.co/ai-babai"
|
|
13
|
+
keywords:
|
|
14
|
+
- text embeddings
|
|
15
|
+
- Apple Silicon
|
|
16
|
+
- Giga Embeddings
|
|
17
|
+
- MLX
|
|
18
|
+
- quantization
|
|
19
|
+
references:
|
|
20
|
+
- type: generic
|
|
21
|
+
title: "Giga-Embeddings-instruct-480M-0826"
|
|
22
|
+
authors:
|
|
23
|
+
- name: ai-sage
|
|
24
|
+
url: "https://huggingface.co/ai-sage/Giga-Embeddings-instruct-480M-0826"
|
|
25
|
+
- type: generic
|
|
26
|
+
title: "Giga-Embeddings-instruct-3B-0826"
|
|
27
|
+
authors:
|
|
28
|
+
- name: ai-sage
|
|
29
|
+
url: "https://huggingface.co/ai-sage/Giga-Embeddings-instruct-3B-0826"
|
|
30
|
+
- type: generic
|
|
31
|
+
title: "Giga-Embeddings-instruct-10B-A1.8B-0826"
|
|
32
|
+
authors:
|
|
33
|
+
- name: ai-sage
|
|
34
|
+
url: "https://huggingface.co/ai-sage/Giga-Embeddings-instruct-10B-A1.8B-0826"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thank you for helping improve this independent Giga Embeddings MLX port.
|
|
4
|
+
|
|
5
|
+
## Development setup
|
|
6
|
+
|
|
7
|
+
Use Python 3.12 or 3.13 on an Apple Silicon Mac. Keep model weights, datasets,
|
|
8
|
+
virtual environments, Hugging Face caches, and raw benchmark outputs outside
|
|
9
|
+
the Git repository.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
python -m venv .venv
|
|
13
|
+
source .venv/bin/activate
|
|
14
|
+
python -m pip install -e '.[dev,server]'
|
|
15
|
+
pytest
|
|
16
|
+
ruff format --check .
|
|
17
|
+
ruff check .
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The production `giga-embeddings-mlx` CLI contains `models`, `encode`, and
|
|
21
|
+
`serve` only. Conversion, parity, quality evaluation, and benchmarks are
|
|
22
|
+
developer-facing. Checkpoint conversion is available through:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
python -m giga_embeddings_mlx.dev_cli --help
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Reference-backend or MTEB work uses the `[reference]` and `[evaluation]`
|
|
29
|
+
extras as needed.
|
|
30
|
+
|
|
31
|
+
## Pull requests
|
|
32
|
+
|
|
33
|
+
- Describe observable behavior and user impact.
|
|
34
|
+
- Add or update behavior tests for changed public behavior.
|
|
35
|
+
- Do not commit weights, datasets, caches, raw outputs, secrets, local paths,
|
|
36
|
+
or private/user text.
|
|
37
|
+
- Preserve upstream attribution and immutable revisions.
|
|
38
|
+
- Keep query instructions explicit and documents unprefixed.
|
|
39
|
+
- If tensor bytes or execution semantics change, rerun strict load, backend
|
|
40
|
+
parity, frozen holdout, downstream, resource, and speed gates.
|
|
41
|
+
- Do not broaden the public release matrix without new evidence and an explicit
|
|
42
|
+
acceptance decision.
|
|
43
|
+
|
|
44
|
+
Security vulnerabilities should follow [`SECURITY.md`](SECURITY.md), not a
|
|
45
|
+
public issue.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Maksim Popkov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: giga-embeddings-mlx
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Native MLX runtime for the Giga Embeddings 0826 model family
|
|
5
|
+
Project-URL: Homepage, https://github.com/ai-babai/giga-embeddings-mlx
|
|
6
|
+
Project-URL: Repository, https://github.com/ai-babai/giga-embeddings-mlx
|
|
7
|
+
Project-URL: Documentation, https://github.com/ai-babai/giga-embeddings-mlx#readme
|
|
8
|
+
Project-URL: Issues, https://github.com/ai-babai/giga-embeddings-mlx/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/ai-babai/giga-embeddings-mlx/blob/main/CHANGELOG.md
|
|
10
|
+
Project-URL: Hugging Face Collection, https://huggingface.co/collections/ai-babai/giga-embeddings-0826-mlx-6a8eec40b26f6543f5da3244
|
|
11
|
+
Project-URL: Upstream 480M Model, https://huggingface.co/ai-sage/Giga-Embeddings-instruct-480M-0826
|
|
12
|
+
Project-URL: Upstream 3B Model, https://huggingface.co/ai-sage/Giga-Embeddings-instruct-3B-0826
|
|
13
|
+
Project-URL: Upstream 10B Model, https://huggingface.co/ai-sage/Giga-Embeddings-instruct-10B-A1.8B-0826
|
|
14
|
+
Author: Maksim Popkov
|
|
15
|
+
Maintainer: Maksim Popkov
|
|
16
|
+
License-Expression: MIT
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Keywords: apple-silicon,embeddings,giga-embeddings,mlx
|
|
19
|
+
Classifier: Development Status :: 4 - Beta
|
|
20
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
21
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Requires-Python: <3.14,>=3.12
|
|
26
|
+
Requires-Dist: huggingface-hub<2,>=1.3
|
|
27
|
+
Requires-Dist: mlx-lm<0.32,>=0.31.3
|
|
28
|
+
Requires-Dist: mlx<0.33,>=0.32.2
|
|
29
|
+
Requires-Dist: numpy<3,>=2.3
|
|
30
|
+
Requires-Dist: safetensors<0.9,>=0.7
|
|
31
|
+
Requires-Dist: transformers<6,>=5.14
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: build<2,>=1.3; extra == 'dev'
|
|
34
|
+
Requires-Dist: httpx2<3,>=2.7; extra == 'dev'
|
|
35
|
+
Requires-Dist: httpx<1,>=0.28; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest<10,>=9.0.3; extra == 'dev'
|
|
37
|
+
Requires-Dist: ruff<0.17,>=0.16.4; extra == 'dev'
|
|
38
|
+
Requires-Dist: twine<8,>=7; extra == 'dev'
|
|
39
|
+
Provides-Extra: evaluation
|
|
40
|
+
Requires-Dist: mteb<3,>=2.20; extra == 'evaluation'
|
|
41
|
+
Requires-Dist: scipy<2,>=1.17; extra == 'evaluation'
|
|
42
|
+
Provides-Extra: reference
|
|
43
|
+
Requires-Dist: sentence-transformers<7,>=6; extra == 'reference'
|
|
44
|
+
Requires-Dist: torch<3,>=2.8; extra == 'reference'
|
|
45
|
+
Provides-Extra: server
|
|
46
|
+
Requires-Dist: fastapi<1,>=0.140; extra == 'server'
|
|
47
|
+
Requires-Dist: uvicorn<1,>=0.52; extra == 'server'
|
|
48
|
+
Description-Content-Type: text/markdown
|
|
49
|
+
|
|
50
|
+
# Giga Embeddings MLX
|
|
51
|
+
|
|
52
|
+
[Русская версия](README.ru.md)
|
|
53
|
+
|
|
54
|
+
Independent native [MLX](https://github.com/ml-explore/mlx) runtime for the
|
|
55
|
+
`0826` Giga Embeddings model family on Apple Silicon. This project is maintained
|
|
56
|
+
by [ai-babai](https://github.com/ai-babai); it is not an official `ai-sage`
|
|
57
|
+
release.
|
|
58
|
+
|
|
59
|
+
[PyPI](https://pypi.org/project/giga-embeddings-mlx/) ·
|
|
60
|
+
[Hugging Face Collection](https://huggingface.co/collections/ai-babai/giga-embeddings-0826-mlx-6a8eec40b26f6543f5da3244) ·
|
|
61
|
+
[Benchmarks](docs/benchmarks/0826-results.md) ·
|
|
62
|
+
[Changelog](CHANGELOG.md)
|
|
63
|
+
|
|
64
|
+
The runtime supports the exact upstream
|
|
65
|
+
[480M](https://huggingface.co/ai-sage/Giga-Embeddings-instruct-480M-0826),
|
|
66
|
+
[3B](https://huggingface.co/ai-sage/Giga-Embeddings-instruct-3B-0826), and
|
|
67
|
+
[10B-A1.8B](https://huggingface.co/ai-sage/Giga-Embeddings-instruct-10B-A1.8B-0826)
|
|
68
|
+
revisions, plus three accepted MLX Q8 artifacts. It performs full-sequence
|
|
69
|
+
bidirectional attention, padding-aware mean pooling in FP32, and FP32 L2
|
|
70
|
+
normalization. Normal inference does not execute Python code from model
|
|
71
|
+
repositories.
|
|
72
|
+
|
|
73
|
+
## Install
|
|
74
|
+
|
|
75
|
+
Requirements: an Apple Silicon Mac, macOS, and Python 3.12 or 3.13.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
python -m pip install giga-embeddings-mlx
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The default artifact is `3b-q8`, the balanced 3B Q8 model with BF16 edge
|
|
82
|
+
layers. Its download is approximately 3.8 GB. Model files are downloaded from
|
|
83
|
+
Hugging Face on first use.
|
|
84
|
+
|
|
85
|
+
## 60-second quick start
|
|
86
|
+
|
|
87
|
+
Documents are encoded without a prefix. Queries require an explicit retrieval
|
|
88
|
+
instruction; the runtime never invents one.
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from giga_embeddings_mlx import load_embedding_model
|
|
92
|
+
|
|
93
|
+
model = load_embedding_model("default")
|
|
94
|
+
|
|
95
|
+
documents = model.encode_documents(["Москва — столица России.", "Париж — столица Франции."])
|
|
96
|
+
queries = model.encode_queries(
|
|
97
|
+
"Где находится Москва?",
|
|
98
|
+
instruction="Given a question, retrieve passages that answer the question",
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
scores = queries @ documents.T
|
|
102
|
+
print(scores.tolist())
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The low-level `model.encode(...)` method accepts already prepared text. Prefer
|
|
106
|
+
`encode_queries` and `encode_documents` when the retrieval role matters.
|
|
107
|
+
|
|
108
|
+
CLI:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
giga-embeddings-mlx models
|
|
112
|
+
giga-embeddings-mlx encode "Москва — столица России." --document
|
|
113
|
+
giga-embeddings-mlx encode "Где находится Москва?" \
|
|
114
|
+
--instruction "Given a question, retrieve passages that answer the question"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Choose a profile
|
|
118
|
+
|
|
119
|
+
| Alias | Weights | Dimension | Role | Expected download |
|
|
120
|
+
|---|---|---:|---|---:|
|
|
121
|
+
| `480m-bf16` | upstream BF16 | 1024 | smallest quality baseline | 1.0 GB |
|
|
122
|
+
| `480m-q8` | Q8, group 64 | 1024 | compact | 0.5 GB |
|
|
123
|
+
| `3b-bf16` | upstream BF16 | 2048 | 3B quality baseline | 6.3 GB |
|
|
124
|
+
| `3b-q8` / `default` | Q8 + BF16 edges, group 64 | 2048 | balanced default | 3.8 GB |
|
|
125
|
+
| `10b-a1.8b-bf16` | upstream BF16 MoE | 1536 | quality-first, high capacity | 21.0 GB |
|
|
126
|
+
| `10b-a1.8b-q8` | Q8, BF16 routers/norms, group 64 | 1536 | compact / research | 11.1 GB |
|
|
127
|
+
|
|
128
|
+
Quant repositories:
|
|
129
|
+
[480M Q8](https://huggingface.co/ai-babai/giga-embeddings-0826-480m-mlx-q8-g64),
|
|
130
|
+
[3B balanced](https://huggingface.co/ai-babai/giga-embeddings-0826-3b-mlx-q8-edges-bf16-g64),
|
|
131
|
+
and
|
|
132
|
+
[10B-A1.8B Q8](https://huggingface.co/ai-babai/giga-embeddings-0826-10b-a1.8b-mlx-q8-g64).
|
|
133
|
+
|
|
134
|
+
The BF16 aliases point to immutable upstream commits; weights are not
|
|
135
|
+
duplicated under `ai-babai`. Q8 aliases also point directly to the exact
|
|
136
|
+
verified Hugging Face commits for this release. Human-facing `0826-v0.1.0`
|
|
137
|
+
tags identify the same artifacts but are not required for runtime resolution.
|
|
138
|
+
|
|
139
|
+
The 10B Q8 artifact is not the default and is not described as near-lossless:
|
|
140
|
+
its aggregate retrieval gate passed, but the measured code-family NDCG@10
|
|
141
|
+
delta was `−0.01297` versus native MLX BF16.
|
|
142
|
+
|
|
143
|
+
Q4, Q6, uniform 3B Q8, and dominated mixed variants are intentionally not
|
|
144
|
+
released.
|
|
145
|
+
|
|
146
|
+
## Explicit Hub repositories and local artifacts
|
|
147
|
+
|
|
148
|
+
Aliases, an explicit Hub repository/revision, and a local directory share the
|
|
149
|
+
same loader:
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from pathlib import Path
|
|
153
|
+
|
|
154
|
+
from giga_embeddings_mlx import load_embedding_model
|
|
155
|
+
|
|
156
|
+
model = load_embedding_model("480m-q8")
|
|
157
|
+
|
|
158
|
+
model = load_embedding_model(
|
|
159
|
+
"owner/repository",
|
|
160
|
+
revision="immutable-commit-or-tag",
|
|
161
|
+
cache_dir=Path("models-cache"),
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
model = load_embedding_model(Path("portable-model-directory"))
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Cache and offline use
|
|
168
|
+
|
|
169
|
+
Use a dedicated cache directory when lifecycle control matters:
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
model = load_embedding_model("3b-q8", cache_dir="models-cache")
|
|
173
|
+
model = load_embedding_model(
|
|
174
|
+
"3b-q8",
|
|
175
|
+
cache_dir="models-cache",
|
|
176
|
+
local_files_only=True,
|
|
177
|
+
)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
CLI equivalents are `--cache-dir models-cache` and `--offline`. If the pinned
|
|
181
|
+
snapshot is absent, offline mode reports the repository and tells you how to
|
|
182
|
+
populate or select a cache.
|
|
183
|
+
|
|
184
|
+
Only remove a cache directory that you deliberately dedicated to this project,
|
|
185
|
+
after confirming that no other Hugging Face application uses it. Do not delete
|
|
186
|
+
the global Hugging Face cache merely to remove one model snapshot.
|
|
187
|
+
|
|
188
|
+
Before loading, the runtime compares artifact bytes with physical unified
|
|
189
|
+
memory using a conservative reserve. Choose a smaller profile if the preflight
|
|
190
|
+
fails. `skip_memory_check=True` / `--skip-memory-check` is an explicit escape
|
|
191
|
+
hatch for users willing to accept swap or out-of-memory risk.
|
|
192
|
+
|
|
193
|
+
## Local OpenAI-compatible endpoint
|
|
194
|
+
|
|
195
|
+
Install the optional server dependencies:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
python -m pip install 'giga-embeddings-mlx[server]'
|
|
199
|
+
giga-embeddings-mlx serve --model default --served-model-name giga-3b
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
The endpoint is `POST /v1/embeddings`. Input without `instruction` is treated
|
|
203
|
+
as a document. A query must provide its instruction explicitly:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
curl http://127.0.0.1:8000/v1/embeddings \
|
|
207
|
+
-H 'Content-Type: application/json' \
|
|
208
|
+
-d '{
|
|
209
|
+
"model": "giga-3b",
|
|
210
|
+
"input": ["Где находится Москва?"],
|
|
211
|
+
"instruction": "Given a question, retrieve passages that answer the question"
|
|
212
|
+
}'
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
The server supports `float` and `base64` output. Dimension truncation is not
|
|
216
|
+
supported because the upstream `0826` cards do not claim Matryoshka training.
|
|
217
|
+
One process serves one model and serializes Metal inference.
|
|
218
|
+
|
|
219
|
+
## Measured results
|
|
220
|
+
|
|
221
|
+
Measurements were made on a MacBook Pro with Apple M4 Pro and 48 GB unified
|
|
222
|
+
memory, Python 3.12.11, MLX 0.32.2, and MLX-LM 0.31.3. Speed uses 2 warmups and
|
|
223
|
+
5 measured repetitions. These numbers do not predict other Macs or compare
|
|
224
|
+
directly with upstream H100 results.
|
|
225
|
+
|
|
226
|
+
Q8 reduced artifact size by about 40–47% for the released choices, but was
|
|
227
|
+
12–19% slower than its BF16 counterpart at B16×1024. Treat weight quantization
|
|
228
|
+
here primarily as a capacity and disk trade-off.
|
|
229
|
+
|
|
230
|
+
The full generated report separates artifact size, process RSS, Metal peak,
|
|
231
|
+
load time, median/p95 speed, BF16 backend preservation, quantized-vector drift,
|
|
232
|
+
ranking, and downstream deltas:
|
|
233
|
+
|
|
234
|
+
- [human-readable tables](docs/benchmarks/0826-results.md);
|
|
235
|
+
- [machine-readable evidence and source hashes](docs/benchmarks/0826-results.json).
|
|
236
|
+
|
|
237
|
+
The acceptance JSON SHA-256 is
|
|
238
|
+
`410b9cf7756e0718816b23a46f0d99e0f3e6574e4eb515cc5a99cff131057316`.
|
|
239
|
+
The 512-text / 256-query / 2048-document frozen holdout covers Russian,
|
|
240
|
+
English, code, and multilingual families up to 2048 tokens. Small positive
|
|
241
|
+
deltas are evidence of no measured regression in this lane, not proof that
|
|
242
|
+
quantization improves the model.
|
|
243
|
+
|
|
244
|
+
## Quality interpretation
|
|
245
|
+
|
|
246
|
+
The original strict revision 1/2 numerical gates exposed BF16 cross-backend
|
|
247
|
+
and dynamic-shape drift and did not pass. Those failures remain documented.
|
|
248
|
+
Revision 3 passed an effectiveness-based gate for pooled vectors, padding,
|
|
249
|
+
aggregate retrieval and every family with a `−0.005` MRR/NDCG margin, while
|
|
250
|
+
retaining rank agreement and hidden-state drift as diagnostics.
|
|
251
|
+
|
|
252
|
+
This distinction matters: backend-level hidden vectors can drift while the
|
|
253
|
+
observable retrieval task remains non-inferior. The public Q8 selection was
|
|
254
|
+
therefore based on representation, ranking, downstream quality, disk, memory,
|
|
255
|
+
load and speed—not one cosine number.
|
|
256
|
+
|
|
257
|
+
## Limitations
|
|
258
|
+
|
|
259
|
+
- Apple Silicon/macOS only; use the upstream reference runtime elsewhere.
|
|
260
|
+
- Maximum sequence length is 8192, but memory grows with batch and sequence
|
|
261
|
+
length; the public speed matrix is not a promise for every workload.
|
|
262
|
+
- Q8 is not guaranteed to be faster than BF16 on Metal.
|
|
263
|
+
- 10B Q8 has the explicit code-retrieval warning above.
|
|
264
|
+
- This package does not silently truncate embedding dimensions.
|
|
265
|
+
- Output-vector `uint8`/binary compression is a separate index-storage choice
|
|
266
|
+
and is not performed by the weight loader.
|
|
267
|
+
- The local benchmark is not an official upstream leaderboard result.
|
|
268
|
+
|
|
269
|
+
## Development and citation
|
|
270
|
+
|
|
271
|
+
Conversion and evaluation remain developer-facing and are not exposed by the
|
|
272
|
+
end-user CLI. See [CONTRIBUTING.md](CONTRIBUTING.md) and
|
|
273
|
+
[docs/EVALUATION.md](docs/EVALUATION.md). Security reports follow
|
|
274
|
+
[SECURITY.md](SECURITY.md).
|
|
275
|
+
|
|
276
|
+
License: MIT for this independent runtime. Upstream model licenses and notices
|
|
277
|
+
remain attached to their respective repositories; see
|
|
278
|
+
[THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). Citation metadata is in
|
|
279
|
+
[CITATION.cff](CITATION.cff).
|