Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3repo = "farrelmahaztra/Dongeng-30M"
4model = AutoModelForCausalLM.from_pretrained(repo).eval()
5tok = AutoTokenizer.from_pretrained(repo)
6
7prompt = "Suatu hari, seekor kucing kecil"
8# add_special_tokens=False so the tokenizer doesn't append [EOS] and end the story early.
9inputs = tok(prompt, return_tensors="pt", add_special_tokens=False)
10out = model.generate(
11 inputs.input_ids, max_new_tokens=400, do_sample=True,
12 temperature=0.7, eos_token_id=tok.eos_token_id,
13)
14
15# Decode and undo the morphological segmentation ("me + baca" -> "membaca").
16print(tok.decode(out[0], skip_special_tokens=True).replace(" + ", ""))[EOS] (the start-of-story token)
instead of a prompt: model.generate(torch.tensor([[tok.eos_token_id]]), ...).Note on prompts. The training corpus is morphologically segmented (e.g.membaca->me + baca), so an affixed word likeseekor(se + ekorin training) tokenizes slightly off-distribution when passed raw. You may want to run the prompt through thedongengpackage'ssegment()first, although the generation should remain coherent either way and unconditional generation is unaffected.
| Model Name | n_params | n_layers | d_model | n_heads | n_ctx | d_vocab |
|---|---|---|---|---|---|---|
| Dongeng-35M | 35 million | 12 | 512 | 8 | 512 | 4096 |
| Dongeng-30M | 30 million | 10 | 512 | 8 | 512 | 4096 |
| Dongeng-11M | 11 million | 6 | 384 | 6 | 512 | 4096 |
| Dongeng-5M | 5 million | 6 | 256 | 4 | 512 | 4096 |
| Dongeng-1.25M | 1.25 million | 4 | 128 | 4 | 512 | 4096 |