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
1/* eslint no-constant-condition:0 */2 3export interface DelimiterSpec {4 left: string;5 right: string;6 display: boolean;7}8 9export interface SplitAtDelimiterData {10 type: "text" | "math";11 data: string;12 rawData?: string;13 display?: boolean;14}15 16const findEndOfMath = function(delimiter: string, text: string, startIndex: number): number {17 // Adapted from18 // https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx19 let index = startIndex;20 let braceLevel = 0;21 22 const delimLength = delimiter.length;23 24 while (index < text.length) {25 const character = text[index];26 27 if (braceLevel <= 0 &&28 text.slice(index, index + delimLength) === delimiter) {29 return index;30 } else if (character === "\\") {31 index++;32 } else if (character === "{") {33 braceLevel++;34 } else if (character === "}") {35 braceLevel--;36 }37 38 index++;39 }40 41 return -1;42};43 44const escapeRegex = function(string: string): string {45 return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");46};47 48const amsRegex = /^\\begin{/;49 50const splitAtDelimiters = function(text: string, delimiters: DelimiterSpec[]): SplitAtDelimiterData[] {51 let index;52 const data: SplitAtDelimiterData[] = [];53 54 const regexLeft = new RegExp(55 "(" + delimiters.map((x) => escapeRegex(x.left)).join("|") + ")"56 );57 58 while (true) {59 index = text.search(regexLeft);60 if (index === -1) {61 break;62 }63 if (index > 0) {64 data.push({65 type: "text",66 data: text.slice(0, index),67 });68 text = text.slice(index); // now text starts with delimiter69 }70 // ... so this always succeeds:71 const i = delimiters.findIndex((delim) => text.startsWith(delim.left));72 index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length);73 if (index === -1) {74 break;75 }76 const rawData = text.slice(0, index + delimiters[i].right.length);77 const math = amsRegex.test(rawData)78 ? rawData79 : text.slice(delimiters[i].left.length, index);80 data.push({81 type: "math",82 data: math,83 rawData,84 display: delimiters[i].display,85 });86 text = text.slice(index + delimiters[i].right.length);87 }88 89 if (text !== "") {90 data.push({91 type: "text",92 data: text,93 });94 }95 96 return data;97};98 99export default splitAtDelimiters;100 