Skip to content

Instantly share code, notes, and snippets.

View lemon-mint's full-sized avatar
🦖
Predicting Next Tokens

lemon-mint

🦖
Predicting Next Tokens
View GitHub Profile
@lemon-mint
lemon-mint / jax_attention_interface.py
Last active July 3, 2025 17:13
JAX Attention interface Example Code
import enum
import jax
import jax.numpy as jnp
import numpy as np
from typing import Optional, Literal
from flax.linen.attention import dot_product_attention_weights
from jax.sharding import Mesh, PartitionSpec as P, NamedSharding
from jax.experimental.pallas.ops.tpu.splash_attention import (
make_splash_mha,
BlockSizes
// https://github.com/gosuda/zu/blob/main/coroutine.go
package main
import (
"fmt"
"iter"
)
type Coro struct {
@lemon-mint
lemon-mint / gosuda.txt
Last active October 16, 2024 07:57
Age Public Key
age173yd8gu3fj6xtx729dm3kneqgyn3csgeqx7zhg05xg48fllx9d4qs8qk3l
@lemon-mint
lemon-mint / gist:2e927d54ec0f26604eb964c74cba16b3
Created August 27, 2024 15:22 — forked from LukasKriesch/gist:e75a0132e93ca989f8870c4f95be734b
Python translation Jina AI chunking regex
import regex as re
import requests
MAX_HEADING_LENGTH = 7
MAX_HEADING_CONTENT_LENGTH = 200
MAX_HEADING_UNDERLINE_LENGTH = 200
MAX_HTML_HEADING_ATTRIBUTES_LENGTH = 100
MAX_LIST_ITEM_LENGTH = 200
MAX_NESTED_LIST_ITEMS = 6
MAX_LIST_INDENT_SPACES = 7
@lemon-mint
lemon-mint / proposal-per-p-storage.md
Last active August 19, 2024 16:40
proposal: runtime/local: new package to provide transparent access to Per-P Local Storage

This proposal introduces a new package, runtime/local, providing an API for per-P local storage in Go. This enables efficient and race-free access to shared yet locally scoped data, like random number generator states or per-P Logger, without the overhead of locks or cas loop.

Several packages within the standard library, including runtime.fastrand and sync.Pool, already utilize per-P or per-M storage internally for performance optimization. This proposal aims to expose a similar mechanism through a public API, enables developers to leverage this approach for their own concurrency needs.

This proposal introduces the runtime/local package with the following API:

package local

// Key represents a unique identifier for accessing local storage.
@lemon-mint
lemon-mint / testRegex.js
Created August 18, 2024 15:16
Regex for chunking by using all semantic cues
// Updated: Aug. 15, 2024
// Run: node testRegex.js testText.txt
// Used in https://jina.ai/tokenizer
const fs = require('fs');
const util = require('util');
// Define variables for magic numbers
const MAX_HEADING_LENGTH = 7;
const MAX_HEADING_CONTENT_LENGTH = 200;
const MAX_HEADING_UNDERLINE_LENGTH = 200;
@lemon-mint
lemon-mint / keybase.md
Created August 9, 2021 04:51
keybase.md

Keybase proof

I hereby claim:

  • I am lemon-mint on github.
  • I am lemonmint (https://keybase.io/lemonmint) on keybase.
  • I have a public key whose fingerprint is 8441 7A53 D94F 6654 4280 77D4 39A0 CD2E 8DA7 3896

To claim this, I am signing this object:

@lemon-mint
lemon-mint / Dockerfile
Created June 28, 2020 06:49
nginx build test with docker
FROM ubuntu:20.04
RUN apt-get update && apt-get upgrade -y && apt-get install apt-utils -y && apt-get install curl wget -y
RUN wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz && tar -xvf pcre-8.44.tar.gz
RUN wget https://nginx.org/download/nginx-1.19.0.tar.gz && tar -xvf nginx-1.19.0.tar.gz
RUN wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz && tar -xvf openssl-1.1.1g.tar.gz
RUN wget https://zlib.net/zlib-1.2.11.tar.gz && tar -xvf zlib-1.2.11.tar.gz
RUN useradd --shell /usr/sbin/nologin www-data2
RUN apt-get install gcc g++ -y