MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / add_batch_tokens

Method add_batch_tokens

examples/server/server.py:12088–12105  ·  view source on GitHub ↗
(
        self,
        *,
        seq_id: int,
        start_pos: int,
        tokens: Sequence[int],
        output_indices: Sequence[Optional[int]],
    )

Source from the content-addressed store, hash-verified

12086 llama_cpp.llama_memory_clear(self.mem, True)
12087
12088 def add_batch_tokens(
12089 self,
12090 *,
12091 seq_id: int,
12092 start_pos: int,
12093 tokens: Sequence[int],
12094 output_indices: Sequence[Optional[int]],
12095 ) -> None:
12096 if not tokens:
12097 return
12098 for index, token in enumerate(tokens):
12099 slot = self.batch.n_tokens
12100 self.batch.token[slot] = token
12101 self.batch.pos[slot] = start_pos + index
12102 self.batch.seq_id[slot][0] = seq_id
12103 self.batch.n_seq_id[slot] = 1
12104 self.batch.logits[slot] = int(output_indices[index] is not None)
12105 self.batch.n_tokens += 1
12106
12107 def add_batch_embeddings(
12108 self,

Callers 2

embedMethod · 0.95
stepMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected