Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1import {NON_ATOMS} from "./atoms";2import type {Atom} from "./atoms";3import type SourceLocation from "./SourceLocation";4import type {AlignSpec, ColSeparationType} from "./environments/array";5import type {DelimiterSize, Mode, StyleStr} from "./types";6import type {MathFont} from "./types/fonts";7import type {Token} from "./Token";8import type {Measurement} from "./units";9export type NodeType = keyof ParseNodeTypes;10export type ParseNode<TYPE extends NodeType> = ParseNodeTypes[TYPE];11 12// ParseNode's corresponding to Symbol `Group`s in symbols.js.13export type SymbolParseNode =14 ParseNode<"atom"> |15 ParseNode<"accent-token"> |16 ParseNode<"mathord"> |17 ParseNode<"op-token"> |18 ParseNode<"spacing"> |19 ParseNode<"textord">;20 21// ParseNode from `Parser.formatUnsupportedCmd`22export type UnsupportedCmdParseNode = ParseNode<"color">;23 24// Union of all possible `ParseNode<>` types.25export type AnyParseNode = ParseNodeTypes[keyof ParseNodeTypes];26 27// Map from `NodeType` to the corresponding `ParseNode`.28type ParseNodeTypes = {29 "array": {30 type: "array";31 mode: Mode;32 loc?: SourceLocation | null | undefined;33 colSeparationType?: ColSeparationType;34 hskipBeforeAndAfter?: boolean;35 addJot?: boolean;36 cols?: AlignSpec[];37 arraystretch: number;38 body: AnyParseNode[][];39 // List of rows in the (2D) array.40 rowGaps: (Measurement | null | undefined)[];41 hLinesBeforeRow: Array<boolean[]>;42 // Whether each row should be automatically numbered, or an explicit tag43 tags?: (boolean | AnyParseNode[])[];44 leqno?: boolean;45 isCD?: boolean;46 };47 "cdlabel": {48 type: "cdlabel";49 mode: Mode;50 loc?: SourceLocation | null | undefined;51 side: string;52 label: AnyParseNode;53 };54 "cdlabelparent": {55 type: "cdlabelparent";56 mode: Mode;57 loc?: SourceLocation | null | undefined;58 fragment: AnyParseNode;59 };60 "color": {61 type: "color";62 mode: Mode;63 loc?: SourceLocation | null | undefined;64 color: string;65 body: AnyParseNode[];66 };67 "color-token": {68 type: "color-token";69 mode: Mode;70 loc?: SourceLocation | null | undefined;71 color: string;72 };73 // To avoid requiring run-time type assertions, this more carefully captures74 // the requirements on the fields per the op.js htmlBuilder logic:75 // - `body` and `value` are NEVER set simultaneously.76 // - When `symbol` is true, `body` is set.77 "op": {78 type: "op";79 mode: Mode;80 loc?: SourceLocation | null | undefined;81 limits: boolean;82 alwaysHandleSupSub?: boolean;83 suppressBaseShift?: boolean;84 parentIsSupSub: boolean;85 symbol: boolean;86 name: string;87 body?: void;88 } | {89 type: "op";90 mode: Mode;91 loc?: SourceLocation | null | undefined;92 limits: boolean;93 alwaysHandleSupSub?: boolean;94 suppressBaseShift?: boolean;95 parentIsSupSub: boolean;96 symbol: false;97 // If 'symbol' is true, `body` *must* be set.98 name?: void;99 body: AnyParseNode[];100 };101 "ordgroup": {102 type: "ordgroup";103 mode: Mode;104 loc?: SourceLocation | null | undefined;105 body: AnyParseNode[];106 semisimple?: boolean;107 };108 "raw": {109 type: "raw";110 mode: Mode;111 loc?: SourceLocation | null | undefined;112 string: string;113 };114 "size": {115 type: "size";116 mode: Mode;117 loc?: SourceLocation | null | undefined;118 value: Measurement;119 isBlank: boolean;120 };121 "styling": {122 type: "styling";123 mode: Mode;124 loc?: SourceLocation | null | undefined;125 style: StyleStr;126 resetFont?: boolean;127 body: AnyParseNode[];128 };129 "supsub": {130 type: "supsub";131 mode: Mode;132 loc?: SourceLocation | null | undefined;133 base: AnyParseNode | null | undefined;134 sup?: AnyParseNode | null | undefined;135 sub?: AnyParseNode | null | undefined;136 };137 "tag": {138 type: "tag";139 mode: Mode;140 loc?: SourceLocation | null | undefined;141 body: AnyParseNode[];142 tag: AnyParseNode[];143 };144 "text": {145 type: "text";146 mode: Mode;147 loc?: SourceLocation | null | undefined;148 body: AnyParseNode[];149 font?: string;150 };151 "url": {152 type: "url";153 mode: Mode;154 loc?: SourceLocation | null | undefined;155 url: string;156 };157 "verb": {158 type: "verb";159 mode: Mode;160 loc?: SourceLocation | null | undefined;161 body: string;162 star: boolean;163 };164 // From symbol groups, constructed in Parser.js via `symbols` lookup.165 // (Some of these have "-token" suffix to distinguish them from existing166 // `ParseNode` types.)167 "atom": {168 type: "atom";169 family: Atom;170 mode: Mode;171 loc?: SourceLocation | null | undefined;172 text: string;173 };174 "mathord": {175 type: "mathord";176 mode: Mode;177 loc?: SourceLocation | null | undefined;178 text: string;179 };180 "spacing": {181 type: "spacing";182 mode: Mode;183 loc?: SourceLocation | null | undefined;184 text: string;185 };186 "textord": {187 type: "textord";188 mode: Mode;189 loc?: SourceLocation | null | undefined;190 text: string;191 };192 // These "-token" types don't have corresponding HTML/MathML builders.193 "accent-token": {194 type: "accent-token";195 mode: Mode;196 loc?: SourceLocation | null | undefined;197 text: string;198 };199 "op-token": {200 type: "op-token";201 mode: Mode;202 loc?: SourceLocation | null | undefined;203 text: string;204 };205 // From functions.js and functions/*.js. See also "color", "op", "styling",206 // and "text" above.207 "accent": {208 type: "accent";209 mode: Mode;210 loc?: SourceLocation | null | undefined;211 label: string;212 isStretchy?: boolean;213 isShifty?: boolean;214 base: AnyParseNode;215 };216 "accentUnder": {217 type: "accentUnder";218 mode: Mode;219 loc?: SourceLocation | null | undefined;220 label: string;221 isStretchy?: boolean;222 isShifty?: boolean;223 base: AnyParseNode;224 };225 "cr": {226 type: "cr";227 mode: Mode;228 loc?: SourceLocation | null | undefined;229 newLine: boolean;230 size: Measurement | null | undefined;231 };232 "delimsizing": {233 type: "delimsizing";234 mode: Mode;235 loc?: SourceLocation | null | undefined;236 size: DelimiterSize;237 mclass: "mopen" | "mclose" | "mrel" | "mord";238 delim: string;239 };240 "enclose": {241 type: "enclose";242 mode: Mode;243 loc?: SourceLocation | null | undefined;244 label: string;245 backgroundColor?: string;246 borderColor?: string;247 body: AnyParseNode;248 };249 "environment": {250 type: "environment";251 mode: Mode;252 loc?: SourceLocation | null | undefined;253 name: string;254 nameGroup: AnyParseNode;255 };256 "font": {257 type: "font";258 mode: Mode;259 loc?: SourceLocation | null | undefined;260 font: Exclude<MathFont, "">;261 body: AnyParseNode;262 };263 "genfrac": {264 type: "genfrac";265 mode: Mode;266 loc?: SourceLocation | null | undefined;267 continued: boolean;268 numer: AnyParseNode;269 denom: AnyParseNode;270 hasBarLine: boolean;271 leftDelim: string | null | undefined;272 rightDelim: string | null | undefined;273 barSize: Measurement | null;274 };275 "hbox": {276 type: "hbox";277 mode: Mode;278 loc?: SourceLocation | null | undefined;279 body: AnyParseNode[];280 };281 "horizBrace": {282 type: "horizBrace";283 mode: Mode;284 loc?: SourceLocation | null | undefined;285 label: string;286 isOver: boolean;287 base: AnyParseNode;288 };289 "href": {290 type: "href";291 mode: Mode;292 loc?: SourceLocation | null | undefined;293 href: string;294 body: AnyParseNode[];295 };296 "html": {297 type: "html";298 mode: Mode;299 loc?: SourceLocation | null | undefined;300 attributes: Record<string, string>;301 body: AnyParseNode[];302 };303 "htmlmathml": {304 type: "htmlmathml";305 mode: Mode;306 loc?: SourceLocation | null | undefined;307 html: AnyParseNode[];308 mathml: AnyParseNode[];309 };310 "includegraphics": {311 type: "includegraphics";312 mode: Mode;313 loc?: SourceLocation | null | undefined;314 alt: string;315 width: Measurement;316 height: Measurement;317 totalheight: Measurement;318 src: string;319 };320 "infix": {321 type: "infix";322 mode: Mode;323 loc?: SourceLocation | null | undefined;324 replaceWith: string;325 size?: Measurement;326 token: Token | null | undefined;327 };328 "internal": {329 type: "internal";330 mode: Mode;331 loc?: SourceLocation | null | undefined;332 };333 "kern": {334 type: "kern";335 mode: Mode;336 loc?: SourceLocation | null | undefined;337 dimension: Measurement;338 };339 "lap": {340 type: "lap";341 mode: Mode;342 loc?: SourceLocation | null | undefined;343 alignment: string;344 body: AnyParseNode;345 };346 "leftright": {347 type: "leftright";348 mode: Mode;349 loc?: SourceLocation | null | undefined;350 body: AnyParseNode[];351 left: string;352 right: string;353 rightColor: string | null | undefined; // undefined means "inherit"354 };355 "leftright-right": {356 type: "leftright-right";357 mode: Mode;358 loc?: SourceLocation | null | undefined;359 delim: string;360 color: string | null | undefined; // undefined means "inherit"361 };362 "mathchoice": {363 type: "mathchoice";364 mode: Mode;365 loc?: SourceLocation | null | undefined;366 display: AnyParseNode[];367 text: AnyParseNode[];368 script: AnyParseNode[];369 scriptscript: AnyParseNode[];370 };371 "middle": {372 type: "middle";373 mode: Mode;374 loc?: SourceLocation | null | undefined;375 delim: string;376 };377 "mclass": {378 type: "mclass";379 mode: Mode;380 loc?: SourceLocation | null | undefined;381 mclass: string;382 body: AnyParseNode[];383 isCharacterBox: boolean;384 };385 "operatorname": {386 type: "operatorname";387 mode: Mode;388 loc?: SourceLocation | null | undefined;389 body: AnyParseNode[];390 alwaysHandleSupSub: boolean;391 limits: boolean;392 parentIsSupSub: boolean;393 };394 "overline": {395 type: "overline";396 mode: Mode;397 loc?: SourceLocation | null | undefined;398 body: AnyParseNode;399 };400 "phantom": {401 type: "phantom";402 mode: Mode;403 loc?: SourceLocation | null | undefined;404 body: AnyParseNode[];405 };406 "vphantom": {407 type: "vphantom";408 mode: Mode;409 loc?: SourceLocation | null | undefined;410 body: AnyParseNode;411 };412 "pmb": {413 type: "pmb";414 mode: Mode;415 loc?: SourceLocation | null | undefined;416 mclass: string;417 body: AnyParseNode[];418 };419 "raisebox": {420 type: "raisebox";421 mode: Mode;422 loc?: SourceLocation | null | undefined;423 dy: Measurement;424 body: AnyParseNode;425 };426 "rule": {427 type: "rule";428 mode: Mode;429 loc?: SourceLocation | null | undefined;430 shift: Measurement | null | undefined;431 width: Measurement;432 height: Measurement;433 };434 "sizing": {435 type: "sizing";436 mode: Mode;437 loc?: SourceLocation | null | undefined;438 size: number;439 body: AnyParseNode[];440 };441 "smash": {442 type: "smash";443 mode: Mode;444 loc?: SourceLocation | null | undefined;445 body: AnyParseNode;446 smashHeight: boolean;447 smashDepth: boolean;448 };449 "sqrt": {450 type: "sqrt";451 mode: Mode;452 loc?: SourceLocation | null | undefined;453 body: AnyParseNode;454 index: AnyParseNode | null | undefined;455 };456 "underline": {457 type: "underline";458 mode: Mode;459 loc?: SourceLocation | null | undefined;460 body: AnyParseNode;461 };462 "vcenter": {463 type: "vcenter";464 mode: Mode;465 loc?: SourceLocation | null | undefined;466 body: AnyParseNode;467 };468 "xArrow": {469 type: "xArrow";470 mode: Mode;471 loc?: SourceLocation | null | undefined;472 label: string;473 body: AnyParseNode;474 below: AnyParseNode | null | undefined;475 };476};477 478/**479 * Asserts that the node is of the given type and returns it with stricter480 * typing. Throws if the node's type does not match.481 */482export function assertNodeType<NODETYPE extends NodeType>(483 node: AnyParseNode | null | undefined,484 type: NODETYPE,485): ParseNode<NODETYPE> {486 if (!node || node.type !== type) {487 throw new Error(488 `Expected node of type ${type}, but got ` +489 (node ? `node of type ${node.type}` : String(node)));490 }491 492 return node as ParseNode<NODETYPE>;493}494 495/**496 * Returns the node more strictly typed iff it is of the given type. Otherwise,497 * returns null.498 */499export function assertSymbolNodeType(node: AnyParseNode | null | undefined): SymbolParseNode {500 const typedNode = checkSymbolNodeType(node);501 if (!typedNode) {502 throw new Error(503 `Expected node of symbol group type, but got ` +504 (node ? `node of type ${node.type}` : String(node)));505 }506 return typedNode;507}508 509/**510 * Returns the node more strictly typed iff it is of the given type. Otherwise,511 * returns null.512 */513export function checkSymbolNodeType(node: AnyParseNode | null | undefined): SymbolParseNode | null | undefined {514 if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) {515 return node as SymbolParseNode;516 }517 return null;518}519 