Model Card for Model ID

---
language: en
license: mit
base_model: NousResearch/Llama-2-7b-chat-hf
library_name: peft
pipeline_tag: text-generation
tags:
- lora
- peft
- causal-lm
---

# Backward model p(x|y) β€” LoRA adapter

This repository contains a LoRA adapter trained to predict the original instruction (x) given an output/response (y). The model was finetuned on the `timdettmers/openassistant-guanaco` dataset. The adapter is intended to be loaded on top of the `NousResearch/Llama-2-7b-chat-hf` base model.

## Quick usage

```python
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch

base = "NousResearch/Llama-2-7b-chat-hf"
adapter_repo = "."  # local folder or hf repo id

tokenizer = AutoTokenizer.from_pretrained(base, use_fast=False)
model = AutoModelForCausalLM.from_pretrained(base, device_map="auto", trust_remote_code=True)
model = PeftModel.from_pretrained(model, adapter_repo, device_map="auto")

prompt = "### Output:\nLeaves fall and wind sings.\n\n### Instruction:\n"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=128)
print(tokenizer.decode(out[0], skip_special_tokens=True))

Model details

  • Base model: NousResearch/Llama-2-7b-chat-hf (used as accessible substitute for gated meta-llama/Llama-2-7b-chat-hf).
  • Fine-tuned task: backward model p(x|y) β€” predict instruction given output.
  • Training dataset: timdettmers/openassistant-guanaco (openassistant-guanaco).

LoRA hyperparameters (training)

  • r: 8
  • alpha: 16
  • dropout: 0.05
  • task_type: CAUSAL_LM

Files included

  • adapter_config.json β€” PEFT adapter config
  • adapter_model.safetensors β€” LoRA adapter weights
  • checkpoint-250/, checkpoint-500/ β€” intermediate adapter checkpoints and trainer state
  • training_args.bin β€” HF Trainer training args
  • README.md β€” this file

How to reproduce

Run train_backward.py in this repository. Example training command used for experiments (adjust per GPU resources):

python train_backward.py \
    --model_name NousResearch/Llama-2-7b-chat-hf \
    --load_in_4bit \
    --num_train_epochs 2 \
    --per_device_train_batch_size 1 \
    --gradient_accumulation_steps 8 \
    --max_train_samples 5000 \
    --output_dir ./backward-finetuned

License

This example uses mit as a placeholder. Replace with the appropriate license.

Contact

Please contact the author for questions about reproduction or use.

Framework versions

  • PEFT 0.18.0

Downloads last month
9
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for comradepenguin1917/backward-llama2-lora

Adapter
(464)
this model