Text Generation
PEFT
Safetensors
Chinese
English
lora
sft
remotion
typescript
educational-video
code-generation
conversational
Instructions to use posprivacy/teachmaster with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use posprivacy/teachmaster with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.8-27B") model = PeftModel.from_pretrained(base_model, "posprivacy/teachmaster") - Notebooks
- Google Colab
- Kaggle
File size: 10,034 Bytes
ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 ba6070f 8948dd4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | ---
library_name: peft
base_model: Qwen/Qwen3.8-27B
pipeline_tag: text-generation
language:
- zh
- en
tags:
- lora
- sft
- remotion
- typescript
- educational-video
- code-generation
model-index:
- name: TeachMaster Qwen3.8-27B LoRA
results: []
---
<div align="center">
# TeachMaster Coder
### Turn lesson text into animated teaching visuals.
**Qwen3.8-27B · LoRA SFT · Remotion TSX**
[](https://huggingface.co/Qwen/Qwen3.8-27B)
[](adapter_config.json)
[](#quick-start)
[](adapter_model.safetensors)
从课程文字出发,生成包含标题、图片、流程图、公式与动画的可执行 TSX。
[Gallery](#generated-gallery) · [Training](#training-at-a-glance) · [Quick Start](#quick-start) · [Limitations](#what-still-needs-work)
</div>

> **Real model output.** Gallery images are Remotion renders of this adapter's generated TSX. No manual layout repairs were applied. The speech-recognition illustrations are existing dataset assets referenced by the code; this model did not generate those images.
## What It Does
TeachMaster Coder is a task-specific adapter for **Chinese educational animation code generation**. It takes lesson Markdown, image-planning JSON and presentation requirements, and produces complete React/Remotion TSX.
| Input | Output |
| :--- | :--- |
| Lesson content and terminology | Structured teaching scenes |
| Image descriptions, ratios and asset paths | Image placement with `Img` and `staticFile` |
| Canvas, timing and visual requirements | Components, layout styles and frame-based animation |
**This repository contains the LoRA adapter, not the full base model.** Use it with [Qwen/Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B). Source training data and image assets are not distributed here.
## Generated Gallery
### 01 / From Audio to Understanding
An illustration, definition panel, processing pipeline and side-by-side comparison share one 1920 × 1080 canvas.

### 02 / Complex Environments, Structured Explanations
Image-and-text composition with three explanatory blocks, an audio-processing pipeline and application cards.

### 03 / A Concept Made Visible
A text-only lesson becomes an application overview and a highlighted Bayesian formula. This example uses no image assets.

<details>
<summary><strong>See the remaining two scenes, including the sparse layout</strong></summary>
The first scene defines prior probability and organizes three sources of prior knowledge.

The mechanism scene illustrates a remaining weakness: content is organized, but too much space is left unused in the middle of the frame.

</details>
### How These Examples Were Checked
| Check | Observation |
| :--- | :--- |
| Evaluation data | 2 held-out pages; neither source job appears in this run's training split |
| Generation | Greedy decoding, thinking disabled, maximum 16,384 new tokens |
| Completion | Both outputs ended normally with EOS; 5,267 and 5,322 output tokens |
| Rendering | All 5 selected scene-end frames rendered without runtime errors |
| Layout inspection | No obvious clipping or text overlap in those screenshots |
| Scope | A small qualitative smoke test, not a full benchmark or all-frame audit |
The images above are **selected still frames**, not evidence of narration alignment or animation quality across the full timeline. The model produced 16- and 21-second compositions despite a request for approximately 40 seconds.
## Training at a Glance
| | Configuration |
| :--- | :--- |
| Base model | `Qwen/Qwen3.8-27B` |
| Transformers architecture | `Qwen3_5ForConditionalGeneration` |
| Training / validation | 11,450 / 515 examples, split by source job |
| Objective | Supervised TSX generation; prompt tokens excluded from loss |
| Thinking | Disabled; no chain-of-thought supervision |
| LoRA | Rank 64 · alpha 128 · dropout 0.05 |
| Target modules | `q_proj`, `k_proj`, `v_proj`, `o_proj` |
| Precision / hardware | BF16 · 8 × NVIDIA A800 80GB |
| Sequence cutoff | 12,288 tokens |
| Effective batch | 32 = 8 GPUs × microbatch 1 × accumulation 4 |
| Schedule | 2 epochs · 716 steps · peak LR 5e-5 · cosine decay · 3% warmup |
| Training runtime | Approximately 12.5 hours, excluding final evaluation |
| Final mean training loss | 0.185514 |
| Final validation loss | 0.173346 |
**Length coverage:** 479 training examples and 19 validation examples exceed the 12,288-token cutoff and are subject to truncation. The run does not cover every example at its original full length.
### Learning Curves
| Training loss | Validation loss |
| :---: | :---: |
|  |  |
Validation loss improved from **0.1851 at step 100** to **0.1733 at completion**. Token loss measures code prediction; it does not directly measure layout aesthetics, content correctness or animation timing.
## Quick Start
The tested runtime used **Transformers 5.8**, **PEFT 0.18.1**, PyTorch with BF16 support, `flash-linear-attention` and `causal-conv1d`. Install versions compatible with your CUDA/PyTorch environment. This base model uses the Qwen3.5 architecture implementation despite its Qwen3.8 model name.
```python
import torch
from peft import PeftModel
from transformers import AutoTokenizer, Qwen3_5ForConditionalGeneration
base_id = "Qwen/Qwen3.8-27B"
adapter_id = "posprivacy/teachmaster-qwen38-27b-lora"
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
base = Qwen3_5ForConditionalGeneration.from_pretrained(
base_id,
dtype=torch.bfloat16,
device_map="auto",
attn_implementation="sdpa",
)
model = PeftModel.from_pretrained(base, adapter_id).eval()
messages = [
{
"role": "system",
"content": (
"你是 Remotion TSX 代码生成器。只输出完整、可运行的 TSX。"
"画布为 1920x1080,fps=30。使用 Sequence 组织场景,"
"确保文字、图形和图片不出界、不重叠。"
),
},
{
"role": "user",
"content": '''【课程讲义 Markdown】
先验概率描述观测新数据之前对模型参数的初始判断。
它可以来自历史经验、科学理论和逻辑推演。
【图片规划 JSON】
{"needs_image": false, "images": []}
【当前分页文件名】
5_1.md
请用定义、流程图和应用示例组织画面。''',
},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
enable_thinking=False,
return_tensors="pt",
return_dict=True,
).to(model.device)
with torch.inference_mode():
output = model.generate(
**inputs,
max_new_tokens=16384,
do_sample=False,
pad_token_id=tokenizer.eos_token_id,
)
tsx = tokenizer.decode(
output[0, inputs["input_ids"].shape[-1]:],
skip_special_tokens=True,
)
print(tsx)
```
This is a compact loading example. The gallery used a longer reconstructed coder system prompt specifying scene structure, typography, color palette, image integration and animation conventions. The short example above is not an exact reproduction of the gallery input.
### Working With Images
Supply an image-planning JSON and an explicit path convention in the user message:
```text
【图片规划 JSON】
{"needs_image": true, "images": [{"index": 1, "ratio": "16:9", "description": "端到端语音识别结构图"}]}
【当前分页文件名】
24_1.md
图片路径使用 staticFile("assets/24_1/image_<index>.png")。
```
Place the actual asset at `public/assets/24_1/image_1.png` in your Remotion project. The adapter generates the reference and layout; image generation and asset delivery are separate stages.
## What Still Needs Work
- **Space utilization:** oversized cards, small text and excessive whitespace remain in some scenes.
- **Timing compliance:** requested composition duration is not reliably followed.
- **Visual diversity:** the gallery uses a shared template and palette supplied by the prompt; broader style generalization has not been established.
- **Content accuracy:** generated explanations and formulas still need subject-matter review.
- **Runtime reliability:** successful rendering of two samples does not establish a general compile-success rate.
- **Animation and narration:** these screenshots do not test all frames, narration generation or semantic audio alignment.
Generated TSX should be compiled, executed and visually inspected before use. The next useful quality checks are full-timeline rendering and DOM-based measurements of clipping, overlap and occupied area.
## Repository Contents
| Files | Purpose |
| :--- | :--- |
| `adapter_model.safetensors`, `adapter_config.json` | LoRA weights and base-model reference |
| `tokenizer*`, `chat_template.jinja`, `processor_config.json` | Tokenization and supporting configuration |
| `train_results.json`, `eval_results.json` | Recorded training and evaluation metrics |
| `training_loss.png`, `training_eval_loss.png` | Learning curves |
| `assets/` | Rendered gallery screenshots |
| `checksums.json` | Adapter SHA256 checksum |
The original base-model weights, training corpus and source image assets are not included. Refer to the base model's model card and license for its usage terms.
|