Downloads · 30 days
9
12% of all-time downloads
Craftic/llm-course-hw1-nano
llm-course-hw1-nano is a text generation model from Craftic. Use it when you need the model to write or continue text. It is set up for pytorch.
Educational causal language model trained as part of a Deep Learning homework assignment on a Russian jokes corpus.
Downloads · 30 days
9
12% of all-time downloads
All-time downloads
78
Public
Parameters
551K
4.1 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors2.1 MB · 96%
How the weights are stored.
F32501K · 91%
From the Hugging Face model README
Educational causal language model trained as part of a Deep Learning homework assignment on a Russian jokes corpus.
This repository contains:
vocabulary.json, merges.json)model.safetensorsconfig.jsonn_head=4, n_kv_head=2)nanoThese weights were uploaded from a custom homework implementation, so loading requires the same Python classes that were used during training.
import torch
# Define ByteLevelBPETokenizer and TransformerForCausalLM exactly as in the homework notebook.
# Then load artifacts from the Hub:
tokenizer = ByteLevelBPETokenizer.from_pretrained("Craftic/llm-course-hw1-nano")
model = TransformerForCausalLM.from_pretrained("Craftic/llm-course-hw1-nano")
model.eval()
prompt = "Муж приходит домой и говорит:"
input_ids = torch.tensor([tokenizer.encode(prompt)], dtype=torch.long)
attention_mask = torch.ones_like(input_ids)
with torch.no_grad():
logits = model(input_ids, attention_mask)
next_token_id = logits[0, -1].argmax().item()
print(tokenizer.decode(tokenizer.encode(prompt, add_eos_token=False) + [next_token_id]))