Downloads · 30 days
22
59% of all-time downloads
coconut19/llama-dialog-lora
llama-dialog-lora is a text generation model from coconut19. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as llama3.2.
A LoRA adapter for meta-llama/Llama-3.2-1B-Instruct that generates short two-speaker conversations ("podcast scripts") from a one-line topic instruction.
Downloads · 30 days
22
59% of all-time downloads
All-time downloads
37
Public
Repo size
58.3 MB
Likes
0
Public
Click a slice to open those files.
.pt27.4 MB · 38%
From the Hugging Face model README
A LoRA adapter for meta-llama/Llama-3.2-1B-Instruct that generates short two-speaker conversations ("podcast scripts") from a one-line topic instruction.
The base model tends to answer a podcast request with headings, segment titles, narration, or extra speakers, which a text-to-speech pipeline can't read directly. This adapter teaches the model to output a plain alternating A: / B: dialogue. Each line can then go straight to a TTS voice.
It was built as the local generation model for Podcast+, a project that turns documents and questions into two-host audio episodes.
meta-llama/Llama-3.2-1B-InstructThe adapter was trained on a plain-text prompt, not the Llama chat template. Use the same format at inference:
Instruction: <your instruction>
Answer:
import torch
from peft import PeftConfig, PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
ADAPTER = "coconut19/llama-dialog-lora"
config = PeftConfig.from_pretrained(ADAPTER)
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
base_model = AutoModelForCausalLM.from_pretrained(
config.base_model_name_or_path,
torch_dtype=torch.bfloat16,
device_map="auto",
)
model = PeftModel.from_pretrained(base_model, ADAPTER)
model.eval()
def generate_dialog(instruction, max_new_tokens=512):
prompt = f"Instruction: {instruction}\nAnswer:\n"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=max_new_tokens,
do_sample=True,
temperature=0.8,
top_p=0.9,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.eos_token_id,
)
text = tokenizer.decode(outputs[0], skip_special_tokens=True)
return text[len(prompt):].strip()
print(generate_dialog(
"Generate a podcast content between two people discussing their favorite class of computer science."
))
Example output:
A: I know what you're thinking, but I really want to go back to school for computer science.
B: You're right. I don't think I'm good at it. I've been out of school for a long time. But I know that I can learn it.
A: You're not going to get it if you don't try. You have to learn something new, no matter how hard you try.
B: I know, but I've been out of school for so long, I don't know where to start.
A: Don't worry. Start with something simple. It's like playing a new sport. You just have to start with the basics and work your way up.
...
To ground the conversation in specific material, put the context before the instruction:
prompt = f"""
Use the information provided in the relevant context to generate the answer.
### Relevant Context:
{retrieved_context}
### Instruction:Instruction: {instruction}
### Answer:
"""
A: / B: line is sent to a different voice. In Podcast+ these lines were voiced with Kokoro-82M.max_new_tokens, so the last line may be cut off mid-sentence. Trim incomplete lines before sending text to TTS.The first 3,000 dialogues from the DailyDialog training split (the dialog column of train.csv), a corpus of human-written, everyday English conversations.
Preprocessing:
sentence-transformers/all-mpnet-base-v2 and given the label of the closest topic (by cosine similarity) out of sports, food, school, health and social.A: / B: speakers.{"instruction": "Generate a podcast content between two people discussing <topic>.", "input": "", "output": "A: ...\nB: ...\n..."}
Each example was formatted as Instruction: {instruction}\nAnswer:\n{output}, tokenized to a fixed length of 512 tokens, and trained with a causal LM objective. Prompt tokens were masked from the loss (labels set to -100), so the model learns only the dialogue.
| Parameter | Value |
|---|---|
Rank (r) | 16 |
lora_alpha | 32 |
lora_dropout | 0.05 |
| Bias | none |
| Target modules | q_proj, k_proj, v_proj, o_proj |
| Trainable parameters | 3,407,872 (about 0.28% of 1.24B) |
| Parameter | Value |
|---|---|
| Training regime | bf16 mixed precision |
| Epochs | 1 |
| Per-device batch size | 2 |
| Gradient accumulation steps | 8 (effective batch size 16) |
| Total steps | 188 |
| Learning rate | 2e-4 |
| Warmup steps | 100 |
| Optimizer | AdamW (adamw_torch) |
| Gradient checkpointing | enabled |
| Max sequence length | 512 |
| Step | Epoch | Loss |
|---|---|---|
| 50 | 0.27 | 2.801 |
| 100 | 0.53 | 0.560 |
| 150 | 0.80 | 0.541 |
Generate a podcast content between two people discussing <topic>, with topics such as Technology. Both models generated at most 100 new tokens with sampling.Both metrics use sentence-transformers/all-mpnet-base-v2 embeddings.
"Please summarize the following conversation.") and the full output. It roughly measures how much an output reads like a conversation. It does not measure relevance to the requested topic.| Setting | Prompts | Semantic consistency | Prompt-output alignment |
|---|---|---|---|
| Base model (Llama-3.2-1B-Instruct) | 50 | 0.417 | 0.301 |
| LoRA (this adapter) | 50 | 0.581 | 0.386 |
| LoRA, technical topics, no context | 10 | 0.630 | 0.268 |
| LoRA + RAG, technical topics | 10 | 0.539 | 0.250 |
Compared to the base model, the adapter produces noticeably more coherent turn-by-turn dialogue and keeps to the A: / B: format that TTS needs. On technical topics, adding retrieved context makes the content more on-topic (the conversation actually discusses the requested concept), but these embedding metrics score it slightly lower. That's because the injected facts make consecutive turns less uniform. The 10-prompt RAG comparison is small, so treat it as indicative only.
Low-rank adapters on the attention projections of Llama-3.2-1B-Instruct (16 layers, hidden size 2048). The objective is causal language modeling with the prompt tokens masked out.
Trained in Google Colab on a single GPU with bf16. One epoch takes 188 optimizer steps (total FLOs about 9.0e15).
Open an issue at https://github.com/Allenwang2004/Podcast-