Run this model with HF Jobs
Run marutitecblic/HtmlTocode 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 and TRL to fine-tune https://huggingface.co/marutitecblic/HtmlTocode. 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/marutitecblic/HtmlTocode 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/marutitecblic/HtmlTocode. 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/marutitecblic/HtmlTocode. 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 marutitecblic/HtmlTocode with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use marutitecblic/HtmlTocode with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="marutitecblic/HtmlTocode", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("marutitecblic/HtmlTocode", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use marutitecblic/HtmlTocode with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "marutitecblic/HtmlTocode" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "marutitecblic/HtmlTocode", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/marutitecblic/HtmlTocode
- SGLang
How to use marutitecblic/HtmlTocode with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "marutitecblic/HtmlTocode" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "marutitecblic/HtmlTocode", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "marutitecblic/HtmlTocode" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "marutitecblic/HtmlTocode", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use marutitecblic/HtmlTocode with Docker Model Runner:
docker model run hf.co/marutitecblic/HtmlTocode
Upload handler.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778import torchfrom PIL import Imagefrom transformers import AutoModelForCausalLM, AutoProcessorfrom transformers.image_utils import to_numpy_array, PILImageResampling, ChannelDimensionfrom transformers.image_transforms import resize, to_channel_dimension_formatimport os
# ConstantsDEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# HF_TASK = os.getenv('HF_TASK')
API_TOKEN = os.getenv['API_TOKEN'] # Ensure you replace this with your actual API token
# Load processor and modelPROCESSOR = AutoProcessor.from_pretrained( "marutitecblic/HtmlTocode", trust_remote_code=True, # token=API_TOKEN,)MODEL = AutoModelForCausalLM.from_pretrained( "marutitecblic/HtmlTocode", # token=API_TOKEN, trust_remote_code=True, torch_dtype=torch.bfloat16,).to(DEVICE)image_seq_len = MODEL.config.perceiver_config.resampler_n_latentsBOS_TOKEN = PROCESSOR.tokenizer.bos_tokenBAD_WORDS_IDS = PROCESSOR.tokenizer(["<image>", "<fake_token_around_image>"], add_special_tokens=False).input_ids
def convert_to_rgb(image): if image.mode == "RGB": return image image_rgba = image.convert("RGBA") background = Image.new("RGBA", image_rgba.size, (255, 255, 255)) alpha_composite = Image.alpha_composite(background, image_rgba) alpha_composite = alpha_composite.convert("RGB") return alpha_composite
def custom_transform(x): x = convert_to_rgb(x) x = to_numpy_array(x) x = resize(x, (960, 960), resample=PILImageResampling.BILINEAR) x = PROCESSOR.image_processor.rescale(x, scale=1 / 255) x = PROCESSOR.image_processor.normalize( x, mean=PROCESSOR.image_processor.image_mean, std=PROCESSOR.image_processor.image_std ) x = to_channel_dimension_format(x, ChannelDimension.FIRST) x = torch.tensor(x) return x
def preprocess(event): image = Image.open(event["file"]).convert("RGB") inputs = PROCESSOR.tokenizer( f"{BOS_TOKEN}<fake_token_around_image>{'<image>' * image_seq_len}<fake_token_around_image>", return_tensors="pt", add_special_tokens=False, ) inputs["pixel_values"] = PROCESSOR.image_processor([image], transform=custom_transform) inputs = {k: v.to(DEVICE) for k, v in inputs.items()} return inputs
def inference(model_inputs): inputs = preprocess(model_inputs) generated_ids = MODEL.generate(**inputs, bad_words_ids=BAD_WORDS_IDS, max_length=4096) generated_text = PROCESSOR.batch_decode(generated_ids, skip_special_tokens=True)[0] return {"generated_text": generated_text}
def postprocess(model_outputs): return model_outputs
def handle(event, context): model_inputs = event model_outputs = inference(model_inputs) response = postprocess(model_outputs) return responsehandler.pyAdded+78