Skip to content

Instantly share code, notes, and snippets.

View CoffeeVampir3's full-sized avatar

Z CoffeeVampir3

View GitHub Profile
@CoffeeVampir3
CoffeeVampir3 / v.py
Last active September 29, 2025 21:49
Model Versioning
from safetensors.torch import save_model, load_model
from safetensors import safe_open
import json
config_dict = {'version': '1.0'}
metadata = {k: json.dumps(v) if not isinstance(v, str) else v for k, v in config_dict.items()}
save_model(model, "model.safetensors", metadata=metadata)
# ...
@CoffeeVampir3
CoffeeVampir3 / TverskyBench.py
Created September 27, 2025 04:01
Fast VS Slow Tversky Multihead Bench
import torch
import torch.nn as nn
import torch.nn.functional as F
from einops import rearrange
def tversky_multihead_similarity_vectorized_simple(x, features, prototypes, theta, alpha, beta, n_heads):
batch_size, total_dim = x.shape
d_head = total_dim // n_heads
x = rearrange(x, 'b (h d) -> b h d', h=n_heads)
import express from "npm:express";
import { randomUUID } from "node:crypto";
import { McpServer } from "npm:@modelcontextprotocol/sdk/server/mcp.js";
import { StreamableHTTPServerTransport } from "npm:@modelcontextprotocol/sdk/server/streamableHttp.js";
import { z } from "npm:zod";
const PORT = 3000;
const MCP_ENDPOINT = "/mcp";
const app = express();
[TOOL_CALLS][{"name": "add", "arguments": {"a": 5, "b": 3}}][/TOOL_CALLS]
@CoffeeVampir3
CoffeeVampir3 / sadadjnsauhd897uashd98sahd9a897udshq.ts
Created April 29, 2025 03:45
wefjuejwuiofwjeuifchwie9ofh8i0923hf89023hf892h89fh298fh289f3h892hf.ts
import { StreamingWebSocket, CancellationError } from "./streamingWebSocket.ts";
/**
* Example of client-side streaming inference implementation
* Following the exact flow described in the specification
*/
async function streamInference(
socket: StreamingWebSocket,
onContent: (content: string) => void
): Promise<void> {
@CoffeeVampir3
CoffeeVampir3 / Router.ts
Created April 23, 2025 04:32
router thing
import {
InferenceJobArguments,
InferenceProcessor,
} from "../frontend/InferenceProcessor.ts";
import { ClientStream } from "../router/clientStream.ts";
import { delay } from "https://deno.land/[email protected]/async/delay.ts";
import { StreamingState } from "./types.ts";
interface StreamingJob {
id: string;
#ifndef RULE_STREAM_HPP
#define RULE_STREAM_HPP
#include <multisampler.hpp>
#include <slot.hpp>
#include "llama.h"
#include "sampling.h"
#include <unordered_map>
#include <utility>
@CoffeeVampir3
CoffeeVampir3 / log.ixx
Created January 20, 2025 10:50
Logging
export module Logging;
import std;
/*
Works exactly like std::print. Fail and ass will show verbose logging data (failure location.)
Logging::info("hello world");
Logging::warn("{} + {}", "sweg and", 5);
Logging::fail("{} {}", "the ", " game");
Logging::ass(false == true, "False was not true"); //outputs to cerr
*/
@CoffeeVampir3
CoffeeVampir3 / quixel.js
Created September 18, 2024 02:05
quixeling
(await (async (startPage = 0, autoClearConsole = true) => {
const getCookie = (name) => {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
const callCacheApi = async (params = {}) => {
const defaultParams = {
@CoffeeVampir3
CoffeeVampir3 / Vulkan.cc
Last active August 22, 2024 11:30
CPP Module Example
export module Vulkan;
import <stdexcept>;
import Validation;
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
export namespace Vulkan {
auto CreateInstance() {
VkInstance instance;