All tasks are now complete; the repository history contains several model generations and ablation experiments.
(The full training scripts and notebooks will be published right after grading is finished.)
1import torch
2
3REPO_NAME = "amocualg/llm-course-hw1"
4device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
5
6tokenizer = ByteLevelBPETokenizer.from_pretrained(REPO_NAME)
7check_model = TransformerForCausalLM.from_pretrained(REPO_NAME)
8check_model = check_model.to(device)
9check_model = check_model.eval()
10
11text = "Штирлиц пришел домой" # change if needed
12input_ids = torch.tensor(tokenizer.encode(text), device=device)
13model_output = check_model.generate(
14 input_ids[None, :], max_new_tokens=200, eos_token_id=tokenizer.eos_token_id, do_sample=True, top_k=10
15)
16print(tokenizer.decode(model_output[0].tolist()))
17
ByteLevelBPETokenizer and TransformerForCausalLM will be available along with the source code
This model has been pushed to the Hub using the
PytorchModelHubMixin