YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

AI Joe Rogan Experience - 完整项目文档

本项目使用 AI 技术克隆 Joe Rogan 和 Warren Buffett 的声音和说话风格,生成播客对话。


📋 项目概述

本项目包含:

  • Joe Rogan LoRA 模型:基于 Llama-3-8B 微调,学习 Joe Rogan 的说话风格
  • Warren Buffett LoRA 模型:基于 Llama-3-8B 微调,学习 Buffett 的投资哲学和表达方式
  • XTTS v2 声音克隆:使用参考音频生成两人的语音
  • 完整训练数据:200+ 期 JRE 文字稿 + Buffett 致股东信 + CNBC 采访

📁 目录结构

/workspace/
├── 📂 模型文件
│   ├── joe_rogan_lora_v2/          # Joe Rogan LoRA (500步训练)
│   │   ├── checkpoint-500/         # 最终检查点
│   │   │   ├── adapter_model.safetensors  # LoRA 权重 (161MB)
│   │   │   ├── optimizer.pt        # 优化器状态 (321MB)
│   │   │   └── ...
│   │   └── adapter_config.json     # LoRA 配置
│   │
│   └── buffett_lora/               # Buffett LoRA (500步训练)
│       ├── checkpoint-500/         # 最终检查点
│       │   ├── adapter_model.safetensors  # LoRA 权重 (161MB)
│       │   └── ...
│       └── adapter_config.json
│
├── 📂 训练数据
│   ├── jre_conversational.jsonl    # 40,291 条 JRE 对话数据 (57MB)
│   ├── jre_finetune.jsonl          # 40,291 条 JRE 原始数据 (55MB)
│   ├── buffett_finetune.jsonl      # 3,574 条 Buffett 数据 (5MB)
│   └── buffett_cnbc_interview.jsonl # 84 条 CNBC 采访数据 (78KB)
│
├── 📂 播客音频
│   ├── jre_podcast_1hr.mp3         # 30 分钟播客 Demo (15MB) ← 推荐使用
│   ├── jre_podcast_v2.mp3          # 5 分钟播客 Demo (2.3MB)
│   ├── jre_podcast_10min.mp3       # 旧版 Demo (2.1MB)
│   └── jre_podcast_demo.mp3        # 最早版 Demo (801KB)
│
├── 📂 训练脚本
│   ├── train_lora.py               # Joe Rogan 训练脚本 (500步)
│   ├── train_buffett.py            # Buffett 训练脚本 (500步)
│   ├── generate_podcast_v2.py      # 5分钟播客生成脚本
│   ├── generate_1hr_podcast.py     # 1小时播客生成脚本 (153段对话)
│   └── generate_remaining.py       # 剩余片段生成脚本
│
├── 📂 参考音频
│   ├── JoeRoganAISample.mp3        # Joe Rogan 参考音频 (3.3MB) ← 推荐使用
│   └── buffett_ref_v2.wav          # Buffett 参考音频 (8.3MB) ← 推荐使用
│
└── 📂 缓存(可删除)
    ├── cache/                      # HuggingFace 和 TTS 模型缓存
    ├── podcast_1hr/                # 153 个中间 wav 文件
    └── podcast_v2/                 # 24 个中间 wav 文件

🛠️ 运行环境(已配置)

⚠️ 新机器开机后,运行以下脚本即可恢复完整环境:

bash /workspace/setup_env.sh

实际环境信息

组件 版本/信息
Python 3.10.13
PyTorch 2.1.0+cu118
CUDA 11.8 (驱动支持)
GPU NVIDIA GeForce RTX 3090 (24GB)
Transformers 4.44.0
PEFT 0.13.0
TTS 0.22.0
Datasets 4.8.4
Accelerate 1.1.0
BitsAndBytes 0.43.3
Triton 2.1.0
磁盘 100GB /workspace

一键环境配置脚本

如果新机器环境丢失,运行以下脚本自动安装:

bash /workspace/setup_env.sh

或手动执行:

# 1. 安装 PyTorch (CUDA 11.8)
pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118

# 2. 安装训练依赖
pip install transformers==4.44.0 peft==0.13.0 datasets accelerate==1.1.0 bitsandbytes==0.43.3

# 3. 安装 TTS
pip install TTS==0.22.0

# 4. 验证
python3 -c "import torch; print(f'CUDA: {torch.cuda.is_available()}, GPU: {torch.cuda.get_device_name(0)}')"
python3 -c "from TTS.api import TTS; print('TTS OK')"

验证环境

python3 -c "import torch; print(f'CUDA: {torch.cuda.is_available()}, GPU: {torch.cuda.get_device_name(0)}')"
python3 -c "from TTS.api import TTS; print('TTS OK')"

🚀 使用方法

1. 加载模型进行文本生成

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

# 加载基础模型
model_name = "unsloth/llama-3-8b-Instruct-bnb-4bit"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
tokenizer.pad_token = tokenizer.eos_token

