Team Ai
Datasetpublic

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.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3kdownloads
parser.ts113 linesDownload Raw Back to src
1const COMMAND = 0;2const NUMBER = 1;3const EOD = 2;4type TokenType = 0 | 1 | 2;5 6interface PathToken {7  type: TokenType;8  text: string;9}10 11export interface Segment {12  key: string;13  data: number[];14}15 16const PARAMS: { [key: string]: number } = { A: 7, a: 7, C: 6, c: 6, H: 1, h: 1, L: 2, l: 2, M: 2, m: 2, Q: 4, q: 4, S: 4, s: 4, T: 2, t: 2, V: 1, v: 1, Z: 0, z: 0 };17 18function tokenize(d: string): PathToken[] {19  const tokens: PathToken[] = new Array();20  while (d !== '') {21    if (d.match(/^([ \t\r\n,]+)/)) {22      d = d.substr(RegExp.$1.length);23    } else if (d.match(/^([aAcChHlLmMqQsStTvVzZ])/)) {24      tokens[tokens.length] = { type: COMMAND, text: RegExp.$1 };25      d = d.substr(RegExp.$1.length);26    } else if (d.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/)) {27      tokens[tokens.length] = { type: NUMBER, text: `${parseFloat(RegExp.$1)}` };28      d = d.substr(RegExp.$1.length);29    } else {30      return [];31    }32  }33  tokens[tokens.length] = { type: EOD, text: '' };34  return tokens;35}36 37function isType(token: PathToken, type: number) {38  return token.type === type;39}40 41export function parsePath(d: string): Segment[] {42  const segments: Segment[] = [];43  const tokens = tokenize(d);44  let mode = 'BOD';45  let index = 0;46  let token = tokens[index];47  while (!isType(token, EOD)) {48    let paramsCount = 0;49    const params: number[] = [];50    if (mode === 'BOD') {51      if (token.text === 'M' || token.text === 'm') {52        index++;53        paramsCount = PARAMS[token.text];54        mode = token.text;55      } else {56        return parsePath('M0,0' + d);57      }58    } else if (isType(token, NUMBER)) {59      paramsCount = PARAMS[mode];60    } else {61      index++;62      paramsCount = PARAMS[token.text];63      mode = token.text;64    }65    if ((index + paramsCount) < tokens.length) {66      for (let i = index; i < index + paramsCount; i++) {67        const numbeToken = tokens[i];68        if (isType(numbeToken, NUMBER)) {69          params[params.length] = +numbeToken.text;70        }71        else {72          throw new Error('Param not a number: ' + mode + ',' + numbeToken.text);73        }74      }75      if (typeof PARAMS[mode] === 'number') {76        const segment: Segment = { key: mode, data: params };77        segments.push(segment);78        index += paramsCount;79        token = tokens[index];80        if (mode === 'M') mode = 'L';81        if (mode === 'm') mode = 'l';82      } else {83        throw new Error('Bad segment: ' + mode);84      }85    } else {86      throw new Error('Path data ended short');87    }88  }89  return segments;90}91 92export function serialize(segments: Segment[]): string {93  const tokens: (string | number)[] = [];94  for (const { key, data } of segments) {95    tokens.push(key);96    switch (key) {97      case 'C':98      case 'c':99        tokens.push(data[0], `${data[1]},`, data[2], `${data[3]},`, data[4], data[5]);100        break;101      case 'S':102      case 's':103      case 'Q':104      case 'q':105        tokens.push(data[0], `${data[1]},`, data[2], data[3]);106        break;107      default:108        tokens.push(...data);109        break;110    }111  }112  return tokens.join(' ');113}
Brunobkr/llama.cpp_AlgMor24_github · Team Ai