Instructions to use masahiroid/contriever-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use masahiroid/contriever-mlx with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download masahiroid/contriever-mlx --local-dir contriever-mlx
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Add Japanese translation (.ja.md)
Browse files- README.ja.md +55 -0
- README.md +2 -0
- SECURITY.ja.md +5 -0
- SECURITY.md +2 -0
README.ja.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# contriever — MLX
|
| 2 |
+
|
| 3 |
+
[English version here (README.md)](README.md)
|
| 4 |
+
|
| 5 |
+
密ベクトル検索用の埋め込みモデルです。マスクを考慮した平均プーリングを使います。埋め込みはL2正規化されていません。
|
| 6 |
+
|
| 7 |
+
[facebook/contriever](https://huggingface.co/facebook/contriever/tree/2bd46a25019aeea091fd42d1f0fd4801675cf699) のリビジョン `2bd46a25019aeea091fd42d1f0fd4801675cf699` を変換したものです。ファインチューニングはしておらず、チェックポイントの差し替えもありません。F32のベースラインで、**4ビット量子化ではありません**。クレジットとライセンス上の権利は元の作者に帰属します。
|
| 8 |
+
|
| 9 |
+
## 使い方と互換性
|
| 10 |
+
|
| 11 |
+
元の推論モデルのテンソル名をそのまま使った、ネイティブのMLX実装です。この独自ランタイムは、mlx-lmのテキスト生成モデルではありません。
|
| 12 |
+
|
| 13 |
+
同梱のMLXランタイムには、Apple Silicon搭載のMacが必要です。入力の長さは可変です(元モデルの上限まで)。下記のコンパイル済みApple向け書き出しは固定形状です。
|
| 14 |
+
|
| 15 |
+
```bash
|
| 16 |
+
pip install huggingface_hub mlx numpy transformers sentencepiece
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
```python
|
| 20 |
+
from huggingface_hub import snapshot_download
|
| 21 |
+
from pathlib import Path
|
| 22 |
+
import sys, numpy as np
|
| 23 |
+
path = snapshot_download("masahiroid/contriever-mlx")
|
| 24 |
+
sys.path.insert(0, path)
|
| 25 |
+
from runtime_mlx import Model
|
| 26 |
+
model = Model(path)
|
| 27 |
+
from transformers import AutoTokenizer
|
| 28 |
+
tok = AutoTokenizer.from_pretrained(path, use_fast=True)
|
| 29 |
+
inputs = tok("Thank you so much!", return_tensors="np", truncation=True, max_length=128)
|
| 30 |
+
output = model(input_ids=inputs["input_ids"], attention_mask=inputs["attention_mask"])
|
| 31 |
+
print(np.array(output).shape)
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
## 数値検証
|
| 35 |
+
|
| 36 |
+
元のPyTorch実装と、6件の決定的なケースで比較しました。出力の最大絶対誤差は **1.2721866e-06**、最小コサイン類似度は **0.99999993** です。各ケースの結果は `validation.json` を見てください。これは変換前後の一致を確かめるもので、タスク品質やレイテンシーの本格的なベンチマークではありません。
|
| 37 |
+
|
| 38 |
+
テキスト系のテストは、英語の感情文、中立的な検索用テキスト、日本語、空の入力、切り詰めを対象にしています。Chronosのテストは、トレンドと正弦波の組み合わせ、一定値の系列、欠測値を含む系列を対象にしています。各モデルには、当てはまるテストだけを使っています。
|
| 39 |
+
|
| 40 |
+
Core ML/Core AIのテキスト向け書き出しは、バッチ1・系列長128です。トークナイズでは128にパディング/切り詰めをしてください。ChronosのApple向け書き出しは、バッチ1・コンテキスト長2048です。MLX/独自GGUFは、追加の学習はせず、元の最大コンテキストをそのまま保っています。固定形状のApple向け書き出しでは、短いChronos入力の左側をNaNでパディングできます。予測期間は64のままです。
|
| 41 |
+
|
| 42 |
+
## 再現性
|
| 43 |
+
|
| 44 |
+
元のリビジョンと出力の意味は `provenance.json` にあります。変換スクリプトも同梱しています。再現するには、スクリプトのとおりに `sources/<original-model-name>/`、`sources.json`、`publish/` の各ディレクトリを置いたチェックアウトで実行してください。使用バージョン: PyTorch 2.14.1; Transformers 4.57.3; MLX 0.32.4; NumPy 1.26.4(MLX/Core ML環境)、coremltools 9.0; chronos-forecasting 2.3.2; GGUF 0.19.0。Core AIの書き出しには coreai-torch 0.4.3 を使っています。Core AIの検証は、別のPython 3.14環境で行っています。確認した環境以外でのバージョン互換性は保証しません。
|
| 45 |
+
|
| 46 |
+
## ライセンス
|
| 47 |
+
|
| 48 |
+
重みのライセンスは引き続き **cc-by-nc-4.0** です。元の条件は `LICENSE` にあります。元のCC BY-NC 4.0の条件により、非商用利用に限ります。変換ツールやランタイムとして追加した部分はMITライセンスです(`CODE_LICENSE`)。新たなタスク学習、安全性の認証、商用ライセンスを意味するものではありません。
|
| 49 |
+
|
| 50 |
+
## ほかの形式
|
| 51 |
+
|
| 52 |
+
- [mlx](https://huggingface.co/masahiroid/contriever-mlx)
|
| 53 |
+
- [coreml](https://huggingface.co/masahiroid/contriever-coreml)
|
| 54 |
+
- [coreai](https://huggingface.co/masahiroid/contriever-coreai)
|
| 55 |
+
- [gguf](https://huggingface.co/masahiroid/contriever-gguf)
|
README.md
CHANGED
|
@@ -7,6 +7,8 @@ tags:
|
|
| 7 |
---
|
| 8 |
# contriever — MLX
|
| 9 |
|
|
|
|
|
|
|
| 10 |
Dense retrieval embeddings with mask-aware mean pooling. Embeddings are not L2-normalized.
|
| 11 |
|
| 12 |
Conversion of [facebook/contriever](https://huggingface.co/facebook/contriever/tree/2bd46a25019aeea091fd42d1f0fd4801675cf699) at revision `2bd46a25019aeea091fd42d1f0fd4801675cf699`. No fine-tuning or replacement checkpoint. F32 baseline, **not a 4-bit quantization**. Original authors retain credit and license rights.
|
|
|
|
| 7 |
---
|
| 8 |
# contriever — MLX
|
| 9 |
|
| 10 |
+
[日本語版はこちら (README.ja.md)](README.ja.md)
|
| 11 |
+
|
| 12 |
Dense retrieval embeddings with mask-aware mean pooling. Embeddings are not L2-normalized.
|
| 13 |
|
| 14 |
Conversion of [facebook/contriever](https://huggingface.co/facebook/contriever/tree/2bd46a25019aeea091fd42d1f0fd4801675cf699) at revision `2bd46a25019aeea091fd42d1f0fd4801675cf699`. No fine-tuning or replacement checkpoint. F32 baseline, **not a 4-bit quantization**. Original authors retain credit and license rights.
|
SECURITY.ja.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 配布物の監査
|
| 2 |
+
|
| 3 |
+
[English version here (SECURITY.md)](SECURITY.md)
|
| 4 |
+
|
| 5 |
+
pickle形式のチェックポイントは含んでいません。モデルのテンソルは、safetensors、Core MLパッケージ、Core AIアセット、GGUFのいずれかで保存しています。同梱のPythonコードはローカルで実行されます。実行前に中身を確認してください。リモートコードの自動読み込みは不要です。ファイルとハッシュは `SHA256SUMS.json` にあります。チェックサムは意図しない変更を見つけるためのもので、安全性の証明ではありません。これは変換の数値チェックであり、敵対的な観点からのセキュリティー評価ではありません。
|
SECURITY.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
| 1 |
# Distribution audit
|
| 2 |
|
|
|
|
|
|
|
| 3 |
No pickle checkpoints are included. Model tensors are stored in safetensors, a Core ML package, a Core AI asset or GGUF. Included Python code executes locally; review it before running. No automatic remote-code loading is required. Files and hashes: `SHA256SUMS.json`. Checksums detect accidental changes; they are not proof of safety. This is a numerical conversion check, not an adversarial safety evaluation.
|
|
|
|
| 1 |
# Distribution audit
|
| 2 |
|
| 3 |
+
[日本語版はこちら (SECURITY.ja.md)](SECURITY.ja.md)
|
| 4 |
+
|
| 5 |
No pickle checkpoints are included. Model tensors are stored in safetensors, a Core ML package, a Core AI asset or GGUF. Included Python code executes locally; review it before running. No automatic remote-code loading is required. Files and hashes: `SHA256SUMS.json`. Checksums detect accidental changes; they are not proof of safety. This is a numerical conversion check, not an adversarial safety evaluation.
|