Run this model with HF Jobs

Run aidando73/llama-3.3-70b-instruct-code-agent-fine-tune-v1 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/aidando73/llama-3.3-70b-instruct-code-agent-fine-tune-v1. 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/aidando73/llama-3.3-70b-instruct-code-agent-fine-tune-v1 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.
aidando73's picture
.
f028aae
Raw History Blame Contribute Delete
1.2 kB
from typing import Dict, List, Any
from unsloth import FastLanguageModel
class EndpointHandler():
def __init__(self, path=""):
# Preload all the elements you are going to need at inference.
# pseudo:
# self.model= load_model(path)
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "aidando73/llama-3.3-70b-instruct-code-agent-fine-tune-v1",
max_seq_length = 2048,
dtype = "float16",
load_in_4bit = True,
)
FastLanguageModel.for_inference(model)
self.model = model
self.tokenizer = tokenizer
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
"""
data args:
inputs (:obj: `str` | `PIL.Image` | `np.array`)
kwargs
Return:
A :obj:`list` | `dict`: will be serialized and returned
"""
input_ids = self.tokenizer.encode(data["inputs"], return_tensors = "pt").to("cuda")
output = self.model.generate(input_ids, max_new_tokens = 128, pad_token_id = self.tokenizer.eos_token_id)
return [{"output": self.tokenizer.decode(output[0], skip_special_tokens = True)}]