File size: 2,591 Bytes
f5bfb39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
license: apache-2.0
base_model: Qwen/Qwen2.5-1.5B-Instruct
tags:
  - text-generation
  - title-generation
  - headline-generation
  - lora
  - qwen2
  - fine-tuned
language:
  - en
pipeline_tag: text-generation
---

# HeadlineGPT

**HeadlineGPT** is a fine-tuned version of
[Qwen/Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct)
specialized for generating concise, engaging titles from source content.

It is designed for:

- News and article headlines
- Research and academic content
- Talks and presentations
- Social media posts
- Other short-form content that needs an attention-grabbing title

## Model Details

| Property | Value |
|---|---|
| Base model | Qwen2.5-1.5B-Instruct |
| Fine-tuning | LoRA / PEFT |
| LoRA rank | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.05 |
| Language | English |
| Training objective | Reward-weighted supervised fine-tuning |

### Training

The model was trained on content–title pairs.

Instead of treating every training example equally, examples were weighted according to their associated engagement score. Higher-scoring examples therefore contribute more strongly to the training loss.

This approach is intended to encourage title characteristics associated with higher engagement while retaining the broader writing patterns present in the training data.

The model was trained for **2 epochs on a randomly sampled 25,000-example subset** of the larger dataset.

## Usage

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

model = AutoModelForCausalLM.from_pretrained(
    "csankalp21/headlinegpt",
    torch_dtype=torch.float16,
    device_map="auto"
)

tokenizer = AutoTokenizer.from_pretrained(
    "csankalp21/headlinegpt"
)

messages = [
    {
        "role": "system",
        "content": "You are an expert at writing highly engaging titles."
    },
    {
        "role": "user",
        "content": (
            "Generate a high-engagement title for the following content:\n\n"
            "<your content here>"
        )
    }
]

text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True
)

inputs = tokenizer(
    text,
    return_tensors="pt"
).to(model.device)

with torch.no_grad():
    output = model.generate(
        **inputs,
        max_new_tokens=40,
        temperature=0.7,
        do_sample=True,
        top_p=0.9,
        repetition_penalty=1.1
    )

generated_tokens = output[0][inputs["input_ids"].shape[1]:]

print(
    tokenizer.decode(
        generated_tokens,
        skip_special_tokens=True
    )
)