Views
No views yet
modeling_simple_lm.py (bundled in this repo) and loaded via
trust_remote_code=True.models/sft_full_science.pt/home/etan/simple_llm/checkpoints/lm_checkpoint_008_shutdown.pt/home/etan/simple_llm/datasets/MegaScience/datasubject_filter: Nonesubject_exclude: ['math']question_regex_filter: None1 at learning_rate 3e-05chat_template.jinja reproduces this format, so you can use
tokenizer.apply_chat_template(...) directly and get byte-identical strings
to what the model saw during training:Question: What is photosynthesis?
Answer: <answer></s>1tokenizer.apply_chat_template(
2 [{"role": "user", "content": "What is photosynthesis?"}],
3 add_generation_prompt=True, tokenize=False,
4)
5# -> 'Question: What is photosynthesis?\nAnswer: '1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4repo = "etanlightstone/simple-lm-sft-science"
5tok = AutoTokenizer.from_pretrained(repo)
6model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True).eval()
7
8messages = [{"role": "user", "content": "What is photosynthesis?"}]
9inputs = tok.apply_chat_template(
10 messages,
11 add_generation_prompt=True,
12 return_tensors="pt",
13 return_dict=True,
14)
15prompt_len = inputs["input_ids"].shape[1]
16with torch.no_grad():
17 out = model.generate(
18 **inputs,
19 max_new_tokens=256,
20 do_sample=True,
21 temperature=0.4,
22 top_p=0.9,
23 repetition_penalty=1.1,
24 )
25answer = tok.decode(out[0, prompt_len:], skip_special_tokens=True)
26print(answer)| field | value |
|---|---|
| vocab_size | 32000 |
| context_length | 512 |
| d_model | 768 |
| n_layers | 12 |
| n_heads | 8 |
| d_ff | 2048 |
| activation | gelu |
| bias | True |
| tie_word_embeddings | True |
TinyLlama/TinyLlama-1.1B-Chat-v1.01{
2 "mode": "sft",
3 "source_pretrain_checkpoint": "/home/etan/simple_llm/checkpoints/lm_checkpoint_008_shutdown.pt",
4 "source_pretrain_train_settings": {
5 "batch_size": 10,
6 "batch_size_note": "per GPU when using torchrun",
7 "world_size": 1,
8 "learning_rate": 0.0003,
9 "weight_decay": 0.01,
10 "num_epochs": 3,
11 "max_steps": null,
12 "grad_clip": 1.0,
13 "seed": 42,
14 "docs_dir": "/home/etan/simple_llm/docs",
15 "block_size": 512,
16 "stride": 448,
17 "stride_overlap_tokens": 64
18 },
19 "data_dir": "/home/etan/simple_llm/datasets/MegaScience/data",
20 "data_glob": "*.parquet",
21 "subject_filter": null,
22 "subject_exclude": [
23 "math"
24 ],
25 "question_regex_filter": null,
26 "batch_size": 10,
27 "world_size": 1,
28 "learning_rate": 3e-05,
29 "min_lr": 3e-06,
30 "warmup_steps": 200,
31 "weight_decay": 0.0,
32 "num_epochs": 1,
33 "max_steps": null,
34 "grad_clip": 1.0,
35 "seed": 42,
36 "block_size": 512,
37 "eval_fraction": 0.005,
38 "eval_every": 500,
39 "max_train_examples": null,
40 "freezing": {
41 "freeze_embeddings": false,
42 "freeze_lm_head": false,
43 "freeze_blocks_below": 0,
44 "tie_word_embeddings": true,
45 "trainable_params": 91138560,
46 "total_params": 91138560,
47 "frozen_params": 0,
48 "frozen_blocks": 0,
49 "total_blocks": 12
50 },
51 "prompt_template": "Question: {question}\nAnswer: ",
52 "completion_suffix": "</s>"
53}