\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{LoiVyen} \pdfinfo{ /Title (abcdefg-train-hijklmnop.pdf) /Creator (Cheatography) /Author (LoiVyen) /Subject (abcdefg train hijklmnop Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{3FCCE8} \definecolor{LightBackground}{HTML}{E7F8FC} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{abcdefg train hijklmnop Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{LoiVyen} via \textcolor{DarkBackground}{\uline{cheatography.com/163788/cs/34315/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}LoiVyen \\ \uline{cheatography.com/loivyen} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 9th October, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Training Process}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{1. Initialize the model weights randomly \{\{nl\}\}2. Predict a few examples with the current weights \{\{nl\}\}3. Compare prediction with true labels \{\{nl\}\}4. Calc how to change weights to improve predictions \{\{nl\}\}5. Update weights slightly \{\{nl\}\}6. Go back to 2.} \tn % Row Count 6 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\seqsplit{https://course.spacy.io/en/chapter4}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Generate a Configuration File for Training}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{`python -m spacy init config ./config.cfg -{}-lang en -{}-pipeline ner`}}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{This will allow training for the ner pipeline} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{init config}}: the command to run \newline {\bf{config.cfg}}: output path for the generated config \newline {\bf{-{}-lang}}: language class of the pipeline, e.g. en for English \newline {\bf{-{}-pipeline}}: comma-separated names of components to include} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Create Training Data (with DocBin)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`from spacy.tokens import DocBin` \{\{nl\}\}\# Create and save a collection of training docs} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`docs train\_docbin = DocBin(docs=train\_docs) \{\{nl\}\}train\_docbin.to\_disk("./train.spacy")`} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\# Create and save a collection of evaluation docs} \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`dev\_docbin = DocBin(docs=dev\_docs) \{\{nl\}\}dev\_docbin.to\_disk("./dev.spacy")`} \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{(via Sypder or Jupyter using DocBin)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Training the Data with CLI}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\# if used a base\_config.cfg file} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`python -m spacy init fill-config base\_config.cfg config.cfg`} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\# if configurations entered in config.cfg (namely the dev/train paths)} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`python -m spacy train config.cfg -{}-output ./output`} \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\# overwrite config file and train} \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`python -m spacy train ./config.cfg -{}-output ./output -{}-paths.train train.spacy -{}-paths.dev dev.spacy`} \tn % Row Count 11 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\# other way to overwrite config file settings (ex.)} \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{in config file:\{\{nl\}\}{\emph{{[}training{]}}} `-{}-training` \{\{nl\}\} {\emph{eval\_frequency}} `.eval\_frequency 10` \{\{nl\}\}{\emph{max\_steps}} `.max\_steps 300`\{\{nl\}\}} \tn % Row Count 16 (+ 3) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{config file to cmd line:} \tn % Row Count 17 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`python -m spacy train config.cfg -{}-output ./output -{}-training.eval\_frequency 10 -{}-training.max\_steps 300`} \tn % Row Count 20 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\seqsplit{https://spacy.io/usage/training}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Train from Python Compiler}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`from spacy.cli.train import train as spacy\_train`} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`config\_path = "./config/config.cfg" \{\{nl\}\}output\_model\_path = "output/" \{\{nl\}\}spacy\_train( \{\{nl\}\}~~~~config\_path, \{\{nl\}\}~~~~output\_path=output\_model\_path, \{\{nl\}\}~~~~overrides=\{ \{\{nl\}\}~~~~~~~~"paths.train": "./train.spacy", \{\{nl\}\}~~~~~~~~"paths.dev": "./test.spacy", \{\{nl\}\}~~~~~~~~"training.eval\_frequency" : 10, \{\{nl\}\}~~~~~~~~"training.max\_steps" : 300 \{\{nl\}\}~~~~\}, \{\{nl\}\})`} \tn % Row Count 15 (+ 14) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{output:}}\{\{nl\}\}ℹ Saving to output directory: output\textbackslash{} \{\{nl\}\}ℹ Using CPU \{\{nl\}\}ℹ To switch to GPU 0, use the option: -{}-gpu-id 0 \{\{nl\}\}`========= Initializing pipeline ========` \{\{nl\}\}`✔ Initialized pipeline` \{\{nl\}\}`=========== Training pipeline ==========` \{\{nl\}\}ℹ Pipeline: {[}'tok2vec', 'ner'{]} \{\{nl\}\}ℹ Initial learn rate: 0.001 \{\{nl\}\}`E \# LOSSTOK2VEC LOSSNER \seqsplit{ENTS\_F~~ENTS\_P~~ENTS\_R~~SCORE} ` \{\{nl\}\}`-{}-{}- -{}-{}- -{}-{}- -{}-{}-{}- -{}-{}-{}- -{}-{}-{}- -{}-{}-{}-{}-{}-{}- -{}-{}-{}-{}-{}- -{}-{}-{}- -{}-{}- -{}-{}-` \{\{nl\}\}` 0~~~~0~~~0.00~~~69.09 ~~~13.42 ~~~10.09~~~20.00~~~0.13` \{\{nl\}\}` 0~~~10~~~0.96~~~855.31 ~~~3.59 ~~~42.86~~~1.88 ~~~0.04` \{\{nl\}\}`...` \{\{nl\}\} (etc) \{\{nl\}\}`✔ Saved pipeline to output directory` \{\{nl\}\}`output\textbackslash{}model-last`} \tn % Row Count 34 (+ 19) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.572 cm} x{2.204 cm} x{1.824 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Trainable Components}} \tn % Row 0 \SetRowColor{LightBackground} tagger~~~~~~~~~ & \seqsplit{morphologizer~~} & \seqsplit{trainable\_lemmatizer} \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} parser & ner & \tn % Row Count 5 (+ 1) % Row 2 \SetRowColor{LightBackground} spancat & texcat & \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Configuration File (Defaults - sample)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`python -m spacy init config ./config.cfg -{}-lang en -{}-pipeline ner`} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{[}paths{]} \{\{nl\}\}train = null \{\{nl\}\}dev = null \{\{nl\}\}vectors = null\{\{nl\}\}init\_tok2vec = null} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{[}nlp{]}\{\{nl\}\} lang = "en"\{\{nl\}\} pipeline = {[}"tok2vec","ner"{]}\{\{nl\}\} batch\_size = 1000\{\{nl\}\} disabled = {[}{]}\{\{nl\}\} before\_creation = null\{\{nl\}\} after\_creation = null\{\{nl\}\} \seqsplit{after\_pipeline\_creation} = null\{\{nl\}\} tokenizer = \{"@tokenizers":"spacy.Tokenizer.v1"\}} \tn % Row Count 10 (+ 6) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{[}training{]}\{\{nl\}\} dev\_corpus = "corpora.dev"\{\{nl\}\} train\_corpus = "corpora.train"\{\{nl\}\} seed = \$\{system.seed\}\{\{nl\}\} gpu\_allocator = \$\{system.gpu\_allocator\}\{\{nl\}\} dropout = 0.1\{\{nl\}\} accumulate\_gradient = 1\{\{nl\}\} patience = 1600\{\{nl\}\} max\_epochs = 0\{\{nl\}\} max\_steps = 20000\{\{nl\}\} eval\_frequency = 200\{\{nl\}\} frozen\_components = {[}{]}\{\{nl\}\} annotating\_components = {[}{]}\{\{nl\}\} before\_to\_disk = null\{\{nl\}\}} \tn % Row Count 18 (+ 8) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{[}training.batcher.size{]}\{\{nl\}\} @schedules = "compounding.v1"\{\{nl\}\} start = 100\{\{nl\}\} stop = 1000\{\{nl\}\} compound = 1.001\{\{nl\}\} t = 0.0\{\{nl\}\}\{\{nl\}\} {[}pretraining{]}} \tn % Row Count 22 (+ 4) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{[}initialize{]}\{\{nl\}\} vectors = \$\{paths.vectors\}\{\{nl\}\} init\_tok2vec = \$\{paths.init\_tok2vec\} \{\{nl\}\}\{\{nl\}\} {[}initialize.components{]} \{\{nl\}\} {[}initialize.tokenizer{]}} \tn % Row Count 26 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{enter in path for train.spacy and test.spacy in train and dev for {[}paths{]} respectively \newline enter in trained pipeline in vectors for {[}path{]} \newline custom rules initialized near bottom \newline \newline config file with annotations: \newline https://github.com/explosion/spaCy/blob/master/spacy/default\_config.cfg} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}