model2vec-rs 0.0.1__tar.gz → 0.4.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 (40) hide show
  1. model2vec_rs-0.4.0/.github/workflows/ci.yaml +124 -0
  2. model2vec_rs-0.4.0/.github/workflows/release-python.yaml +135 -0
  3. model2vec_rs-0.4.0/.github/workflows/release.yaml +29 -0
  4. model2vec_rs-0.4.0/.gitignore +25 -0
  5. model2vec_rs-0.4.0/CITATION.cff +27 -0
  6. model2vec_rs-0.4.0/Cargo.lock +1831 -0
  7. model2vec_rs-0.4.0/Cargo.toml +73 -0
  8. model2vec_rs-0.4.0/LICENSE +21 -0
  9. model2vec_rs-0.4.0/PKG-INFO +58 -0
  10. model2vec_rs-0.4.0/README.md +283 -0
  11. model2vec_rs-0.4.0/benches/README.md +116 -0
  12. model2vec_rs-0.4.0/benches/encode.rs +82 -0
  13. model2vec_rs-0.4.0/benches/nanobeir.rs +135 -0
  14. model2vec_rs-0.4.0/benches/nanobeir_baseline.json +137 -0
  15. model2vec_rs-0.4.0/benches/python_compare.rs +80 -0
  16. model2vec_rs-0.4.0/benches/quantize.rs +175 -0
  17. model2vec_rs-0.4.0/benches/throughput.rs +86 -0
  18. model2vec_rs-0.4.0/pyproject.toml +33 -0
  19. model2vec_rs-0.4.0/python/Cargo.lock +1845 -0
  20. model2vec_rs-0.4.0/python/Cargo.toml +20 -0
  21. model2vec_rs-0.4.0/python/README.md +44 -0
  22. model2vec_rs-0.4.0/python/model2vec_rs.pyi +33 -0
  23. model2vec_rs-0.4.0/python/src/lib.rs +199 -0
  24. model2vec_rs-0.4.0/python/tests/test_bindings.py +148 -0
  25. model2vec_rs-0.4.0/python/uv.lock +412 -0
  26. model2vec_rs-0.4.0/rustfmt.toml +1 -0
  27. model2vec_rs-0.4.0/scripts/bench_compare.py +303 -0
  28. model2vec_rs-0.4.0/scripts/bindings_chart.py +93 -0
  29. model2vec_rs-0.4.0/scripts/nanobeir.py +206 -0
  30. model2vec_rs-0.4.0/scripts/python_compare.py +319 -0
  31. model2vec_rs-0.4.0/scripts/speedup_chart.py +104 -0
  32. model2vec_rs-0.4.0/src/fast_unigram.rs +458 -0
  33. model2vec_rs-0.4.0/src/fast_wordpiece.rs +933 -0
  34. model2vec_rs-0.4.0/src/lib.rs +4 -0
  35. model2vec_rs-0.4.0/src/main.rs +73 -0
  36. model2vec_rs-0.4.0/src/model.rs +1003 -0
  37. model2vec_rs-0.4.0/src/trie.rs +234 -0
  38. model2vec_rs-0.0.1/PKG-INFO +0 -6
  39. model2vec_rs-0.0.1/pyproject.toml +0 -13
  40. model2vec_rs-0.0.1/src/model2vec_rs/__init__.py +0 -0
