Skip to content

feat: experimental C bindings - #2375

Open
SBrandeis wants to merge 17 commits into
mainfrom
feat/cpp-bindings
Open

SBrandeis wants to merge 17 commits into
mainfrom
feat/cpp-bindings

Conversation

@SBrandeis

Copy link
Copy Markdown
Contributor

No description provided.

@SBrandeis SBrandeis changed the title wip: C and C++ bindings wip: C bindings Sep 1, 2026

@ArthurZucker ArthurZucker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me, not sure how much of an in depth review is needed, but decode is kind of a must, we can have streaming for a later use case.

Parallel would be nice, not sure how hard it is to pull it off

Comment thread .github/workflows/c.yml Outdated
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: uvx --from huggingface_hub hf download hf-internal-testing/tokenizers-test-data gpt2.json --repo-type dataset --revision e20ac5914f5ada06874e4f9d45e49b31a049904e --local-dir ../../tokenizers/data

# examples/Makefile's `test` target builds and runs encode.c and null_safety.c against

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand much of this 馃槗 but yeah, we don't want to run too many test, just test the bindings (test we can encode, we can decode, we can load, but not test results in a whole bunch of stuff)

/// 2. `out` must be valid, writable pointer to a [`TkHandle<TkTokenizer>`]. On return, it
/// holds a live handle if this function returns NULL, or NULL otherwise.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn tk_tokenizer_from_file(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from pretrained would be nice is well, but fine without

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my only comment is to align as much as possible with the name of the function we have for node when relevant. Same for the structure names and etc?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good!

@SBrandeis
SBrandeis marked this pull request as ready for review September 3, 2026 15:47
@SBrandeis SBrandeis changed the title wip: C bindings feat: experimental C bindings Sep 3, 2026
Base automatically changed from feat/train_encode_split to main September 18, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants