class_docstr: High-level Python wrapper for a llama.cpp model.
docstr: Create a generator of tokens from a prompt.
  
  Examples:
      >>> llama = Llama("models/ggml-7b.bin")
      >>> tokens = llama.tokenize(b"Hello, world!")
      >>> for token in llama.generate(tokens, top_k=40, top_p=0.95,
      >>>                             temp=1.0, repeat_penalty=1.1):
      ...     print(llama.detokenize([token]))
  
  Args:
      tokens: The prompt tokens.
      top_k: The top-k sampling parameter.
      top_p: The top-p sampling parameter.
      temp: The temperature parameter.
      repeat_penalty: The repeat penalty parameter.
      reset: Whether to reset the model state.
  
  Yields:
      The generated tokens.
docstr_tok: ["Create","a","generator","of","tokens","from","a","prompt",".","Examples",":",">",">",">","llama","=","Llama","(","``","models\/ggml-7b.bin","''",")",">",">",">","tokens","=","llama.tokenize","(","b","''","Hello",",","world","!","''",")",">",">",">","for","token","in","llama.generate","(","tokens",",","top_k=40",",","top_p=0.95",",",">",">",">","temp=1.0",",","repeat_penalty=1.1",")",":","...","print","(","llama.detokenize","(","[","token","]",")",")","Args",":","tokens",":","The","prompt","tokens",".","top_k",":","The","top-k","sampling","parameter",".","top_p",":","The","top-p","sampling","parameter",".","temp",":","The","temperature","parameter",".","repeat_penalty",":","The","repeat","penalty","parameter",".","reset",":","Whether","to","reset","the","model","state",".","Yields",":","The","generated","tokens","."]
code: def _generate(
      self,
      tokens: Sequence[int],
      top_k: int = 40,
      top_p: float = 0.95,
      temp: float = 0.80,
      repeat_penalty: float = 1.1,
      reset: bool = True,
      frequency_penalty: float = 0.0,
      presence_penalty: float = 0.0,
      tfs_z: float = 1.0,
      mirostat_mode: int = 0,
      mirostat_tau: float = 5.0,
      mirostat_eta: float = 0.1,
  ) -> Generator[int, Optional[Sequence[int]], None]:
      """Create a generator of tokens from a prompt.
  
      Examples:
          >>> llama = Llama("models/ggml-7b.bin")
          >>> tokens = llama.tokenize(b"Hello, world!")
          >>> for token in llama.generate(tokens, top_k=40, top_p=0.95,
          >>>                             temp=1.0, repeat_penalty=1.1):
          ...     print(llama.detokenize([token]))
  
      Args:
          tokens: The prompt tokens.
          top_k: The top-k sampling parameter.
          top_p: The top-p sampling parameter.
          temp: The temperature parameter.
          repeat_penalty: The repeat penalty parameter.
          reset: Whether to reset the model state.
  
      Yields:
          The generated tokens.
      """
      invalidInputError(
          self.ctx is not None,
          "The attribute `ctx` of `Llama` object is None.",
      )
  
      if reset and len(self.eval_tokens) > 0:
          longest_prefix = 0
          for a, b in zip(self.eval_tokens, tokens[:-1]):
              if a == b:
                  longest_prefix += 1
              else:
                  break
          if longest_prefix > 0:
              if self.verbose:
                  print(
                      "Llama.generate: prefix-match hit",
                      file=sys.stderr,
                  )
              reset = False
              tokens = tokens[longest_prefix:]
              for _ in range(len(self.eval_tokens) - longest_prefix):
                  self.eval_tokens.pop()
                  try:
                      self.eval_logits.pop()
                  except IndexError:
                      pass
  
      if reset:
          self.reset()
  
      while True:
          self.eval(tokens)
          token = self.sample(
              top_k=top_k,
              top_p=top_p,
              temp=temp,
              repeat_penalty=repeat_penalty,
              frequency_penalty=frequency_penalty,
              presence_penalty=presence_penalty,
              tfs_z=tfs_z,
              mirostat_mode=mirostat_mode,
              mirostat_tau=mirostat_tau,
              mirostat_eta=mirostat_eta,
          )
          tokens_or_none = yield token
          tokens = [token]
          if tokens_or_none is not None:
              tokens.extend(tokens_or_none)
  
imports: import os
  import sys
  import uuid
  import time
  import math
  import multiprocessing
  from typing import List, Optional, Union, Generator, Sequence, Iterator, Deque, Tuple
  from collections import deque, OrderedDict
  from bigdl.llm.utils.common import invalidInputError
  from bigdl.llm.ggml.model.generation import GenerationMixin
  from .None import llama_cpp
  from .llama_types import *
label_desc: Use image node_id 9 for calling the Llama obj's underlying member method code with example usage: obj._generate(tokens, top_k, top_p, temp, repeat_penalty, reset, frequency_penalty, presence_penalty, tfs_z, mirostat_mode, mirostat_tau, mirostat_eta) without return types