Run this model with HF Jobs

Run Kunger/Sakura-13B-v0.11Pre-4Bit-AWQ 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/Kunger/Sakura-13B-v0.11Pre-4Bit-AWQ. 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/Kunger/Sakura-13B-v0.11Pre-4Bit-AWQ 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/Kunger/Sakura-13B-v0.11Pre-4Bit-AWQ. 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/Kunger/Sakura-13B-v0.11Pre-4Bit-AWQ. 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.
Sakura-13B-v0.11Pre-4Bit-AWQ / generation_utils.py
Kunger's picture
Upload folder using huggingface_hub
ae0200d verified
Raw History Blame Contribute Delete
1.7 kB
from typing import List
from queue import Queue
# build chat input prompt
def build_chat_input(tokenizer, messages: List[dict]):
# chat format:
# single-turn: <s>Human: Hello!\n\nAssistant: </s>
# multi-turn: <s>Human: Hello!\n\nAssistant: </s>Hi!</s>Human: How are you?\n\nAssistant: </s>I'm fine</s>
prompt = "<s>"
for msg in messages:
role = msg["role"]
message = msg["content"]
if message is None :
continue
if role == "user":
prompt += "Human: " + message + "\n\nAssistant: </s>"
if role == "assistant":
prompt += message + "</s>"
input_tokens = tokenizer.encode(prompt)
return input_tokens
class TextIterStreamer:
def __init__(self, tokenizer, skip_prompt=False, skip_special_tokens=False):
self.tokenizer = tokenizer
self.skip_prompt = skip_prompt
self.skip_special_tokens = skip_special_tokens
self.tokens = []
self.text_queue = Queue()
self.next_tokens_are_prompt = True
def put(self, value):
if self.skip_prompt and self.next_tokens_are_prompt:
self.next_tokens_are_prompt = False
else:
if len(value.shape) > 1:
value = value[0]
self.tokens.extend(value.tolist())
self.text_queue.put(
self.tokenizer.decode(self.tokens, skip_special_tokens=self.skip_special_tokens))
def end(self):
self.text_queue.put(None)
def __iter__(self):
return self
def __next__(self):
value = self.text_queue.get()
if value is None:
raise StopIteration()
else:
return value