باختصار
ورقة شهيرة في الذكاء الاصطناعي، مختصرة ومنضّدة من جديد. أمثلة الموجّهات وأجوبة النموذج في إطارات معنونة متجاورة، وعلى كل جواب علامة صواب أو خطأ، والرسوم مرسومة من أرقام الورقة نفسها.
ما الذي ستنضده
سبع صفحات من ورقة أولية في التعلم الآلي بمقاس الرسالة الأمريكي: Chain-of-Thought Prompting Elicits Reasoning in Large Language Models لـWei وزملائه، مختصرة من نسختها في arXiv بترخيص CC BY 4.0. في الصفحة الأولى أشهر أشكال الورقة، منضّدًا بإطارات لا ملصقًا صورةً: الموجّه المعتاد على اليسار، وموجّه سلسلة التفكير على اليمين؛ كل موجّه في إطار لسانه Model Input وكل جواب في إطار لسانه Model Output، والأمثلة بخط IBM Plex Mono، والاستدلال بخط عريض ملوّن، مع علامة خطأ على الجواب الخاطئ وعلامة صواب على الصحيح. يستشهد النص كما تفعل أوراق NeurIPS، (Brown et al., 2020)، من قائمة مراجع الورقة نفسها بعد تحويلها إلى BibTeX. والجدول 2 ورسمان معادة رسمها من الأرقام التي تنشرها الورقة.
تجيب هذه الوصفة عن
- كيف أنضّد أمثلة الموجّهات ومخرجات النموذج في ورقة ذكاء اصطناعي داخل إطارات متجاورة؟
- كيف أعيد تنضيد ورقة بحثية مفتوحة الوصول من arXiv أو PubMed Central بـPostext، مع استشهاداتها وأشكالها وسطر ترخيصها؟
- كيف أستشهد بالأعمال وأبني قائمة المراجع بأسلوب APA أو IEEE أو أسلوب استشهاد آخر؟
الجواب المختصر
// :::columns{count=2 breaks="4"} inside the "figure" box opens the right column at its fourth
// block; each nested box counts as one block.
const tab = (fill) => ({ fontFamily: SANS, fontSize: pt(7), fontWeight: 600,
color: col('paper'), background: col(fill), position: 'top-left', inset: mm(3),
height: mm(4.2), offset: mm(2.1), paddingX: mm(2.2) }); // straddles the top edge
const exemplar = (id, fill, ink, extra) => ({ id, background: col(fill),
border: { enabled: true, color: col('rule'), width: pt(0.6) }, borderRadius: mm(2.4),
padding: { top: mm(4.4), right: mm(3), bottom: mm(2.6), left: mm(3) },
marginTop: mm(4.2), marginBottom: ZERO, label: tab(ink),
body: { fontFamily: MONO, fontSize: pt(7.8), lineHeight: pt(10.4), color: col('ink'),
boldColor: col(ink), // **…** marks the chain of thought: the highlight of the original
textAlign: 'left', hyphenation: false, paragraphSpacing: true, firstLineIndent: ZERO },
...extra });
const mark = (id) => ({ icon: { kind: 'resource', resourceId: id, size: mm(5.6),
position: 'corner', cornerSide: 'right' } }); // a badge on the top-right corner
const promptBoxes = [
{ id: 'figure', span: 'page', backgroundEnabled: false, border: { enabled: false },
padding: mm(0), columnGap: mm(6), marginTop: ZERO, marginBottom: pt(LEAD),
body: { fontFamily: SANS, fontSize: pt(8.4), lineHeight: pt(11.4), color: col('ink'),
boldColor: col('accent'), textAlign: 'left', paragraphSpacing: true,
firstLineIndent: ZERO } },
exemplar('input', 'tint', 'accent'),
exemplar('right', 'mint', 'green', mark('mark-right')),
exemplar('wrong', 'mint', 'green', mark('mark-wrong')),
];
المكونات
- الميزات
- أعمدة داخل الإطار أو النصإطارات متداخلةألسنة الإطارات المرقّمةأيقونات الإطارات وشارات الزواياإطارات التنبيهالاستشهادات بأسلوب توثيققائمة المراجع من البيانات المرجعيةالإحالاتالعناوين المرقّمةأنماط العناوينصفحات افتتاح مصمَّمةأنواع موارد مخصّصةنمط التعليقجداول من البياناتنمط الجدولالحواشي السفليةعناوين الروابط في النسخة المطبوعةالترويسات وأرقام الصفحاتلوحة ألوان دلاليةالتصدير إلى PDF
- تستخدم أيضًا
- استشهادات تضع الأشكالسمات العنوانالترويسات بحسب دور الصفحةأنماط الفقراتالخطوط المضمَّنة في PDFالأشكال والجداول بوصفها مواردفواصل الأسطر في العناوينفصول بلا أرقام
- الخطوط
- Newsreader, IBM Plex Sans, IBM Plex Mono (SIL OFL 1.1)
- الأصول
- لا شيء: كل صورة مرسومة بالشيفرة
طريقة التحضير
#1 · الشكل 1 ثلاثة أنماط إطارات
الشيفرة هي الجواب المختصر أعلاه. الشكل إطار واحد بعرض الصفحة بلا حدود خاصة به؛ وداخله يفتح :::columns{count=2 breaks="4"} العمود الأيمن عند الكتلة الرابعة، ويُعدّ كل إطار متداخل كتلة واحدة. تخرج إطارات الموجّه والجواب من الدالة نفسها، فلا تختلف إلا في الخلفية ولون اللسان والشارة على الزاوية: يقبل icon مع position: 'corner' موردًا بصيغة SVG، وبهذا تصل علامتا الصواب والخطأ إلى الصفحة مع أن خطوط المستند لا تحويهما. في ورقتك، اكتب كل مثال فقرات عادية داخل إطار وعلّم الاستدلال بـ**…**، فيحوّله boldColor في النمط إلى تظليل.
#2 · استشهادات مؤلف–سنة على طريقة natbib
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
// Chicago author-date writes (Brown et al. 2020); ML venues put a comma before the year.
const AUTHOR_YEAR = '<group delimiter=" ">\n <text macro="author-inline"/>';
const natbib = STYLES['chicago-author-date']
.replace(AUTHOR_YEAR, AUTHOR_YEAR.replace('" "', '", "'));
const citations = { style: 'custom', customStyle: natbib, link: true,
bibliography: { fontSize: em(0.8), lineHeight: pt(10.2), entrySpacing: pt(1.8),
hangingIndent: mm(4), doi: 'text' } };
// The text's two web addresses are links: clickable in the PDF, printed in parentheses on
// paper, `[name census data](https://namecensus.com/)` as "name census data (namecensus.com)".
const links = { print: 'inline', urlDisplay: 'short' };
تستعمل مؤتمرات التعلم الآلي مظهر مؤلف–سنة في natbib: فاصلة بين الاسم والسنة، وet al. من ثلاثة مؤلفين فأكثر. وأقرب الأساليب المضمّنة إليه Chicago author-date، فتغيّر الوصفة مجموعة واحدة من ملف CSL، تلك التي تصل المؤلف بالسنة، من مسافة إلى فاصلة. أحضر ملف .bib كما هو: الصقه في كتلة :::references{format=bibtex} واستشهد بـ[@key] لتحصل على (Brown et al., 2020) وبـ@key لتحصل على Brown et al. (2020). وتحتفظ اللاحقة بالفاصلة المكتوبة قبلها وبتنسيقها، فيُطبع [@brown2020language, *inter alia*] هكذا: (Brown et al., 2020, inter alia)، كما في الورقة. وتستشهد التعليقات بالطريقة نفسها: يكتب تعليق الشكل 4 @jie2022learning و@lan2021mwptoolkit، فيدخل العملان قائمة المراجع دون nocite.
يُكتب عنوانا الويب في النص، بيانات إحصاء الأسماء في القسم 5 والترخيص في السطر الختامي، رابطين: [name census data](https://namecensus.com/). ومع links: { print: 'inline', urlDisplay: 'short' } تطبع الورقة كل عنوان بين قوسين بعد نصه، من غير https://، ويبقى الرابط في PDF قابلًا للنقر. أما العنوان المكتوب نصًّا عاديًّا فيُطبع بالشكل نفسه، لكنه لا يفتح شيئًا عند النقر عليه.
#3 · كتلة العنوان
const text = (id, content, family, size, extra) => ({ kind: 'text', id, content, align: 'left',
fontFamily: family, fontSize: pt(size), color: col('ink'), overflow: 'wrap', ...extra });
const at = (to, edge, y, width = MEASURE) => ({ anchor: { to, edge },
offset: { x: ZERO, y: mm(y) }, size: { width: mm(width), height: 'auto' } });
const titleBlock = { enabled: true, minHeight: mm(58), slot: { elements: [
text('venue', '{attr.venue}', MONO, 7.5, { fontWeight: 500, letterSpacing: pt(0.6),
color: col('accent'), placement: at('container', 'top-left', 0) }),
text('title', '{titleText}', SERIF, 23, { fontWeight: 600, lineHeight: 1.1,
placement: at('#venue', 'below', 5) }),
text('authors', '{attr.authors}', SANS, 9.6, { fontWeight: 500, lineHeight: 1.45,
placement: at('#title', 'below', 6) }),
text('affiliation', '{attr.affiliation}', SANS, 8.6, { color: col('muted'),
placement: at('#authors', 'below', 1.2) }),
{ kind: 'rule', id: 'rule', thickness: pt(0.5), color: col('rule'),
placement: at('#affiliation', 'below', 4) },
text('note', '{attr.note}', SERIF, 8.2, { lineHeight: 1.35,
color: col('muted'), placement: at('#rule', 'below', 2) }),
] } };
العنوان هو العنوان الوحيد من المستوى الأول في المستند، بنمط يمتد عبر العمودين ويرسم كتلة مصمّمة: سطر المؤتمر، والعنوان، والمؤلفون في صفين، والجهة، وملاحظة عن الاختصار. المؤلفون والملاحظة سمات للعنوان، و\n داخل السمة يبدأ صفًا جديدًا كما يفعل \\ في \author في LaTeX. لورقتك، غيّر السمات ويبقى التصميم.
#4 · أرقام أشكال تطابق الأصل
// Figure 1 is boxes, which the figure counter does not see: number the charts by type.
const numbered = (id, word, n, extra) => ({ id, name: `${word} ${n}`,
shortLabel: `${word} ${n}`, captionPrefix: `${word} ${n}`, numberingTemplate: '',
resetOn: 'never', counterFormat: 'decimal', ...extra });
const resourceTypes = [numbered('mark', 'Mark', ''), numbered('fig2', 'Figure', 2),
numbered('fig4', 'Figure', 4),
numbered('tab2', 'Table', 2, { captionStyle: { position: 'above' } })];
const ACROSS = { position: 'top', span: 'page' }; // a float over both columns
const svg = (id, typeId, file, [width, height], caption, note, altText, placement) => ({
id, typeId, kind: 'svg', createdAt: 0, updatedAt: 0,
placement: placement ?? { position: 'top' }, svg: { fileId: file, width, height },
caption, note, altText });
يرقّم المحرك الأشكال بترتيب أول إحالة إليها، لكن الشكل 1 هنا إطار لا يراه العدّاد. لذلك لكل رسم معاد نوع مورد خاص به، رقمه مكتوب في التسمية وnumberingTemplate فارغ، فيحتفظ بأرقام نسخة arXiv: الشكل 2 والشكل 4 والجدول 2. في ورقة من تأليفك، حيث كل الأشكال موارد، يكفي نوع figure واحد مع numberingTemplate: '{n}'.
#5 · الجدول 2 من بيانات الورقة
const SETS = ['GSM8K', 'SVAMP', 'ASDiv', 'AQuA', 'MAWPS'];
const RESULTS = [ // model, size, then standard / CoT pairs per benchmark; * CoT beats standard
['UL2', '20B', '4.1 4.4* 10.1 12.5* 16.0 16.9* 20.5 23.6* 16.6 19.1*'],
['LaMDA', '420M', '2.6 0.4 2.5 1.6 3.2 0.8 23.5 8.3 3.2 0.9'],
['', '2B', '3.6 1.9 3.3 2.4 4.1 3.8 22.9 17.7 3.9 3.1'],
['', '8B', '3.2 1.6 4.3 3.4 5.9 5.0 22.8 18.6 5.3 4.8'],
['', '68B', '5.7 8.2* 13.6 18.8* 21.8 23.1* 22.3 20.2 21.6 30.6*'],
['', '137B', '6.5 14.3* 29.5 37.5* 40.1 46.6* 25.5 20.6 43.2 57.9*'],
['GPT', '350M', '2.2 0.5 1.4 0.8 2.1 0.8 18.1 8.7 2.4 1.1'],
['', '1.3B', '2.4 0.5 1.5 1.7 2.6 1.4 12.6 4.3 3.1 1.7'],
['', '6.7B', '4.0 2.4 6.1 3.1 8.6 3.6 15.4 13.4 8.8 3.5'],
['', '175B', '15.6 46.9* 65.7 68.9* 70.3 71.3* 24.8 35.8* 72.7 87.1*'],
['Codex', '–', '19.7 63.1* 69.9 76.4* 74.0 80.4* 29.5 45.3* 78.7 92.6*'],
['PaLM', '8B', '4.9 4.1 15.1 16.8* 23.7 25.2* 19.3 21.7* 26.2 30.5*'],
['', '62B', '9.6 29.9* 48.2 46.7 58.7 61.9* 25.6 22.4 61.8 80.3*'],
['', '540B', '17.9 56.9* 69.4 79.0* 72.1 73.9* 25.2 35.8* 79.2 93.3*'],
];
const cell = (content, extra) => ({ content, align: 'right', ...extra });
const tableRows = () => [
[cell('Model', { isHeader: true, align: 'left', colSpan: 2 }), { content: '',
hiddenBy: { row: 0, col: 0 } }, // gotcha: merged-cells-hiddenby
...SETS.flatMap((set, i) => [cell(set, { isHeader: true, align: 'center', colSpan: 2 }),
{ content: '', hiddenBy: { row: 0, col: 2 + 2 * i } }])],
[cell('', { isHeader: true }), cell('', { isHeader: true }),
...SETS.flatMap(() => [cell('standard', { isHeader: true }), cell('CoT', { isHeader: true })])],
...RESULTS.map(([model, size, values]) => [cell(model ? `**${model}**` : '', { align: 'left' }),
cell(size, { align: 'left' }),
...values.split(' ').map((v) => cell(v.endsWith('*') ? `**${v.slice(0, -1)}**` : v))]),
];
تُكتب النتائج مرة واحدة كما هي في مصدر LaTeX، وتغذي الجدول 2 والشكل 4 معًا، فلا يمكن أن يخالف الرسم الجدول. يمتد اسم كل مقياس على عمودين؛ والخلية المدموجة تحتاج حيث تمتد إلى خلايا حشو معلّمة بـhiddenBy. ويميّز الخط العريض الخلايا التي تتفوق فيها سلسلة التفكير على الموجّه المعتاد، كالخلايا الخضراء في الأصل.
الوصفة كاملة
// ═══ Postext Cookbook · Nº 137 · An AI preprint with prompt exemplars in boxes ═══════
// https://postext.dev/en/cookbook/ai-preprint-prompt-exemplars
// Code: MIT · Text: Wei et al. 2022, arXiv:2201.11903 (CC BY 4.0) · Charts: drawn in code
// Fonts: Newsreader, IBM Plex Sans, IBM Plex Mono (SIL OFL 1.1) · Needs postext ≥ 1.65.0
import {
buildDocumentWithFonts, renderPageToCanvas, registerCitationEngine, registerResourceImage,
inlineSvgFonts,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
import { createCiteprocEngine, STYLES, LOCALES } from 'https://esm.sh/postext-citeproc';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'ai-preprint-prompt-exemplars';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a cool ink, a prompt blue, an answer green and a red for the wrong answer
const palette = { ink: '#1b1e24', accent: '#1f5fa6', green: '#21744a', red: '#b3362d',
tint: '#e9f0f8', mint: '#e6f2eb', rule: '#b4bcc8', muted: '#5b6270', paper: '#ffffff' };
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.accent })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const [SERIF, SANS, MONO] = ['Newsreader', 'IBM Plex Sans', 'IBM Plex Mono'];
// US letter, two columns of 85.5 mm as ML venues print.
const [TRIM_W, TRIM_H, TOP, BOTTOM, SIDE, GUTTER] = [215.9, 279.4, 22, 22, 19, 7];
const MEASURE = TRIM_W - 2 * SIDE;
const COLUMN = (MEASURE - GUTTER) / 2;
const LEAD = 12.8; // pt
const ZERO = pt(0);
// #region answer: Figure 1 as boxes: two columns, a tab on each box, a ✓ or ✗ in the corner
// :::columns{count=2 breaks="4"} inside the "figure" box opens the right column at its fourth
// block; each nested box counts as one block.
const tab = (fill) => ({ fontFamily: SANS, fontSize: pt(7), fontWeight: 600,
color: col('paper'), background: col(fill), position: 'top-left', inset: mm(3),
height: mm(4.2), offset: mm(2.1), paddingX: mm(2.2) }); // straddles the top edge
const exemplar = (id, fill, ink, extra) => ({ id, background: col(fill),
border: { enabled: true, color: col('rule'), width: pt(0.6) }, borderRadius: mm(2.4),
padding: { top: mm(4.4), right: mm(3), bottom: mm(2.6), left: mm(3) },
marginTop: mm(4.2), marginBottom: ZERO, label: tab(ink),
body: { fontFamily: MONO, fontSize: pt(7.8), lineHeight: pt(10.4), color: col('ink'),
boldColor: col(ink), // **…** marks the chain of thought: the highlight of the original
textAlign: 'left', hyphenation: false, paragraphSpacing: true, firstLineIndent: ZERO },
...extra });
const mark = (id) => ({ icon: { kind: 'resource', resourceId: id, size: mm(5.6),
position: 'corner', cornerSide: 'right' } }); // a badge on the top-right corner
const promptBoxes = [
{ id: 'figure', span: 'page', backgroundEnabled: false, border: { enabled: false },
يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)
تنويعات
#استشهد بأسلوب APA
يكتب APA (Roy & Roth, 2015) ويسرد حتى عشرين مؤلفًا، وهذا ما لا تريده عادةً مراجع ورقة عن النماذج الكبيرة.
-const citations = { style: 'custom', customStyle: natbib, link: true,
+const citations = { style: 'apa', link: true,#نضّد الورقة في عمود واحد
يحتاج العمود الواحد على طريقة NeurIPS هوامش جانبية أعرض ليبقى عرض السطر مقروءًا؛ وتأخذ الإطارات بعرض الصفحة ذلك العمود.
-const [TRIM_W, TRIM_H, TOP, BOTTOM, SIDE, GUTTER] = [215.9, 279.4, 22, 22, 19, 7];
+const [TRIM_W, TRIM_H, TOP, BOTTOM, SIDE, GUTTER] = [215.9, 279.4, 24, 24, 38, 7];
- layout: { layoutType: 'double', gutterWidth: mm(GUTTER) },
+ layout: { layoutType: 'single' },#قوائم الشيفرة داخل إطارات
إن كانت موجّهاتك تحوي شيفرة، فإطارات القوائم في قوائم الشيفرة والمفاتيح تلوّن الصياغة بمقاطع عريضة ومائلة.
أخطاء شائعة
خطأ شائع
الإطار المتداخل يتجاهل span وplacement وsnapToGrid
الإطار المتداخل في إطار آخر يتجاهل span وplacement وsnapToGrid وfloatBarrier الخاصة به: يجري دائمًا داخل الإطار الأم، بالعرض الداخلي للأم. إطارات متداخلة →
- الإطار الممتد بعرض الصفحة في تخطيط من عمودين لا يبقى في الصفحة الحالية إلا إذا اتسع مع سطرين على الأقل من النص تحته. يقع الشكل 1 في الصفحة 1 لأن الملخص منضّد بحجم 9.3 نقطة وبحشو ضيق؛ ولو طال الملخص لانتقل الشكل إلى الصفحة 2.
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- “Chain-of-Thought Prompting Elicits Reasoning in Large Language Models”, NeurIPS 2022, arXiv:2201.11903v6, abridged (sections 3.3, 3.4, 7 and the appendices cut, pointers to omitted figures and appendices removed); Figures 2 and 4 redrawn in code from the paper’s numbers, Figure 1 set as boxes, Table 2 reset · Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Brian Ichter, Fei Xia, Ed H. Chi, Quoc V. Le, Denny Zhou · CC BY 4.0
- الخطوط
- Newsreader (SIL OFL 1.1) · IBM Plex Sans (SIL OFL 1.1) · IBM Plex Mono (SIL OFL 1.1)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


