Skip to content

Instantly share code, notes, and snippets.

View pszemraj's full-sized avatar

Peter pszemraj

View GitHub Profile
"""
example script for inference with LFM2-VL-3B model
https://hf.co/LiquidAI/LFM2-VL-3B
"""
from transformers import AutoModelForImageTextToText, AutoProcessor
from transformers.image_utils import load_image
# Load model and processor
@pszemraj
pszemraj / encoding_visualizer.py
Last active October 1, 2025 13:21
helper scripts for tokenizer encoding viz
import argparse
import webbrowser
from pathlib import Path
from typing import Any, Callable, Optional, Union
from tokenizers import Tokenizer as RustTokenizer
from tokenizers.tools import EncodingVisualizer
from transformers import AutoTokenizer, PreTrainedTokenizerBase
SAMPLE_TEXT = '''class DyT(nn.Module):
@pszemraj
pszemraj / clipboard_helper_xclip.sh
Created September 25, 2025 02:09
cz() two letter clipboard helper for linux/xclip
# Copy file contents or stdin to clipboard
# Usage: cz [file]
# cz file.txt - copy file to clipboard
# cmd | cz - copy stdin to clipboard
# Fails on: binary files, files >10MB, non-existent files
cz() {
if [ -z "$1" ]; then
xclip -selection clipboard
elif [ -f "$1" ]; then
# Check if it's a text file
@pszemraj
pszemraj / check_md_links.py
Last active September 20, 2025 00:21
check through .md files a repo [directory] and subdirs for broken/nonexistent links to files
@pszemraj
pszemraj / wsl_clipboard.md
Created September 16, 2025 15:35
CLI/'programmatically' copy to clipboard from wsl

copy to clipboard from wsl

An adapted fn of what I use on ubuntu but leverages WSL exposing clip.exe to get stuff on your clipboard

# Copy file contents or stdin to clipboard
# Usage: cz [file]
#   cz file.txt  - copy file to clipboard
#   cmd | cz     - copy stdin to clipboard
# Fails on: binary files, files >10MB, non-existent files
@pszemraj
pszemraj / clock.html
Last active September 12, 2025 04:37
simple html clock
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Clock AI</title>
<style>
:root {
--bg: #0a0b0d;
--panel: #141518;
@pszemraj
pszemraj / lfm_1b6.py
Created September 8, 2025 07:59
LFM2-VL inference with recommended params
from transformers import AutoProcessor, AutoModelForImageTextToText
from transformers.image_utils import load_image
# Load model and processor
model_id = "LiquidAI/LFM2-VL-1.6B"
model = AutoModelForImageTextToText.from_pretrained(
model_id, device_map="auto", torch_dtype="bfloat16", trust_remote_code=True
)
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
@pszemraj
pszemraj / alacritty.toml
Created August 29, 2025 03:00
config for alacritty+0xProto
# Font configuration - all font settings in ONE section
[font]
size = 15.0
builtin_box_drawing = false # 0xProto has its own box drawing chars
[font.normal]
family = "0xProto"
style = "Regular"
[font.bold]
%%writefile emoji_search.py
#!/usr/bin/env python3
"""
Emoji Semantic Search CLI
reqs:
pip install fire sentence-transformers pandas numpy
Usage:
python emoji_search.py "that is flames"