winnex-xfactor 1.0.5__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.
- winnex_xfactor-1.0.5/.github/workflows/publish.yml +137 -0
- winnex_xfactor-1.0.5/.gitignore +113 -0
- winnex_xfactor-1.0.5/CMakeLists.txt +38 -0
- winnex_xfactor-1.0.5/LICENSE +65 -0
- winnex_xfactor-1.0.5/PKG-INFO +175 -0
- winnex_xfactor-1.0.5/README.md +91 -0
- winnex_xfactor-1.0.5/bindings/py_module.cpp +109 -0
- winnex_xfactor-1.0.5/include/winnex_xfactor/x_factor.hpp +152 -0
- winnex_xfactor-1.0.5/pyproject.toml +79 -0
- winnex_xfactor-1.0.5/python/winnex_xfactor/__init__.py +99 -0
- winnex_xfactor-1.0.5/python/winnex_xfactor/py.typed +0 -0
- winnex_xfactor-1.0.5/src/x_factor.cpp +227 -0
- winnex_xfactor-1.0.5/tests/test_x_factor.cpp +100 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
name: Build and Publish Multi-Platform Wheels
|
|
2
|
+
|
|
3
|
+
# Publica winnex-xfactor no PyPI com wheels para CPython 3.10–3.13 em Linux
|
|
4
|
+
# (manylinux), macOS (x86_64 + arm64) e Windows, mais o sdist.
|
|
5
|
+
#
|
|
6
|
+
# POR QUE ESTE ARQUIVO EXISTE ASSIM
|
|
7
|
+
# ---------------------------------
|
|
8
|
+
# A versão anterior tinha três defeitos que deixavam a maioria dos ambientes
|
|
9
|
+
# sem wheel:
|
|
10
|
+
#
|
|
11
|
+
# 1. CIBW_BUILD era `cp312-manylinux_x86_64` — uma única combinação. Os
|
|
12
|
+
# outros dois jobs da matriz construíam o MESMO wheel cp312 e o
|
|
13
|
+
# sobrescreviam. Resultado publicado: só cp312 existe no PyPI.
|
|
14
|
+
#
|
|
15
|
+
# 2. `requires_python = ">=3.10"` no pyproject, mas só cp312 publicado. O
|
|
16
|
+
# pip em 3.10, 3.11 ou 3.13 responde "No matching distribution found" —
|
|
17
|
+
# sem explicar que o problema é a ausência do wheel.
|
|
18
|
+
#
|
|
19
|
+
# 3. Nenhuma plataforma além de manylinux_x86_64. macOS e Windows ficavam
|
|
20
|
+
# sem binário, e o `pip install` caía no sdist, que exige compilador
|
|
21
|
+
# C++20 e uma árvore de build completa.
|
|
22
|
+
#
|
|
23
|
+
# A matriz agora segue os alvos do cibuildwheel (sem CIBW_BUILD manual), o
|
|
24
|
+
# que elimina a classe de erro acima: não há lista de ABIs escrita à mão para
|
|
25
|
+
# divergir do que é realmente construído. O job `verify` falha o pipeline se
|
|
26
|
+
# faltar qualquer combinação exigida.
|
|
27
|
+
#
|
|
28
|
+
# Publicação por Trusted Publisher (OIDC) — sem token no repositório.
|
|
29
|
+
#
|
|
30
|
+
# PyPI Project Name : winnex-xfactor
|
|
31
|
+
# Owner : winnex-ai
|
|
32
|
+
# Repository name : winnex-xfactor
|
|
33
|
+
# Workflow name : build-and-publish.yml
|
|
34
|
+
# Environment name : publish
|
|
35
|
+
|
|
36
|
+
on:
|
|
37
|
+
push:
|
|
38
|
+
tags: ['v*']
|
|
39
|
+
workflow_dispatch:
|
|
40
|
+
|
|
41
|
+
permissions:
|
|
42
|
+
contents: read
|
|
43
|
+
|
|
44
|
+
jobs:
|
|
45
|
+
build-wheels:
|
|
46
|
+
name: Wheels on ${{ matrix.os }}
|
|
47
|
+
strategy:
|
|
48
|
+
fail-fast: false # um alvo quebrado não cancela os outros
|
|
49
|
+
matrix:
|
|
50
|
+
# macos-13 (Intel) foi retirado do GitHub Actions e deixa o job em
|
|
51
|
+
# `queued` para sempre, travando o run inteiro. macos-14 é arm64.
|
|
52
|
+
os: [ubuntu-latest, macos-14, windows-latest]
|
|
53
|
+
runs-on: ${{ matrix.os }}
|
|
54
|
+
steps:
|
|
55
|
+
- uses: actions/checkout@v4
|
|
56
|
+
|
|
57
|
+
- name: Build wheels
|
|
58
|
+
uses: pypa/cibuildwheel@v2.21
|
|
59
|
+
with:
|
|
60
|
+
output-dir: wheelhouse
|
|
61
|
+
|
|
62
|
+
- uses: actions/upload-artifact@v4
|
|
63
|
+
with:
|
|
64
|
+
name: wheels-${{ matrix.os }}
|
|
65
|
+
path: wheelhouse/*.whl
|
|
66
|
+
if-no-files-found: error
|
|
67
|
+
|
|
68
|
+
build-sdist:
|
|
69
|
+
name: Source distribution
|
|
70
|
+
runs-on: ubuntu-latest
|
|
71
|
+
steps:
|
|
72
|
+
- uses: actions/checkout@v4
|
|
73
|
+
- uses: actions/setup-python@v5
|
|
74
|
+
with:
|
|
75
|
+
python-version: '3.12'
|
|
76
|
+
- run: pipx run build --sdist
|
|
77
|
+
- uses: actions/upload-artifact@v4
|
|
78
|
+
with:
|
|
79
|
+
name: sdist
|
|
80
|
+
path: dist/*.tar.gz
|
|
81
|
+
if-no-files-found: error
|
|
82
|
+
|
|
83
|
+
verify:
|
|
84
|
+
name: Verify wheel matrix
|
|
85
|
+
needs: [build-wheels]
|
|
86
|
+
runs-on: ubuntu-latest
|
|
87
|
+
steps:
|
|
88
|
+
- uses: actions/download-artifact@v4
|
|
89
|
+
with:
|
|
90
|
+
pattern: wheels-*
|
|
91
|
+
merge-multiple: true
|
|
92
|
+
path: dist
|
|
93
|
+
|
|
94
|
+
- name: Conferir a matriz publicada
|
|
95
|
+
run: |
|
|
96
|
+
python3 - <<'PY'
|
|
97
|
+
import glob, sys
|
|
98
|
+
from collections import Counter
|
|
99
|
+
wheels = glob.glob("dist/*.whl")
|
|
100
|
+
if not wheels:
|
|
101
|
+
sys.exit("nenhum wheel construido")
|
|
102
|
+
abis = Counter(w.split("-")[2] for w in wheels)
|
|
103
|
+
plats = Counter(w.split("-")[-1].replace(".whl", "") for w in wheels)
|
|
104
|
+
print(f"{len(wheels)} wheels")
|
|
105
|
+
print("ABIs :", dict(sorted(abis.items())))
|
|
106
|
+
print("plataf :", dict(sorted(plats.items())))
|
|
107
|
+
faltando = [a for a in ("cp310", "cp311", "cp312", "cp313")
|
|
108
|
+
if a not in abis]
|
|
109
|
+
if faltando:
|
|
110
|
+
sys.exit(f"ABIs ausentes: {faltando}")
|
|
111
|
+
for fam in ("manylinux", "macosx", "win"):
|
|
112
|
+
if not any(p.startswith(fam) for p in plats):
|
|
113
|
+
sys.exit(f"plataforma ausente: {fam}")
|
|
114
|
+
print("matriz completa")
|
|
115
|
+
PY
|
|
116
|
+
|
|
117
|
+
publish:
|
|
118
|
+
name: Publish to PyPI
|
|
119
|
+
needs: [build-wheels, build-sdist, verify]
|
|
120
|
+
runs-on: ubuntu-latest
|
|
121
|
+
environment: publish
|
|
122
|
+
permissions:
|
|
123
|
+
id-token: write
|
|
124
|
+
contents: read
|
|
125
|
+
steps:
|
|
126
|
+
- uses: actions/download-artifact@v4
|
|
127
|
+
with:
|
|
128
|
+
pattern: wheels-*
|
|
129
|
+
merge-multiple: true
|
|
130
|
+
path: dist
|
|
131
|
+
- uses: actions/download-artifact@v4
|
|
132
|
+
with:
|
|
133
|
+
name: sdist
|
|
134
|
+
path: dist
|
|
135
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
136
|
+
with:
|
|
137
|
+
packages-dir: dist
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# ============================================================================
|
|
2
|
+
# winnex-xfactor .gitignore — robusto e seguro
|
|
3
|
+
# ============================================================================
|
|
4
|
+
|
|
5
|
+
# ---------------------------------------------------------------------------
|
|
6
|
+
# Credenciais e segredos — NUNCA versionar
|
|
7
|
+
# ---------------------------------------------------------------------------
|
|
8
|
+
*.pypirc
|
|
9
|
+
.pypirc
|
|
10
|
+
.twine.cfg
|
|
11
|
+
.twine*
|
|
12
|
+
credentials.json
|
|
13
|
+
*credential*
|
|
14
|
+
*.token
|
|
15
|
+
*.key
|
|
16
|
+
*.pem
|
|
17
|
+
*.pfx
|
|
18
|
+
*.jks
|
|
19
|
+
*.secret
|
|
20
|
+
secrets/
|
|
21
|
+
.env
|
|
22
|
+
.env.*
|
|
23
|
+
!.env.example
|
|
24
|
+
!*.example
|
|
25
|
+
.pypi*
|
|
26
|
+
twine.env
|
|
27
|
+
netrc
|
|
28
|
+
_netrc
|
|
29
|
+
|
|
30
|
+
# ---------------------------------------------------------------------------
|
|
31
|
+
# Artefatos de build — nunca versionar binários/objetos
|
|
32
|
+
# ---------------------------------------------------------------------------
|
|
33
|
+
build/
|
|
34
|
+
build_*/
|
|
35
|
+
dist/
|
|
36
|
+
*.egg-info/
|
|
37
|
+
*.egg
|
|
38
|
+
*.whl
|
|
39
|
+
*.tar.gz
|
|
40
|
+
*.so
|
|
41
|
+
*.dylib
|
|
42
|
+
*.dll
|
|
43
|
+
*.a
|
|
44
|
+
*.o
|
|
45
|
+
*.obj
|
|
46
|
+
*.lib
|
|
47
|
+
*.exe
|
|
48
|
+
CMakeCache.txt
|
|
49
|
+
CMakeFiles/
|
|
50
|
+
cmake_install.cmake
|
|
51
|
+
CTestTestfile.cmake
|
|
52
|
+
Makefile
|
|
53
|
+
.ninja*
|
|
54
|
+
Ninja
|
|
55
|
+
Testing/
|
|
56
|
+
install_manifest.txt
|
|
57
|
+
|
|
58
|
+
# ---------------------------------------------------------------------------
|
|
59
|
+
# Python
|
|
60
|
+
# ---------------------------------------------------------------------------
|
|
61
|
+
__pycache__/
|
|
62
|
+
*.py[cod]
|
|
63
|
+
*$py.class
|
|
64
|
+
*.pyc
|
|
65
|
+
.pytest_cache/
|
|
66
|
+
.mypy_cache/
|
|
67
|
+
.ruff_cache/
|
|
68
|
+
.coverage
|
|
69
|
+
.coverage.*
|
|
70
|
+
htmlcov/
|
|
71
|
+
.tox/
|
|
72
|
+
nox/
|
|
73
|
+
*.log
|
|
74
|
+
*.prof
|
|
75
|
+
|
|
76
|
+
# ---------------------------------------------------------------------------
|
|
77
|
+
# Documentos que NÃO devem ser publicados (apenas README.md é publicado)
|
|
78
|
+
# ---------------------------------------------------------------------------
|
|
79
|
+
*.pdf
|
|
80
|
+
*.ipynb
|
|
81
|
+
*.docx
|
|
82
|
+
!README.md
|
|
83
|
+
|
|
84
|
+
# ---------------------------------------------------------------------------
|
|
85
|
+
# Ambientes virtuais
|
|
86
|
+
# ---------------------------------------------------------------------------
|
|
87
|
+
.venv/
|
|
88
|
+
venv/
|
|
89
|
+
env/
|
|
90
|
+
ENV/
|
|
91
|
+
.env-local/
|
|
92
|
+
|
|
93
|
+
# ---------------------------------------------------------------------------
|
|
94
|
+
# Editores / IDE
|
|
95
|
+
# ---------------------------------------------------------------------------
|
|
96
|
+
.vscode/
|
|
97
|
+
.idea/
|
|
98
|
+
*.swp
|
|
99
|
+
*.swo
|
|
100
|
+
*~
|
|
101
|
+
.DS_Store
|
|
102
|
+
Thumbs.db
|
|
103
|
+
|
|
104
|
+
# ---------------------------------------------------------------------------
|
|
105
|
+
# Diversos
|
|
106
|
+
# ---------------------------------------------------------------------------
|
|
107
|
+
*.tmp
|
|
108
|
+
*.bak
|
|
109
|
+
*.orig
|
|
110
|
+
*.rej
|
|
111
|
+
core
|
|
112
|
+
core.*
|
|
113
|
+
!core/
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.20)
|
|
2
|
+
project(winnex_xfactor VERSION 1.0.0 LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
5
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
|
+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
7
|
+
|
|
8
|
+
# Options
|
|
9
|
+
option(WINNEX_XFACTOR_BUILD_TESTS "Build tests" ON)
|
|
10
|
+
option(WINNEX_XFACTOR_BUILD_PYTHON "Build the pybind11 Python module" ON)
|
|
11
|
+
|
|
12
|
+
# --- Core static library ---------------------------------------------------
|
|
13
|
+
add_library(winnex_xfactor src/x_factor.cpp)
|
|
14
|
+
target_include_directories(winnex_xfactor PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
15
|
+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
|
|
16
|
+
target_compile_options(winnex_xfactor PRIVATE -O3 -funroll-loops)
|
|
17
|
+
endif()
|
|
18
|
+
|
|
19
|
+
# --- Python bindings (pybind11) --------------------------------------------
|
|
20
|
+
# scikit-build-core sets up Python3_ROOT_DIR / Python_EXECUTABLE in the build
|
|
21
|
+
# environment; pybind11's pybind11_add_module resolves the interpreter without
|
|
22
|
+
# us requiring Development/Development.Embed (which manylinux lacks).
|
|
23
|
+
if(WINNEX_XFACTOR_BUILD_PYTHON)
|
|
24
|
+
find_package(pybind11 CONFIG REQUIRED)
|
|
25
|
+
pybind11_add_module(_winnex_xfactor bindings/py_module.cpp)
|
|
26
|
+
target_link_libraries(_winnex_xfactor PRIVATE winnex_xfactor)
|
|
27
|
+
if(DEFINED SKBUILD_PLATLIB_DIR)
|
|
28
|
+
install(TARGETS _winnex_xfactor DESTINATION ${SKBUILD_PLATLIB_DIR})
|
|
29
|
+
endif()
|
|
30
|
+
endif()
|
|
31
|
+
|
|
32
|
+
# --- Tests -----------------------------------------------------------------
|
|
33
|
+
if(WINNEX_XFACTOR_BUILD_TESTS)
|
|
34
|
+
enable_testing()
|
|
35
|
+
add_executable(test_x_factor tests/test_x_factor.cpp)
|
|
36
|
+
target_link_libraries(test_x_factor PRIVATE winnex_xfactor)
|
|
37
|
+
add_test(NAME x_factor COMMAND test_x_factor)
|
|
38
|
+
endif()
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
5
|
+
|
|
6
|
+
Parameters
|
|
7
|
+
|
|
8
|
+
Licensor: Winnex Brasil Solucoes Empresariais LTDA - ME
|
|
9
|
+
Licensed Work: winnex-madhava
|
|
10
|
+
The Licensed Work is (c) 2026 Winnex Brasil Solucoes
|
|
11
|
+
Empresariais LTDA - ME
|
|
12
|
+
Additional Use Grant: You may make use of the Licensed Work, provided that
|
|
13
|
+
you do not use the Licensed Work for a Search Service,
|
|
14
|
+
or any other service that exposes the functionality of
|
|
15
|
+
the Licensed Work to third parties as a service.
|
|
16
|
+
"Search Service" means a commercial offering that allows
|
|
17
|
+
third parties (other than your employees and contractors)
|
|
18
|
+
to use the functionality of the Licensed Work to perform
|
|
19
|
+
vector similarity search.
|
|
20
|
+
|
|
21
|
+
Change Date: 2036-01-01
|
|
22
|
+
Change License: GNU General Public License v2.0 or later
|
|
23
|
+
|
|
24
|
+
*****************************************************************************
|
|
25
|
+
|
|
26
|
+
Business Source License 1.1
|
|
27
|
+
|
|
28
|
+
Terms
|
|
29
|
+
|
|
30
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
31
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
32
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
33
|
+
production use.
|
|
34
|
+
|
|
35
|
+
Effective on the Change Date, or the fourth anniversary of the first
|
|
36
|
+
publicly available distribution of a specific version of the Licensed Work
|
|
37
|
+
under this license, whichever comes first, the Licensed Work will be made
|
|
38
|
+
available under the terms of the Change License, or in the absence of a
|
|
39
|
+
Change License, the GNU General Public License version 2.0 or later.
|
|
40
|
+
|
|
41
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
42
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
43
|
+
separately for each version of the Licensed Work and the Change Date may
|
|
44
|
+
vary for each version of the Licensed Work released by Licensor.
|
|
45
|
+
|
|
46
|
+
You must conspicuously display this License on each original or modified
|
|
47
|
+
copy of the Licensed Work. If you receive the Licensed Work in original or
|
|
48
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
49
|
+
License apply to your use of that work.
|
|
50
|
+
|
|
51
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
52
|
+
terminate your rights under this License for the current and all other
|
|
53
|
+
versions of the Licensed Work.
|
|
54
|
+
|
|
55
|
+
This License does not grant you any right in any trademark or logo of
|
|
56
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
57
|
+
Licensor as expressly required by this License).
|
|
58
|
+
|
|
59
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
60
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
61
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
62
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
63
|
+
TITLE.
|
|
64
|
+
|
|
65
|
+
For inquiries: pay@winnex.ai
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: winnex-xfactor
|
|
3
|
+
Version: 1.0.5
|
|
4
|
+
Summary: Deterministic manifold embedding for native LLM inference — the X-Factor operator (O(D²r) power iteration, no training).
|
|
5
|
+
Keywords: x-factor,manifold,embedding,llm,inference,spectral,eigenvalue,power-iteration,deterministic,winnex,madhava,semantic,dimension-reduction
|
|
6
|
+
Author-Email: Winnex Brasil Soluções Empresariais LTDA-ME <pay@winnex.ai>
|
|
7
|
+
License: Business Source License 1.1
|
|
8
|
+
|
|
9
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
10
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
11
|
+
|
|
12
|
+
Parameters
|
|
13
|
+
|
|
14
|
+
Licensor: Winnex Brasil Solucoes Empresariais LTDA - ME
|
|
15
|
+
Licensed Work: winnex-madhava
|
|
16
|
+
The Licensed Work is (c) 2026 Winnex Brasil Solucoes
|
|
17
|
+
Empresariais LTDA - ME
|
|
18
|
+
Additional Use Grant: You may make use of the Licensed Work, provided that
|
|
19
|
+
you do not use the Licensed Work for a Search Service,
|
|
20
|
+
or any other service that exposes the functionality of
|
|
21
|
+
the Licensed Work to third parties as a service.
|
|
22
|
+
"Search Service" means a commercial offering that allows
|
|
23
|
+
third parties (other than your employees and contractors)
|
|
24
|
+
to use the functionality of the Licensed Work to perform
|
|
25
|
+
vector similarity search.
|
|
26
|
+
|
|
27
|
+
Change Date: 2036-01-01
|
|
28
|
+
Change License: GNU General Public License v2.0 or later
|
|
29
|
+
|
|
30
|
+
*****************************************************************************
|
|
31
|
+
|
|
32
|
+
Business Source License 1.1
|
|
33
|
+
|
|
34
|
+
Terms
|
|
35
|
+
|
|
36
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
37
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
38
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
39
|
+
production use.
|
|
40
|
+
|
|
41
|
+
Effective on the Change Date, or the fourth anniversary of the first
|
|
42
|
+
publicly available distribution of a specific version of the Licensed Work
|
|
43
|
+
under this license, whichever comes first, the Licensed Work will be made
|
|
44
|
+
available under the terms of the Change License, or in the absence of a
|
|
45
|
+
Change License, the GNU General Public License version 2.0 or later.
|
|
46
|
+
|
|
47
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
48
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
49
|
+
separately for each version of the Licensed Work and the Change Date may
|
|
50
|
+
vary for each version of the Licensed Work released by Licensor.
|
|
51
|
+
|
|
52
|
+
You must conspicuously display this License on each original or modified
|
|
53
|
+
copy of the Licensed Work. If you receive the Licensed Work in original or
|
|
54
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
55
|
+
License apply to your use of that work.
|
|
56
|
+
|
|
57
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
58
|
+
terminate your rights under this License for the current and all other
|
|
59
|
+
versions of the Licensed Work.
|
|
60
|
+
|
|
61
|
+
This License does not grant you any right in any trademark or logo of
|
|
62
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
63
|
+
Licensor as expressly required by this License).
|
|
64
|
+
|
|
65
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
66
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
67
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
68
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
69
|
+
TITLE.
|
|
70
|
+
|
|
71
|
+
For inquiries: pay@winnex.ai
|
|
72
|
+
|
|
73
|
+
Classifier: Programming Language :: C++
|
|
74
|
+
Classifier: Programming Language :: Python :: 3
|
|
75
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
76
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
77
|
+
Classifier: Intended Audience :: Developers
|
|
78
|
+
Classifier: Intended Audience :: Science/Research
|
|
79
|
+
Project-URL: Homepage, https://winnex.ai
|
|
80
|
+
Project-URL: Source, https://github.com/winnex-ai/winnex-xfactor
|
|
81
|
+
Requires-Python: >=3.10
|
|
82
|
+
Requires-Dist: numpy>=1.20
|
|
83
|
+
Description-Content-Type: text/markdown
|
|
84
|
+
|
|
85
|
+
<div align="center">
|
|
86
|
+
|
|
87
|
+
# winnex-xfactor
|
|
88
|
+
|
|
89
|
+
**Deterministic manifold embedding for native LLM inference.**
|
|
90
|
+
|
|
91
|
+
The X-Factor is a training-free operator that embeds text into a pretrained
|
|
92
|
+
model's latent space — computed *structurally* from `embed_tokens`, never by
|
|
93
|
+
running the model.
|
|
94
|
+
|
|
95
|
+
[](https://pypi.org/project/winnex-xfactor)
|
|
96
|
+
[](https://www.python.org/)
|
|
97
|
+
[](https://isocpp.org/)
|
|
98
|
+
[](LICENSE)
|
|
99
|
+
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
## What it is
|
|
103
|
+
|
|
104
|
+
For any model, the X-Factor is the orthonormal basis of the manifold where its
|
|
105
|
+
token embeddings live:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
Ē = E − mean(E) (center)
|
|
109
|
+
C = ĒᵀĒ / V (D×D covariance)
|
|
110
|
+
C = U Λ Uᵀ (eigh, Λ descending)
|
|
111
|
+
r = min{r : cumsum(Λ₁..r)/ΣΛ ≥ τ} (effective rank)
|
|
112
|
+
X = U[:, :r] (the X factor: D×r manifold basis)
|
|
113
|
+
P = X·Xᵀ (orthogonal projector)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The projector is **idempotent** (P²=P) and **symmetric** (Pᵀ=P) — the
|
|
117
|
+
orthogonal projection onto the model's embedding manifold.
|
|
118
|
+
|
|
119
|
+
## Why it is fast
|
|
120
|
+
|
|
121
|
+
The eigendecomposition uses **power iteration with deflation**:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
O(D²·r·iters) vs O(D³) for a full Jacobi/eigh
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
~2000× faster at D=2048, with the same deterministic guarantee (the Madhava
|
|
128
|
+
philosophy: bound-guided selection, provable operators, no black boxes).
|
|
129
|
+
|
|
130
|
+
## Install
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
pip install winnex-xfactor
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Requires Python ≥ 3.8 and NumPy. The C++ core ships pre-built in the wheel.
|
|
137
|
+
|
|
138
|
+
## Quick start
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
import numpy as np
|
|
142
|
+
import winnex_xfactor
|
|
143
|
+
|
|
144
|
+
# 1. Compute the X-Factor from a model's embed_tokens (a sample is enough).
|
|
145
|
+
E = np.random.randn(5000, 2048).astype(np.float32)
|
|
146
|
+
P, rank, variance = winnex_xfactor.compute_xfactor(E, 5000, 2048, tau=0.95)
|
|
147
|
+
print(f"rank={rank}, variance captured={variance:.3f}")
|
|
148
|
+
|
|
149
|
+
# 2. Embed a spectral token into the model's manifold.
|
|
150
|
+
psi = np.ones(64, dtype=np.float32)
|
|
151
|
+
h = winnex_xfactor.embed_spectral(psi, P) # length 2048, on the manifold
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## API
|
|
155
|
+
|
|
156
|
+
- `compute_xfactor(embed_tokens, vocab, dim, tau=0.95) -> (P, rank, variance)`
|
|
157
|
+
- `XFactor(embed_tokens, vocab, dim, tau)` — object with `.project`, `.project_batch`,
|
|
158
|
+
`.projector`, `.basis`, `.rank`, `.variance_captured`, `.dim`
|
|
159
|
+
- `expand_spectral(psi, d, D)` — zero-pad + L2 normalize
|
|
160
|
+
- `embed_spectral(psi, P)` — full text→manifold projection
|
|
161
|
+
|
|
162
|
+
## Benchmark
|
|
163
|
+
|
|
164
|
+
Run the benchmark on Kaggle — installs `winnex-xfactor` (and `winnex-nano` for
|
|
165
|
+
the safetensors loader) from PyPI and computes the X-Factor from **real
|
|
166
|
+
embeddings** of a Qwen model (Kaggle `qwen-lm/qwen`):
|
|
167
|
+
|
|
168
|
+
[](https://www.kaggle.com/code/kleniopadilha/winnex-xfactor-benchmark-manifold)
|
|
169
|
+
|
|
170
|
+
Result: effective rank 118 (D=128, τ=0.95, variance captured 0.954),
|
|
171
|
+
compute 0.03s — power iteration with deflation (O(D²·r)) on real embeddings.
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
BSL 1.1 | pay@winnex.ai | (c) Winnex Brasil Soluções Empresariais LTDA-ME
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# winnex-xfactor
|
|
4
|
+
|
|
5
|
+
**Deterministic manifold embedding for native LLM inference.**
|
|
6
|
+
|
|
7
|
+
The X-Factor is a training-free operator that embeds text into a pretrained
|
|
8
|
+
model's latent space — computed *structurally* from `embed_tokens`, never by
|
|
9
|
+
running the model.
|
|
10
|
+
|
|
11
|
+
[](https://pypi.org/project/winnex-xfactor)
|
|
12
|
+
[](https://www.python.org/)
|
|
13
|
+
[](https://isocpp.org/)
|
|
14
|
+
[](LICENSE)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
## What it is
|
|
19
|
+
|
|
20
|
+
For any model, the X-Factor is the orthonormal basis of the manifold where its
|
|
21
|
+
token embeddings live:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
Ē = E − mean(E) (center)
|
|
25
|
+
C = ĒᵀĒ / V (D×D covariance)
|
|
26
|
+
C = U Λ Uᵀ (eigh, Λ descending)
|
|
27
|
+
r = min{r : cumsum(Λ₁..r)/ΣΛ ≥ τ} (effective rank)
|
|
28
|
+
X = U[:, :r] (the X factor: D×r manifold basis)
|
|
29
|
+
P = X·Xᵀ (orthogonal projector)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The projector is **idempotent** (P²=P) and **symmetric** (Pᵀ=P) — the
|
|
33
|
+
orthogonal projection onto the model's embedding manifold.
|
|
34
|
+
|
|
35
|
+
## Why it is fast
|
|
36
|
+
|
|
37
|
+
The eigendecomposition uses **power iteration with deflation**:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
O(D²·r·iters) vs O(D³) for a full Jacobi/eigh
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
~2000× faster at D=2048, with the same deterministic guarantee (the Madhava
|
|
44
|
+
philosophy: bound-guided selection, provable operators, no black boxes).
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install winnex-xfactor
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Requires Python ≥ 3.8 and NumPy. The C++ core ships pre-built in the wheel.
|
|
53
|
+
|
|
54
|
+
## Quick start
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
import numpy as np
|
|
58
|
+
import winnex_xfactor
|
|
59
|
+
|
|
60
|
+
# 1. Compute the X-Factor from a model's embed_tokens (a sample is enough).
|
|
61
|
+
E = np.random.randn(5000, 2048).astype(np.float32)
|
|
62
|
+
P, rank, variance = winnex_xfactor.compute_xfactor(E, 5000, 2048, tau=0.95)
|
|
63
|
+
print(f"rank={rank}, variance captured={variance:.3f}")
|
|
64
|
+
|
|
65
|
+
# 2. Embed a spectral token into the model's manifold.
|
|
66
|
+
psi = np.ones(64, dtype=np.float32)
|
|
67
|
+
h = winnex_xfactor.embed_spectral(psi, P) # length 2048, on the manifold
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## API
|
|
71
|
+
|
|
72
|
+
- `compute_xfactor(embed_tokens, vocab, dim, tau=0.95) -> (P, rank, variance)`
|
|
73
|
+
- `XFactor(embed_tokens, vocab, dim, tau)` — object with `.project`, `.project_batch`,
|
|
74
|
+
`.projector`, `.basis`, `.rank`, `.variance_captured`, `.dim`
|
|
75
|
+
- `expand_spectral(psi, d, D)` — zero-pad + L2 normalize
|
|
76
|
+
- `embed_spectral(psi, P)` — full text→manifold projection
|
|
77
|
+
|
|
78
|
+
## Benchmark
|
|
79
|
+
|
|
80
|
+
Run the benchmark on Kaggle — installs `winnex-xfactor` (and `winnex-nano` for
|
|
81
|
+
the safetensors loader) from PyPI and computes the X-Factor from **real
|
|
82
|
+
embeddings** of a Qwen model (Kaggle `qwen-lm/qwen`):
|
|
83
|
+
|
|
84
|
+
[](https://www.kaggle.com/code/kleniopadilha/winnex-xfactor-benchmark-manifold)
|
|
85
|
+
|
|
86
|
+
Result: effective rank 118 (D=128, τ=0.95, variance captured 0.954),
|
|
87
|
+
compute 0.03s — power iteration with deflation (O(D²·r)) on real embeddings.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
BSL 1.1 | pay@winnex.ai | (c) Winnex Brasil Soluções Empresariais LTDA-ME
|