Run this model with HF Jobs

Run exillarml/Mistral7b_11Labs_DoctorDS_Testing 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/exillarml/Mistral7b_11Labs_DoctorDS_Testing. 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/exillarml/Mistral7b_11Labs_DoctorDS_Testing 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.
exillar25's picture
Update handler.py
e09cabc verified
Raw History Blame Contribute Delete
930 Bytes
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, pipeline
import torch
from peft import PeftModel
REPOSITORY_ID = "exillarml/Mistral7b_11Labs_DoctorDS_Testing"
# Load the base model with quantization
model = AutoModelForCausalLM.from_pretrained(
"unsloth/mistral-7b-bnb-4bit",
load_in_4bit=True,
trust_remote_code=True,
device_map="auto"
)
# Load the tokenizer and set the pad token
tokenizer = AutoTokenizer.from_pretrained(REPOSITORY_ID) # Your repo ID.
tokenizer.pad_token = tokenizer.eos_token
# Load the LoRA adapter
model = PeftModel.from_pretrained(model, REPOSITORY_ID) # Your repo ID
# Create the text generation pipeline
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
def handler(inputs):
prompt = inputs.get("prompt", "")
generated_text = pipe(prompt, max_length=100)[0]["generated_text"]
return {"generated_text": generated_text}