pplx-context-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.
Files changed (28) hide show
  1. pplx_context_mlx-0.1.0/LICENSE +21 -0
  2. pplx_context_mlx-0.1.0/NOTICE +346 -0
  3. pplx_context_mlx-0.1.0/PKG-INFO +199 -0
  4. pplx_context_mlx-0.1.0/README.md +168 -0
  5. pplx_context_mlx-0.1.0/pplx_context_mlx/__init__.py +5 -0
  6. pplx_context_mlx-0.1.0/pplx_context_mlx/checkpoint.py +55 -0
  7. pplx_context_mlx-0.1.0/pplx_context_mlx/cli.py +23 -0
  8. pplx_context_mlx-0.1.0/pplx_context_mlx/config.py +113 -0
  9. pplx_context_mlx-0.1.0/pplx_context_mlx/engine.py +119 -0
  10. pplx_context_mlx-0.1.0/pplx_context_mlx/gated_delta.py +651 -0
  11. pplx_context_mlx-0.1.0/pplx_context_mlx/images.py +176 -0
  12. pplx_context_mlx-0.1.0/pplx_context_mlx/model.py +73 -0
  13. pplx_context_mlx-0.1.0/pplx_context_mlx/text.py +233 -0
  14. pplx_context_mlx-0.1.0/pplx_context_mlx/tokenizer.py +83 -0
  15. pplx_context_mlx-0.1.0/pplx_context_mlx/vision.py +167 -0
  16. pplx_context_mlx-0.1.0/pplx_context_mlx.egg-info/PKG-INFO +199 -0
  17. pplx_context_mlx-0.1.0/pplx_context_mlx.egg-info/SOURCES.txt +26 -0
  18. pplx_context_mlx-0.1.0/pplx_context_mlx.egg-info/dependency_links.txt +1 -0
  19. pplx_context_mlx-0.1.0/pplx_context_mlx.egg-info/entry_points.txt +2 -0
  20. pplx_context_mlx-0.1.0/pplx_context_mlx.egg-info/requires.txt +19 -0
  21. pplx_context_mlx-0.1.0/pplx_context_mlx.egg-info/top_level.txt +1 -0
  22. pplx_context_mlx-0.1.0/pyproject.toml +39 -0
  23. pplx_context_mlx-0.1.0/setup.cfg +4 -0
  24. pplx_context_mlx-0.1.0/tests/test_float16.py +61 -0
  25. pplx_context_mlx-0.1.0/tests/test_images.py +76 -0
  26. pplx_context_mlx-0.1.0/tests/test_parity.py +91 -0
  27. pplx_context_mlx-0.1.0/tests/test_pooling.py +25 -0
  28. pplx_context_mlx-0.1.0/tests/test_tokenizer.py +42 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Merchantry LLC
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.
@@ -0,0 +1,346 @@
1
+ pplx_context_mlx/images.py (_cubic, _resample_axis) reproduces the arithmetic of PyTorch's CPU uint8
2
+ antialiased bicubic interpolation, modified and adapted from the bicubic_uint8 function of pplx-embed-mlx
3
+ (https://github.com/Obscyra-app/pplx-embed-mlx), code/pplx_mlx/resize.py.
4
+
5
+ ==============================================================================
6
+ pplx-embed-mlx notice
7
+ ==============================================================================
8
+ Model: perplexity-ai/pplx-embed-v2-late-0.6b, revision
9
+ 8fc2de24534aa3610d85fa59c463313a5f096455. Model card declares MIT.
10
+ Original weights are neither modified in place nor committed here.
11
+
12
+ The gated_delta.py numerical/Metal routines were copied from mlx-vlm 0.7.6,
13
+ mlx_vlm/models/qwen3_5/gated_delta.py (itself based on mlx-lm 0.31.3).
14
+ The unused generation-cache history dispatch was replaced with an explicit error.
15
+ See licenses/mlx-vlm-LICENSE and licenses/mlx-lm-LICENSE.
16
+ Encoder architecture follows Transformers 5.19.0 Qwen3.5 implementation
17
+ (Apache-2.0). Processor patch ordering follows Transformers Qwen2VL.
18
+ See licenses/transformers-LICENSE. No Transformers/Torch imports in inference.
19
+ No claim of being the first MLX implementation.
20
+
21
+ resize.py implements the uint8 separable bicubic-antialias integer arithmetic
22
+ used by PyTorch / torchvision v2. The first failed diagnostic used torchvision
23
+ v1's float-cast path; v2 is the path actually used by Transformers 5.19.0.
24
+ See licenses/PYTORCH_LICENSE. Native image size limits are explicit local policy.
25
+
26
+ ==============================================================================
27
+ PyTorch license
28
+ ==============================================================================
29
+ From PyTorch:
30
+
31
+ Copyright (c) 2016- Facebook, Inc (Adam Paszke)
32
+ Copyright (c) 2014- Facebook, Inc (Soumith Chintala)
33
+ Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert)
34
+ Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu)
35
+ Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu)
36
+ Copyright (c) 2011-2013 NYU (Clement Farabet)
37
+ Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston)
38
+ Copyright (c) 2006 Idiap Research Institute (Samy Bengio)
39
+ Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz)
40
+
41
+ From Caffe2:
42
+
43
+ Copyright (c) 2016-present, Facebook Inc. All rights reserved.
44
+
45
+ All contributions by Facebook:
46
+ Copyright (c) 2016 Facebook Inc.
47
+
48
+ All contributions by Google:
49
+ Copyright (c) 2015 Google Inc.
50
+ All rights reserved.
51
+
52
+ All contributions by Yangqing Jia:
53
+ Copyright (c) 2015 Yangqing Jia
54
+ All rights reserved.
55
+
56
+ All contributions by Kakao Brain:
57
+ Copyright 2019-2020 Kakao Brain
58
+
59
+ All contributions by Cruise LLC:
60
+ Copyright (c) 2022 Cruise LLC.
61
+ All rights reserved.
62
+
63
+ All contributions by Tri Dao:
64
+ Copyright (c) 2024 Tri Dao.
65
+ All rights reserved.
66
+
67
+ All contributions by Arm:
68
+ Copyright (c) 2021, 2023-2025 Arm Limited and/or its affiliates
69
+
70
+ All contributions from Caffe:
71
+ Copyright(c) 2013, 2014, 2015, the respective contributors
72
+ All rights reserved.
73
+
74
+ All other contributions:
75
+ Copyright(c) 2015, 2016 the respective contributors
76
+ All rights reserved.
77
+
78
+ Caffe2 uses a copyright model similar to Caffe: each contributor holds
79
+ copyright over their contributions to Caffe2. The project versioning records
80
+ all such contribution and copyright details. If a contributor wants to further
81
+ mark their specific copyright on a particular contribution, they should
82
+ indicate their copyright solely in the commit message of the change when it is
83
+ committed.
84
+
85
+ All rights reserved.
86
+
87
+ Redistribution and use in source and binary forms, with or without
88
+ modification, are permitted provided that the following conditions are met:
89
+
90
+ 1. Redistributions of source code must retain the above copyright
91
+ notice, this list of conditions and the following disclaimer.
92
+
93
+ 2. Redistributions in binary form must reproduce the above copyright
94
+ notice, this list of conditions and the following disclaimer in the
95
+ documentation and/or other materials provided with the distribution.
96
+
97
+ 3. Neither the names of Facebook, Deepmind Technologies, NYU, NEC Laboratories America
98
+ and IDIAP Research Institute nor the names of its contributors may be
99
+ used to endorse or promote products derived from this software without
100
+ specific prior written permission.
101
+
102
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
103
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
104
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
105
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
106
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
107
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
108
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
109
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
110
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
111
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
112
+ POSSIBILITY OF SUCH DAMAGE.
113
+
114
+ ==============================================================================
115
+ mlx-lm license
116
+ ==============================================================================
117
+ pplx_context_mlx/gated_delta.py is vendored from mlx-lm 0.32.2 under the following license:
118
+
119
+ MIT License
120
+
121
+ Copyright © 2023 Apple Inc.
122
+
123
+ Permission is hereby granted, free of charge, to any person obtaining a copy
124
+ of this software and associated documentation files (the "Software"), to deal
125
+ in the Software without restriction, including without limitation the rights
126
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
127
+ copies of the Software, and to permit persons to whom the Software is
128
+ furnished to do so, subject to the following conditions:
129
+
130
+ The above copyright notice and this permission notice shall be included in all
131
+ copies or substantial portions of the Software.
132
+
133
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
134
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
135
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
136
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
137
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
138
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
139
+ SOFTWARE.
140
+
141
+ ==============================================================================
142
+ pplx-embed-mlx license (Apache-2.0)
143
+ ==============================================================================
144
+ Copyright 2018- The Hugging Face team. All rights reserved.
145
+
146
+ Apache License
147
+ Version 2.0, January 2004
148
+ http://www.apache.org/licenses/
149
+
150
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
151
+
152
+ 1. Definitions.
153
+
154
+ "License" shall mean the terms and conditions for use, reproduction,
155
+ and distribution as defined by Sections 1 through 9 of this document.
156
+
157
+ "Licensor" shall mean the copyright owner or entity authorized by
158
+ the copyright owner that is granting the License.
159
+
160
+ "Legal Entity" shall mean the union of the acting entity and all
161
+ other entities that control, are controlled by, or are under common
162
+ control with that entity. For the purposes of this definition,
163
+ "control" means (i) the power, direct or indirect, to cause the
164
+ direction or management of such entity, whether by contract or
165
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
166
+ outstanding shares, or (iii) beneficial ownership of such entity.
167
+
168
+ "You" (or "Your") shall mean an individual or Legal Entity
169
+ exercising permissions granted by this License.
170
+
171
+ "Source" form shall mean the preferred form for making modifications,
172
+ including but not limited to software source code, documentation
173
+ source, and configuration files.
174
+
175
+ "Object" form shall mean any form resulting from mechanical
176
+ transformation or translation of a Source form, including but
177
+ not limited to compiled object code, generated documentation,
178
+ and conversions to other media types.
179
+
180
+ "Work" shall mean the work of authorship, whether in Source or
181
+ Object form, made available under the License, as indicated by a
182
+ copyright notice that is included in or attached to the work
183
+ (an example is provided in the Appendix below).
184
+
185
+ "Derivative Works" shall mean any work, whether in Source or Object
186
+ form, that is based on (or derived from) the Work and for which the
187
+ editorial revisions, annotations, elaborations, or other modifications
188
+ represent, as a whole, an original work of authorship. For the purposes
189
+ of this License, Derivative Works shall not include works that remain
190
+ separable from, or merely link (or bind by name) to the interfaces of,
191
+ the Work and Derivative Works thereof.
192
+
193
+ "Contribution" shall mean any work of authorship, including
194
+ the original version of the Work and any modifications or additions
195
+ to that Work or Derivative Works thereof, that is intentionally
196
+ submitted to Licensor for inclusion in the Work by the copyright owner
197
+ or by an individual or Legal Entity authorized to submit on behalf of
198
+ the copyright owner. For the purposes of this definition, "submitted"
199
+ means any form of electronic, verbal, or written communication sent
200
+ to the Licensor or its representatives, including but not limited to
201
+ communication on electronic mailing lists, source code control systems,
202
+ and issue tracking systems that are managed by, or on behalf of, the
203
+ Licensor for the purpose of discussing and improving the Work, but
204
+ excluding communication that is conspicuously marked or otherwise
205
+ designated in writing by the copyright owner as "Not a Contribution."
206
+
207
+ "Contributor" shall mean Licensor and any individual or Legal Entity
208
+ on behalf of whom a Contribution has been received by Licensor and
209
+ subsequently incorporated within the Work.
210
+
211
+ 2. Grant of Copyright License. Subject to the terms and conditions of
212
+ this License, each Contributor hereby grants to You a perpetual,
213
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
214
+ copyright license to reproduce, prepare Derivative Works of,
215
+ publicly display, publicly perform, sublicense, and distribute the
216
+ Work and such Derivative Works in Source or Object form.
217
+
218
+ 3. Grant of Patent License. Subject to the terms and conditions of
219
+ this License, each Contributor hereby grants to You a perpetual,
220
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
221
+ (except as stated in this section) patent license to make, have made,
222
+ use, offer to sell, sell, import, and otherwise transfer the Work,
223
+ where such license applies only to those patent claims licensable
224
+ by such Contributor that are necessarily infringed by their
225
+ Contribution(s) alone or by combination of their Contribution(s)
226
+ with the Work to which such Contribution(s) was submitted. If You
227
+ institute patent litigation against any entity (including a
228
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
229
+ or a Contribution incorporated within the Work constitutes direct
230
+ or contributory patent infringement, then any patent licenses
231
+ granted to You under this License for that Work shall terminate
232
+ as of the date such litigation is filed.
233
+
234
+ 4. Redistribution. You may reproduce and distribute copies of the
235
+ Work or Derivative Works thereof in any medium, with or without
236
+ modifications, and in Source or Object form, provided that You
237
+ meet the following conditions:
238
+
239
+ (a) You must give any other recipients of the Work or
240
+ Derivative Works a copy of this License; and
241
+
242
+ (b) You must cause any modified files to carry prominent notices
243
+ stating that You changed the files; and
244
+
245
+ (c) You must retain, in the Source form of any Derivative Works
246
+ that You distribute, all copyright, patent, trademark, and
247
+ attribution notices from the Source form of the Work,
248
+ excluding those notices that do not pertain to any part of
249
+ the Derivative Works; and
250
+
251
+ (d) If the Work includes a "NOTICE" text file as part of its
252
+ distribution, then any Derivative Works that You distribute must
253
+ include a readable copy of the attribution notices contained
254
+ within such NOTICE file, excluding those notices that do not
255
+ pertain to any part of the Derivative Works, in at least one
256
+ of the following places: within a NOTICE text file distributed
257
+ as part of the Derivative Works; within the Source form or
258
+ documentation, if provided along with the Derivative Works; or,
259
+ within a display generated by the Derivative Works, if and
260
+ wherever such third-party notices normally appear. The contents
261
+ of the NOTICE file are for informational purposes only and
262
+ do not modify the License. You may add Your own attribution
263
+ notices within Derivative Works that You distribute, alongside
264
+ or as an addendum to the NOTICE text from the Work, provided
265
+ that such additional attribution notices cannot be construed
266
+ as modifying the License.
267
+
268
+ You may add Your own copyright statement to Your modifications and
269
+ may provide additional or different license terms and conditions
270
+ for use, reproduction, or distribution of Your modifications, or
271
+ for any such Derivative Works as a whole, provided Your use,
272
+ reproduction, and distribution of the Work otherwise complies with
273
+ the conditions stated in this License.
274
+
275
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
276
+ any Contribution intentionally submitted for inclusion in the Work
277
+ by You to the Licensor shall be under the terms and conditions of
278
+ this License, without any additional terms or conditions.
279
+ Notwithstanding the above, nothing herein shall supersede or modify
280
+ the terms of any separate license agreement you may have executed
281
+ with Licensor regarding such Contributions.
282
+
283
+ 6. Trademarks. This License does not grant permission to use the trade
284
+ names, trademarks, service marks, or product names of the Licensor,
285
+ except as required for reasonable and customary use in describing the
286
+ origin of the Work and reproducing the content of the NOTICE file.
287
+
288
+ 7. Disclaimer of Warranty. Unless required by applicable law or
289
+ agreed to in writing, Licensor provides the Work (and each
290
+ Contributor provides its Contributions) on an "AS IS" BASIS,
291
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
292
+ implied, including, without limitation, any warranties or conditions
293
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
294
+ PARTICULAR PURPOSE. You are solely responsible for determining the
295
+ appropriateness of using or redistributing the Work and assume any
296
+ risks associated with Your exercise of permissions under this License.
297
+
298
+ 8. Limitation of Liability. In no event and under no legal theory,
299
+ whether in tort (including negligence), contract, or otherwise,
300
+ unless required by applicable law (such as deliberate and grossly
301
+ negligent acts) or agreed to in writing, shall any Contributor be
302
+ liable to You for damages, including any direct, indirect, special,
303
+ incidental, or consequential damages of any character arising as a
304
+ result of this License or out of the use or inability to use the
305
+ Work (including but not limited to damages for loss of goodwill,
306
+ work stoppage, computer failure or malfunction, or any and all
307
+ other commercial damages or losses), even if such Contributor
308
+ has been advised of the possibility of such damages.
309
+
310
+ 9. Accepting Warranty or Additional Liability. While redistributing
311
+ the Work or Derivative Works thereof, You may choose to offer,
312
+ and charge a fee for, acceptance of support, warranty, indemnity,
313
+ or other liability obligations and/or rights consistent with this
314
+ License. However, in accepting such obligations, You may act only
315
+ on Your own behalf and on Your sole responsibility, not on behalf
316
+ of any other Contributor, and only if You agree to indemnify,
317
+ defend, and hold each Contributor harmless for any liability
318
+ incurred by, or claims asserted against, such Contributor by reason
319
+ of your accepting any such warranty or additional liability.
320
+
321
+ END OF TERMS AND CONDITIONS
322
+
323
+ APPENDIX: How to apply the Apache License to your work.
324
+
325
+ To apply the Apache License to your work, attach the following
326
+ boilerplate notice, with the fields enclosed by brackets "[]"
327
+ replaced with your own identifying information. (Don't include
328
+ the brackets!) The text should be enclosed in the appropriate
329
+ comment syntax for the file format. We also recommend that a
330
+ file or class name and description of purpose be included on the
331
+ same "printed page" as the copyright notice for easier
332
+ identification within third-party archives.
333
+
334
+ Copyright [yyyy] [name of copyright owner]
335
+
336
+ Licensed under the Apache License, Version 2.0 (the "License");
337
+ you may not use this file except in compliance with the License.
338
+ You may obtain a copy of the License at
339
+
340
+ http://www.apache.org/licenses/LICENSE-2.0
341
+
342
+ Unless required by applicable law or agreed to in writing, software
343
+ distributed under the License is distributed on an "AS IS" BASIS,
344
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
345
+ See the License for the specific language governing permissions and
346
+ limitations under the License.
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.4
2
+ Name: pplx-context-mlx
3
+ Version: 0.1.0
4
+ Summary: Perplexity pplx-embed-v2-context contextual embeddings on Apple silicon with MLX
5
+ Author: Merchantry LLC
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/zm2231/pplx-context-mlx
8
+ Project-URL: Model, https://huggingface.co/perplexity-ai/pplx-embed-v2-context-0.6b
9
+ Keywords: mlx,apple-silicon,embeddings,contextual-embeddings,retrieval,perplexity
10
+ Requires-Python: >=3.11
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ License-File: NOTICE
14
+ Requires-Dist: huggingface-hub>=0.27.0
15
+ Requires-Dist: mlx>=0.32
16
+ Requires-Dist: numpy>=1.26
17
+ Requires-Dist: pillow>=10
18
+ Requires-Dist: tokenizers>=0.22
19
+ Provides-Extra: test
20
+ Requires-Dist: pytest>=8; extra == "test"
21
+ Provides-Extra: eval
22
+ Requires-Dist: datasets>=3; extra == "eval"
23
+ Provides-Extra: reference
24
+ Requires-Dist: torch>=2.8; extra == "reference"
25
+ Requires-Dist: transformers==5.4.0; extra == "reference"
26
+ Requires-Dist: torchvision; extra == "reference"
27
+ Requires-Dist: pillow; extra == "reference"
28
+ Requires-Dist: safetensors; extra == "reference"
29
+ Requires-Dist: tqdm; extra == "reference"
30
+ Dynamic: license-file
31
+
32
+ # pplx-context-mlx
33
+
34
+ Perplexity's [pplx-embed-v2-context-0.6b](https://huggingface.co/perplexity-ai/pplx-embed-v2-context-0.6b) contextual embeddings on Apple silicon. Each chunk's vector sees the rest of its document, and the upstream checkpoint loads unchanged, with no conversion step, PyTorch, or Transformers.
35
+
36
+ Independent project; not affiliated with or endorsed by Perplexity.
37
+
38
+ ## Quick start
39
+
40
+ ```bash
41
+ pip install pplx-context-mlx
42
+ ```
43
+
44
+ ```python
45
+ from pplx_context_mlx import load_model
46
+
47
+ engine = load_model() # the first call downloads about 2.4 GB of weights
48
+ chunks = engine.encode(
49
+ [["First chunk of a document.", "Second chunk, which sees the first."]],
50
+ normalize_embeddings=True,
51
+ )
52
+ query = engine.encode_queries([["What does the second chunk see?"]], normalize_embeddings=True)
53
+ scores = chunks[0] @ query[0][0]
54
+ ```
55
+
56
+ Each document is a list of chunks, and you get one 1,024-dimensional vector per chunk. Pass `dtype="float16"` to `load_model` for half the weight memory and a slightly faster model.
57
+
58
+ Page images embed as horizontal bands, with one vector per band:
59
+
60
+ ```python
61
+ from PIL import Image
62
+
63
+ bands = engine.encode_images([Image.open("page.png")], chunks=8, normalize_embeddings=True)[0]
64
+ page_score = (bands @ query[0][0]).max()
65
+ ```
66
+
67
+ From the command line, input is a JSON list of documents:
68
+
69
+ ```bash
70
+ pplx-context-mlx docs.json --dtype float16 --normalize > vectors.json
71
+ ```
72
+
73
+ ## At a glance
74
+
75
+ Measured on an M4 Pro with 64 GB, against upstream PyTorch on CPU. Sections below have the details and the report behind each figure.
76
+
77
+ | Question | Answer |
78
+ |---|---|
79
+ | Same vectors as upstream? | Within 1 int8 step; lowest cosine 0.999998 at `float32`, 0.99978 at `float16` |
80
+ | Same retrieval scores as the paper? | ViDoRe-V3 55.82 against 55.81; ConTEB within 0.22 on six of eight tasks, with [two gaps upstream shares](#conteb) |
81
+ | How fast? | One query in 7.4 ms; a 7,137-token document in 1.16 s (`float16`), 3 to 12 times upstream CPU |
82
+ | How much memory? | 3.8 GB (`float16`) or 5.5 GB (`float32`) on the speed suite; 13.2 GB at 119,041 tokens (`float16`) |
83
+
84
+ Not tested: a 16 GB Mac, the 9B model, or a comparison with upstream on a GPU. Vector accuracy against upstream is verified up to 13,871 tokens.
85
+
86
+ ## Parity
87
+
88
+ Measured against the upstream PyTorch model at revision `6d1fddab`, FP32 on CPU (its PyTorch fallback, not its CUDA fast path), over 16 text cases and 8 image cases, including padded batches, multilingual text, and a 13,871-token document.
89
+
90
+ | MLX dtype | Largest int8 difference | Lowest cosine | Weights |
91
+ |---|---:|---:|---:|
92
+ | `float32` (default) | 1 step | 0.999998 | 2.38 GB |
93
+ | `float16` | 1 step | 0.99978 | 1.19 GB |
94
+
95
+ Both rows compare against upstream at FP32. Other checks:
96
+
97
+ | Check | Result | Report |
98
+ |---|---|---|
99
+ | Image pixels, every fixture | Byte-for-byte match | `tests/test_images.py` |
100
+ | 48 real ViDoRe-V3 pages, 384 band vectors (`float32`) | Within 1 int8 step, lowest cosine 0.9999986 | `reports/real-pages/summary.json` |
101
+ | Upstream on transformers 5.22.1 against the recorded 5.4.0 fixtures | Within 1 int8 step, once its missing `config._commit_hash` is set by hand; otherwise upstream raises `AttributeError` | `reports/compat/transformers-5.22.1-drift.json` |
102
+ | Nine parts of the model broken on purpose | The vectors catch all nine | `reports/fault-injection.json` |
103
+
104
+ Regenerate with `scripts/make_reference.py` and `scripts/parity_report.py`. Results are in `reports/parity-*.json`.
105
+
106
+ ## Retrieval
107
+
108
+ Scored against the tables in the [paper](https://arxiv.org/abs/2610.38854). Reproduce with `evals/`.
109
+
110
+ ### ViDoRe-V3, text to Markdown
111
+
112
+ Whole pages, one chunk per page, nDCG@10 averaged over six languages, 18,252 pages. This setting has no chunker to choose, so it is the cleanest comparison (paper Table 12).
113
+
114
+ | Task | Paper | MLX `float32` |
115
+ |---|---:|---:|
116
+ | Finance (EN) | 59.14 | 59.19 |
117
+ | Finance (FR) | 43.51 | 43.54 |
118
+ | Industrial | 43.47 | 43.45 |
119
+ | Pharmaceuticals | 63.37 | 63.46 |
120
+ | Computer science | 70.69 | 70.66 |
121
+ | HR | 56.22 | 56.25 |
122
+ | Energy | 63.62 | 63.64 |
123
+ | Physics | 46.47 | 46.35 |
124
+ | Average | 55.81 | 55.82 |
125
+
126
+ With 128-token chunks (paper Table 13) the average is 58.33 against 58.51. The paper's chunker is not public, so this run uses fixed token slices.
127
+
128
+ ### ConTEB
129
+
130
+ nDCG@10 on the official task splits (paper Table 5).
131
+
132
+ | Task | Paper | MLX `float32` | MLX `float16` |
133
+ |---|---:|---:|---:|
134
+ | Geography | 94.1 | 94.10 | 94.10 |
135
+ | Football | 79.2 | 79.17 | 79.16 |
136
+ | SQuAD | 87.3 | 87.27 | 87.24 |
137
+ | NarrativeQA | 83.4 | 83.39 | 83.40 |
138
+ | MLDR | 89.8 | 89.65 | 89.78 |
139
+ | COVID-QA | 56.1 | 56.32 | 56.21 |
140
+ | Insurance | 88.0 | 88.93 | 88.93 |
141
+ | ESG | 67.3 | 53.54 | 52.74 |
142
+ | Average | 80.7 | 79.05 | 78.94 |
143
+
144
+ ESG is the one large gap, and it is not specific to this port: upstream's PyTorch model scored 52.74 under the same harness, and 88.93 on Insurance, the same as MLX. On those two tasks every query has the same top result in both runtimes, with 99.7% to 100% top-10 overlap (`reports/conteb/upstream-insurance-esg.json`, `reports/conteb/mlx-vs-upstream-rankings.json`). ESG has 36 queries and documents of up to 60,217 tokens, which were embedded whole here. Its score changes with how much context each chunk sees:
145
+
146
+ | Context per pass | ESG nDCG@10 |
147
+ |---:|---:|
148
+ | Non-contextual | 49.8 |
149
+ | 512 tokens | 54.3 |
150
+ | 2,048 | 62.4 |
151
+ | 4,096 | 66.4 |
152
+ | 8,192 | 62.1 |
153
+ | 32,768 | 57.3 |
154
+ | Whole document | 53.5 |
155
+
156
+ So more context is not automatically better on this task. Which setting the paper used for ESG is not stated, and one query is worth about 2.8 points. Windows split documents between chunks (`--window-tokens`); results are in `reports/conteb/esg-windows/`, and the whole-document row is in `reports/conteb/mlx-float32.json`.
157
+
158
+ ## Speed
159
+
160
+ On an M4 Pro with 64 GB. Each run started with 1-minute and 5-minute load averages under 2.7, as recorded in its report. Background services were running. MLX values are medians of three runs. Upstream ran on CPU at its best thread count for each workload, chosen from 1, 2, 4 and 6, because 1 thread was fastest for short inputs and 4 to 6 for long ones. No CUDA comparison was run.
161
+
162
+ | Workload | MLX `float16` | MLX `float32` | Upstream CPU |
163
+ |---|---:|---:|---:|
164
+ | One query | 7.4 ms | 11.4 ms | 71.9 ms |
165
+ | Queries per second, batches of 32 | 600 | 522 | 50 |
166
+ | 224-token document | 0.029 s | 0.032 s | 0.160 s |
167
+ | 1,785-token document | 0.20 s | 0.24 s | 1.13 s |
168
+ | 7,137-token document | 1.16 s | 1.43 s | 4.55 s |
169
+ | A4 page, 8 bands | 0.87 s | 1.03 s | 4.11 s |
170
+
171
+ Results are in `reports/benchmark/`. Reproduce with `scripts/benchmark.py`.
172
+
173
+ ## Memory
174
+
175
+ `load_model` caps MLX's buffer cache at 1 GB by default; set `cache_limit_mb` to change it. MLX's cache is process-wide, so the cap covers the whole process, and a later `load_model` call replaces it.
176
+
177
+ Peak footprints below come from the OS and include the cache. All are for the 0.6B model. Times are indicative, because these runs were not held to the load limits above.
178
+
179
+ | Tokens | `float16` time | `float16` peak | `float32` time | `float32` peak |
180
+ |---:|---:|---:|---:|---:|
181
+ | 13,681 | 3.0 s | 4.1 GB | 3.8 s | 6.0 GB |
182
+ | 29,521 | 10.8 s | 5.3 GB | 17.9 s | 9.1 GB |
183
+ | 59,041 | 42.0 s | 8.0 GB | | |
184
+ | 119,041 | 171 s | 13.2 GB | | |
185
+
186
+ Upstream on CPU measured a lower footprint on the speed workloads, 2.6 GB against 5.5 GB for MLX `float32`, so no memory advantage over upstream is claimed.
187
+
188
+ Attention scores queries in slices, which keeps memory far below the square of the document length. Very long inputs are possible, but they are not automatically better; see [ESG](#conteb).
189
+
190
+ **Why the cap exists.** Without it, a traced run over ESG documents in 32,768-token windows reached 50.47 GB of cache with 2.38 GB of active memory, then ended at window 10 of 38 without a traceback (`reports/memory/uncapped-esg-trace.log`). An earlier run of that task exited with code 137. What killed them was not identified. With the cap, the same workload holds the cache near 1 GB and completes all 38 windows (`reports/memory/capped-esg-trace.log`).
191
+
192
+ ## Scope
193
+
194
+ - **Models:** tested with `pplx-embed-v2-context-0.6b` only.
195
+ - **Inputs:** text and page images. Video is not supported.
196
+ - **Weights:** this package contains none and downloads them from Perplexity's repository.
197
+ - **License:** the code is MIT. Perplexity's cards for `pplx-embed-v2-context-9b` and `pplx-embed-v2-late-0.6b` declare MIT; the `0.6b` context card does not currently carry a license tag.
198
+
199
+ Third-party notices are in `NOTICE`.