@@ -0,0 +1,124 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ build-and-test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ include:
16
+ - name: default
17
+ build: cargo build --verbose
18
+ test: cargo test --verbose
19
+ - name: cli
20
+ build: cargo build --features cli --verbose
21
+ test: cargo test --features cli --verbose
22
+ - name: fancy-regex
23
+ build: cargo build --no-default-features --features fancy-regex --verbose
24
+ test: cargo test --no-default-features --features fancy-regex --verbose
25
+ - name: local-only
26
+ build: cargo build --no-default-features --features onig,local-only --verbose
27
+ test: cargo test --no-default-features --features onig,local-only --verbose
28
+
29
+ steps:
30
+ - name: Checkout
31
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
32
+
33
+ - name: Set up Rust
34
+ uses: dtolnay/rust-toolchain@39008827e6b4319a349e9a42dfc90579dd25f1ca # stable
35
+ with:
36
+ toolchain: stable
37
+ components: clippy, rustfmt
38
+
39
+ - name: Build
40
+ run: ${{ matrix.build }}
41
+
42
+ - name: Test
43
+ run: ${{ matrix.test }}
44
+
45
+ - name: Lint (clippy)
46
+ run: cargo clippy --all-targets --all-features -- -D warnings
47
+
48
+ - name: Format check
49
+ run: cargo fmt -- --check
50
+
51
+ wasm-check:
52
+ runs-on: ubuntu-latest
53
+
54
+ steps:
55
+ - name: Checkout
56
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
57
+
58
+ - name: Set up Rust
59
+ uses: dtolnay/rust-toolchain@39008827e6b4319a349e9a42dfc90579dd25f1ca # stable
60
+ with:
61
+ toolchain: stable
62
+ target: wasm32-unknown-unknown
63
+
64
+ - name: Check wasm feature set
65
+ run: RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo check --no-default-features --features wasm --target wasm32-unknown-unknown
66
+
67
+ python-bindings-lint:
68
+ runs-on: ubuntu-latest
69
+ defaults:
70
+ run:
71
+ working-directory: python
72
+
73
+ steps:
74
+ - name: Checkout
75
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
76
+
77
+ - name: Set up Rust
78
+ uses: dtolnay/rust-toolchain@39008827e6b4319a349e9a42dfc90579dd25f1ca # stable
79
+ with:
80
+ toolchain: stable
81
+ components: clippy, rustfmt
82
+
83
+ - name: Lint (clippy)
84
+ run: cargo clippy --all-targets -- -D warnings
85
+
86
+ - name: Format check
87
+ run: cargo fmt -- --check
88
+
89
+ python-bindings:
90
+ runs-on: ${{ matrix.os }}
91
+ strategy:
92
+ fail-fast: false
93
+ matrix:
94
+ os: [ubuntu-latest, macos-latest, windows-latest]
95
+ python-version: ["3.10", "3.13"]
96
+ defaults:
97
+ run:
98
+ working-directory: python
99
+ shell: bash
100
+
101
+ steps:
102
+ - name: Checkout
103
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
104
+
105
+ - name: Set up Rust
106
+ uses: dtolnay/rust-toolchain@39008827e6b4319a349e9a42dfc90579dd25f1ca # stable
107
+ with:
108
+ toolchain: stable
109
+
110
+ - name: Set up Python
111
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
112
+ with:
113
+ python-version: ${{ matrix.python-version }}
114
+
115
+ - name: Build wheel
116
+ run: |
117
+ python -m pip install maturin
118
+ maturin build --release --out dist
119
+
120
+ - name: Install wheel
121
+ run: python -m pip install pytest dist/*.whl
122
+
123
+ - name: Test
124
+ run: python -m pytest tests
@@ -0,0 +1,135 @@
1
+ name: Release Python
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ tag:
7
+ description: "Tag to release (e.g. py-v0.4.1)"
8
+ required: true
9
+ type: string
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ jobs:
15
+ verify:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - name: Checkout
19
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
20
+ with:
21
+ ref: refs/tags/${{ inputs.tag }}
22
+
23
+ - name: Check tag matches python/Cargo.toml version
24
+ env:
25
+ TAG: ${{ inputs.tag }}
26
+ run: |
27
+ case "$TAG" in
28
+ py-v*) ;;
29
+ *) echo "Tag must start with py-v, got $TAG"; exit 1 ;;
30
+ esac
31
+ VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' python/Cargo.toml | head -1)
32
+ if [ "py-v$VERSION" != "$TAG" ]; then
33
+ echo "Tag $TAG does not match python/Cargo.toml version $VERSION"
34
+ exit 1
35
+ fi
36
+
37
+ wheels:
38
+ name: Wheel (${{ matrix.platform.name }})
39
+ needs: verify
40
+ runs-on: ${{ matrix.platform.runner }}
41
+ strategy:
42
+ fail-fast: false
43
+ matrix:
44
+ platform:
45
+ - { name: linux-x86_64, runner: ubuntu-latest, target: x86_64, manylinux: "2_28" }
46
+ - { name: linux-aarch64, runner: ubuntu-24.04-arm, target: aarch64, manylinux: "2_28" }
47
+ - { name: musllinux-x86_64, runner: ubuntu-latest, target: x86_64, manylinux: musllinux_1_2 }
48
+ - { name: musllinux-aarch64, runner: ubuntu-24.04-arm, target: aarch64, manylinux: musllinux_1_2 }
49
+ - { name: macos-x86_64, runner: macos-latest, target: x86_64-apple-darwin }
50
+ - { name: macos-aarch64, runner: macos-latest, target: aarch64-apple-darwin }
51
+ - { name: windows-x86_64, runner: windows-latest, target: x64 }
52
+ - { name: windows-aarch64, runner: windows-11-arm, target: aarch64-pc-windows-msvc }
53
+
54
+ steps:
55
+ - name: Checkout
56
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
57
+ with:
58
+ ref: refs/tags/${{ inputs.tag }}
59
+
60
+ - name: Set up Python
61
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
62
+ with:
63
+ python-version: "3.13"
64
+
65
+ - name: Build wheel
66
+ uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
67
+ with:
68
+ working-directory: python
69
+ target: ${{ matrix.platform.target }}
70
+ manylinux: ${{ matrix.platform.manylinux || 'auto' }}
71
+ args: --release --out dist
72
+
73
+ - name: Upload wheel
74
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
75
+ with:
76
+ name: wheel-${{ matrix.platform.name }}
77
+ path: python/dist
78
+
79
+ sdist:
80
+ needs: verify
81
+ runs-on: ubuntu-latest
82
+ steps:
83
+ - name: Checkout
84
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
85
+ with:
86
+ ref: refs/tags/${{ inputs.tag }}
87
+
88
+ - name: Build sdist
89
+ uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
90
+ with:
91
+ working-directory: python
92
+ command: sdist
93
+ args: --out dist
94
+
95
+ - name: Set up Python
96
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
97
+ with:
98
+ python-version: "3.13"
99
+
100
+ - name: Build wheel from sdist
101
+ run: |
102
+ mkdir "$RUNNER_TEMP/sdist-check"
103
+ tar -xzf python/dist/*.tar.gz -C "$RUNNER_TEMP/sdist-check"
104
+ python -m pip wheel --no-deps --wheel-dir "$RUNNER_TEMP/sdist-wheel" "$RUNNER_TEMP"/sdist-check/*/
105
+
106
+ - name: Test wheel built from sdist
107
+ working-directory: python
108
+ run: |
109
+ python -m pip install pytest "$RUNNER_TEMP"/sdist-wheel/*.whl
110
+ python -m pytest tests
111
+
112
+ - name: Upload sdist
113
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
114
+ with:
115
+ name: sdist
116
+ path: python/dist
117
+
118
+ publish:
119
+ needs: [wheels, sdist]
120
+ runs-on: ubuntu-latest
121
+ environment: pypi
122
+ permissions:
123
+ id-token: write
124
+
125
+ steps:
126
+ - name: Download artifacts
127
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
128
+ with:
129
+ path: dist
130
+ merge-multiple: true
131
+
132
+ - name: Publish to PyPI
133
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
134
+ with:
135
+ packages-dir: dist
@@ -0,0 +1,29 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ publish:
8
+ runs-on: ubuntu-latest
9
+ environment: release
10
+ permissions:
11
+ id-token: write
12
+
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
16
+
17
+ - name: Set up Rust
18
+ uses: dtolnay/rust-toolchain@39008827e6b4319a349e9a42dfc90579dd25f1ca # stable
19
+ with:
20
+ toolchain: stable
21
+
22
+ - name: Authenticate with crates.io
23
+ uses: rust-lang/crates-io-auth-action@3268eb413133e2960fa4ae0e963ca76380c54cd9 # v1.0.6
24
+ id: auth
25
+
26
+ - name: Publish
27
+ run: cargo publish
28
+ env:
29
+ CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
@@ -0,0 +1,25 @@
1
+ __pycache__/*
2
+ # Generated by Cargo
3
+ # will have compiled files and executables
4
+ debug/
5
+ target/
6
+
7
+ # These are backup files generated by rustfmt
8
+ **/*.rs.bk
9
+
10
+ # MSVC Windows builds of rustc generate these, which store debugging information
11
+ *.pdb
12
+
13
+ # RustRover
14
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
15
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
16
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
17
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
18
+ #.idea/
19
+
20
+ local
21
+ .DS_Store
22
+ data
23
+ .venv
24
+ __pycache__
25
+ *.so
@@ -0,0 +1,27 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use Model2Vec in your research, please cite it as below."
3
+ title: "Model2Vec: Fast State-of-the-Art Static Embeddings"
4
+ authors:
5
+ - family-names: "Tulkens"
6
+ given-names: "Stephan"
7
+ - family-names: "van Dongen"
8
+ given-names: "Thomas"
9
+ doi: 10.5281/zenodo.17270888
10
+ license: MIT
11
+ url: "https://github.com/MinishLab/model2vec"
12
+ repository-code: "https://github.com/MinishLab/model2vec-rs"
13
+ date-released: "2024-09-20"
14
+
15
+ preferred-citation:
16
+ type: software
17
+ title: "Model2Vec: Fast State-of-the-Art Static Embeddings"
18
+ authors:
19
+ - family-names: "Tulkens"
20
+ given-names: "Stephan"
21
+ - family-names: "van Dongen"
22
+ given-names: "Thomas"
23
+ year: 2024
24
+ publisher: Zenodo
25
+ doi: 10.5281/zenodo.17270888
26
+ url: "https://github.com/MinishLab/model2vec"
27
+ license: MIT