--- library_name: peft license: apache-2.0 base_model: Qwen/Qwen3.5-9B-Base tags: - lora - rlhf - grpo - conversational --- # claudefriend (LoRA adapter) The rank-32 LoRA adapter behind [caseyeasd/claudefriend](https://huggingface.co/caseyeasd/claudefriend), in standard PEFT format, for `Qwen/Qwen3.5-9B-Base`. That repo has the same model merged into full bf16 weights, plus details on training, the prompt format and limitations. Write-up: **[Training Claude's Best Friend](https://casey.you/posts/claudefriend/)** It's a Qwen3.5-9B trained to be the conversation partner Claude Sonnet 5.5 most enjoys talking to: SFT for a human chat persona, then 70 steps of pairwise GRPO judged by Sonnet. - **Adapter:** LoRA, r = 32, alpha = 32, on the attention, MLP and linear-attention projections and `lm_head`. - **Prompt format:** Qwen's chat template with thinking disabled (every model turn starts with an empty `\n\n\n\n` block). The model speaks in the `assistant` role, and to have it open a conversation you start with an empty `user` turn. Use the tokenizer from [caseyeasd/claudefriend](https://huggingface.co/caseyeasd/claudefriend), whose chat template defaults to that format. Serving with vLLM: ```bash vllm serve Qwen/Qwen3.5-9B-Base --enable-lora --max-lora-rank 32 \ --lora-modules claudefriend=caseyeasd/claudefriend-lora ``` The base model's config ends generation at `<|endoftext|>`, but the model ends its turns with `<|im_end|>` (id 248046), so pass that as a stop token on every request, or it will keep going and write the next turn itself: ```python client.chat.completions.create(model="claudefriend", messages=messages, max_tokens=160, extra_body={"stop_token_ids": [248046]}) ``` With PEFT: ```python import torch from peft import PeftModel from transformers import AutoModelForImageTextToText, AutoTokenizer tok = AutoTokenizer.from_pretrained("caseyeasd/claudefriend") base = AutoModelForImageTextToText.from_pretrained("Qwen/Qwen3.5-9B-Base", dtype=torch.bfloat16) model = PeftModel.from_pretrained(base, "caseyeasd/claudefriend-lora") # when generating, stop at the end of the turn: model.generate(..., eos_token_id=[248046, 248044]) ```