Run this model with HF Jobs

Run peterjandre/codet5-vbnet-csharp 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/peterjandre/codet5-vbnet-csharp. 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/peterjandre/codet5-vbnet-csharp 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.
codet5-vbnet-csharp / handler.py
peterjandre's picture
Create handler.py
adf4873 verified
Raw History Blame Contribute Delete
672 Bytes
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, pipeline
# Global variables to cache model and tokenizer
model = None
tokenizer = None
nlp = None
def init():
global model, tokenizer, nlp
model_name_or_path = "."
model = AutoModelForSeq2SeqLM.from_pretrained(model_name_or_path)
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
nlp = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
def inference(payload):
inputs = payload.get("inputs", "")
if not inputs:
return {"error": "No inputs provided"}
# Run generation pipeline
outputs = nlp(inputs, max_length=256)
return outputs