Commit 3e4a1b88 by wangchenglong

update.

parent 7f8cee0c
param(
[string]$OutputDir = "chapter-pdfs"
)
$ErrorActionPreference = "Stop"
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
Set-Location $repoRoot
$buildDir = Join-Path $repoRoot ".chapter-build"
$outDir = Join-Path $repoRoot $OutputDir
New-Item -ItemType Directory -Force $buildDir | Out-Null
New-Item -ItemType Directory -Force $outDir | Out-Null
$main = Get-Content -Raw -Encoding UTF8 "rl-introduction.tex"
$preamble = [regex]::Match($main, "(?s)^.*?\\begin\{document\}").Value
$preamble = $preamble -replace "(?m)^\\def\\bibdata#1\{\}\r?\n", ""
$preamble = $preamble -replace "(?m)^\\def\\bibstyle#1\{\}\r?\n", ""
$introMatch = [regex]::Match(
$main,
"(?s)\\section\{Introduction\}.*?(?=\r?\n\\input\{section2/section2\})"
)
if (-not $introMatch.Success) {
throw "Could not extract the Introduction section from rl-introduction.tex"
}
$chapters = @(
@{
Job = "chapter-01-introduction"
Title = "Chapter 1: Introduction"
Counter = $null
Body = $introMatch.Value
},
@{
Job = "chapter-02-preliminary"
Title = "Chapter 2: Preliminary"
Counter = 1
Body = "\input{section2/section2}"
},
@{
Job = "chapter-03-understanding-rl-in-llm-training"
Title = "Chapter 3: Understanding RL in LLM Training"
Counter = 2
Body = "\input{section3/section3}"
},
@{
Job = "chapter-04-improved-rl-for-llms"
Title = "Chapter 4: Improved RL for LLMs"
Counter = 3
Body = "\input{section4/section4}"
},
@{
Job = "chapter-05-rl-for-llm-reasoning"
Title = "Chapter 5: RL for LLM Reasoning"
Counter = 4
Body = "\input{section5/section5}"
},
@{
Job = "chapter-06-agentic-rl"
Title = "Chapter 6: Agentic RL"
Counter = 5
Body = "\input{section6/section6}"
},
@{
Job = "chapter-07-multimodal-rl"
Title = "Chapter 7: Multimodal RL"
Counter = 6
Body = "\input{section7/section7}"
},
@{
Job = "chapter-08-conclusions-and-future-directions"
Title = "Chapter 8: Conclusions and Future Directions"
Counter = 7
Body = "\input{section8/section8}"
},
@{
Job = "appendix-datasets-and-systems"
Title = "Appendix: Datasets and Systems"
Counter = $null
Body = "\input{appendix/appendix}"
}
)
foreach ($chapter in $chapters) {
$counterLine = ""
if ($null -ne $chapter.Counter) {
$counterLine = "\setcounter{section}{$($chapter.Counter)}"
}
$tex = @"
$preamble
\title{RL without Tears:\\ $($chapter.Title)}
\begin{CJK*}{UTF8}{gbsn}
\maketitle
$counterLine
$($chapter.Body)
\clearpage
\bibliography{rl-introduction}
\bibliographystyle{rl-introduction}
\end{CJK*}
\end{document}
"@
$texPath = Join-Path $buildDir "$($chapter.Job).tex"
Set-Content -Path $texPath -Value $tex -Encoding UTF8
& latexmk -pdf -bibtex -interaction=nonstopmode -halt-on-error `
"-outdir=$buildDir" `
$texPath
$pdfPath = Join-Path $buildDir "$($chapter.Job).pdf"
if (-not (Test-Path $pdfPath)) {
throw "Expected PDF was not generated: $pdfPath"
}
Copy-Item -Path $pdfPath -Destination (Join-Path $outDir "$($chapter.Job).pdf") -Force
}
Write-Host "Chapter PDFs written to: $outDir"
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论