daichira's picture
Revert "Upload folder using huggingface_hub"
c63c1cb
metadata
library_name: peft
tags:
  - lora
  - qlora
  - japanese
  - haiku
  - poetry
base_model: Qwen/Qwen3-4B-Instruct-2507
license: other

Haiku LoRA Adapter (Qwen3-4B-Instruct, 5-7-5 with Kigo)

This repository contains LoRA adapter weights fine-tuned with Unsloth/TRL to compose Japanese haiku that follow the 5-7-5 pattern and include a given kigo (seasonal word).

Usage

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

base_model = "Qwen/Qwen3-4B-Instruct-2507"
adapter_id = "daichira/haiku-qwen3-4b-lora-unsloth"

tok = AutoTokenizer.from_pretrained(base_model, trust_remote_code=True, use_fast=True)
base = AutoModelForCausalLM.from_pretrained(base_model, device_map="auto", trust_remote_code=True)
model = PeftModel.from_pretrained(base, adapter_id)

messages = [
    {"role":"system","content":"あなたは一流の俳人です。5-7-5を厳守し、必ず季語を含め、俳句一首のみを出力してください。"},
    {"role":"user","content":"季語: 桜\n季節: 春\n一首だけ。"},
]
prompt = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=64, do_sample=True, top_p=0.9, temperature=0.7)
print(tok.decode(out[0], skip_special_tokens=True))

Note: This repo only ships LoRA adapters, not the full base model.