Token 错误率(TER,分数越低越好)
:计算生成的 Markdown 里有多少 token 在原始 HTML 里没有出现,用来评估模型的“胡说八道率”。
为了让 LLM 来完成此任务,我们使用的 Prompt 都是一致的:
Your task is to convert the content of the provided HTML file into the corresponding markdown file. You need to convert the structure, elements, and attributes of the HTML into equivalent representations in markdown format, ensuring that no important information is lost. The output should strictly be in markdown format, without any additional explanations.
评估结果如下:
定性研究
为了更直观地了解 Reader-LM 的效果,眼见为实,我们还用肉眼定性评估了模型生成的 Markdown 输出,评估了 22 个 HTML 网页,
包括新闻、博客、产品落地页、电商页面和论坛帖子,涵盖了英语、德语、日语、中文、俄语等
,我们还把 Jina Reader API(基于规则的方法)也拉进来做了对比。
Reader-LM-1.5B 在所有维度都表现不错,尤其是在结构保留和使用 Markdown 语法方面。虽然它不一定总是比 Jina Reader API 更好,但它的表现跟 Gemini 1.5 Pro 这种大型语言模型差不多,可以作为这些大型模型的高效替代品。Reader-LM-0.5B 虽然体积小,但在结构保留方面也很出色。
我们如何训练 Reader-LM
数据准备:精挑细选,喂饱模型
我们用 Jina Reader API 生成了大量的 HTML 和 Markdown 训练数据对。
在实验中,我们发现小型语言模型(SLM)对训练数据的质量非常敏感
。所以,我们专门构建了一个数据管道,保证只有高质量的 Markdown 数据才能进入训练集。
另外,我们还用 GPT-4o 生成了一些 HTML 和对应的 Markdown 数据。跟真实的网页代码相比,这些合成数据通常更短,结构简单可预测,噪音也少得多。
最后,我们把 HTML 和 Markdown 用 Chat 模板连起来,最终的训练数据格式像这样:
<|im_start|>system You are a helpful assistant.<|im_end|> <|im_start|>user {{RAW_HTML}}<|im_end|> <|im_start|>assistant {{MARKDOWN}}<|im_end|>