feat(python): add Arrow string batch tokenization - #2400
granthamtaylor wants to merge 1 commit into
Conversation
|
Happy to have a look once rebased on #2119 |
Accept Arrow string and large_string arrays through the C Data Interface without materializing Python strings. Use the existing pipeline encoding and padding APIs, with configurable null handling and Literal typing. Add FFI lifetime and parity tests plus a Python benchmark matrix for conversion, encoding, throughput, and process peak memory.
f47c8a2 to
f489f05
Compare
🚨 Workflow security review — 16 critical, 20 high, 35 medium, 17 low, 2 informationalScanned 10 workflow file(s) with zizmor, pinact, OSV/GHSA, Claude, in full.
|
|
@ArthurZucker thank you so much ! I have rebased. |
|
Ty! this won't make it to rc0 but we'll se after that! |
|
I understand! Please feel free to tag me with any next steps. I'd love to see this feature integrated for my current project in which I am trying to tokenize many, many small strings. Thank you for your consideration here. |
Arrow callers currently need to convert arrays to Python lists before calling
encode_batch. This addsTokenizer.encode_batch_arrow, which accepts Arrowstringandlarge_stringarrays through__arrow_c_array__and returns the existing pipelineEncodingobjects.Depends on #2119 and targets
feat/train_encode_split. The diff contains one commit confined to the Python bindings.Behavior
null_handling="empty"encodes them as empty strings;"skip"omits them while preserving retained row order.Includes generated type hints, parity and ownership tests, and a standalone benchmark. PyArrow is a development dependency only. Chunked arrays and non-string Arrow types are outside the method's scope.
Validation
On macOS ARM64 with Python 3.13:
ty check python tests tools: passed.The full example type check still reports errors in the unchanged upstream
examples/train_parity_bpe.py, which uses the previous binding API.Related: #1415.