Skip to content

chore(v1): reduce public API surface - #2698

Merged
SBrandeis merged 16 commits into
mainfrom
chore/cleanup-public-api-2
Nov 17, 2026
Merged

SBrandeis merged 16 commits into
mainfrom
chore/cleanup-public-api-2

Conversation

@SBrandeis

@SBrandeis SBrandeis commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR

Reduce the amount of pub members in the library

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@SBrandeis
SBrandeis marked this pull request as ready for review November 16, 2026 16:49
@SBrandeis
SBrandeis added this pull request to stack #2702 November 16, 2026 18:08
@SBrandeis
SBrandeis force-pushed the chore/cleanup-public-api-2 branch 2 times, most recently from 892c36a to 73c019b Compare November 17, 2026 14:59
@SBrandeis
SBrandeis removed this pull request from stack #2702 November 17, 2026 15:48
@SBrandeis
SBrandeis added this pull request to stack #2708 November 17, 2026 15:48
Base automatically changed from chore/rm-deadcode to main November 17, 2026 15:52
Nothing outside bitcannon uses them. Atom itself stays pub: it is the value
set classify() writes into its public tags output.
Json, its accessors, MAX_DEPTH and json::Error's fields are only used by the
reader in tk-serialize. json::Error itself stays pub for now: the umbrella
re-exports the json module, so the compiler cannot tell who names it.
Buckets, Bucket, AddedTokenFlags, BucketVocabStore and its key hashing, plus
AddedVocabulary's lookup accessors, are only used inside tk-encode.
get_vocab, get_vocab_size, id_to_token and token_to_id on Unigram, WordLevel,
PipelineWordPiece and PipelineModel are only called by PipelineTokenizer, which
keeps its own pub lookups.
…the crate

Lattice's insert, piece, len, bos_node, eos_node, sample and sample_nbest,
Node::new, Unigram's alpha and nbest_size fields, and UnigramError are only
used inside tk-encode.
…rate

WordLevelBuilder::new and WordPieceBuilder::new are reached through
WordLevel::builder() and WordPiece::builder(); nothing outside tk-encode reads
WordPiece's max_input_chars_per_word field.
PipelineTokenizer's resolve_padding and resolve_truncation, PreTokenizerScratch's
split_on_bytes, split_on_bits, take_pair and put_pair, and Template's
has_type_ids and post_process are only called inside tk-encode.
The Pattern trait, Invert, Split's Search enum and search field, and
whitespace::is_word_char are only used by tk-encode's pre-tokenizers.
Only its Default impl calls it; tk-serialize builds the unit struct directly.
…egex::find_iter to the crate

Only tk-encode uses them.
Unigram, its only caller, calls content() directly. Now that the store is
crate-private the alias was dead in builds without the unigram feature.
ENV_VARIABLE, get_parallelism and num_threads are only read by tk-encode's
pool setup; set_num_threads stays pub as the library knob.
Since MB went pub(crate), a target without a classify kernel (scalar wasm32,
riscv64) flags it as dead, which broke the bitcannon wasm clippy job.
split, its SplitPolicy, split_delimiter and split_matches are only called by
tk-encode's pre-tokenizers. split and SplitPolicy need no re-export at all.
Only Split and the regex recognizer use it. Its last pub use, Split::grammar,
was removed as test-only.
@SBrandeis
SBrandeis force-pushed the chore/cleanup-public-api-2 branch 2 times, most recently from 73c019b to 1d3efcc Compare November 17, 2026 15:57
@SBrandeis
SBrandeis merged commit c24e47b into main Nov 17, 2026
39 checks passed
@SBrandeis
SBrandeis deleted the chore/cleanup-public-api-2 branch November 17, 2026 16:03
@SBrandeis SBrandeis mentioned this pull request Nov 19, 2026
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