You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by kr...@apache.org on 2026/09/01 04:24:22 UTC

(opennlp) branch OPENNLP-1885-sentencepiece updated: OPENNLP-1885: Document where the subword API lives and what a piece contains

This is an automated email from the ASF dual-hosted git repository.

krickert pushed a commit to branch OPENNLP-1885-sentencepiece
in repository https://gitbox.apache.org/repos/asf/opennlp.git


The following commit(s) were added to refs/heads/OPENNLP-1885-sentencepiece by this push:
     new ae29ff8f6 OPENNLP-1885: Document where the subword API lives and what a piece contains
ae29ff8f6 is described below

commit ae29ff8f65e1bd06cb4e75a81209923d7aec002e
Author: Kristian Rickert <kr...@gmail.com>
AuthorDate: Tue Sep 1 00:09:32 2026 -0400

    OPENNLP-1885: Document where the subword API lives and what a piece contains
    
    The manual states which parts are in opennlp-api and which in the
    opennlp-subword artifact, that no model is bundled, what the parts of a
    SubwordPiece are, and which tests pin the span rules and reference parity.
---
 opennlp-docs/src/docbkx/tokenizer.xml | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/opennlp-docs/src/docbkx/tokenizer.xml b/opennlp-docs/src/docbkx/tokenizer.xml
index 6733728d3..8bf163674 100644
--- a/opennlp-docs/src/docbkx/tokenizer.xml
+++ b/opennlp-docs/src/docbkx/tokenizer.xml
@@ -555,6 +555,30 @@ wordTokenizer.tokenize("The quick brown fox.", (start, end, type) -> {
 			both implementations described below are immutable and safe for concurrent use by
 			multiple threads.
 		</para>
+		<para>
+			The interface and <code>SubwordPiece</code> live in <code>opennlp-api</code>, so
+			any component can accept a subword tokenizer without depending on a particular
+			model format. The two implementations differ in where they live:
+			<code>WordpieceEncoder</code> needs only a vocabulary list and stays in
+			<code>opennlp-api</code>; <code>SentencePieceTokenizer</code> reads a trained model
+			file and ships as its own artifact, <code>opennlp-subword</code>, which depends only on
+			<code>opennlp-api</code>. No model is bundled with either; the model file is the
+			user's.
+		</para>
+		<para>
+			A <code>SubwordPiece</code> has three parts: the piece string as the vocabulary
+			spells it (for SentencePiece models with the word-boundary marker, so
+			<code>&#x2581;world</code> for the word that opens with a space), the vocabulary
+			id the embedding layer expects, and the span of the caller's original text the
+			piece came from. Pieces that produce no surface of their own, such as control
+			symbols and the fill bytes of a byte-fallback expansion, report an empty span. The
+			span is a <code>Span</code> through <code>SubwordPiece.span</code>, so pieces can
+			be laid over the original text like any other annotation.
+			<code>SentencePieceAlignmentTest</code> pins the span rules, including
+			supplementary-plane characters, collapsed whitespace, and ligature replacement,
+			and <code>SentencePieceParityTest</code> checks pieces, ids, and spans against
+			fixtures produced by the reference implementation.
+		</para>
 		<section xml:id="tools.tokenizer.subword.sentencepiece">
 			<title>SentencePiece</title>
 			<para>