MCPcopy Index your code
hub / github.com/abetlen/llama-cpp-python / detokenize

Method detokenize

llama_cpp/llama.py:613–631  ·  view source on GitHub ↗

Detokenize a list of tokens. Args: tokens: The list of tokens to detokenize. prev_tokens: The list of previous tokens. Offset mapping will be performed if provided. special: Whether to detokenize special tokens. Returns: The detokeniz

(
        self,
        tokens: List[int],
        prev_tokens: Optional[List[int]] = None,
        special: bool = False,
    )

Source from the content-addressed store, hash-verified

611 return self.tokenizer_.tokenize(text, add_bos, special)
612
613 def detokenize(
614 self,
615 tokens: List[int],
616 prev_tokens: Optional[List[int]] = None,
617 special: bool = False,
618 ) -> bytes:
619 """Detokenize a list of tokens.
620
621 Args:
622 tokens: The list of tokens to detokenize.
623 prev_tokens: The list of previous tokens. Offset mapping will be performed if provided.
624 special: Whether to detokenize special tokens.
625
626 Returns:
627 The detokenized string.
628 """
629 return self.tokenizer_.detokenize(
630 tokens, prev_tokens=prev_tokens, special=special
631 )
632
633 def set_cache(self, cache: Optional[BaseLlamaCache]):
634 """Set the cache.

Callers 5

_create_completionMethod · 0.95
__call__Method · 0.45
__call__Method · 0.45
detokenizeFunction · 0.45

Calls

no outgoing calls

Tested by 1