repo_id
stringlengths
15
89
file_path
stringlengths
27
180
content
stringlengths
1
2.23M
__index_level_0__
int64
0
0
hf_public_repos/tokenizers/tokenizers/src/models
hf_public_repos/tokenizers/tokenizers/src/models/wordpiece/mod.rs
//! [WordPiece](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/37842.pdf) //! model. use crate::models::bpe::BPE; use crate::tokenizer::{Model, Result, Token}; use std::{ borrow::Cow, collections::HashMap, fs::File, io::prelude::*, io::{BufRead, BufReader}, path...
0
hf_public_repos/tokenizers/tokenizers/src/models
hf_public_repos/tokenizers/tokenizers/src/models/wordpiece/trainer.rs
use super::WordPiece; use crate::models::bpe::{BpeTrainer, BpeTrainerBuilder, BPE}; use crate::tokenizer::{AddedToken, Result, Trainer}; use serde::{Deserialize, Serialize}; use std::collections::HashSet; /// A `WordPieceTrainerBuilder` can be used to create a `WordPieceTrainer` with a custom /// configuration. pub st...
0
hf_public_repos/tokenizers/tokenizers/src/models
hf_public_repos/tokenizers/tokenizers/src/models/wordpiece/serialization.rs
use super::{super::OrderedVocabIter, WordPiece, WordPieceBuilder}; use serde::{ de::{MapAccess, Visitor}, ser::SerializeStruct, Deserialize, Deserializer, Serialize, Serializer, }; use std::collections::HashSet; impl Serialize for WordPiece { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Er...
0
hf_public_repos/tokenizers/tokenizers/src/models
hf_public_repos/tokenizers/tokenizers/src/models/bpe/mod.rs
//! [Byte Pair Encoding](https://www.aclweb.org/anthology/P16-1162/) model. use std::{iter, mem}; mod model; mod serialization; pub mod trainer; mod word; type Pair = (u32, u32); /// Errors that can be encountered while using or constructing a `BPE` model. #[derive(thiserror::Error, Debug)] pub enum Error { /// ...
0
hf_public_repos/tokenizers/tokenizers/src/models
hf_public_repos/tokenizers/tokenizers/src/models/bpe/word.rs
use super::Pair; use rand::{thread_rng, Rng}; use std::cmp::Ordering; use std::collections::{BinaryHeap, HashMap}; #[derive(Debug, Eq)] struct Merge { pos: usize, rank: u32, new_id: u32, } impl PartialEq for Merge { fn eq(&self, other: &Self) -> bool { self.rank == other.rank && self.pos == ot...
0
hf_public_repos/tokenizers/tokenizers/src/models
hf_public_repos/tokenizers/tokenizers/src/models/bpe/trainer.rs
#![allow(clippy::map_entry)] use super::{Pair, WithFirstLastIterator, Word, BPE}; use crate::parallelism::*; use crate::tokenizer::{AddedToken, Result, Trainer}; use crate::utils::progress::{ProgressBar, ProgressStyle}; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::collections::{BinaryHeap, Has...
0
hf_public_repos/tokenizers/tokenizers/src/models
hf_public_repos/tokenizers/tokenizers/src/models/bpe/serialization.rs
use super::{super::OrderedVocabIter, convert_merges_to_hashmap, BpeBuilder, Pair, BPE}; use serde::{ de::{Error, MapAccess, Visitor}, ser::SerializeStruct, Deserialize, Deserializer, Serialize, Serializer, }; use std::collections::HashMap; impl Serialize for BPE { fn serialize<S>(&self, serializer: S) ...
0
hf_public_repos/tokenizers/tokenizers/src/models
hf_public_repos/tokenizers/tokenizers/src/models/bpe/model.rs
use super::{super::OrderedVocabIter, trainer::BpeTrainer, Error, Pair, Word}; use crate::tokenizer::{Model, Result, Token}; use crate::utils::cache::{Cache, DEFAULT_CACHE_CAPACITY}; use crate::utils::iter::ResultShunt; use serde_json::Value; use std::borrow::Cow; use std::{ collections::HashMap, fs::File, i...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/decoders/sequence.rs
use crate::decoders::DecoderWrapper; use crate::tokenizer::{Decoder, Result}; use crate::utils::macro_rules_attribute; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug)] #[macro_rules_attribute(impl_serde_type!)] pub struct Sequence { decoders: Vec<DecoderWrapper>, } impl Sequence { pub fn new(decod...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/decoders/fuse.rs
use crate::tokenizer::{Decoder, Result}; use monostate::MustBe; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Serialize, Deserialize, Default)] /// Fuse simply fuses all tokens into one big string. /// It's usually the last decoding step anyway, but this /// decoder exists incase some decoders need to ha...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/decoders/mod.rs
pub mod bpe; pub mod byte_fallback; pub mod ctc; pub mod fuse; pub mod sequence; pub mod strip; pub mod wordpiece; // Re-export these as decoders pub use super::pre_tokenizers::byte_level; pub use super::pre_tokenizers::metaspace; use serde::{Deserialize, Serialize}; use crate::decoders::bpe::BPEDecoder; use crate::...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/decoders/ctc.rs
use crate::decoders::wordpiece; use crate::tokenizer::{Decoder, Result}; use itertools::Itertools; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize)] /// The CTC (Connectionist Temporal Classification) decoder takes care /// of sanitizing a list of inputs token. /// Due to some align...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/decoders/byte_fallback.rs
use crate::tokenizer::{Decoder, Result}; use monostate::MustBe; use serde::{Deserialize, Serialize}; #[derive(Deserialize, Clone, Debug, Serialize, Default)] /// ByteFallback is a simple trick which converts tokens looking like `<0x61>` /// to pure bytes, and attempts to make them into a string. If the tokens /// can...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/decoders/bpe.rs
use crate::tokenizer::{Decoder, Result}; use serde::{Deserialize, Serialize}; #[derive(Deserialize, Clone, Debug, Serialize)] /// Allows decoding Original BPE by joining all the tokens and then replacing /// the suffix used to identify end-of-words by whitespaces #[serde(tag = "type")] #[non_exhaustive] pub struct BP...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/decoders/wordpiece.rs
use crate::tokenizer::{Decoder, Result}; use serde::{Deserialize, Serialize}; #[derive(Deserialize, Clone, Debug, Serialize)] /// The WordPiece decoder takes care of decoding a list of wordpiece tokens /// back into a readable string. #[serde(tag = "type")] #[non_exhaustive] pub struct WordPiece { /// The prefix ...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/decoders/strip.rs
use crate::tokenizer::{Decoder, Result}; use serde::{Deserialize, Serialize}; #[derive(Deserialize, Clone, Debug, Serialize, Default)] /// Strip is a simple trick which converts tokens looking like `<0x61>` /// to pure bytes, and attempts to make them into a string. If the tokens /// cannot be decoded you will get � ...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/utils/truncation.rs
use crate::tokenizer::{Encoding, Result}; use serde::{Deserialize, Serialize}; use std::cmp; use std::mem; #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Eq, Default)] pub enum TruncationDirection { Left, #[default] Right, } impl std::convert::AsRef<str> for TruncationDirection { fn a...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/utils/from_pretrained.rs
use crate::Result; use hf_hub::{api::sync::ApiBuilder, Repo, RepoType}; use std::collections::HashMap; use std::path::PathBuf; /// Defines the aditional parameters available for the `from_pretrained` function #[derive(Debug, Clone)] pub struct FromPretrainedParameters { pub revision: String, pub user_agent: Ha...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/utils/mod.rs
pub(crate) mod cache; #[cfg(feature = "http")] pub(crate) mod from_pretrained; #[cfg(feature = "unstable_wasm")] mod fancy; #[cfg(feature = "unstable_wasm")] pub use fancy::SysRegex; #[cfg(not(feature = "unstable_wasm"))] mod onig; #[cfg(not(feature = "unstable_wasm"))] pub use crate::utils::onig::SysRegex; pub mod i...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/utils/cache.rs
use std::borrow::Borrow; use std::collections::HashMap; use std::hash::Hash; use std::sync::RwLock; /// The default capacity for a `BPE`'s internal cache. pub static DEFAULT_CACHE_CAPACITY: usize = 10_000; /// Provides a simple multithread cache to speed up BPE tokenization that will try to read values /// concurrent...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/utils/onig.rs
use crate::tokenizer::pattern::Pattern; use crate::{Offsets, Result}; use onig::Regex; use std::error::Error; #[derive(Debug)] pub struct SysRegex { regex: Regex, } impl SysRegex { pub fn find_iter<'r, 't>(&'r self, inside: &'t str) -> onig::FindMatches<'r, 't> { self.regex.find_iter(inside) } ...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/utils/iter.rs
//! This comes from the Rust libcore and is duplicated here because it is not exported //! (cf <https://github.com/rust-lang/rust/blob/25091ed9b7739e12466fb2490baa1e8a2815121c/src/libcore/iter/adapters/mod.rs#L2664>) //! We are now using the version from <https://stackoverflow.com/questions/44544323/how-to-unzip-a-sequ...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/utils/progress.rs
#[cfg(feature = "progressbar")] pub(crate) use indicatif::{ProgressBar, ProgressStyle}; #[cfg(not(feature = "progressbar"))] mod progressbar { use std::borrow::Cow; pub struct ProgressBar; impl ProgressBar { pub fn new(_length: u64) -> Self { Self {} } pub fn set_length...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/utils/parallelism.rs
//! //! This module defines helpers to allow optional Rayon usage. //! use rayon::iter::IterBridge; use rayon::prelude::*; use rayon_cond::CondIterator; // Re-export rayon current_num_threads pub use rayon::current_num_threads; pub const ENV_VARIABLE: &str = "TOKENIZERS_PARALLELISM"; // Reading/Writing this variabl...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/utils/fancy.rs
use fancy_regex::Regex; use std::error::Error; #[derive(Debug)] pub struct SysRegex { regex: Regex, } impl SysRegex { pub fn find_iter<'r, 't>(&'r self, inside: &'t str) -> Matches<'r, 't> { Matches(self.regex.find_iter(inside)) } pub fn new(regex_str: &str) -> Result<Self, Box<dyn Error + Se...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/utils/padding.rs
use crate::parallelism::*; use crate::tokenizer::{Encoding, Result}; use serde::{Deserialize, Serialize}; /// The various possible padding directions. #[derive(Debug, Clone, Copy, Serialize, Deserialize)] pub enum PaddingDirection { Left, Right, } impl std::convert::AsRef<str> for PaddingDirection { fn as...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers/whitespace.rs
use regex::Regex; use crate::tokenizer::{ pattern::Invert, PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior, }; use crate::utils::macro_rules_attribute; #[derive(Clone, Debug, PartialEq, Eq)] #[macro_rules_attribute(impl_serde_type!)] pub struct Whitespace; impl Default for Whitespace { fn de...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers/metaspace.rs
use crate::tokenizer::{Decoder, PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior}; use serde::{Deserialize, Deserializer, Serialize}; /// Enum representing options for the metaspace prepending scheme. #[derive(Debug, Clone, PartialEq, Serialize, Eq, Deserialize, Copy)] #[serde(rename_all = "snake_case"...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers/sequence.rs
use crate::pre_tokenizers::PreTokenizerWrapper; use crate::tokenizer::{PreTokenizedString, PreTokenizer, Result}; use crate::utils::macro_rules_attribute; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq)] #[macro_rules_attribute(impl_serde_type!)] pub struct Sequence { pretokenizers: Vec<PreT...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers/mod.rs
pub mod bert; pub mod byte_level; pub mod delimiter; pub mod digits; pub mod metaspace; pub mod punctuation; pub mod sequence; pub mod split; pub mod unicode_scripts; pub mod whitespace; use serde::{Deserialize, Serialize}; use crate::pre_tokenizers::bert::BertPreTokenizer; use crate::pre_tokenizers::byte_level::Byte...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers/split.rs
use crate::utils::SysRegex; use serde::{Deserialize, Deserializer, Serialize}; use crate::tokenizer::{ pattern::Invert, PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior, }; /// Represents the different patterns that `Split` can use #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq)] pub...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers/digits.rs
use serde::{Deserialize, Serialize}; use crate::tokenizer::{PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior}; use crate::utils::macro_rules_attribute; #[derive(Clone, Debug, PartialEq, Eq)] /// Pre tokenizes the numbers into single tokens. If individual_digits is set /// to true, then all digits are ...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers/bert.rs
use crate::tokenizer::{PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior}; use crate::utils::macro_rules_attribute; use unicode_categories::UnicodeCategories; fn is_bert_punc(x: char) -> bool { char::is_ascii_punctuation(&x) || x.is_punctuation() } #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[mac...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers/punctuation.rs
use serde::{Deserialize, Serialize}; use crate::tokenizer::{PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior}; use crate::utils::macro_rules_attribute; use unicode_categories::UnicodeCategories; fn is_punc(x: char) -> bool { char::is_ascii_punctuation(&x) || x.is_punctuation() } #[derive(Copy, Cl...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers/byte_level.rs
use std::collections::{HashMap, HashSet}; use crate::utils::SysRegex; use serde::{Deserialize, Serialize}; use crate::tokenizer::{ Decoder, Encoding, PostProcessor, PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior, }; use crate::utils::macro_rules_attribute; /// Converts bytes to unicode char...
0
hf_public_repos/tokenizers/tokenizers/src
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers/delimiter.rs
use serde::{Deserialize, Serialize}; use crate::tokenizer::{PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior}; use crate::utils::macro_rules_attribute; #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[non_exhaustive] #[macro_rules_attribute(impl_serde_type!)] pub struct CharDelimiterSplit { pub deli...
0
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers/unicode_scripts/mod.rs
mod pre_tokenizer; mod scripts; // Re-export the PreTokenizer pub use pre_tokenizer::UnicodeScripts;
0
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers/unicode_scripts/pre_tokenizer.rs
use crate::pre_tokenizers::unicode_scripts::scripts::{get_script, Script}; use crate::tokenizer::{normalizer::Range, PreTokenizedString, PreTokenizer, Result}; use crate::utils::macro_rules_attribute; #[derive(Clone, Debug, PartialEq, Eq)] #[macro_rules_attribute(impl_serde_type!)] pub struct UnicodeScripts; impl Uni...
0
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers
hf_public_repos/tokenizers/tokenizers/src/pre_tokenizers/unicode_scripts/scripts.rs
// Generated by modified Perl script at https://github.com/google/sentencepiece/blob/master/data/gen_unicode_scripts_code.pl // Unicode scripts : https://gist.github.com/Narsil/07556f26dc84a6baeff4d499e68d3cd2 // Rust adaptation : https://gist.github.com/Narsil/1df9fbbf5296a8d4d62de55dcb2fe700 #[derive(PartialEq, Debu...
0
hf_public_repos/tokenizers
hf_public_repos/tokenizers/docs/README.md
## Requirements In order to generate the documentation, it is necessary to have a Python environment with the following: ```python pip install sphinx sphinx_rtd_theme setuptools_rust ``` It is also necessary to have the `tokenizers` library in this same environment, for Sphinx to generate all the API Reference and li...
0
hf_public_repos/tokenizers
hf_public_repos/tokenizers/docs/Makefile
# Minimal makefile for Sphinx documentation # # You can set these variables from the command line, and also # from the environment for those with `?=` SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build BUILDDIR ?= build SOURCEDIR = source # Put it first so that "make" without argument is like "make html_all". h...
0
hf_public_repos/tokenizers/docs
hf_public_repos/tokenizers/docs/source/entities.inc
.. entities:: python :global: class class classmethod class method Tokenizer :class:`~tokenizers.Tokenizer` Tokenizer.train :meth:`~tokenizers.Tokenizer.train` Tokenizer.save :meth:`~tokenizers.Tokenizer.save` Tokenizer.from_file :meth:`~toke...
0
hf_public_repos/tokenizers/docs
hf_public_repos/tokenizers/docs/source/quicktour.rst
Quicktour ==================================================================================================== Let's have a quick look at the 🤗 Tokenizers library features. The library provides an implementation of today's most used tokenizers that is both easy to use and blazing fast. .. only:: python It can b...
0
hf_public_repos/tokenizers/docs
hf_public_repos/tokenizers/docs/source/pipeline.rst
The tokenization pipeline ==================================================================================================== When calling :entity:`Tokenizer.encode` or :entity:`Tokenizer.encode_batch`, the input text(s) go through the following pipeline: - :ref:`normalization` - :ref:`pre-tokenization` - :ref:`mode...
0
hf_public_repos/tokenizers/docs
hf_public_repos/tokenizers/docs/source/components.rst
Components ==================================================================================================== When building a Tokenizer, you can attach various types of components to this Tokenizer in order to customize its behavior. This page lists most provided components. .. _normalizers: .. entities:: python ...
0
hf_public_repos/tokenizers/docs
hf_public_repos/tokenizers/docs/source/conf.py
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
0
hf_public_repos/tokenizers/docs
hf_public_repos/tokenizers/docs/source/index.rst
Tokenizers ==================================================================================================== Fast State-of-the-art tokenizers, optimized for both research and production `🤗 Tokenizers`_ provides an implementation of today's most used tokenizers, with a focus on performance and versatility. These t...
0
hf_public_repos/tokenizers/docs/source/_static
hf_public_repos/tokenizers/docs/source/_static/js/custom.js
// These three variables below need to be updated at each release for the selectors. const languages = [ "rust", "python", "node" ]; // Last stable version for each language const stableVersion = { "rust": "master", "python": "v0.10.0", "node": "master" } // Dictionary doc folder to Label for each language...
0
hf_public_repos/tokenizers/docs/source/_static
hf_public_repos/tokenizers/docs/source/_static/css/code-snippets.css
.highlight .c1, .highlight .sd{ color: #999 } .highlight .nn, .highlight .k, .highlight .s1, .highlight .nb, .highlight .bp, .highlight .kc, .highlight .kt { color: #FB8D68; } .highlight .kn, .highlight .nv, .highlight .s2, .highlight .ow, .highlight .kd, .highlight .kr, .highlight .s { color: #6670FF; }...
0
hf_public_repos/tokenizers/docs/source/_static
hf_public_repos/tokenizers/docs/source/_static/css/huggingface.css
/* Our DOM objects */ /* Version control */ .selectors { margin-bottom: 10px; } .dropdown-button { display: inline-block; width: 50%; background-color: #6670FF; color: white; border: none; padding: 5px; font-size: 15px; cursor: pointer; } .dropdown-button:hover, .dropdown-button:...
0
hf_public_repos/tokenizers/docs/source
hf_public_repos/tokenizers/docs/source/api/python.inc
Input sequences ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ These types represent all the different kinds of sequence that can be used as input of a Tokenizer. Globally, any sequence can be either a string or a list of strings, according to the operating mode of...
0
hf_public_repos/tokenizers/docs/source
hf_public_repos/tokenizers/docs/source/api/node.inc
Documentation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The node API has not been documented yet.
0
hf_public_repos/tokenizers/docs/source
hf_public_repos/tokenizers/docs/source/api/reference.rst
.. only:: python .. include:: python.inc .. only:: rust .. include:: rust.inc .. only:: node .. include:: node.inc
0
hf_public_repos/tokenizers/docs/source
hf_public_repos/tokenizers/docs/source/api/rust.inc
Documentation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Rust API Reference is available directly on the `Docs.rs <https://docs.rs/tokenizers>`__ website.
0
hf_public_repos/tokenizers/docs/source
hf_public_repos/tokenizers/docs/source/_ext/toctree_tags.py
import re from sphinx.directives.other import TocTree class TocTreeTags(TocTree): hasPat = re.compile("^\s*:(.+):(.+)$") def filter_entries(self, entries): filtered = [] for e in entries: m = self.hasPat.match(e) if m != None: if self.env.app.tags.has(m...
0
hf_public_repos/tokenizers/docs/source
hf_public_repos/tokenizers/docs/source/_ext/rust_doc.py
from docutils import nodes import sphinx from sphinx.locale import _ from conf import rust_version logger = sphinx.util.logging.getLogger(__name__) class RustRef: def __call__(self, name, rawtext, text, lineno, inliner, options={}, content=[]): doctype = name.split("_")[1] parts = text.split(":...
0
hf_public_repos/tokenizers/docs/source
hf_public_repos/tokenizers/docs/source/_ext/entities.py
from collections import defaultdict, abc from typing import cast from docutils import nodes from docutils.parsers.rst import Directive import sphinx from sphinx.locale import _ from sphinx.util.docutils import SphinxDirective from sphinx.errors import ExtensionError from conf import languages as LANGUAGES logger = ...
0
hf_public_repos/tokenizers/docs/source/tutorials
hf_public_repos/tokenizers/docs/source/tutorials/python/training_from_memory.rst
Training from memory ---------------------------------------------------------------------------------------------------- In the `Quicktour <quicktour>`__, we saw how to build and train a tokenizer using text files, but we can actually use any Python Iterator. In this section we'll see a few different ways of training...
0
hf_public_repos/tokenizers/docs/source
hf_public_repos/tokenizers/docs/source/installation/python.inc
🤗 Tokenizers is tested on Python 3.5+. You should install 🤗 Tokenizers in a `virtual environment <https://docs.python.org/3/library/venv.html>`_. If you're unfamiliar with Python virtual environments, check out the `user guide <https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/>`__. C...
0
hf_public_repos/tokenizers/docs/source
hf_public_repos/tokenizers/docs/source/installation/node.inc
Installation with npm ---------------------------------------------------------------------------------------------------- You can simply install 🤗 Tokenizers with npm using:: npm install tokenizers
0
hf_public_repos/tokenizers/docs/source
hf_public_repos/tokenizers/docs/source/installation/rust.inc
Crates.io ---------------------------------------------------------------------------------------------------- 🤗 Tokenizers is available on `crates.io <https://crates.io/crates/tokenizers>`__. You just need to add it to your :obj:`Cargo.toml`:: tokenizers = "0.10"
0
hf_public_repos/tokenizers/docs/source
hf_public_repos/tokenizers/docs/source/installation/main.rst
Installation ==================================================================================================== .. only:: python .. include:: python.inc .. only:: rust .. include:: rust.inc .. only:: node .. include:: node.inc
0
hf_public_repos/tokenizers/docs
hf_public_repos/tokenizers/docs/source-doc-builder/quicktour.mdx
# Quicktour Let's have a quick look at the 🤗 Tokenizers library features. The library provides an implementation of today's most used tokenizers that is both easy to use and blazing fast. ## Build a tokenizer from scratch To illustrate how fast the 🤗 Tokenizers library is, let's train a new tokenizer on [wikitext-...
0
hf_public_repos/tokenizers/docs
hf_public_repos/tokenizers/docs/source-doc-builder/training_from_memory.mdx
# Training from memory In the [Quicktour](quicktour), we saw how to build and train a tokenizer using text files, but we can actually use any Python Iterator. In this section we'll see a few different ways of training our tokenizer. For all the examples listed below, we'll use the same [`~tokenizers.Tokenizer`] and [...
0
hf_public_repos/tokenizers/docs
hf_public_repos/tokenizers/docs/source-doc-builder/installation.mdx
# Installation <tokenizerslangcontent> <python> 🤗 Tokenizers is tested on Python 3.5+. You should install 🤗 Tokenizers in a [virtual environment](https://docs.python.org/3/library/venv.html). If you're unfamiliar with Python virtual environments, check out the [user guide](https://packaging.python.org/guides/instal...
0
hf_public_repos/tokenizers/docs
hf_public_repos/tokenizers/docs/source-doc-builder/index.mdx
<!-- DISABLE-FRONTMATTER-SECTIONS --> # Tokenizers Fast State-of-the-art tokenizers, optimized for both research and production [🤗 Tokenizers](https://github.com/huggingface/tokenizers) provides an implementation of today's most used tokenizers, with a focus on performance and versatility. These tokenizers are also...
0
hf_public_repos/tokenizers/docs
hf_public_repos/tokenizers/docs/source-doc-builder/components.mdx
# Components When building a Tokenizer, you can attach various types of components to this Tokenizer in order to customize its behavior. This page lists most provided components. ## Normalizers A `Normalizer` is in charge of pre-processing the input string in order to normalize it as relevant for a given use case. S...
0
hf_public_repos/tokenizers/docs
hf_public_repos/tokenizers/docs/source-doc-builder/_toctree.yml
- sections: - local: index title: 🤗 Tokenizers - local: quicktour title: Quicktour - local: installation title: Installation - local: pipeline title: The tokenization pipeline - local: components title: Components - local: training_from_memory title: Training from memory title: G...
0
hf_public_repos/tokenizers/docs
hf_public_repos/tokenizers/docs/source-doc-builder/pipeline.mdx
# The tokenization pipeline When calling `Tokenizer.encode` or `Tokenizer.encode_batch`, the input text(s) go through the following pipeline: - `normalization` - `pre-tokenization` - `model` - `post-processing` We'll see in details what happens during each of those steps in detail, as well as when you want t...
0
hf_public_repos/tokenizers/docs/source-doc-builder
hf_public_repos/tokenizers/docs/source-doc-builder/api/visualizer.mdx
# Visualizer <tokenizerslangcontent> <python> ## Annotation [[autodoc]] tokenizers.tools.Annotation ## EncodingVisualizer [[autodoc]] tokenizers.tools.EncodingVisualizer - __call__ </python> <rust> The Rust API Reference is available directly on the [Docs.rs](https://docs.rs/tokenizers/latest/tokenizers/) webs...
0
hf_public_repos/tokenizers/docs/source-doc-builder
hf_public_repos/tokenizers/docs/source-doc-builder/api/post-processors.mdx
# Post-processors <tokenizerslangcontent> <python> ## BertProcessing [[autodoc]] tokenizers.processors.BertProcessing ## ByteLevel [[autodoc]] tokenizers.processors.ByteLevel ## RobertaProcessing [[autodoc]] tokenizers.processors.RobertaProcessing ## TemplateProcessing [[autodoc]] tokenizers.processors.Template...
0
hf_public_repos/tokenizers/docs/source-doc-builder
hf_public_repos/tokenizers/docs/source-doc-builder/api/added-tokens.mdx
# Added Tokens <tokenizerslangcontent> <python> ## AddedToken [[autodoc]] tokenizers.AddedToken - content - lstrip - normalized - rstrip - single_word </python> <rust> The Rust API Reference is available directly on the [Docs.rs](https://docs.rs/tokenizers/latest/tokenizers/) website. </rust> <nod...
0
hf_public_repos/tokenizers/docs/source-doc-builder
hf_public_repos/tokenizers/docs/source-doc-builder/api/tokenizer.mdx
# Tokenizer <tokenizerslangcontent> <python> ## Tokenizer [[autodoc]] tokenizers.Tokenizer - all - decoder - model - normalizer - padding - post_processor - pre_tokenizer - truncation </python> <rust> The Rust API Reference is available directly on the [Docs.rs](https://docs.rs/tokeniz...
0
hf_public_repos/tokenizers/docs/source-doc-builder
hf_public_repos/tokenizers/docs/source-doc-builder/api/models.mdx
# Models <tokenizerslangcontent> <python> ## BPE [[autodoc]] tokenizers.models.BPE ## Model [[autodoc]] tokenizers.models.Model ## Unigram [[autodoc]] tokenizers.models.Unigram ## WordLevel [[autodoc]] tokenizers.models.WordLevel ## WordPiece [[autodoc]] tokenizers.models.WordPiece </python> <rust> The Rust A...
0
hf_public_repos/tokenizers/docs/source-doc-builder
hf_public_repos/tokenizers/docs/source-doc-builder/api/normalizers.mdx
# Normalizers <tokenizerslangcontent> <python> ## BertNormalizer [[autodoc]] tokenizers.normalizers.BertNormalizer ## Lowercase [[autodoc]] tokenizers.normalizers.Lowercase ## NFC [[autodoc]] tokenizers.normalizers.NFC ## NFD [[autodoc]] tokenizers.normalizers.NFD ## NFKC [[autodoc]] tokenizers.normalizers.NF...
0
hf_public_repos/tokenizers/docs/source-doc-builder
hf_public_repos/tokenizers/docs/source-doc-builder/api/decoders.mdx
# Decoders <tokenizerslangcontent> <python> ## BPEDecoder [[autodoc]] tokenizers.decoders.BPEDecoder ## ByteLevel [[autodoc]] tokenizers.decoders.ByteLevel ## CTC [[autodoc]] tokenizers.decoders.CTC ## Metaspace [[autodoc]] tokenizers.decoders.Metaspace ## WordPiece [[autodoc]] tokenizers.decoders.WordPiece <...
0
hf_public_repos/tokenizers/docs/source-doc-builder
hf_public_repos/tokenizers/docs/source-doc-builder/api/encode-inputs.mdx
# Encode Inputs <tokenizerslangcontent> <python> These types represent all the different kinds of input that a [`~tokenizers.Tokenizer`] accepts when using [`~tokenizers.Tokenizer.encode_batch`]. ## TextEncodeInput[[[[tokenizers.TextEncodeInput]]]] <code>tokenizers.TextEncodeInput</code> Represents a textual input ...
0
hf_public_repos/tokenizers/docs/source-doc-builder
hf_public_repos/tokenizers/docs/source-doc-builder/api/trainers.mdx
# Trainers <tokenizerslangcontent> <python> ## BpeTrainer [[autodoc]] tokenizers.trainers.BpeTrainer ## UnigramTrainer [[autodoc]] tokenizers.trainers.UnigramTrainer ## WordLevelTrainer [[autodoc]] tokenizers.trainers.WordLevelTrainer ## WordPieceTrainer [[autodoc]] tokenizers.trainers.WordPieceTrainer </python...
0
hf_public_repos/tokenizers/docs/source-doc-builder
hf_public_repos/tokenizers/docs/source-doc-builder/api/pre-tokenizers.mdx
# Pre-tokenizers <tokenizerslangcontent> <python> ## BertPreTokenizer [[autodoc]] tokenizers.pre_tokenizers.BertPreTokenizer ## ByteLevel [[autodoc]] tokenizers.pre_tokenizers.ByteLevel ## CharDelimiterSplit [[autodoc]] tokenizers.pre_tokenizers.CharDelimiterSplit ## Digits [[autodoc]] tokenizers.pre_tokenizers...
0
hf_public_repos/tokenizers/docs/source-doc-builder
hf_public_repos/tokenizers/docs/source-doc-builder/api/encoding.mdx
# Encoding <tokenizerslangcontent> <python> ## Encoding [[autodoc]] tokenizers.Encoding - all - attention_mask - ids - n_sequences - offsets - overflowing - sequence_ids - special_tokens_mask - tokens - type_ids - word_ids - words </python> <rust> The Rust API Reference...
0
hf_public_repos/tokenizers/docs/source-doc-builder
hf_public_repos/tokenizers/docs/source-doc-builder/api/input-sequences.mdx
# Input Sequences <tokenizerslangcontent> <python> These types represent all the different kinds of sequence that can be used as input of a Tokenizer. Globally, any sequence can be either a string or a list of strings, according to the operating mode of the tokenizer: `raw text` vs `pre-tokenized`. ## TextInputSequen...
0
hf_public_repos
hf_public_repos/text-generation-inference/.dockerignore
aml target server/transformers server/flash-attention
0
hf_public_repos
hf_public_repos/text-generation-inference/update_doc.py
import subprocess import argparse def main(): parser = argparse.ArgumentParser() parser.add_argument("--check", action="store_true") args = parser.parse_args() output = subprocess.check_output(["text-generation-launcher", "--help"]).decode( "utf-8" ) wrap_code_blocks_flag = "<!-- WR...
0
hf_public_repos
hf_public_repos/text-generation-inference/Dockerfile
# Rust builder FROM lukemathwalker/cargo-chef:latest-rust-1.71 AS chef WORKDIR /usr/src ARG CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse FROM chef as planner COPY Cargo.toml Cargo.toml COPY rust-toolchain.toml rust-toolchain.toml COPY proto proto COPY benchmark benchmark COPY router router COPY launcher launcher RUN ca...
0
hf_public_repos
hf_public_repos/text-generation-inference/README.md
<div align="center"> <a href="https://www.youtube.com/watch?v=jlMAX2Oaht0"> <img width=560 width=315 alt="Making TGI deployment optimal" src="https://huggingface.co/datasets/Narsil/tgi_assets/resolve/main/thumbnail.png"> </a> # Text Generation Inference <a href="https://github.com/huggingface/text-generation-inf...
0
hf_public_repos
hf_public_repos/text-generation-inference/rust-toolchain.toml
[toolchain] channel = "1.70.0" components = ["rustfmt", "clippy"]
0
hf_public_repos
hf_public_repos/text-generation-inference/Dockerfile_amd
# Rust builder FROM lukemathwalker/cargo-chef:latest-rust-1.71 AS chef WORKDIR /usr/src ARG CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse FROM chef as planner COPY Cargo.toml Cargo.toml COPY rust-toolchain.toml rust-toolchain.toml COPY proto proto COPY benchmark benchmark COPY router router COPY launcher launcher RUN ca...
0
hf_public_repos
hf_public_repos/text-generation-inference/sagemaker-entrypoint.sh
#!/bin/bash if [[ -z "${HF_MODEL_ID}" ]]; then echo "HF_MODEL_ID must be set" exit 1 fi export MODEL_ID="${HF_MODEL_ID}" if [[ -n "${HF_MODEL_REVISION}" ]]; then export REVISION="${HF_MODEL_REVISION}" fi if [[ -n "${SM_NUM_GPUS}" ]]; then export NUM_SHARD="${SM_NUM_GPUS}" fi if [[ -n "${HF_MODEL_QUANTIZE}" ...
0
hf_public_repos
hf_public_repos/text-generation-inference/Cargo.lock
# This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "addr2line" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "giml...
0
hf_public_repos
hf_public_repos/text-generation-inference/Makefile
install-server: cd server && make install install-custom-kernels: if [ "$$BUILD_EXTENSIONS" = "True" ]; then cd server/custom_kernels && python setup.py install; else echo "Custom kernels are disabled, you need to set the BUILD_EXTENSIONS environment variable to 'True' in order to build them. (Please read the docs, ...
0
hf_public_repos
hf_public_repos/text-generation-inference/Cargo.toml
[workspace] members = [ "benchmark", "router", "router/client", "router/grpc-metadata", "launcher" ] [workspace.package] version = "1.3.4" edition = "2021" authors = ["Olivier Dehaene"] homepage = "https://github.com/huggingface/text-generation-inference" [profile.release] debug = 1 incremental = ...
0
hf_public_repos
hf_public_repos/text-generation-inference/LICENSE
Hugging Face Optimized Inference License 1.0 (HFOILv1.0) This License Agreement governs the use of the Software and its Modifications. It is a binding agreement between the Licensor and You. This License Agreement shall be referred to as Hugging Face Optimized Inference License 1.0 or HFOILv1.0. We may publish revis...
0
hf_public_repos/text-generation-inference
hf_public_repos/text-generation-inference/load_tests/vllm.js
import { get_options, run } from "./common.js"; const reference_latency_ms = 22; const host = __ENV.HOST || '127.0.0.1:8000'; const max_new_tokens = 50; function generate_payload(gpt){ const input = gpt["conversations"][0]["value"]; return {"prompt": input, "temperature": 0.5, "ignore_eos": true} } export ...
0
hf_public_repos/text-generation-inference
hf_public_repos/text-generation-inference/load_tests/common.js
import { check, randomSeed } from 'k6'; import http from 'k6/http'; import { Trend, Counter } from 'k6/metrics'; import { randomItem } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js'; const seed = 0; const host = __ENV.HOST || '127.0.0.1:8000'; const timePerToken = new Trend('time_per_token', true); const tokens =...
0
hf_public_repos/text-generation-inference
hf_public_repos/text-generation-inference/load_tests/tgi.js
import { get_options, run } from "./common.js"; const reference_latency_ms = 70; const host = __ENV.HOST || '127.0.0.1:8000'; const max_new_tokens = 50; function generate_payload(gpt){ const input = gpt["conversations"][0]["value"]; return {"inputs": input, "parameters": {"max_new_tokens": max_new_tokens, "...
0
hf_public_repos/text-generation-inference
hf_public_repos/text-generation-inference/load_tests/starcoder_load.js
import {check} from 'k6'; import http from 'k6/http'; import {Trend} from 'k6/metrics'; const host = __ENV.HOST || '127.0.0.1:3000'; const totalTime = new Trend('total_time', true); const validationTime = new Trend('validation_time', true); const queueTime = new Trend('queue_time', true); const inferenceTime = new Tr...
0
hf_public_repos/text-generation-inference
hf_public_repos/text-generation-inference/integration-tests/pyproject.toml
[tool.poetry] name = "text-generation-integration-tests" version = "1.3.4" description = "Text Generation Inference integration tests" authors = ["Nicolas Patry <nicolas@huggingface.co>"] [tool.poetry.dependencies] python = ">=3.9,<3.13" syrupy = "4.0.1" text-generation = "^0.6.0" pytest = "^7.4.0" pytest-asyncio = "^...
0
hf_public_repos/text-generation-inference
hf_public_repos/text-generation-inference/integration-tests/poetry.lock
# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. [[package]] name = "aiohttp" version = "3.8.5" description = "Async http client/server framework (asyncio)" optional = false python-versions = ">=3.6" files = [ {file = "aiohttp-3.8.5-cp310-cp310-macosx_10_9_universal2.whl",...
0
hf_public_repos/text-generation-inference
hf_public_repos/text-generation-inference/integration-tests/requirements.txt
aiohttp==3.8.5 ; python_version >= "3.9" and python_version < "3.13" aiosignal==1.3.1 ; python_version >= "3.9" and python_version < "3.13" async-timeout==4.0.3 ; python_version >= "3.9" and python_version < "3.13" attrs==23.1.0 ; python_version >= "3.9" and python_version < "3.13" certifi==2023.7.22 ; python_version >...
0
hf_public_repos/text-generation-inference
hf_public_repos/text-generation-inference/integration-tests/pytest.ini
[pytest] addopts = --snapshot-warn-unused asyncio_mode = auto markers = private: marks tests as requiring an admin hf token (deselect with '-m "not private"')
0