Views
No views yet
idealab-cs2/reddit_task_predict_next_k5 (predict next post from k=5 most recent posts)1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B", device_map="auto")
5model = PeftModel.from_pretrained(base, "idealab-cs2/qwen2.5-0.5b-reddit-next-post-lora")
6tokenizer = AutoTokenizer.from_pretrained("idealab-cs2/qwen2.5-0.5b-reddit-next-post-lora")You are an expert assistant that predicts Reddit posts. Your task is to generate the content for the single next post based on a user's history. The response must contain only the title and text of the predicted post, adhering strictly to the format. Do not add any conversational text, explanations, or extra posts.
Given the following posts:
REDDIT POST TITLE 1: {title of post 1}
REDDIT POST TEXT 1: {text of post 1}
REDDIT POST TITLE 2: {title of post 2}
REDDIT POST TEXT 2: {text of post 2}
Predict the title and text for the single next post. Your response must begin directly with the cue below and contain nothing else.
REDDIT POST TITLE 3:REDDIT POST TEXT 3: ... with the post body. Renumber the cues according to how many context posts you provide (the next post is always N+1). Prioritize the most recent posts if you need to truncate for context length.1prompt = """You are an expert assistant that predicts Reddit posts. Your task is to generate the content for the single next post based on a user's history. The response must contain only the title and text of the predicted post, adhering strictly to the format. Do not add any conversational text, explanations, or extra posts.
2
3Given the following posts:
4
5REDDIT POST TITLE 1: My cat learned to open the fridge
6REDDIT POST TEXT 1: She's 4kg of pure menace. Caught her at 3am eating the cheese.
7
8REDDIT POST TITLE 2: Update: fridge cat has been thwarted
9REDDIT POST TEXT 2: Child lock installed. She now screams at the fridge instead.
10
11Predict the title and text for the single next post. Your response must begin directly with the cue below and contain nothing else.
12
13REDDIT POST TITLE 3: """
14
15inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
16outputs = model.generate(
17 **inputs,
18 max_new_tokens=256,
19 do_sample=True,
20 temperature=0.7,
21 top_p=0.9,
22)
23print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))| Metric | Value |
|---|---|
| Adjusted semantic similarity (best of grid) | -0.098 |
| Raw semantic similarity | 0.782 |
| Parse failure rate | 4.8% |
| Eval loss | 1.964 |
| Eval token accuracy | 0.628 |
1@misc{lazzaroni2025redditnextpost,
2 author = {Lazzaroni, Ruggero Marino},
3 title = {Qwen2.5-0.5B Reddit Next-Post LoRA},
4 year = {2025},
5 publisher = {Hugging Face},
6 howpublished = {\url{https://huggingface.co/idealab-cs2/qwen2.5-0.5b-reddit-next-post-lora}}
7}