Run this model with HF Jobs

Run jyh8876/vinylo-e2b-lyrics 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/jyh8876/vinylo-e2b-lyrics. 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/jyh8876/vinylo-e2b-lyrics 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/jyh8876/vinylo-e2b-lyrics. 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/jyh8876/vinylo-e2b-lyrics. 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.
vinylo-e2b-lyrics / example.py
jyh8876's picture
Add 2-bit Q2_K QAT GGUF (0.98 GB), model card, example client
22fb5ca verified
Raw History Blame Contribute Delete
3.26 kB
"""Minimal client for vinylo-e2b-lyrics GGUF via llama-server (same prompt and chunking as the Vinylo app).
llama-server -m vinylo-e2b-lyrics-Q2_K-qat.gguf -c 4096 -ngl 99 --port 8080
python example.py --target ko lyrics.txt # one lyric line per text line
echo "ๆ™‚่จˆใฎ้‡ใŒใ€€่ƒธใ‚’็ชใ" | python example.py --target en -
Prints one JSON object per line: {"i": index, "src": original, "t": translation, "r": reading} ("copy": true when the
line is already in the target language). Standard library only."""
import argparse, json, sys, urllib.request
LANGS = {"ko": "Korean", "en": "English", "zh": "Simplified Chinese", "ja": "Japanese"}
READING = {"ko": "Hangul (Korean ๋…์Œ, e.g. ๅ›ใฎๅใฏ โ†’ ํ‚ค๋ฏธ๋…ธ ๋‚˜์™€)", "ja": "Katakana",
"zh": "Pinyin with tone marks for Chinese lines, otherwise Latin letters"}
def system_prompt(code):
name = LANGS[code]
return f'''You translate song lyrics for language learners.
Translate each numbered line into natural, idiomatic {name} ({code}).
Rules:
- Keep the meaning, tone and register of the song; prefer natural phrasing over literal word order.
- Use the surrounding lines as context for pronouns, tense and slang.
- Return exactly one entry per input index. Never merge or split lines.
- If a line is already in {name}, return it with "copy": true and no translation.
- For every translated line also give "r": how the ORIGINAL line sounds when sung, written in {READING.get(code, "Latin letters (romanization)")}. Transcribe the sound only; do not translate it. Leave "r" out when the original is already written in that script.
- Do not censor the original meaning.
Respond only with JSON: {{"lines":[{{"i":0,"t":"...","r":"..."}},{{"i":1,"copy":true}}]}}'''
def translate_chunk(url, target, lines, start):
user = "\n".join(f"{start + k}\t{t}" for k, t in enumerate(lines))
prompt = f"<|turn>system\n{system_prompt(target)}<turn|>\n<|turn>user\n{user}<turn|>\n<|turn>model\n" # server adds <bos>
body = {"prompt": prompt, "temperature": 0, "top_k": 1, "n_predict": 1024, "stop": ["<turn|>"]}
req = urllib.request.Request(url + "/completion", json.dumps(body).encode(), {"content-type": "application/json"})
text = json.load(urllib.request.urlopen(req, timeout=600))["content"]
return {e["i"]: e for e in json.loads(text[text.find("{"):text.rfind("}") + 1])["lines"]}
def main():
ap = argparse.ArgumentParser()
ap.add_argument("file", help="lyrics file, one line per lyric line ('-' = stdin)")
ap.add_argument("--target", required=True, choices=LANGS)
ap.add_argument("--url", default="http://127.0.0.1:8080")
ap.add_argument("--chunk", type=int, default=8, help="lines per request (the model was trained on 8)")
a = ap.parse_args()
src = [l.rstrip("\n") for l in (sys.stdin if a.file == "-" else open(a.file, encoding="utf-8")) if l.strip()]
for s in range(0, len(src), a.chunk):
got = translate_chunk(a.url, a.target, src[s:s + a.chunk], s)
for i in range(s, min(s + a.chunk, len(src))):
e = got.get(i, {})
print(json.dumps({"i": i, "src": src[i], **{k: v for k, v in e.items() if k != "i"}}, ensure_ascii=False))
if __name__ == "__main__":
main()