{
  "id": "task_libraries:tokenizer/python",
  "path": "/exapedia/python-tokenizer-libraries",
  "template": {
    "id": "task_libraries",
    "version": 4
  },
  "title": "Python tokenizer libraries",
  "answer": [
    {
      "t": "text",
      "text": "Python tokenizer libraries split text into the tokens a language model reads and map each token to an integer ID. A subword tokenizer trains its vocabulary from text rather than splitting only on spaces and punctuation. These libraries let apps and AI agents count tokens before a model call."
    }
  ],
  "breadcrumb": [
    {
      "label": "Tools"
    },
    {
      "label": "Python tokenizer libraries"
    }
  ],
  "sections": [
    {
      "id": "libraries_popularity",
      "anchor": "popularity",
      "heading": "Popularity",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Monthly downloads",
            "Stars",
            "Last release",
            "License"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#tiktoken",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F140"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F141"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F147"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F144"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F142"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#tokenizers",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F159"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F160"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F166"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F163"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F161"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#transformers",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F176"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F177"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F183"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F180"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F178"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#nltk",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F193"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F194"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F202"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F197"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F195"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#sentencepiece",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F212"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F213"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F219"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F216"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F214"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#spacy",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F230"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F231"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F239"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F232"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#sentence-transformers",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F247"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F248"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F256"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F251"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F249"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#jieba",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F268"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F269"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F277"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F272"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F270"
                }
              ]
            ]
          ],
          "variant": "pop",
          "caption": [
            {
              "t": "text",
              "text": "Downloads: "
            },
            {
              "t": "text",
              "text": "PyPI"
            },
            {
              "t": "text",
              "text": ", last thirty days. Stars and releases: GitHub. Amber: no release in over a year."
            }
          ]
        }
      ],
      "note": [
        {
          "t": "link",
          "href": "#tiktoken",
          "label": [
            {
              "t": "text",
              "text": "tiktoken"
            }
          ]
        },
        {
          "t": "text",
          "text": " has the most monthly downloads in this comparison, at "
        },
        {
          "t": "fact",
          "fact": "F141"
        },
        {
          "t": "text",
          "text": "."
        }
      ]
    },
    {
      "id": "libraries_capabilities",
      "anchor": "capabilities",
      "heading": "Capabilities",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Subword model IDs",
            "Python three ten installation"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#tiktoken",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F140"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F148"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F149"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#tokenizers",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F159"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F167"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F168"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#transformers",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F176"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#nltk",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F193"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F203"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F204"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#sentencepiece",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F212"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F220"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F221"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#spacy",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F230"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F240"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F241"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#sentence-transformers",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F247"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F257"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F258"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#jieba",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F268"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F278"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F279"
                }
              ]
            ]
          ],
          "variant": "cap"
        }
      ]
    },
    {
      "id": "libraries_entries",
      "anchor": "libraries",
      "heading": "Libraries",
      "blocks": [
        {
          "b": "entry",
          "anchor": "tiktoken",
          "name": [
            {
              "t": "fact",
              "fact": "F140"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/openai/tiktoken"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/tiktoken"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/tiktoken/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F11"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F141"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F147"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F143"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F142"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/tiktoken/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F140"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F12"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F13"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F14"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F15"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F16"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F17"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F18"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F19"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F157"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F158"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/langchain-ai/langchain",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F157"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def __init__(\n    self,\n    encoding_name: str = \"gpt2\",\n    model_name: str | None = None,\n    allowed_special: Literal[\"all\"] | AbstractSet[str] | None = None,\n    disallowed_special: Literal[\"all\"] | Collection[str] = \"all\",\n    **kwargs: Any,\n) -> None:\n    \"\"\"Create a new `TokenTextSplitter`.\n\n    Args:\n        encoding_name: The name of the tiktoken encoding to use.\n        model_name: The name of the model to use.\n            If provided, this will override the `encoding_name`.\n        allowed_special: Special tokens that are allowed during encoding.\n        disallowed_special: Special tokens that are disallowed during encoding.\n\n    Raises:\n        ImportError: If the tiktoken package is not installed.\n    \"\"\"\n    if allowed_special is None:\n        allowed_special = set[str]()\n    super().__init__(**kwargs)\n    try:\n        tiktoken = cast(\"Any\", _import_tiktoken())\n    except ImportError as err:\n        msg = (\n            \"Could not import tiktoken python package. \"\n            \"This is needed in order to for TokenTextSplitter. \"\n            \"Please install it with `pip install tiktoken`.\"\n        )\n        raise ImportError(msg) from err\n\n    if model_name is not None:\n        enc = tiktoken.encoding_for_model(model_name)\n    else:\n        enc = tiktoken.get_encoding(encoding_name)\n    self._tokenizer = enc\n    self._allowed_special = allowed_special\n    self._disallowed_special = disallowed_special",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/langchain-ai/langchain/blob/80655a182f24002f78f6baf884a67e227c06d7fa/libs/text-splitters/langchain_text_splitters/base.py#L329-L368",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F156"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20tiktoken%20to%20encode%2C%20decode%20and%20prepare%20model%20tokens&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F140"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import tiktoken\nencoding = tiktoken.get_encoding('o200k_base')\nprint(encoding.encode('Hello world'))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://pypi.org/pypi/tiktoken/0.14.0/json#info.description",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F145"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "tokenizers",
          "name": [
            {
              "t": "fact",
              "fact": "F159"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/huggingface/tokenizers"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/tokenizers"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/tokenizers/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F38"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F160"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F166"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F162"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F161"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/tokenizers/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F159"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F39"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F40"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F41"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F42"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F43"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F44"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F174"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F175"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/resemble-ai/chatterbox",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F174"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def encode(self, txt: str):\n    \"\"\"\n    clean_text > (append `lang_id`) > replace SPACE > encode text using Tokenizer\n    \"\"\"\n    txt = txt.replace(' ', SPACE)\n    code = self.tokenizer.encode(txt)\n    ids = code.ids\n    return ids",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/resemble-ai/chatterbox/blob/ab55923c27757c90cfcc407baa57dc25a7d25217/src/chatterbox/models/tokenizers/tokenizer.py#L35-L42",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F173"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20tokenizers%20to%20encode%2C%20decode%20and%20prepare%20model%20tokens&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F159"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from tokenizers import Tokenizer\ntokenizer = Tokenizer.from_pretrained('bert-base-cased')\nprint(tokenizer.encode('Hello world').ids)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://huggingface.co/docs/tokenizers/en/api/tokenizer",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F164"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "transformers",
          "name": [
            {
              "t": "fact",
              "fact": "F176"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/huggingface/transformers"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/transformers"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/transformers/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F63"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F177"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F183"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F179"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F178"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/transformers/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F176"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F64"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F65"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F66"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F67"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F68"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F69"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F70"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F71"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F191"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F192"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/langchain-ai/langchain",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F191"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "@classmethod\ndef from_huggingface_tokenizer(\n    cls, tokenizer: PreTrainedTokenizerBase, **kwargs: Any\n) -> TextSplitter:\n    \"\"\"Text splitter that uses Hugging Face tokenizer to count length.\n\n    Args:\n        tokenizer: The Hugging Face tokenizer to use.\n\n    Returns:\n        An instance of `TextSplitter` using the Hugging Face tokenizer for length\n            calculation.\n    \"\"\"\n    pretrained_tokenizer_base = _import_pretrained_tokenizer_base()\n\n    if not isinstance(tokenizer, pretrained_tokenizer_base):\n        msg = \"Tokenizer received was not an instance of PreTrainedTokenizerBase\"\n        raise ValueError(msg)  # noqa: TRY004\n\n    def _huggingface_tokenizer_length(text: str) -> int:\n        return len(tokenizer.tokenize(text))\n\n    return cls(length_function=_huggingface_tokenizer_length, **kwargs)",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/langchain-ai/langchain/blob/80655a182f24002f78f6baf884a67e227c06d7fa/libs/text-splitters/langchain_text_splitters/base.py#L212-L234",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F190"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20transformers%20to%20encode%2C%20decode%20and%20prepare%20model%20tokens&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F176"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from transformers import AutoTokenizer\ntokenizer = AutoTokenizer.from_pretrained('bert-base-cased')\nprint(tokenizer('Hello world')['input_ids'])\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://huggingface.co/docs/transformers/v5.23.0/en/model_doc/auto",
                  "label": [
                    {
                      "t": "text",
                      "text": "custom_tokenizers.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F181"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "nltk",
          "name": [
            {
              "t": "fact",
              "fact": "F193"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/nltk/nltk"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/nltk"
            },
            {
              "label": "Docs",
              "href": "https://www.nltk.org/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F200"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F194"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F202"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F196"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F195"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://www.nltk.org/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F193"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F210"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F211"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/sloria/TextBlob",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F210"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def tokenize(self, text, include_punc=True):\n    \"\"\"Return a list of word tokens.\n\n    :param text: string of text.\n    :param include_punc: (optional) whether to\n        include punctuation as separate tokens. Default to True.\n    \"\"\"\n    tokens = nltk.tokenize.word_tokenize(text)\n    if include_punc:\n        return tokens\n    else:\n        # Return each word token\n        # Strips punctuation unless the word comes from a contraction\n        # e.g. \"Let's\" => [\"Let\", \"'s\"]\n        # e.g. \"Can't\" => [\"Ca\", \"n't\"]\n        # e.g. \"home.\" => ['home']\n        return [\n            word if word.startswith(\"'\") else strip_punc(word, all=False)\n            for word in tokens\n            if strip_punc(word, all=False)\n        ]",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/sloria/TextBlob/blob/e496077fb8fd127b3c841cd192d16677e1fde960/src/textblob/tokenizers.py#L27-L47",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F209"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=nltk%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F193"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from nltk.tokenize import wordpunct_tokenize\nprint(wordpunct_tokenize('Hello, world!'))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://www.nltk.org/api/nltk.tokenize.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "nltk.tokenize.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F198"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "sentencepiece",
          "name": [
            {
              "t": "fact",
              "fact": "F212"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/google/sentencepiece"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/sentencepiece"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/sentencepiece/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F89"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F213"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F219"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F215"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F214"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/sentencepiece/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F212"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F90"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F91"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F92"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F93"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F94"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F95"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F228"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/NVIDIA-NeMo/Speech",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F228"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def __init__(\n    self,\n    model_path: str,\n    special_tokens: Optional[Union[Dict[str, str], List[str]]] = None,\n    legacy: bool = False,\n    ignore_extra_whitespaces: bool = True,\n    chat_template: Optional[Dict] = None,\n    trim_spm_separator_after_special_token=True,\n    spm_separator='▁',\n):\n    self.chat_template = chat_template\n    if not model_path or not os.path.exists(model_path):\n        raise ValueError(f\"model_path: {model_path} is invalid\")\n    self.tokenizer = sentencepiece.SentencePieceProcessor()\n    self.tokenizer.Load(model_path)\n\n    self.original_vocab_size = self.tokenizer.get_piece_size()\n    self.vocab_size = self.tokenizer.get_piece_size()\n    self.legacy = legacy\n    self.ignore_extra_whitespaces = ignore_extra_whitespaces\n    # using special symbol for extra_space token, so it is not likely to be in the vocabulary\n    self.extra_space_token = '☯'\n    self.special_token_to_id = {}\n    self.id_to_special_token = {}\n    self.trim_spm_separator_after_special_token = trim_spm_separator_after_special_token\n    self.spm_separator = spm_separator\n    self.spm_separator_id = self.tokenizer.piece_to_id(spm_separator)\n\n    if special_tokens:\n        if not self.legacy:\n            raise ValueError(\n                \"Special tokens must be None when legacy is set to False. Provide special tokens at train time.\"\n            )\n        self.add_special_tokens(special_tokens)\n\n    self.removed_extra_spaces = self.tokenizer.encode_as_pieces('x  y') == self.tokenizer.encode_as_pieces('x y')\n    self.space_sensitive = self.text_to_tokens('x y') != self.text_to_tokens('x') + self.text_to_tokens('y')\n    self._var_bpe_extension: VarBPEExtension | None = None  # lazy init\n    self._var_bpe_extension_case_insensitive: VarBPEExtension | None = None  # lazy init",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/NVIDIA-NeMo/Speech/blob/3fce68a9ead4f2e47381a09378848b33bdf70553/nemo/collections/common/tokenizers/sentencepiece_tokenizer.py#L141-L179",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F227"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20sentencepiece%20to%20encode%2C%20decode%20and%20prepare%20model%20tokens&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F212"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import sentencepiece as spm\nprocessor = spm.SentencePieceProcessor(model_file='test/botchan_en_unigram_1000.model')\nprint(processor.encode('This is a test'))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://pypi.org/pypi/sentencepiece/0.2.3/json#info.description",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F217"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "spacy",
          "name": [
            {
              "t": "fact",
              "fact": "F230"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/explosion/spaCy"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/spacy"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/spacy/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F237"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F231"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F239"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F233"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F232"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/spacy/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F230"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import spacy\nnlp = spacy.blank('en')\nprint([token.text for token in nlp.tokenizer('Hello, world!')])\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://spacy.io/api/tokenizer",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=spacy%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F230"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F235"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "sentence-transformers",
          "name": [
            {
              "t": "fact",
              "fact": "F247"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/huggingface/sentence-transformers"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/sentence-transformers"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/sentence-transformers/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F254"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F248"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F256"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F250"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F249"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/sentence-transformers/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F247"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F266"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F267"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/langchain-ai/langchain",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F266"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def __init__(\n    self,\n    chunk_overlap: int = 50,\n    model_name: str = \"sentence-transformers/all-mpnet-base-v2\",\n    tokens_per_chunk: int | None = None,\n    model_kwargs: dict[str, Any] | None = None,\n    **kwargs: Any,\n) -> None:\n    \"\"\"Create a new `TextSplitter`.\n\n    Args:\n        chunk_overlap: The number of tokens to overlap between chunks.\n        model_name: The name of the sentence transformer model to use.\n        tokens_per_chunk: The number of tokens per chunk.\n\n            If `None`, uses the maximum tokens allowed by the model.\n        model_kwargs: Additional parameters for model initialization.\n            Parameters of sentence_transformers.SentenceTransformer can be used.\n\n    Raises:\n        ImportError: If the `sentence_transformers` package is not installed.\n        ValueError: If `tokens_per_chunk` exceeds the model's maximum token limit.\n    \"\"\"\n    super().__init__(**kwargs, chunk_overlap=chunk_overlap)\n\n    try:\n        sentence_transformers = cast(\"Any\", import_module(\"sentence_transformers\"))\n        sentence_transformer_cls = sentence_transformers.SentenceTransformer\n    except ImportError as err:\n        msg = (\n            \"Could not import sentence_transformers python package. \"\n            \"This is needed in order to use SentenceTransformersTokenTextSplitter. \"\n            \"Please install it with `pip install sentence-transformers`.\"\n        )\n        raise ImportError(msg) from err\n\n    self.model_name = model_name\n    self._model = sentence_transformer_cls(self.model_name, **(model_kwargs or {}))\n    self.tokenizer = self._model.tokenizer\n    self._initialize_chunk_configuration(tokens_per_chunk=tokens_per_chunk)",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/langchain-ai/langchain/blob/80655a182f24002f78f6baf884a67e227c06d7fa/libs/text-splitters/langchain_text_splitters/sentence_transformers.py#L16-L55",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F265"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=sentence-transformers%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F247"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from sentence_transformers import SentenceTransformer\nmodel = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')\nfeatures = model.preprocess(['Hello world'])\nprint(features)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://sbert.net/docs/package_reference/sentence_transformer/SentenceTransformer.html#sentence_transformers.SentenceTransformer.tokenize",
                  "label": [
                    {
                      "t": "text",
                      "text": "SentenceTransformer.html#sentence_transformers.SentenceTransformer.tokenize"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F252"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "jieba",
          "name": [
            {
              "t": "fact",
              "fact": "F268"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/fxsjy/jieba"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/jieba"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/jieba/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F275"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F269"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F277"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F271"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F270"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/jieba/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F268"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F286"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F287"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/PaddlePaddle/PaddleNLP",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F286"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def cut(self, sentence, cut_all=False, use_hmm=True):\n    \"\"\"\n    The method used to cut the text to tokens.\n\n    Args:\n        sentence(str): The text that needs to be cut.\n        cut_all(bool, optional): Whether to use the full mode. If True,\n            using full mode that gets all the possible words from the\n            sentence, which is fast but not accurate. If False, using\n            accurate mode that attempts to cut the sentence into the most\n            accurate segmentations, which is suitable for text analysis.\n            Default: False.\n        use_hmm(bool, optional): Whether to use the HMM model. Default: True.\n\n    Returns:\n        list[str]: A list of tokens.\n\n    Example:\n        .. code-block:: python\n\n            from paddlenlp.data import Vocab, JiebaTokenizer\n            # The vocab file. The sample file can be downloaded firstly.\n            # wget https://bj.bcebos.com/paddlenlp/data/senta_word_dict.txt\n            vocab_file_path = './senta_word_dict.txt'\n            # Initialize the Vocab\n            vocab = Vocab.load_vocabulary(\n                vocab_file_path,\n                unk_token='[UNK]',\n                pad_token='[PAD]')\n            tokenizer = JiebaTokenizer(vocab)\n\n            tokens = tokenizer.cut('我爱你中国')\n            print(tokens)\n            # ['我爱你', '中国']\n    \"\"\"\n    return self.tokenizer.lcut(sentence, cut_all, use_hmm)",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/PaddlePaddle/PaddleNLP/blob/3f87dac9b719f75399f92f8bf634ae2ef0611832/paddlenlp/data/tokenizer.py#L56-L91",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F285"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=jieba%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F268"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import jieba\nprint(jieba.lcut('我来到北京清华大学'))\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://raw.githubusercontent.com/fxsjy/jieba/master/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F273"
            }
          ]
        }
      ]
    }
  ],
  "questions": [
    {
      "q": "Which Python tokenizer library should I use?",
      "a": [
        {
          "t": "link",
          "href": "#tiktoken",
          "label": [
            {
              "t": "text",
              "text": "tiktoken"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits counting and encoding tokens for OpenAI models. "
        },
        {
          "t": "link",
          "href": "#tokenizers",
          "label": [
            {
              "t": "text",
              "text": "Tokenizers"
            }
          ]
        },
        {
          "t": "text",
          "text": " and "
        },
        {
          "t": "link",
          "href": "#sentencepiece",
          "label": [
            {
              "t": "text",
              "text": "SentencePiece"
            }
          ]
        },
        {
          "t": "text",
          "text": " suit training a custom vocabulary. "
        },
        {
          "t": "link",
          "href": "#transformers",
          "label": [
            {
              "t": "text",
              "text": "Transformers"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits loading the tokenizer that matches a specific model."
        }
      ]
    },
    {
      "q": "What is tiktoken?",
      "a": [
        {
          "t": "link",
          "href": "#tiktoken",
          "label": [
            {
              "t": "text",
              "text": "tiktoken"
            }
          ]
        },
        {
          "t": "text",
          "text": " encodes and decodes text with byte-pair tokenization for OpenAI models. It can select the encoding for a given model name."
        }
      ]
    },
    {
      "q": "What is SentencePiece?",
      "a": [
        {
          "t": "link",
          "href": "#sentencepiece",
          "label": [
            {
              "t": "text",
              "text": "SentencePiece"
            }
          ]
        },
        {
          "t": "text",
          "text": " trains and applies subword tokenization directly on raw sentences."
        }
      ]
    },
    {
      "q": "What is Jieba?",
      "a": [
        {
          "t": "link",
          "href": "#jieba",
          "label": [
            {
              "t": "text",
              "text": "Jieba"
            }
          ]
        },
        {
          "t": "text",
          "text": " segments Chinese text into words."
        }
      ]
    },
    {
      "q": "Why does tiktoken raise an error on special-token text?",
      "a": [
        {
          "t": "text",
          "text": "Encoding raises by default for text that matches a special token. The allowed_special and disallowed_special parameters control that behavior."
        }
      ]
    }
  ],
  "facts": {
    "F1": {
      "label": "Library name, tiktoken",
      "display": "tiktoken",
      "asOf": "2026-11-17"
    },
    "F2": {
      "label": "Monthly downloads, tiktoken",
      "display": "212.5M",
      "asOf": "2026-11-16"
    },
    "F3": {
      "label": "License, tiktoken",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F4": {
      "label": "Package release, tiktoken",
      "display": "0.14.0, Aug 2026",
      "asOf": "2026-08-17"
    },
    "F5": {
      "label": "Package release date, tiktoken",
      "display": "Aug 2026",
      "asOf": "2026-08-17"
    },
    "F6": {
      "label": "Repository stars, tiktoken",
      "display": "19.7K",
      "asOf": "2026-11-17"
    },
    "F7": {
      "label": "Encodes tokens, tiktoken",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F8": {
      "label": "Decodes tokens, tiktoken",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F9": {
      "label": "Token offsets, tiktoken",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F10": {
      "label": "Install, tiktoken",
      "display": "pip install tiktoken",
      "asOf": "2026-11-17"
    },
    "F11": {
      "label": "What it does, tiktoken",
      "display": "Encodes and decodes text using byte-pair tokenization for OpenAI models.",
      "asOf": "2026-11-17"
    },
    "F12": {
      "label": "strengths lead, tiktoken",
      "display": "Selects encodings by model name",
      "asOf": "2026-11-17"
    },
    "F13": {
      "label": "strengths, tiktoken",
      "display": "Use encoding_for_model to select the model’s encoding.",
      "asOf": "2026-11-17"
    },
    "F14": {
      "label": "strengths lead, tiktoken",
      "display": "Preserves token bytes for inspection",
      "asOf": "2026-11-17"
    },
    "F15": {
      "label": "strengths, tiktoken",
      "display": "Use decode_single_token_bytes to inspect an individual token.",
      "asOf": "2026-11-17"
    },
    "F16": {
      "label": "limitations lead, tiktoken",
      "display": "Special-token text raises by default",
      "asOf": "2026-11-17"
    },
    "F17": {
      "label": "limitations, tiktoken",
      "display": "Choose allowed_special or disallowed_special behavior for text containing special-token strings.",
      "asOf": "2026-11-17"
    },
    "F18": {
      "label": "limitations lead, tiktoken",
      "display": "Partial decoding can replace bytes",
      "asOf": "2026-11-17"
    },
    "F19": {
      "label": "limitations, tiktoken",
      "display": "Use byte decoding or strict errors when inspecting incomplete UTF-8 tokens.",
      "asOf": "2026-11-17"
    },
    "F20": {
      "label": "Quickstart, tiktoken",
      "display": "import tiktoken\nenc = tiktoken.get_encoding(\"o200k_base\")\nassert enc.decode(enc.encode(\"hello world\")) == \"hello world\"\n\n# To get the tokeniser corresponding to a specific model in the OpenAI API:\nenc = tiktoken.encoding_for_model(\"gpt-4o\")\n",
      "asOf": "2026-11-17"
    },
    "F21": {
      "label": "Project function, tiktoken",
      "display": "def __init__(\n    self,\n    encoding_name: str = \"gpt2\",\n    model_name: str | None = None,\n    allowed_special: Literal[\"all\"] | AbstractSet[str] | None = None,\n    disallowed_special: Literal[\"all\"] | Collection[str] = \"all\",\n    **kwargs: Any,\n) -> None:\n    \"\"\"Create a new `TokenTextSplitter`.\n\n    Args:\n        encoding_name: The name of the tiktoken encoding to use.\n        model_name: The name of the model to use.\n            If provided, this will override the `encoding_name`.\n        allowed_special: Special tokens that are allowed during encoding.\n        disallowed_special: Special tokens that are disallowed during encoding.\n\n    Raises:\n        ImportError: If the tiktoken package is not installed.\n    \"\"\"\n    if allowed_special is None:\n        allowed_special = set[str]()\n    super().__init__(**kwargs)\n    try:\n        tiktoken = cast(\"Any\", _import_tiktoken())\n    except ImportError as err:\n        msg = (\n            \"Could not import tiktoken python package. \"\n            \"This is needed in order to for TokenTextSplitter. \"\n            \"Please install it with `pip install tiktoken`.\"\n        )\n        raise ImportError(msg) from err\n\n    if model_name is not None:\n        enc = tiktoken.encoding_for_model(model_name)\n    else:\n        enc = tiktoken.get_encoding(encoding_name)\n    self._tokenizer = enc\n    self._allowed_special = allowed_special\n    self._disallowed_special = disallowed_special\n",
      "asOf": "2026-11-17"
    },
    "F22": {
      "label": "Project function reference, tiktoken",
      "display": "base.py · __init__()",
      "asOf": "2026-11-17"
    },
    "F23": {
      "label": "Project repository, tiktoken",
      "display": "langchain-ai/langchain",
      "asOf": "2026-11-17"
    },
    "F24": {
      "label": "Project stars, langchain-ai/langchain",
      "display": "149.7K",
      "asOf": "2026-11-17"
    },
    "F25": {
      "label": "Project push date, langchain-ai/langchain",
      "display": "Nov 2026",
      "asOf": "2026-11-16"
    },
    "F26": {
      "label": "Library name, tokenizers",
      "display": "Tokenizers",
      "asOf": "2026-11-17"
    },
    "F27": {
      "label": "Monthly downloads, tokenizers",
      "display": "207.9M",
      "asOf": "2026-11-16"
    },
    "F28": {
      "label": "License, tokenizers",
      "display": "Apache",
      "asOf": "2026-11-17"
    },
    "F29": {
      "label": "Package release, tokenizers",
      "display": "0.23.3, Oct 2026",
      "asOf": "2026-10-09"
    },
    "F30": {
      "label": "Package release date, tokenizers",
      "display": "Oct 2026",
      "asOf": "2026-10-09"
    },
    "F31": {
      "label": "Repository stars, tokenizers",
      "display": "11.2K",
      "asOf": "2026-11-17"
    },
    "F32": {
      "label": "Encodes tokens, tokenizers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F33": {
      "label": "Decodes tokens, tokenizers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F34": {
      "label": "Trains tokenizers, tokenizers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F35": {
      "label": "Token offsets, tokenizers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F36": {
      "label": "Output formats, tokenizers",
      "display": "JSON",
      "asOf": "2026-11-17"
    },
    "F37": {
      "label": "Install, tokenizers",
      "display": "pip install tokenizers",
      "asOf": "2026-11-17"
    },
    "F38": {
      "label": "What it does, tokenizers",
      "display": "Provides configurable tokenization pipelines and vocabulary training through Rust-backed Python bindings.",
      "asOf": "2026-11-17"
    },
    "F39": {
      "label": "strengths lead, tokenizers",
      "display": "Trains a custom vocabulary",
      "asOf": "2026-11-17"
    },
    "F40": {
      "label": "strengths, tokenizers",
      "display": "Train from files or an iterator of text.",
      "asOf": "2026-11-17"
    },
    "F41": {
      "label": "strengths lead, tokenizers",
      "display": "Tracks tokens to original text",
      "asOf": "2026-11-17"
    },
    "F42": {
      "label": "strengths, tokenizers",
      "display": "Use offsets to recover the input span behind each token.",
      "asOf": "2026-11-17"
    },
    "F43": {
      "label": "limitations lead, tokenizers",
      "display": "Decoding needs a matching decoder",
      "asOf": "2026-11-17"
    },
    "F44": {
      "label": "limitations, tokenizers",
      "display": "Configure the decoder to handle the vocabulary’s subword markers.",
      "asOf": "2026-11-17"
    },
    "F45": {
      "label": "Quickstart, tokenizers",
      "display": "from tokenizers import Tokenizer, models, pre_tokenizers, decoders, trainers, processors\n\n# Initialize a tokenizer\ntokenizer = Tokenizer(models.BPE())\n\n# Customize pre-tokenization and decoding\ntokenizer.pre_tokenizer = pre_tokenizers.ByteLevel(add_prefix_space=True)\ntokenizer.decoder = decoders.ByteLevel()\ntokenizer.post_processor = processors.ByteLevel(trim_offsets=True)\n\n# And then train\ntrainer = trainers.BpeTrainer(\n    vocab_size=20000,\n    min_frequency=2,\n    initial_alphabet=pre_tokenizers.ByteLevel.alphabet()\n)\ntokenizer.train([\n    \"./path/to/dataset/1.txt\",\n    \"./path/to/dataset/2.txt\",\n    \"./path/to/dataset/3.txt\"\n], trainer=trainer)\n\n# And Save it\ntokenizer.save(\"byte-level-bpe.tokenizer.json\", pretty=True)\n",
      "asOf": "2026-11-17"
    },
    "F46": {
      "label": "Project function, tokenizers",
      "display": "def encode(self, txt: str):\n    \"\"\"\n    clean_text > (append `lang_id`) > replace SPACE > encode text using Tokenizer\n    \"\"\"\n    txt = txt.replace(' ', SPACE)\n    code = self.tokenizer.encode(txt)\n    ids = code.ids\n    return ids\n",
      "asOf": "2026-11-17"
    },
    "F47": {
      "label": "Project function reference, tokenizers",
      "display": "tokenizer.py · encode()",
      "asOf": "2026-11-17"
    },
    "F48": {
      "label": "Project repository, tokenizers",
      "display": "resemble-ai/chatterbox",
      "asOf": "2026-11-17"
    },
    "F49": {
      "label": "Project stars, resemble-ai/chatterbox",
      "display": "27.9K",
      "asOf": "2026-11-17"
    },
    "F50": {
      "label": "Project push date, resemble-ai/chatterbox",
      "display": "Nov 2026",
      "asOf": "2026-11-04"
    },
    "F51": {
      "label": "Library name, transformers",
      "display": "Transformers",
      "asOf": "2026-11-17"
    },
    "F52": {
      "label": "Monthly downloads, transformers",
      "display": "116.7M",
      "asOf": "2026-11-16"
    },
    "F53": {
      "label": "License, transformers",
      "display": "Apache 2.0 License",
      "asOf": "2026-11-17"
    },
    "F54": {
      "label": "Package release, transformers",
      "display": "5.23.0, Nov 2026",
      "asOf": "2026-11-13"
    },
    "F55": {
      "label": "Package release date, transformers",
      "display": "Nov 2026",
      "asOf": "2026-11-13"
    },
    "F56": {
      "label": "Repository stars, transformers",
      "display": "169.0K",
      "asOf": "2026-11-17"
    },
    "F57": {
      "label": "Encodes tokens, transformers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F58": {
      "label": "Decodes tokens, transformers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F59": {
      "label": "Trains tokenizers, transformers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F60": {
      "label": "Token offsets, transformers",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F61": {
      "label": "Output formats, transformers",
      "display": "JSON",
      "asOf": "2026-11-17"
    },
    "F62": {
      "label": "Install, transformers",
      "display": "pip install transformers",
      "asOf": "2026-11-17"
    },
    "F63": {
      "label": "What it does, transformers",
      "display": "Loads model-specific tokenizers and prepares encoded model inputs with padding and special tokens.",
      "asOf": "2026-11-17"
    },
    "F64": {
      "label": "strengths lead, transformers",
      "display": "Loads the matching tokenizer class",
      "asOf": "2026-11-17"
    },
    "F65": {
      "label": "strengths, transformers",
      "display": "AutoTokenizer resolves a tokenizer using the model configuration.",
      "asOf": "2026-11-17"
    },
    "F66": {
      "label": "strengths lead, transformers",
      "display": "Prepares padded model input batches",
      "asOf": "2026-11-17"
    },
    "F67": {
      "label": "strengths, transformers",
      "display": "Create input IDs and attention masks with padding and truncation.",
      "asOf": "2026-11-17"
    },
    "F68": {
      "label": "limitations lead, transformers",
      "display": "New tokens need matching embeddings",
      "asOf": "2026-11-17"
    },
    "F69": {
      "label": "limitations, transformers",
      "display": "Resize the model’s token embeddings after extending its vocabulary.",
      "asOf": "2026-11-17"
    },
    "F70": {
      "label": "limitations lead, transformers",
      "display": "Offsets depend on the backend",
      "asOf": "2026-11-17"
    },
    "F71": {
      "label": "limitations, transformers",
      "display": "Use a fast tokenizer when requesting character offset mappings.",
      "asOf": "2026-11-17"
    },
    "F72": {
      "label": "Quickstart, transformers",
      "display": "from transformers import GemmaTokenizer\n\nvocab={\n    \"<pad>\": 0,\n    \"</s>\": 1,\n    \"<s>\": 2,\n    \"<unk>\": 3,\n    \"<mask>\": 4,\n    \"▁the\": 5,\n    \"▁stock\": 6,\n    \"▁market\": 7,\n    \"▁\": 8,\n    \"r\": 9,\n    \"a\": 10,\n    \"l\": 11,\n    \"i\": 12,\n    \"e\": 13,\n    \"d\": 14,\n    \"ra\": 15,\n    \"li\": 16,\n    \"lie\": 17,\n    \"lied\": 18,\n    \"ral\": 19,\n    \"ralli\": 20,\n    \"rallie\": 21,\n    \"rallied\": 22,\n}\nmerges=[\n    (\"r\", \"a\"),       # r + a → ra\n    (\"l\", \"i\"),       # l + i → li\n    (\"li\", \"e\"),      # li + e → lie\n    (\"lie\", \"d\"),     # lie + d → lied\n    (\"ra\", \"l\"),      # ra + l → ral\n    (\"ral\", \"li\"),    # ral + li → ralli\n    (\"ralli\", \"e\"),   # ralli + e → rallie\n    (\"rallie\", \"d\"),  # rallie + d → rallied\n]\n\ntokenizer = GemmaTokenizer(vocab=vocab, merges=merges)\nencoded = tokenizer(\"the stock market rallied\")\nprint(encoded[\"input_ids\"])\n",
      "asOf": "2026-11-17"
    },
    "F73": {
      "label": "Project function, transformers",
      "display": "@classmethod\ndef from_huggingface_tokenizer(\n    cls, tokenizer: PreTrainedTokenizerBase, **kwargs: Any\n) -> TextSplitter:\n    \"\"\"Text splitter that uses Hugging Face tokenizer to count length.\n\n    Args:\n        tokenizer: The Hugging Face tokenizer to use.\n\n    Returns:\n        An instance of `TextSplitter` using the Hugging Face tokenizer for length\n            calculation.\n    \"\"\"\n    pretrained_tokenizer_base = _import_pretrained_tokenizer_base()\n\n    if not isinstance(tokenizer, pretrained_tokenizer_base):\n        msg = \"Tokenizer received was not an instance of PreTrainedTokenizerBase\"\n        raise ValueError(msg)  # noqa: TRY004\n\n    def _huggingface_tokenizer_length(text: str) -> int:\n        return len(tokenizer.tokenize(text))\n\n    return cls(length_function=_huggingface_tokenizer_length, **kwargs)\n",
      "asOf": "2026-11-17"
    },
    "F74": {
      "label": "Project function reference, transformers",
      "display": "base.py · from_huggingface_tokenizer()",
      "asOf": "2026-11-17"
    },
    "F75": {
      "label": "Project repository, transformers",
      "display": "langchain-ai/langchain",
      "asOf": "2026-11-17"
    },
    "F76": {
      "label": "Project stars, langchain-ai/langchain",
      "display": "149.7K",
      "asOf": "2026-11-17"
    },
    "F77": {
      "label": "Project push date, langchain-ai/langchain",
      "display": "Nov 2026",
      "asOf": "2026-11-16"
    },
    "F78": {
      "label": "Library name, sentencepiece",
      "display": "SentencePiece",
      "asOf": "2026-11-17"
    },
    "F79": {
      "label": "Monthly downloads, sentencepiece",
      "display": "29.0M",
      "asOf": "2026-11-16"
    },
    "F80": {
      "label": "License, sentencepiece",
      "display": "Apache-2.0",
      "asOf": "2026-11-17"
    },
    "F81": {
      "label": "Package release, sentencepiece",
      "display": "0.2.3, Nov 2026",
      "asOf": "2026-11-05"
    },
    "F82": {
      "label": "Package release date, sentencepiece",
      "display": "Nov 2026",
      "asOf": "2026-11-05"
    },
    "F83": {
      "label": "Repository stars, sentencepiece",
      "display": "12.2K",
      "asOf": "2026-11-17"
    },
    "F84": {
      "label": "Encodes tokens, sentencepiece",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F85": {
      "label": "Decodes tokens, sentencepiece",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F86": {
      "label": "Trains tokenizers, sentencepiece",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F87": {
      "label": "Token offsets, sentencepiece",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F88": {
      "label": "Install, sentencepiece",
      "display": "pip install sentencepiece",
      "asOf": "2026-11-17"
    },
    "F89": {
      "label": "What it does, sentencepiece",
      "display": "Trains and applies subword tokenization directly to raw text.",
      "asOf": "2026-11-17"
    },
    "F90": {
      "label": "strengths lead, sentencepiece",
      "display": "Trains directly from raw text",
      "asOf": "2026-11-17"
    },
    "F91": {
      "label": "strengths, sentencepiece",
      "display": "Train a vocabulary without a language-specific word splitter.",
      "asOf": "2026-11-17"
    },
    "F92": {
      "label": "strengths lead, sentencepiece",
      "display": "Supports sampled segmentations",
      "asOf": "2026-11-17"
    },
    "F93": {
      "label": "strengths, sentencepiece",
      "display": "Sample different subword splits while preparing training text.",
      "asOf": "2026-11-17"
    },
    "F94": {
      "label": "limitations lead, sentencepiece",
      "display": "Normalization can change whitespace",
      "asOf": "2026-11-17"
    },
    "F95": {
      "label": "limitations, sentencepiece",
      "display": "Check the model’s whitespace rules before assuming exact text reconstruction.",
      "asOf": "2026-11-17"
    },
    "F96": {
      "label": "Quickstart, sentencepiece",
      "display": "import sentencepiece as spm\n\nsp = spm.SentencePieceProcessor(model_file='test/botchan_en_unigram_1000.model')\n\ntext = \"吾輩は猫である。\"\n\n# 1. Encoding text to get offsets in the original text\nenc_res = sp.encode(text, return_type='offset_mapping')\nprint(enc_res['offsets'])  # list[tuple[int, int]] containing Unicode char indices\n\nfor piece, (start, end) in zip(enc_res['pieces'], enc_res['offsets']):\n  # Note: the first piece might be the dummy prefix (e.g. '▁') which maps to empty surface ''\n  original_surface = text[start:end]\n  print(f\"Piece: {piece} -> Surface in original text: {original_surface}\")\n\n# 2. Decoding IDs back to text while retrieving offsets in the reconstructed text\ndec_res = sp.decode(enc_res['ids'], return_type='offset_mapping')\n\nprint(dec_res['text'])    # \"吾輩は猫である。\" (the reconstructed text)\nprint(dec_res['offsets']) # Unicode char indices in `dec_res['text']`\n\nfor (start, end), piece in zip(dec_res['offsets'], dec_res['pieces']):\n  # Note: piece might contain meta symbols (like '▁'), \n  # but slicing `dec_res['text']` using offsets yields the clean surface text.\n  surface = dec_res['text'][start:end]\n  print(f\"Piece: {piece} -> Surface in reconstructed text: {surface}\")\n",
      "asOf": "2026-11-17"
    },
    "F97": {
      "label": "Project function, sentencepiece",
      "display": "def __init__(\n    self,\n    model_path: str,\n    special_tokens: Optional[Union[Dict[str, str], List[str]]] = None,\n    legacy: bool = False,\n    ignore_extra_whitespaces: bool = True,\n    chat_template: Optional[Dict] = None,\n    trim_spm_separator_after_special_token=True,\n    spm_separator='▁',\n):\n    self.chat_template = chat_template\n    if not model_path or not os.path.exists(model_path):\n        raise ValueError(f\"model_path: {model_path} is invalid\")\n    self.tokenizer = sentencepiece.SentencePieceProcessor()\n    self.tokenizer.Load(model_path)\n\n    self.original_vocab_size = self.tokenizer.get_piece_size()\n    self.vocab_size = self.tokenizer.get_piece_size()\n    self.legacy = legacy\n    self.ignore_extra_whitespaces = ignore_extra_whitespaces\n    # using special symbol for extra_space token, so it is not likely to be in the vocabulary\n    self.extra_space_token = '☯'\n    self.special_token_to_id = {}\n    self.id_to_special_token = {}\n    self.trim_spm_separator_after_special_token = trim_spm_separator_after_special_token\n    self.spm_separator = spm_separator\n    self.spm_separator_id = self.tokenizer.piece_to_id(spm_separator)\n\n    if special_tokens:\n        if not self.legacy:\n            raise ValueError(\n                \"Special tokens must be None when legacy is set to False. Provide special tokens at train time.\"\n            )\n        self.add_special_tokens(special_tokens)\n\n    self.removed_extra_spaces = self.tokenizer.encode_as_pieces('x  y') == self.tokenizer.encode_as_pieces('x y')\n    self.space_sensitive = self.text_to_tokens('x y') != self.text_to_tokens('x') + self.text_to_tokens('y')\n    self._var_bpe_extension: VarBPEExtension | None = None  # lazy init\n    self._var_bpe_extension_case_insensitive: VarBPEExtension | None = None  # lazy init\n",
      "asOf": "2026-11-17"
    },
    "F98": {
      "label": "Project function reference, sentencepiece",
      "display": "sentencepiece_tokenizer.py · __init__()",
      "asOf": "2026-11-17"
    },
    "F99": {
      "label": "Project repository, sentencepiece",
      "display": "NVIDIA-NeMo/Speech",
      "asOf": "2026-11-17"
    },
    "F100": {
      "label": "Project stars, NVIDIA-NeMo/Speech",
      "display": "18.8K",
      "asOf": "2026-11-17"
    },
    "F101": {
      "label": "Project push date, NVIDIA-NeMo/Speech",
      "display": "Nov 2026",
      "asOf": "2026-11-16"
    },
    "F102": {
      "label": "Developer need",
      "display": "OpenAI model text encodings",
      "asOf": "2026-11-17"
    },
    "F103": {
      "label": "Why choose tiktoken",
      "display": "selecting a model-specific encoding",
      "asOf": "2026-11-17"
    },
    "F104": {
      "label": "Developer need in introduction",
      "display": "OpenAI model text encodings",
      "asOf": "2026-11-17"
    },
    "F105": {
      "label": "Developer need",
      "display": "Custom tokenization pipelines",
      "asOf": "2026-11-17"
    },
    "F106": {
      "label": "Why choose tokenizers",
      "display": "training a vocabulary from text",
      "asOf": "2026-11-17"
    },
    "F107": {
      "label": "Developer need in introduction",
      "display": "custom tokenization pipelines",
      "asOf": "2026-11-17"
    },
    "F108": {
      "label": "When to consider transformers",
      "display": "a model configuration should choose the tokenizer class",
      "asOf": "2026-11-17"
    },
    "F109": {
      "label": "Developer need",
      "display": "Subwords from raw text",
      "asOf": "2026-11-17"
    },
    "F110": {
      "label": "Why choose sentencepiece",
      "display": "training without a language-specific word splitter",
      "asOf": "2026-11-17"
    },
    "F111": {
      "label": "Developer need in introduction",
      "display": "subwords from raw text",
      "asOf": "2026-11-17"
    },
    "F112": {
      "label": "When to consider tokenizers",
      "display": "customizing the pipeline and token-to-text alignment is central",
      "asOf": "2026-11-17"
    },
    "F113": {
      "label": "Developer need",
      "display": "Model-specific input preparation",
      "asOf": "2026-11-17"
    },
    "F114": {
      "label": "Why choose transformers",
      "display": "resolving the matching tokenizer class",
      "asOf": "2026-11-17"
    },
    "F115": {
      "label": "Developer need in introduction",
      "display": "model-specific input preparation",
      "asOf": "2026-11-17"
    },
    "F116": {
      "label": "When to consider tiktoken",
      "display": "only an OpenAI model text encoding is needed",
      "asOf": "2026-11-17"
    },
    "F117": {
      "label": "Page introduction",
      "display": "Python tokenizer libraries let text-processing developers split and encode text into tokens.",
      "asOf": "2026-11-17"
    },
    "F118": {
      "label": "FAQ: Which Python tokenizer should I use for an agent?",
      "display": "tiktoken can select an encoding for an OpenAI model.",
      "asOf": "2026-11-17"
    },
    "F119": {
      "label": "FAQ: Which Python tokenizer should I use for an agent?",
      "display": "Transformers AutoTokenizer resolves the tokenizer using a model configuration.",
      "asOf": "2026-11-17"
    },
    "F120": {
      "label": "FAQ: Which Python tokenizer should I use for an agent?",
      "display": "Tokenizers and SentencePiece support training vocabularies from text.",
      "asOf": "2026-11-17"
    },
    "F121": {
      "label": "FAQ: Which Python tokenizer should I use for an agent?",
      "display": "SentencePiece can train directly from raw sentences.",
      "asOf": "2026-11-17"
    },
    "F122": {
      "label": "FAQ: Does a tokenizer’s tokenize method return model input IDs?",
      "display": "Transformers encode returns input_ids.",
      "asOf": "2026-11-17"
    },
    "F123": {
      "label": "FAQ: Does a tokenizer’s tokenize method return model input IDs?",
      "display": "Calling the tokenizer can also add special tokens and prepare attention masks.",
      "asOf": "2026-11-17"
    },
    "F124": {
      "label": "FAQ: Why does tiktoken reject text containing a special-token string?",
      "display": "Encoding raises by default for text that corresponds to a special token; allowed_special and disallowed_special control that behavior.",
      "asOf": "2026-11-17"
    },
    "F125": {
      "label": "FAQ: Can decoding an incomplete tiktoken sequence lose bytes?",
      "display": "decode defaults to replacing invalid UTF-8; byte decoding or strict errors preserve the distinction.",
      "asOf": "2026-11-17"
    },
    "F126": {
      "label": "FAQ: Can decoding an incomplete tiktoken sequence lose bytes?",
      "display": "decode_single_token_bytes returns the original bytes of a token.",
      "asOf": "2026-11-17"
    },
    "F127": {
      "label": "FAQ: Do all token offsets mean the same thing?",
      "display": "tiktoken decode_with_offsets reports starts in decoded text.",
      "asOf": "2026-11-17"
    },
    "F128": {
      "label": "FAQ: Do all token offsets mean the same thing?",
      "display": "Tokenizers offsets identify the original input span that produced a token.",
      "asOf": "2026-11-17"
    },
    "F129": {
      "label": "FAQ: Do all token offsets mean the same thing?",
      "display": "SentencePiece’s offset mapping defaults to Unicode character offsets for encoding and decoding.",
      "asOf": "2026-11-17"
    },
    "F130": {
      "label": "FAQ: Can multiple tiktoken tokens share a character offset?",
      "display": "When UTF-8 and token boundaries differ, the offset identifies the first character containing bytes from the token.",
      "asOf": "2026-11-17"
    },
    "F131": {
      "label": "FAQ: Can I train a tokenizer without loading an entire corpus into memory?",
      "display": "Tokenizers accepts an iterator for vocabulary training.",
      "asOf": "2026-11-17"
    },
    "F132": {
      "label": "FAQ: Can I train a tokenizer without loading an entire corpus into memory?",
      "display": "Transformers train_new_from_iterator accepts text batches from a generator.",
      "asOf": "2026-11-17"
    },
    "F133": {
      "label": "FAQ: Does SentencePiece need a language-specific word splitter?",
      "display": "SentencePiece trains from raw sentences without language-specific pre-tokenizers.",
      "asOf": "2026-11-17"
    },
    "F134": {
      "label": "FAQ: Can SentencePiece normalization change repeated whitespace?",
      "display": "The own normalization example reduces repeated spaces under the loaded model’s rules.",
      "asOf": "2026-11-17"
    },
    "F135": {
      "label": "FAQ: Can SentencePiece normalization change repeated whitespace?",
      "display": "The normalizer can override dummy-prefix, whitespace escaping, and extra-whitespace behavior.",
      "asOf": "2026-11-17"
    },
    "F136": {
      "label": "FAQ: Why can a Tokenizers decoder show subword markers?",
      "display": "A model with special subword markers needs a decoder configured to interpret them.",
      "asOf": "2026-11-17"
    },
    "F137": {
      "label": "FAQ: Can I add tokens to a pretrained model without changing its embeddings?",
      "display": "After adding special tokens, resize the model’s embedding matrix to match the tokenizer.",
      "asOf": "2026-11-17"
    },
    "F138": {
      "label": "FAQ: What does the JSON output format mean here?",
      "display": "Tokenizers saves its serialized tokenizer as a JSON file.",
      "asOf": "2026-11-17"
    },
    "F139": {
      "label": "FAQ: What does the JSON output format mean here?",
      "display": "Transformers save_pretrained creates tokenizer.json containing vocabulary, merges, and pipeline configuration.",
      "asOf": "2026-11-17"
    },
    "F140": {
      "label": "Library name, tiktoken",
      "display": "tiktoken",
      "asOf": "2026-11-20"
    },
    "F141": {
      "label": "Monthly downloads, tiktoken",
      "display": "223.6M",
      "asOf": "2026-11-20"
    },
    "F142": {
      "label": "License, tiktoken",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F143": {
      "label": "Package release, tiktoken",
      "display": "0.14.0",
      "asOf": "2026-11-20"
    },
    "F144": {
      "label": "Package release date, tiktoken",
      "display": "Aug 2026",
      "asOf": "2026-11-20"
    },
    "F145": {
      "label": "Install, tiktoken",
      "display": "python -m pip install tiktoken",
      "asOf": "2026-11-20"
    },
    "F146": {
      "label": "Quickstart, tiktoken",
      "display": "import tiktoken\nencoding = tiktoken.get_encoding('o200k_base')\nprint(encoding.encode('Hello world'))\n",
      "asOf": "2026-11-20"
    },
    "F147": {
      "label": "Repository stars, tiktoken",
      "display": "19.7K",
      "asOf": "2026-11-20"
    },
    "F148": {
      "label": "Subword model IDs, tiktoken",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F149": {
      "label": "Python three ten installation, tiktoken",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F150": {
      "label": "Python requirement, tiktoken",
      "display": ">=3.9",
      "asOf": "2026-11-20"
    },
    "F151": {
      "label": "Tokenizer/model selection, tiktoken",
      "display": "Named OpenAI-model or encoding vocabulary",
      "asOf": "2026-11-20"
    },
    "F152": {
      "label": "Character offsets, tiktoken",
      "display": "Decoded Unicode start positions per token",
      "asOf": "2026-11-20"
    },
    "F153": {
      "label": "Round-trip scope, tiktoken",
      "display": "Reversible BPE over input bytes",
      "asOf": "2026-11-20"
    },
    "F154": {
      "label": "Training surface, tiktoken",
      "display": "Educational BPE trainer,not a production trainer benchmark",
      "asOf": "2026-11-20"
    },
    "F155": {
      "label": "Project function, tiktoken",
      "display": "def __init__(\n    self,\n    encoding_name: str = \"gpt2\",\n    model_name: str | None = None,\n    allowed_special: Literal[\"all\"] | AbstractSet[str] | None = None,\n    disallowed_special: Literal[\"all\"] | Collection[str] = \"all\",\n    **kwargs: Any,\n) -> None:\n    \"\"\"Create a new `TokenTextSplitter`.\n\n    Args:\n        encoding_name: The name of the tiktoken encoding to use.\n        model_name: The name of the model to use.\n            If provided, this will override the `encoding_name`.\n        allowed_special: Special tokens that are allowed during encoding.\n        disallowed_special: Special tokens that are disallowed during encoding.\n\n    Raises:\n        ImportError: If the tiktoken package is not installed.\n    \"\"\"\n    if allowed_special is None:\n        allowed_special = set[str]()\n    super().__init__(**kwargs)\n    try:\n        tiktoken = cast(\"Any\", _import_tiktoken())\n    except ImportError as err:\n        msg = (\n            \"Could not import tiktoken python package. \"\n            \"This is needed in order to for TokenTextSplitter. \"\n            \"Please install it with `pip install tiktoken`.\"\n        )\n        raise ImportError(msg) from err\n\n    if model_name is not None:\n        enc = tiktoken.encoding_for_model(model_name)\n    else:\n        enc = tiktoken.get_encoding(encoding_name)\n    self._tokenizer = enc\n    self._allowed_special = allowed_special\n    self._disallowed_special = disallowed_special",
      "asOf": "2026-11-20"
    },
    "F156": {
      "label": "Project source file, tiktoken",
      "display": "libs/text-splitters/langchain_text_splitters/base.py",
      "asOf": "2026-11-20"
    },
    "F157": {
      "label": "Project full_name, tiktoken",
      "display": "langchain-ai/langchain",
      "asOf": "2026-11-20"
    },
    "F158": {
      "label": "Project stargazers_count, tiktoken",
      "display": "149.7K",
      "asOf": "2026-11-20"
    },
    "F159": {
      "label": "Library name, tokenizers",
      "display": "Tokenizers",
      "asOf": "2026-11-20"
    },
    "F160": {
      "label": "Monthly downloads, tokenizers",
      "display": "216.8M",
      "asOf": "2026-11-20"
    },
    "F161": {
      "label": "License, tokenizers",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F162": {
      "label": "Package release, tokenizers",
      "display": "0.23.3",
      "asOf": "2026-11-20"
    },
    "F163": {
      "label": "Package release date, tokenizers",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F164": {
      "label": "Install, tokenizers",
      "display": "python -m pip install tokenizers",
      "asOf": "2026-11-20"
    },
    "F165": {
      "label": "Quickstart, tokenizers",
      "display": "from tokenizers import Tokenizer\ntokenizer = Tokenizer.from_pretrained('bert-base-cased')\nprint(tokenizer.encode('Hello world').ids)\n",
      "asOf": "2026-11-20"
    },
    "F166": {
      "label": "Repository stars, tokenizers",
      "display": "11.3K",
      "asOf": "2026-11-20"
    },
    "F167": {
      "label": "Subword model IDs, tokenizers",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F168": {
      "label": "Python three ten installation, tokenizers",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F169": {
      "label": "Python requirement, tokenizers",
      "display": ">=3.10",
      "asOf": "2026-11-20"
    },
    "F170": {
      "label": "Pipeline role, tokenizers",
      "display": "Trainable model,normalizer,pre-tokenizer,post-processor,and decoder",
      "asOf": "2026-11-20"
    },
    "F171": {
      "label": "Character offsets, tokenizers",
      "display": "Encoding offsets map tokens to original input slices",
      "asOf": "2026-11-20"
    },
    "F172": {
      "label": "Project function, tokenizers",
      "display": "def encode(self, txt: str):\n    \"\"\"\n    clean_text > (append `lang_id`) > replace SPACE > encode text using Tokenizer\n    \"\"\"\n    txt = txt.replace(' ', SPACE)\n    code = self.tokenizer.encode(txt)\n    ids = code.ids\n    return ids",
      "asOf": "2026-11-20"
    },
    "F173": {
      "label": "Project source file, tokenizers",
      "display": "src/chatterbox/models/tokenizers/tokenizer.py",
      "asOf": "2026-11-20"
    },
    "F174": {
      "label": "Project full_name, tokenizers",
      "display": "resemble-ai/chatterbox",
      "asOf": "2026-11-20"
    },
    "F175": {
      "label": "Project stargazers_count, tokenizers",
      "display": "27.9K",
      "asOf": "2026-11-20"
    },
    "F176": {
      "label": "Library name, transformers",
      "display": "Transformers",
      "asOf": "2026-11-20"
    },
    "F177": {
      "label": "Monthly downloads, transformers",
      "display": "116.7M",
      "asOf": "2026-11-20"
    },
    "F178": {
      "label": "License, transformers",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F179": {
      "label": "Package release, transformers",
      "display": "5.23.0",
      "asOf": "2026-11-20"
    },
    "F180": {
      "label": "Package release date, transformers",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F181": {
      "label": "Install, transformers",
      "display": "python -m pip install transformers",
      "asOf": "2026-11-20"
    },
    "F182": {
      "label": "Quickstart, transformers",
      "display": "from transformers import AutoTokenizer\ntokenizer = AutoTokenizer.from_pretrained('bert-base-cased')\nprint(tokenizer('Hello world')['input_ids'])\n",
      "asOf": "2026-11-20"
    },
    "F183": {
      "label": "Repository stars, transformers",
      "display": "169.2K",
      "asOf": "2026-11-20"
    },
    "F184": {
      "label": "Subword model IDs, transformers",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F185": {
      "label": "Python three ten installation, transformers",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F186": {
      "label": "Python requirement, transformers",
      "display": ">=3.11.0",
      "asOf": "2026-11-20"
    },
    "F187": {
      "label": "Checkpoint role, transformers",
      "display": "Loads matching pretrained model tokenizer configuration",
      "asOf": "2026-11-20"
    },
    "F188": {
      "label": "Character offsets, transformers",
      "display": "return_offsets_mapping on supported backend",
      "asOf": "2026-11-20"
    },
    "F189": {
      "label": "Project function, transformers",
      "display": "@classmethod\ndef from_huggingface_tokenizer(\n    cls, tokenizer: PreTrainedTokenizerBase, **kwargs: Any\n) -> TextSplitter:\n    \"\"\"Text splitter that uses Hugging Face tokenizer to count length.\n\n    Args:\n        tokenizer: The Hugging Face tokenizer to use.\n\n    Returns:\n        An instance of `TextSplitter` using the Hugging Face tokenizer for length\n            calculation.\n    \"\"\"\n    pretrained_tokenizer_base = _import_pretrained_tokenizer_base()\n\n    if not isinstance(tokenizer, pretrained_tokenizer_base):\n        msg = \"Tokenizer received was not an instance of PreTrainedTokenizerBase\"\n        raise ValueError(msg)  # noqa: TRY004\n\n    def _huggingface_tokenizer_length(text: str) -> int:\n        return len(tokenizer.tokenize(text))\n\n    return cls(length_function=_huggingface_tokenizer_length, **kwargs)",
      "asOf": "2026-11-20"
    },
    "F190": {
      "label": "Project source file, transformers",
      "display": "libs/text-splitters/langchain_text_splitters/base.py",
      "asOf": "2026-11-20"
    },
    "F191": {
      "label": "Project full_name, transformers",
      "display": "langchain-ai/langchain",
      "asOf": "2026-11-20"
    },
    "F192": {
      "label": "Project stargazers_count, transformers",
      "display": "149.7K",
      "asOf": "2026-11-20"
    },
    "F193": {
      "label": "Library name, nltk",
      "display": "NLTK",
      "asOf": "2026-11-20"
    },
    "F194": {
      "label": "Monthly downloads, nltk",
      "display": "48.7M",
      "asOf": "2026-11-20"
    },
    "F195": {
      "label": "License, nltk",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F196": {
      "label": "Package release, nltk",
      "display": "3.10.4",
      "asOf": "2026-11-20"
    },
    "F197": {
      "label": "Package release date, nltk",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F198": {
      "label": "Install, nltk",
      "display": "python -m pip install nltk",
      "asOf": "2026-11-20"
    },
    "F199": {
      "label": "Quickstart, nltk",
      "display": "from nltk.tokenize import wordpunct_tokenize\nprint(wordpunct_tokenize('Hello, world!'))\n",
      "asOf": "2026-11-20"
    },
    "F200": {
      "label": "Official description, nltk",
      "display": "Provides a natural language toolkit.",
      "asOf": "2026-11-20"
    },
    "F201": {
      "label": "Quickstart source file, nltk",
      "display": "nltk.tokenize package reference",
      "asOf": "2026-11-20"
    },
    "F202": {
      "label": "Repository stars, nltk",
      "display": "14.8K",
      "asOf": "2026-11-20"
    },
    "F203": {
      "label": "Subword model IDs, nltk",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F204": {
      "label": "Python three ten installation, nltk",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F205": {
      "label": "Python requirement, nltk",
      "display": ">=3.10",
      "asOf": "2026-11-20"
    },
    "F206": {
      "label": "Token units, nltk",
      "display": "Linguistic word/punctuation tokens rather than model vocabulary IDs",
      "asOf": "2026-11-20"
    },
    "F207": {
      "label": "Character offsets, nltk",
      "display": "TreebankWordTokenizer.span_tokenize yields integer spans",
      "asOf": "2026-11-20"
    },
    "F208": {
      "label": "Project function, nltk",
      "display": "def tokenize(self, text, include_punc=True):\n    \"\"\"Return a list of word tokens.\n\n    :param text: string of text.\n    :param include_punc: (optional) whether to\n        include punctuation as separate tokens. Default to True.\n    \"\"\"\n    tokens = nltk.tokenize.word_tokenize(text)\n    if include_punc:\n        return tokens\n    else:\n        # Return each word token\n        # Strips punctuation unless the word comes from a contraction\n        # e.g. \"Let's\" => [\"Let\", \"'s\"]\n        # e.g. \"Can't\" => [\"Ca\", \"n't\"]\n        # e.g. \"home.\" => ['home']\n        return [\n            word if word.startswith(\"'\") else strip_punc(word, all=False)\n            for word in tokens\n            if strip_punc(word, all=False)\n        ]",
      "asOf": "2026-11-20"
    },
    "F209": {
      "label": "Project source file, nltk",
      "display": "src/textblob/tokenizers.py",
      "asOf": "2026-11-20"
    },
    "F210": {
      "label": "Project full_name, nltk",
      "display": "sloria/TextBlob",
      "asOf": "2026-11-20"
    },
    "F211": {
      "label": "Project stargazers_count, nltk",
      "display": "9.6K",
      "asOf": "2026-11-20"
    },
    "F212": {
      "label": "Library name, sentencepiece",
      "display": "SentencePiece",
      "asOf": "2026-11-20"
    },
    "F213": {
      "label": "Monthly downloads, sentencepiece",
      "display": "29.8M",
      "asOf": "2026-11-20"
    },
    "F214": {
      "label": "License, sentencepiece",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F215": {
      "label": "Package release, sentencepiece",
      "display": "0.2.3",
      "asOf": "2026-11-20"
    },
    "F216": {
      "label": "Package release date, sentencepiece",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F217": {
      "label": "Install, sentencepiece",
      "display": "python -m pip install sentencepiece",
      "asOf": "2026-11-20"
    },
    "F218": {
      "label": "Quickstart, sentencepiece",
      "display": "import sentencepiece as spm\nprocessor = spm.SentencePieceProcessor(model_file='test/botchan_en_unigram_1000.model')\nprint(processor.encode('This is a test'))\n",
      "asOf": "2026-11-20"
    },
    "F219": {
      "label": "Repository stars, sentencepiece",
      "display": "12.2K",
      "asOf": "2026-11-20"
    },
    "F220": {
      "label": "Subword model IDs, sentencepiece",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F221": {
      "label": "Python three ten installation, sentencepiece",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F222": {
      "label": "Python requirement, sentencepiece",
      "display": ">=3.10",
      "asOf": "2026-11-20"
    },
    "F223": {
      "label": "Input/model preparation, sentencepiece",
      "display": "Trained .model asset required before processor encoding",
      "asOf": "2026-11-20"
    },
    "F224": {
      "label": "Character offsets, sentencepiece",
      "display": "Unicode offsets for str; byte offsets for bytes",
      "asOf": "2026-11-20"
    },
    "F225": {
      "label": "Native batch outputs, sentencepiece",
      "display": "IDs,pieces,NumPy buffers,and offset mappings",
      "asOf": "2026-11-20"
    },
    "F226": {
      "label": "Project function, sentencepiece",
      "display": "def __init__(\n    self,\n    model_path: str,\n    special_tokens: Optional[Union[Dict[str, str], List[str]]] = None,\n    legacy: bool = False,\n    ignore_extra_whitespaces: bool = True,\n    chat_template: Optional[Dict] = None,\n    trim_spm_separator_after_special_token=True,\n    spm_separator='▁',\n):\n    self.chat_template = chat_template\n    if not model_path or not os.path.exists(model_path):\n        raise ValueError(f\"model_path: {model_path} is invalid\")\n    self.tokenizer = sentencepiece.SentencePieceProcessor()\n    self.tokenizer.Load(model_path)\n\n    self.original_vocab_size = self.tokenizer.get_piece_size()\n    self.vocab_size = self.tokenizer.get_piece_size()\n    self.legacy = legacy\n    self.ignore_extra_whitespaces = ignore_extra_whitespaces\n    # using special symbol for extra_space token, so it is not likely to be in the vocabulary\n    self.extra_space_token = '☯'\n    self.special_token_to_id = {}\n    self.id_to_special_token = {}\n    self.trim_spm_separator_after_special_token = trim_spm_separator_after_special_token\n    self.spm_separator = spm_separator\n    self.spm_separator_id = self.tokenizer.piece_to_id(spm_separator)\n\n    if special_tokens:\n        if not self.legacy:\n            raise ValueError(\n                \"Special tokens must be None when legacy is set to False. Provide special tokens at train time.\"\n            )\n        self.add_special_tokens(special_tokens)\n\n    self.removed_extra_spaces = self.tokenizer.encode_as_pieces('x  y') == self.tokenizer.encode_as_pieces('x y')\n    self.space_sensitive = self.text_to_tokens('x y') != self.text_to_tokens('x') + self.text_to_tokens('y')\n    self._var_bpe_extension: VarBPEExtension | None = None  # lazy init\n    self._var_bpe_extension_case_insensitive: VarBPEExtension | None = None  # lazy init",
      "asOf": "2026-11-20"
    },
    "F227": {
      "label": "Project source file, sentencepiece",
      "display": "nemo/collections/common/tokenizers/sentencepiece_tokenizer.py",
      "asOf": "2026-11-20"
    },
    "F228": {
      "label": "Project full_name, sentencepiece",
      "display": "NVIDIA-NeMo/Speech",
      "asOf": "2026-11-20"
    },
    "F229": {
      "label": "Project stargazers_count, sentencepiece",
      "display": "18.8K",
      "asOf": "2026-11-20"
    },
    "F230": {
      "label": "Library name, spacy",
      "display": "spaCy",
      "asOf": "2026-11-20"
    },
    "F231": {
      "label": "Monthly downloads, spacy",
      "display": "25.2M",
      "asOf": "2026-11-20"
    },
    "F232": {
      "label": "License, spacy",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F233": {
      "label": "Package release, spacy",
      "display": "3.8.18",
      "asOf": "2026-11-20"
    },
    "F234": {
      "label": "Package release date, spacy",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F235": {
      "label": "Install, spacy",
      "display": "python -m pip install spacy",
      "asOf": "2026-11-20"
    },
    "F236": {
      "label": "Quickstart, spacy",
      "display": "import spacy\nnlp = spacy.blank('en')\nprint([token.text for token in nlp.tokenizer('Hello, world!')])\n",
      "asOf": "2026-11-20"
    },
    "F237": {
      "label": "Official description, spacy",
      "display": "Processes natural language in Python.",
      "asOf": "2026-11-20"
    },
    "F238": {
      "label": "Quickstart source file, spacy",
      "display": "api/tokenizer (official reference)",
      "asOf": "2026-11-20"
    },
    "F239": {
      "label": "Repository stars, spacy",
      "display": "34.1K",
      "asOf": "2026-11-20"
    },
    "F240": {
      "label": "Subword model IDs, spacy",
      "display": "Via plugin",
      "asOf": "2026-11-20"
    },
    "F241": {
      "label": "Python three ten installation, spacy",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F242": {
      "label": "Python requirement, spacy",
      "display": "<3.16,>=3.10",
      "asOf": "2026-11-20"
    },
    "F243": {
      "label": "Token units, spacy",
      "display": "Non-destructive linguistic Doc/Token representation",
      "asOf": "2026-11-20"
    },
    "F244": {
      "label": "Character offsets, spacy",
      "display": "Token.idx starts in original document",
      "asOf": "2026-11-20"
    },
    "F245": {
      "label": "Tokenization-only path, spacy",
      "display": "Language.make_doc bypasses remaining pipeline components",
      "asOf": "2026-11-20"
    },
    "F246": {
      "label": "Transformer model tokens, spacy",
      "display": "Optional spacy-transformers exposes backend tokenizer BatchEncoding",
      "asOf": "2026-11-20"
    },
    "F247": {
      "label": "Library name, sentence-transformers",
      "display": "Sentence Transformers",
      "asOf": "2026-11-20"
    },
    "F248": {
      "label": "Monthly downloads, sentence-transformers",
      "display": "22.8M",
      "asOf": "2026-11-20"
    },
    "F249": {
      "label": "License, sentence-transformers",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F250": {
      "label": "Package release, sentence-transformers",
      "display": "6.3.0",
      "asOf": "2026-11-20"
    },
    "F251": {
      "label": "Package release date, sentence-transformers",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F252": {
      "label": "Install, sentence-transformers",
      "display": "python -m pip install sentence-transformers",
      "asOf": "2026-11-20"
    },
    "F253": {
      "label": "Quickstart, sentence-transformers",
      "display": "from sentence_transformers import SentenceTransformer\nmodel = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')\nfeatures = model.preprocess(['Hello world'])\nprint(features)\n",
      "asOf": "2026-11-20"
    },
    "F254": {
      "label": "Official description, sentence-transformers",
      "display": "Computes embeddings for retrieval and reranking.",
      "asOf": "2026-11-20"
    },
    "F255": {
      "label": "Quickstart source file, sentence-transformers",
      "display": "SentenceTransformer generated API reference",
      "asOf": "2026-11-20"
    },
    "F256": {
      "label": "Repository stars, sentence-transformers",
      "display": "19.3K",
      "asOf": "2026-11-20"
    },
    "F257": {
      "label": "Subword model IDs, sentence-transformers",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F258": {
      "label": "Python three ten installation, sentence-transformers",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F259": {
      "label": "Python requirement, sentence-transformers",
      "display": ">=3.10",
      "asOf": "2026-11-20"
    },
    "F260": {
      "label": "Model-preparation role, sentence-transformers",
      "display": "Model input preprocessing through embedding-model facade",
      "asOf": "2026-11-20"
    },
    "F261": {
      "label": "Migration boundary, sentence-transformers",
      "display": "tokenize remains a deprecated alias; preprocess is preferred",
      "asOf": "2026-11-20"
    },
    "F262": {
      "label": "Character offsets, sentence-transformers",
      "display": "Inspect exposed backend tokenizer for model-specific mappings",
      "asOf": "2026-11-20"
    },
    "F263": {
      "label": "Chunking boundary, sentence-transformers",
      "display": "Model maximum sequence length constrains token chunk size",
      "asOf": "2026-11-20"
    },
    "F264": {
      "label": "Project function, sentence-transformers",
      "display": "def __init__(\n    self,\n    chunk_overlap: int = 50,\n    model_name: str = \"sentence-transformers/all-mpnet-base-v2\",\n    tokens_per_chunk: int | None = None,\n    model_kwargs: dict[str, Any] | None = None,\n    **kwargs: Any,\n) -> None:\n    \"\"\"Create a new `TextSplitter`.\n\n    Args:\n        chunk_overlap: The number of tokens to overlap between chunks.\n        model_name: The name of the sentence transformer model to use.\n        tokens_per_chunk: The number of tokens per chunk.\n\n            If `None`, uses the maximum tokens allowed by the model.\n        model_kwargs: Additional parameters for model initialization.\n            Parameters of sentence_transformers.SentenceTransformer can be used.\n\n    Raises:\n        ImportError: If the `sentence_transformers` package is not installed.\n        ValueError: If `tokens_per_chunk` exceeds the model's maximum token limit.\n    \"\"\"\n    super().__init__(**kwargs, chunk_overlap=chunk_overlap)\n\n    try:\n        sentence_transformers = cast(\"Any\", import_module(\"sentence_transformers\"))\n        sentence_transformer_cls = sentence_transformers.SentenceTransformer\n    except ImportError as err:\n        msg = (\n            \"Could not import sentence_transformers python package. \"\n            \"This is needed in order to use SentenceTransformersTokenTextSplitter. \"\n            \"Please install it with `pip install sentence-transformers`.\"\n        )\n        raise ImportError(msg) from err\n\n    self.model_name = model_name\n    self._model = sentence_transformer_cls(self.model_name, **(model_kwargs or {}))\n    self.tokenizer = self._model.tokenizer\n    self._initialize_chunk_configuration(tokens_per_chunk=tokens_per_chunk)",
      "asOf": "2026-11-20"
    },
    "F265": {
      "label": "Project source file, sentence-transformers",
      "display": "libs/text-splitters/langchain_text_splitters/sentence_transformers.py",
      "asOf": "2026-11-20"
    },
    "F266": {
      "label": "Project full_name, sentence-transformers",
      "display": "langchain-ai/langchain",
      "asOf": "2026-11-20"
    },
    "F267": {
      "label": "Project stargazers_count, sentence-transformers",
      "display": "149.7K",
      "asOf": "2026-11-20"
    },
    "F268": {
      "label": "Library name, jieba",
      "display": "Jieba",
      "asOf": "2026-11-20"
    },
    "F269": {
      "label": "Monthly downloads, jieba",
      "display": "6.2M",
      "asOf": "2026-11-20"
    },
    "F270": {
      "label": "License, jieba",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F271": {
      "label": "Package release, jieba",
      "display": "0.42.1",
      "asOf": "2026-11-20"
    },
    "F272": {
      "label": "Package release date, jieba",
      "display": "Jan 2020",
      "asOf": "2026-11-20"
    },
    "F273": {
      "label": "Install, jieba",
      "display": "python -m pip install jieba",
      "asOf": "2026-11-20"
    },
    "F274": {
      "label": "Quickstart, jieba",
      "display": "import jieba\nprint(jieba.lcut('我来到北京清华大学'))\n",
      "asOf": "2026-11-20"
    },
    "F275": {
      "label": "Official description, jieba",
      "display": "Segments Chinese text into words.",
      "asOf": "2026-11-20"
    },
    "F276": {
      "label": "Quickstart source file, jieba",
      "display": "README.md",
      "asOf": "2026-11-20"
    },
    "F277": {
      "label": "Repository stars, jieba",
      "display": "35.2K",
      "asOf": "2026-11-20"
    },
    "F278": {
      "label": "Subword model IDs, jieba",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F279": {
      "label": "Python three ten installation, jieba",
      "display": "Undocumented",
      "asOf": "2026-11-20"
    },
    "F280": {
      "label": "Python requirement, jieba",
      "display": "No explicit Requires-Python range",
      "asOf": "2026-11-20"
    },
    "F281": {
      "label": "Segmentation role, jieba",
      "display": "Chinese default,full,and search segmentation modes",
      "asOf": "2026-11-20"
    },
    "F282": {
      "label": "Dictionary and unknown-word handling, jieba",
      "display": "Custom dictionaries and optional HMM new-word discovery",
      "asOf": "2026-11-20"
    },
    "F283": {
      "label": "Character offsets, jieba",
      "display": "tokenize returns word,start,end positions",
      "asOf": "2026-11-20"
    },
    "F284": {
      "label": "Project function, jieba",
      "display": "def cut(self, sentence, cut_all=False, use_hmm=True):\n    \"\"\"\n    The method used to cut the text to tokens.\n\n    Args:\n        sentence(str): The text that needs to be cut.\n        cut_all(bool, optional): Whether to use the full mode. If True,\n            using full mode that gets all the possible words from the\n            sentence, which is fast but not accurate. If False, using\n            accurate mode that attempts to cut the sentence into the most\n            accurate segmentations, which is suitable for text analysis.\n            Default: False.\n        use_hmm(bool, optional): Whether to use the HMM model. Default: True.\n\n    Returns:\n        list[str]: A list of tokens.\n\n    Example:\n        .. code-block:: python\n\n            from paddlenlp.data import Vocab, JiebaTokenizer\n            # The vocab file. The sample file can be downloaded firstly.\n            # wget https://bj.bcebos.com/paddlenlp/data/senta_word_dict.txt\n            vocab_file_path = './senta_word_dict.txt'\n            # Initialize the Vocab\n            vocab = Vocab.load_vocabulary(\n                vocab_file_path,\n                unk_token='[UNK]',\n                pad_token='[PAD]')\n            tokenizer = JiebaTokenizer(vocab)\n\n            tokens = tokenizer.cut('我爱你中国')\n            print(tokens)\n            # ['我爱你', '中国']\n    \"\"\"\n    return self.tokenizer.lcut(sentence, cut_all, use_hmm)",
      "asOf": "2026-11-20"
    },
    "F285": {
      "label": "Project source file, jieba",
      "display": "paddlenlp/data/tokenizer.py",
      "asOf": "2026-11-20"
    },
    "F286": {
      "label": "Project full_name, jieba",
      "display": "PaddlePaddle/PaddleNLP",
      "asOf": "2026-11-20"
    },
    "F287": {
      "label": "Project stargazers_count, jieba",
      "display": "13.0K",
      "asOf": "2026-11-20"
    }
  },
  "dataCheckedAt": "2026-11-20",
  "agent": {
    "exaCall": {
      "endpoint": "/search",
      "body": {
        "query": "Best Python tokenizer libraries tiktoken Hugging Face Tokenizers SentencePiece Transformers code examples",
        "numResults": 5
      },
      "docsUrl": "https://exa.ai/docs/reference/search"
    },
    "calls": []
  }
}