model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.float16,
    device_map="auto",
    trust_remote_code=True,
)

# 加载 Joe Rogan LoRA
model = PeftModel.from_pretrained(model, "/workspace/joe_rogan_lora_v2/checkpoint-500")
model.eval()

# 生成对话
prompt = """System: You are Joe Rogan hosting The Joe Rogan Experience podcast. Speak naturally, casually, and with genuine curiosity.
User: What do you think about AI?
Assistant:"""

inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=200, temperature=0.8, top_p=0.9, do_sample=True)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

2. 生成语音 (XTTS v2)

from TTS.api import TTS

# 加载模型
tts = TTS(model_name='tts_models/multilingual/multi-dataset/xtts_v2')
tts.to('cuda')

# Joe Rogan 声音
tts.tts_to_file(
    text="Welcome to the Joe Rogan Experience.",
    speaker_wav="/workspace/JoeRoganAISample.mp3",  # Joe 参考音频
    language='en',
    file_path="joe_output.wav",
)

# Buffett 声音
tts.tts_to_file(
    text="The best investment you can make is in yourself.",
    speaker_wav="/workspace/buffett_ref_v2.wav",  # Buffett 参考音频
    language='en',
    file_path="buffett_output.wav",
)

3. 生成完整播客

# 5分钟播客
python /workspace/generate_podcast_v2.py

# 30分钟播客
python /workspace/generate_1hr_podcast.py

📊 训练配置

Joe Rogan 模型

参数
基础模型 unsloth/llama-3-8B-Instruct-bnb-4bit
训练数据 40,291 条 JRE 对话
训练步数 500
学习率 2e-4 (线性衰减)
Batch Size 1 (gradient accumulation=8)
LoRA r 16
LoRA alpha 16
最终 Loss ~2.94
模型大小 161MB

Buffett 模型

参数
基础模型 unsloth/llama-3-8B-Instruct-bnb-4bit
训练数据 3,574 条致股东信 + 84 条 CNBC 采访
训练步数 500
学习率 2e-4 (线性衰减)
Batch Size 1 (gradient accumulation=8)
LoRA r 16
LoRA alpha 16
最终 Loss ~1.06
模型大小 161MB

🔄 继续微调

增加训练步数到 1000 步

# 修改 train_lora.py 或 train_buffett.py
# 将 max_steps=500 改为 max_steps=1000

# 从 checkpoint-500 恢复训练
from peft import PeftModel

model = PeftModel.from_pretrained(model, "/workspace/joe_rogan_lora_v2/checkpoint-500")
model.train()

trainer = Trainer(
    model=model,
    train_dataset=tokenized_dataset,
    args=TrainingArguments(
        ...
        max_steps=1000,  # 继续训练 500 步
        ...
    ),
)

trainer.train(resume_from_checkpoint="/workspace/joe_rogan_lora_v2/checkpoint-500")

使用新数据重新训练

  1. 准备新的 JSONL 数据文件
  2. 修改训练脚本中的数据路径
  3. 运行训练脚本
python /workspace/train_lora.py

📝 训练数据格式

JSONL 格式示例

{"messages": [
  {"role": "system", "content": "You are Joe Rogan hosting The Joe Rogan Experience podcast."},
  {"role": "user", "content": "Continue the conversation:\n\n[上下文]"},
  {"role": "assistant", "content": "[Joe 的回答]"}
]}

数据清洗脚本

# 清洗 JRE 数据
python /workspace/clean_jre_data.py

# 清洗 Buffett 数据
python /workspace/clean_buffett_data.py

# 转换为对话格式
python /workspace/clean_jre_conversational.py

⚠️ 注意事项

  1. 磁盘空间:训练需要约 20GB 可用空间,确保 /workspace 有足够空间
  2. 缓存清理:定期清理 /workspace/cache/ 和中间 wav 文件释放空间
  3. 检查点保存:每 50 步保存一次检查点,防止训练中断丢失进度
  4. 模型限制:当前模型仅训练 500 步,效果有限,建议增加到 1000-3000 步

🔗 外部资源


📞 常见问题

Q: 训练时显存不足怎么办?

A: 减小 batch_size 或启用 gradient checkpointing:

args=TrainingArguments(
    per_device_train_batch_size=1,
    gradient_checkpointing=True,
    ...
)

Q: 如何评估模型效果?

A: 使用 test_model.py 生成样本对话,人工评估质量:

python /workspace/test_model.py

Q: XTTS 生成的语音质量不好怎么办?

A: 尝试:

  1. 使用更纯净的参考音频(无背景音)
  2. 增加参考音频时长(建议 3-5 分钟)
  3. 调整 TTS 参数(speed, temperature)

📜 License

本项目仅供学习和研究使用。


最后更新:2026-04-05 项目状态:✅ 训练完成,模型可用

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support