Views
No views yet
AutoModelForCausalLM and AutoTokenizer.transformers installed:pip install -U transformers torch1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "lewtun/talkie-1930-13b-it-hf"
4
5tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
6model = AutoModelForCausalLM.from_pretrained(
7 model_name,
8 trust_remote_code=True,
9 dtype="bfloat16",
10).to("cuda")
11
12prompt = "Write an essay predicting what life will be like in the year 1960."
13messages = [{"role": "user", "content": prompt}]
14
15text = tokenizer.apply_chat_template(
16 messages,
17 tokenize=False,
18 add_generation_prompt=True,
19)
20model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
21
22generated_ids = model.generate(**model_inputs, max_new_tokens=512, temperature=0.7, do_sample=True)
23output_ids = generated_ids[0][len(model_inputs.input_ids[0]):]
24print(tokenizer.decode(output_ids, skip_special_tokens=True))1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "lewtun/talkie-1930-13b-it-hf"
4
5tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
6model = AutoModelForCausalLM.from_pretrained(
7 model_name,
8 trust_remote_code=True,
9 dtype="bfloat16",
10).to("cuda")
11
12messages = [
13 {"role": "user", "content": "What were the causes of the French Revolution?"},
14]
15
16text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
17inputs = tokenizer([text], return_tensors="pt").to(model.device)
18
19output = model.generate(**inputs, max_new_tokens=512, temperature=0.7, do_sample=True)
20reply = tokenizer.decode(output[0][len(inputs.input_ids[0]):], skip_special_tokens=True)
21print(reply)
22
23# Continue the conversation
24messages.append({"role": "assistant", "content": reply})
25messages.append({"role": "user", "content": "Which of those causes was the most significant?"})
26
27text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
28inputs = tokenizer([text], return_tensors="pt").to(model.device)
29
30output = model.generate(**inputs, max_new_tokens=512, temperature=0.7, do_sample=True)
31print(tokenizer.decode(output[0][len(inputs.input_ids[0]):], skip_special_tokens=True))<|system|>{system_message}<|end|><|user|>{user_message}<|end|><|assistant|>{assistant_message}<|end|>tokenizer.apply_chat_template().| Component | Details |
|---|---|
| Parameters | 13B |
| Layers | 40 |
| Attention heads | 40 (MHA, no GQA) |
| Hidden size | 5120 |
| Head dimension | 128 |
| Intermediate size (MLP) | 13696 |
| Position encoding | RoPE (θ = 1,000,000) |
| Activation | SwiGLU |
| Normalization | RMSNorm (pre-norm) |
| Context length | 2048 |
| Vocabulary | 65,540 (65,535 BPE + 5 special tokens) |
| Precision | bfloat16 |
.pt state dict was remapped to a PreTrainedModel subclass (TalkieForCausalLM) and saved as safetensorsPreTrainedTokenizerFast with the HuggingFace TikTokenConverter, including all 5 special tokens (<|endoftext|>, <|end|>, <|user|>, <|assistant|>, <|system|>)trust_remote_code=True.