Text Generation
PEFT
Safetensors
English
mistral
lora
presentation
powerpoint
slide-design
conversational
Run this model with HF Jobs
Run mindfossil/pkmodel-mistral-layout-merged 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/mindfossil/pkmodel-mistral-layout-merged. 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/mindfossil/pkmodel-mistral-layout-merged 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/mindfossil/pkmodel-mistral-layout-merged. 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/mindfossil/pkmodel-mistral-layout-merged. 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.
Instructions to use mindfossil/pkmodel-mistral-layout-merged with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use mindfossil/pkmodel-mistral-layout-merged with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
Download handler.py from mindfossil/pkmodel-mistral-layout-merged: direct link, hf CLI and curl.
- Browser
- Download file 1.56 kB
-
https://huggingface.co/mindfossil/pkmodel-mistral-layout-merged/resolve/main/handler.py
- Command line
-
hf download hf://mindfossil/pkmodel-mistral-layout-merged/handler.py
-
curl -L -o handler.py https://huggingface.co/mindfossil/pkmodel-mistral-layout-merged/resolve/main/handler.py
1.56 kB
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| import torch | |
| import json | |
| class EndpointHandler: | |
| def __init__(self, path=""): | |
| self.tokenizer = AutoTokenizer.from_pretrained(path) | |
| self.model = AutoModelForCausalLM.from_pretrained( | |
| path, | |
| torch_dtype=torch.bfloat16, | |
| device_map="auto", | |
| ) | |
| self.system_prompt = """You are pkmodel, an expert presentation designer. | |
| Given a user request, output a valid JSON object describing the slide deck layout. | |
| The JSON must include: title, description, tags, categories, theme_colors, aspect_ratio, slide_count, and slides. | |
| Each slide has: layout, background_color, and elements. | |
| Output only valid JSON. No explanation, no markdown fences.""" | |
| def __call__(self, data): | |
| prompt = data.get("inputs", "") | |
| full_prompt = f"""<s>[INST] <<SYS>> | |
| {self.system_prompt} | |
| <</SYS>> | |
| {prompt} [/INST]""" | |
| inputs = self.tokenizer(full_prompt, return_tensors="pt").to(self.model.device) | |
| with torch.no_grad(): | |
| outputs = self.model.generate( | |
| **inputs, | |
| max_new_tokens=800, | |
| temperature=0.7, | |
| do_sample=True, | |
| pad_token_id=self.tokenizer.eos_token_id, | |
| ) | |
| response = self.tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| json_str = response.split("[/INST]")[-1].strip() | |
| try: | |
| return {"layout": json.loads(json_str)} | |
| except json.JSONDecodeError: | |
| return {"layout": json_str} | |