MCPcopy Index your code
hub / github.com/tinygrad/tinygrad / encode_message

Function encode_message

examples/llama3.py:323–324  ·  view source on GitHub ↗
(role: str, content: str)

Source from the content-addressed store, hash-verified

321 def encode_role(role: str):
322 return [tokenizer.special_tokens["<|start_header_id|>"]] + tokenizer.encode(role) + [tokenizer.special_tokens["<|end_header_id|>"]] + tokenizer.encode("\n\n")
323 def encode_message(role: str, content: str):
324 return encode_role(role) + tokenizer.encode(content.strip()) + [tokenizer.special_tokens["<|eot_id|>"]]
325
326 device = tuple(f"{Device.DEFAULT}:{i}" for i in range(args.shard)) if args.shard > 1 else Device.DEFAULT
327 model = build_transformer(args.model, model_size=args.size, quantize=args.quantize, device=device)

Callers 3

chat_token_encodeFunction · 0.85
chat_completionsFunction · 0.85
llama3.pyFile · 0.85

Calls 2

encode_roleFunction · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…