Skip to main content

polars-candle

A polars extension for running candle ML models on polars DataFrames.

Example

Pull any applicable model from Huggingface, such as the recently released Snowflake model, and embed text using a simple API.

import polars as pl
import polars_candle  # ignore: F401

df = pl.DataFrame({"s": ["This is a sentence", "This is another sentence"]})

embed_kwargs = {
    "model_repo": "Snowflake/snowflake-arctic-embed-xs",
    "pooling": "mean", 
}

df = df.with_columns(
    pl.col("s").candle.embed_text(**embed_kwargs).alias("s_embedding")
)
print(df)
# ┌──────────────────────────┬───────────────────────────────────┐
# │ s                        ┆ s_embedding                       │
# │ ---                      ┆ ---                               │
# │ str                      ┆ array[f32, 384]                   │
# ╞══════════════════════════╪═══════════════════════════════════╡
# │ This is a sentence       ┆ [-0.056457, 0.559411, … -0.20403… │
# │ This is another sentence ┆ [-0.117206, 0.336827, … 0.174078… │
# └──────────────────────────┴───────────────────────────────────┘

Currently, Bert, JinaBert, and Distilbert models are supported. More models will be added in the future. Check my other repository wdoppenberg/glowrs to learn more about the underlying implementation for sentence embedding.

Installation

Make sure you have polars installed. If not, install it using pip install polars. Then, install polars-candle using

pip install polars-candle

Note: The macOS ARM wheels of this library come with Metal support out of the box. For CUDA, check the below instructions on how to build from source.

If you want to install the latest version from the repository, you can use:

pip install git+https://github.com/wdoppenberg/polars-candle.git

Note: You need to have the Rust toolchain installed on your system to compile the library. See here for instructions on how to install Rust.

You can set build features using maturin:

maturin develop --release -F <feature>

Where <feature> can be one of the following:

  • metal Install with Metal acceleration.
  • cuda Install with CUDA acceleration. Might require additional setup such as installing CUDA libraries.
  • accelerate Install with the Accelerate framework.

Roadmap

  • Embed text using Bert, JinaBert, and Distilbert models.
  • Add more models.
  • More configuration options for embedding (e.g. pooling strategy, device selection, etc.).
  • Support & test streaming workloads.

Credits

  • Massive thanks to polars & their contributors for providing a blazing fast DataFrame library with the ability to extend it with custom functions using pyo3-polars.
  • Great work so far by Huggingface on candle for providing a simple interface to run ML models.

Note

This is a work in progress and the API might change in the future. Feel free to open an issue if you have any suggestions or improvements.

Release files for polars-candle 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polars-candle 0.1.7
File Size Uploaded
polars_candle-0.1.7.tar.gz 43.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for polars-candle 0.1.7
File
polars_candle-0.1.7-cp312-none-win_amd64.whl CPython 3.12 none Windows x86-64 Details
polars_candle-0.1.7-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
polars_candle-0.1.7-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
polars_candle-0.1.7-cp311-none-win_amd64.whl CPython 3.11 none Windows x86-64 Details
polars_candle-0.1.7-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details
polars_candle-0.1.7-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
polars_candle-0.1.7-cp310-none-win_amd64.whl CPython 3.10 none Windows x86-64 Details
polars_candle-0.1.7-cp310-cp310-manylinux_2_34_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64 Details
polars_candle-0.1.7-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
polars_candle-0.1.7-cp39-none-win_amd64.whl CPython 3.9 none Windows x86-64 Details
polars_candle-0.1.7-cp39-cp39-manylinux_2_34_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.34+ x86-64 Details
polars_candle-0.1.7-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details

Total release size: 76.9 MB

Release files / polars_candle-0.1.7.tar.gz

Download URL polars_candle-0.1.7.tar.gz
Size 43.0 kB
Tags Source
SHA-256 checksum
How to use checksums
65bf42e02e1db6130d79f3925c6ef96926a6ee49a5c71a5d9434e54cef21acab
BLAKE2b-256 checksum
How to use checksums
dd311670ae4e5ba0b2b528a84ef1f7fe6e9fc8381f43f8df41e05d3636e7b042
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.5.1

Release files / polars_candle-0.1.7-cp312-none-win_amd64.whl

Download URL polars_candle-0.1.7-cp312-none-win_amd64.whl
Size 6.3 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
da69a8aceff91b16130467bb641d3176b9f5a80f531692c15498d1b202b0c48d
BLAKE2b-256 checksum
How to use checksums
c5cfbb78811777e0dd5c4099a45099ff65cb3ccbd6b7c888e907630f9a244bc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.5.1

Release files / polars_candle-0.1.7-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL polars_candle-0.1.7-cp312-cp312-manylinux_2_34_x86_64.whl
Size 6.9 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
838f908197e65e7d072528a7e172d20981aa0bff8fe23148f40dd3e2e5856252
BLAKE2b-256 checksum
How to use checksums
0b4906d845f3faa246b91ea4282a7092638e8c418f7c0fd849f0f24877c04daa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.5.1

