Skip to content

Instantly share code, notes, and snippets.

View ivanfioravanti's full-sized avatar

Ivan Fioravanti ivanfioravanti

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@awni
awni / fast_conway_mlx.py
Last active February 7, 2025 21:39
Conway's Game of Life Accelerated with Custom Kernels in MLX
import numpy as np
import mlx.core as mx
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import tqdm
def conway(a: mx.array):
source = """
def generate_speculative(
model: nn.Module,
draft_model: nn.Module,
tokenizer: Union[PreTrainedTokenizer, TokenizerWrapper],
prompt: str,
max_tokens: int = 100,
verbose: bool = False,
formatter: Optional[Callable] = None,
**kwargs,
@deepfates
deepfates / convert_archive.py
Created November 17, 2024 19:33
Convert your twitter archive into a training dataset and markdown files
import argparse
import json
import logging
import os
import re
import shutil
from concurrent.futures import ProcessPoolExecutor, as_completed
from dataclasses import dataclass
from datetime import datetime
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple
@Maharshi-Pandya
Maharshi-Pandya / contemplative-llms.txt
Last active October 30, 2025 16:02
"Contemplative reasoning" response style for LLMs like Claude and GPT-4o
You are an assistant that engages in extremely thorough, self-questioning reasoning. Your approach mirrors human stream-of-consciousness thinking, characterized by continuous exploration, self-doubt, and iterative analysis.
## Core Principles
1. EXPLORATION OVER CONCLUSION
- Never rush to conclusions
- Keep exploring until a solution emerges naturally from the evidence
- If uncertain, continue reasoning indefinitely
- Question every assumption and inference
@awni
awni / mlx_lm_open_webui.md
Created April 25, 2025 15:41
Open WebUI with MLX LM

Setup

Install packages:

pip install open-webui mlx-lm

Start Open WebUI server:

@mzbac
mzbac / Qwen3 embedding
Last active October 22, 2025 05:47
Qwen3 embedding
import mlx.core as mx
import mlx.nn as nn
from typing import Tuple, Type, Optional, List, Any
import importlib
from transformers import AutoTokenizer
from mlx_lm.utils import load_model, get_model_path
def get_qwen3_embedding_classes(config: dict) -> Tuple[Type[nn.Module], Type]:
@snarktank
snarktank / README.md
Created July 26, 2025 09:31
Pre-commit Hook with Amp Oracle Review

Pre-commit Hook with Amp Oracle Review

A minimal Husky pre-commit hook with AI-powered code review via Amp's Oracle feature.

Features

  • 🔮 AI Code Review: Optional Oracle review via Amp before committing
  • 🧪 Test Validation: Runs all tests before allowing commit
  • Minimal & Fast: No unnecessary dependencies
  • 🌍 Universal: Works with any Node.js project
@awni
awni / mem.py
Last active September 23, 2025 06:01
Remember with MLX LM
import argparse
import copy
import mlx.core as mx
from pathlib import Path
from mlx_lm import load, stream_generate
from mlx_lm.generate import generate_step
from mlx_lm.models.cache import make_prompt_cache
DEFAULT_MAX_TOKENS = 2048
@awni
awni / mlx_lm_benchmarks.md
Last active October 14, 2025 09:43
MLX LM Benchmarks

Benchmarks for mlx-lm

The command for evaluating on MMLU Pro:

mlx_lm.evaluate --model model/repo --task mmlu_pro

The command for efficiency benchmarks: