Views
No views yet
| 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 |
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model = AutoModelForCausalLM.from_pretrained(
5 "csankalp21/headlinegpt",
6 torch_dtype=torch.float16,
7 device_map="auto"
8)
9
10tokenizer = AutoTokenizer.from_pretrained(
11 "csankalp21/headlinegpt"
12)
13
14messages = [
15 {
16 "role": "system",
17 "content": "You are an expert at writing highly engaging titles."
18 },
19 {
20 "role": "user",
21 "content": (
22 "Generate a high-engagement title for the following content:\n\n"
23 "<your content here>"
24 )
25 }
26]
27
28text = tokenizer.apply_chat_template(
29 messages,
30 tokenize=False,
31 add_generation_prompt=True
32)
33
34inputs = tokenizer(
35 text,
36 return_tensors="pt"
37).to(model.device)
38
39with torch.no_grad():
40 output = model.generate(
41 **inputs,
42 max_new_tokens=40,
43 temperature=0.7,
44 do_sample=True,
45 top_p=0.9,
46 repetition_penalty=1.1
47 )
48
49generated_tokens = output[0][inputs["input_ids"].shape[1]:]
50
51print(
52 tokenizer.decode(
53 generated_tokens,
54 skip_special_tokens=True
55 )
56)