Release files / polars_candle-0.1.7-cp312-cp312-macosx_11_0_arm64.whl

Download URL polars_candle-0.1.7-cp312-cp312-macosx_11_0_arm64.whl
Size 6.0 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
30305c4eaac82771551f2609fc4c7669c739c77a9491a2c0d650fc85218133b7
BLAKE2b-256 checksum
How to use checksums
9b717c18c00a56811824b1fdb7c940f58b70eba69b3a5498fa5e55d4bebab761
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.5.1

Release files / polars_candle-0.1.7-cp311-none-win_amd64.whl

Download URL polars_candle-0.1.7-cp311-none-win_amd64.whl
Size 6.3 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
dc4f2e57b6b0f4fc297e82e75564034bfe5dfe6ee540679a156392d0796bc469
BLAKE2b-256 checksum
How to use checksums
d01dcee526471859088985c2893ad0048107511d7f6fa8f31f944b74918b6c54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.5.1

Release files / polars_candle-0.1.7-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL polars_candle-0.1.7-cp311-cp311-manylinux_2_34_x86_64.whl
Size 6.9 MB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
fedd44c085217ed7a2320690371360e46c6ce885e13194cdf67700f8ade4e0d2
BLAKE2b-256 checksum
How to use checksums
36ed8fc33ef07f4224eebd09cd56a2cee93671142da61039c5ef6bbddd46872e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.5.1

Release files / polars_candle-0.1.7-cp311-cp311-macosx_11_0_arm64.whl

Download URL polars_candle-0.1.7-cp311-cp311-macosx_11_0_arm64.whl
Size 6.0 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
26ea7c7f6773ef58d44663914ecd54bd77b2640cd1537f29035b2a24ed6a6e32
BLAKE2b-256 checksum
How to use checksums
9d646e96d0d5396c73a0a14f51eb9fdade733da31daf2c7b11deb95239e4f1ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.5.1

Release files / polars_candle-0.1.7-cp310-none-win_amd64.whl

Download URL polars_candle-0.1.7-cp310-none-win_amd64.whl
Size 6.3 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
c2deeee33b7cf06539a386400e8d5a9f9fed4fd4469f8f353df20e56c4cec3ca
BLAKE2b-256 checksum
How to use checksums
22e04b93d9a09c25811ce3b5b4311b6e1344b513afa37ea4ad68242a92edd214
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.5.1

Release files / polars_candle-0.1.7-cp310-cp310-manylinux_2_34_x86_64.whl

Download URL polars_candle-0.1.7-cp310-cp310-manylinux_2_34_x86_64.whl
Size 6.9 MB
Tags CPython 3.10 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
f9ae245dbfbbb674d235f3df04bac322ef6c5bfad97206a2d4c5cf50f8cce62c
BLAKE2b-256 checksum
How to use checksums
0630e85f5103bc1f1d05ceb1a475cfc43634162ae67f37e11f89eae0c9ced895
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.5.1

Release files / polars_candle-0.1.7-cp310-cp310-macosx_11_0_arm64.whl

Download URL polars_candle-0.1.7-cp310-cp310-macosx_11_0_arm64.whl
Size 6.0 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2cc4db47365b2bbf429ac2fa7495797313711df5128a2506cb4802d41873f2f8
BLAKE2b-256 checksum
How to use checksums
fd993d0425e2b86d4684bdeaf458e52727e252835b29f809333e4bff64df0465
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.5.1

Release files / polars_candle-0.1.7-cp39-none-win_amd64.whl

Download URL polars_candle-0.1.7-cp39-none-win_amd64.whl
Size 6.3 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
0b7facdc7610bda4093ca4cca1e705d27b13a1d38318d2b546dac485a2f7da46
BLAKE2b-256 checksum
How to use checksums
15e71f5f2d98cfdc8aab187ef310112b8943c41f3dbcb66df92ac7f03c27262d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.5.1

Release files / polars_candle-0.1.7-cp39-cp39-manylinux_2_34_x86_64.whl

Download URL polars_candle-0.1.7-cp39-cp39-manylinux_2_34_x86_64.whl
Size 6.9 MB
Tags CPython 3.9 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
e00daee55dbce06316d6e0830db02b79377054e1565513a3c6b31f5322eabb92
BLAKE2b-256 checksum
How to use checksums
e913b2a5da0bf7db969378d0bf8f6997aa20b8a2f29eb67f57e58f14b94cccb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.5.1

Release files / polars_candle-0.1.7-cp39-cp39-macosx_11_0_arm64.whl

Download URL polars_candle-0.1.7-cp39-cp39-macosx_11_0_arm64.whl
Size 6.0 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
51da3b23e88beaec7ccc778db830624b548f7e187d6a84072f355cd971e68e11
BLAKE2b-256 checksum
How to use checksums
1989544a9c0ed8fd4161f9dcef4f5bafbadf9ab1675ff3e012bd69b8c8ecc859
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.5.1

Release history Release notifications | RSS feed

This release

0.1.7 This release

13 release files

0.1.6

13 release files

0.1.5

12 release files

0.1.4

12 release files

0.1.3

12 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page