Text Generation
MLX
Safetensors
PyTorch
English
from-scratch
tiny
chat

Run this model with HF Jobs

Run Jainam59/MangoShake-50M on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/Jainam59/MangoShake-50M. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/Jainam59/MangoShake-50M on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/Jainam59/MangoShake-50M. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/Jainam59/MangoShake-50M. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
MangoShake-50M / generate.py
Jainam59's picture
Upload 10 files
0f35d55 verified
Raw History Blame Contribute Delete
1.08 kB
"""Continue a prompt with the base (pretrained, not chat) model.
pip install torch safetensors
python generate.py "Once upon a time" --tokens 200
"""
import argparse
import os
import torch
from model import load, sample
from tokenizer import BPETokenizer
HERE = os.path.dirname(os.path.abspath(__file__))
if __name__ == "__main__":
p = argparse.ArgumentParser()
p.add_argument("prompt", nargs="?", default="Once upon a time")
p.add_argument("--tokens", type=int, default=200)
p.add_argument("--temp", type=float, default=0.8)
p.add_argument("--top_k", type=int, default=40)
p.add_argument("--device", default="cpu")
p.add_argument("--weights", default="base.safetensors", help="base.safetensors or model.safetensors (chat)")
a = p.parse_args()
torch.set_num_threads(max(1, os.cpu_count() // 2))
model = load(HERE, a.device, a.weights)
tok = BPETokenizer.load(os.path.join(HERE, "tokenizer.json"))
out = sample(model, tok.encode(a.prompt), a.tokens, tok.eot_id, a.temp, a.top_k)
print(a.prompt + tok.decode(out))