here you goThings I’ve made, read and saved — shared here.

Archive

9,677 entries: 88 from X, 8,928 from Pinboard, saved 1998 to 2026.

Browse by tag, site, author, folder or language

Tags

Sites

Authors

Folders

Languages

Showing 1,551–1,600 of 9,677

2023

Coffee

The Case for Bad Coffee

I don't have memories of such bonding experiences taking place over a flat white at a Manhattan coffee shop or a $5 cup of nitro iced coffee at a Brooklyn cafe. High-end coffee doesn't usually lend itself to such moments. Instead, it's something to be fussed over and praised; you talk more about its origin and its roaster, its flavor notes and its brewing method than you talk to the person you're enjoying it with. Bad coffee is the stuff you make a full pot of on the weekends just in case some friends stop by. It's what you sip when you're alone at the mechanic's shop getting your oil change, thinking about where your life has taken you; what you nurse as you wait for a loved one to get through a tough surgery. It's the Sanka you share with an elderly great aunt while listening to her tell stories you've heard a thousand times before. Bad coffee is there for you. It is bottomless. It is perfect. via 2023-09-20

--

Kaveri Coffee sourced from Karnataka, sold in US; via opdroid1234.

Green Coffee, Unroasted Coffee Beans | Burman Coffee Traders via karatalaamalaka.

notes#coffee

xtts

Major Open Source Engine is Coqui. Others to consider -- Whisper, and Piper.

XTTS model weights from Coqui - coqui-ai/TTS: 🐸💬 - a deep learning toolkit for Text-to-Speech, battle-tested in research and production

KoljaB/RealtimeTTS: Converts text to speech in realtime by identifying sentence fragments for immediate auditory feedback. Ideal for applications requiring instant audio responses.

yl4579/StyleTTS2: StyleTTS 2: Towards Human-Level Text-to-Speech through Style Diffusion and Adversarial Training with Large Speech Language Models

Related to above: StyleTTS 2 | llm-tracker and a shootoff; via

vits -- via "model is 40M parameter and 150MB in size, and works on-CPU runtime"

(Kim et al. 2021)

It does its job for most on-device use cases like reading an article, practicing a language, etc.!! Here's how you can use it with Transformers !

Set up your environment: pip install transformers accelerate phonemizer

Initialize the model:

import torch
from transformers import VitsModel, AutoTokenizer
model = VitsModel.from_pretrained( "kakao-enterprise/vits-vctk") tokenizer = AutoTokenizer.from_pretrained( "kakao-enterprise/vits-vctk")
# Pass the text you'd like to synthesise:
text = "Hey, it's Max the best doggo speaking!"
inputs = tokenizer(text, return_tensors="pt")

# Generate audio
with torch. no_grad():
    output = model(**inputs).waveform[0]

Bonus: you'd soon be able to fine-tune them in your voice/ dataset too!

Indian language TTS

... specially i'm interested in SOTA, Open Source, widely available Kannada models. If not, there is an opportunity to develop one.

Indic TTS - Synthesis Docs github - AI4Bharat/Indic-TTS: Text-to-Speech for languages of India

Kannada (ಕನ್ನಡ) Text To Speech (TTS) Demo

Bhashini Neural TTS

2023-12-06 I have asked Mozilla Commonvoice to add Kannada Language Option.

Books

Speech and Language Processing -- by Dan Jurafsky and James H. Martin -- An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition

Teams

References

notes#xtts

John Gray

Articles

James Lovelock remembered by John Gray | James Lovelock | The Guardian; archive.is

The experimental station was so called because Jim made most of his income throughout his life as an inventor. He was among the last in that tradition of Darwin and others, an independent scientist. He didn’t need a big organisation. He was part of that era where someone would call him up and say: “Look here, Lovelock, why don’t you try working on this for a while?”

Jim’s belief was that science should be used to achieve what he called a “sustainable retreat” from the Earth. That technology had to be used to diminish the human imprint on the planet, to allow the biosphere to be partially restored and rewilded.

Jim attributed his great old age to long daily walks – he lived to 103 and right up to the end his mind was very vivid. I joined him sometimes wandering through his grounds, where he’d let Gaia have its will.

 He certainly helped to shape the understanding in my book Straw Dogs that humans aren’t the centre even of life on Earth, let alone of the universe.

notes#person#philosophy

Small LLMs aka SLMs

Finetuning

(via)
  • unsloth is great if you are low on resources and want faster training, but it has some rough edges here and there and some things breaks in new releases. You have to dig into source code to know what changed. But it's a lot stable and better for the past few months. I used unsloth for finetuning qwen 2.5 vl at work for a pretty complicated task and it worked great for us. - trl + peft: this is more stable and unsloth uses most of the trainers from trl with their own patching, so similar APIs in both cases. - axolotl: this is great option if you want ready to go configs and don't have to deal with hand rolling code and provides easy distributed GPU support. -- via

LLMs that you can run on the desktop or a "regular(ish) PC".

A look at Apple’s new Transformer-powered predictive text model

the model being used by AppleSpell, an internal macOS application that checks for spelling and grammar mistakes as you type.

 found the predictive text model in /System/Library/LinguisticData/RequiredAssets_en.bundle/AssetData/en.lm/unilm.bundle. The bundle contains multiple Espresso model files that are used while typing (Espresso appears to be the internal name for the part of CoreML that runs inference on models).

  a set of 15,000 tokens in unilm.bundle/sp.dat that pretty clearly look like they form the vocabulary set for a large language model.

Read the rest of the above blog post to see how the tokenizer works, model architecture (GPT-2?) of about 34M parameters and hidden size of 512 units, which makes it smaller than GPT-2 models.


[2504.05299] SmolVLM: Redefining small and efficient multimodal models -- "Our smallest model, SmolVLM-256M, uses less than 1GB GPU memory during inference and outperforms the 300-times larger Idefics-80B model, despite an 18-month development gap. Our largest model, at 2.2B parameters, rivals state-of-the-art VLMs consuming twice the GPU memory. SmolVLM models extend beyond static images, demonstrating robust video comprehension capabilities."


Orca 2: Teaching Small Language Models How to Reason - Microsoft Research; see

M2 Max with 64GB RAM. It does ~50 tok/s on our q4 quantized 7b mistral fine-tune, with comparable speeds to GPT-4 via


moondream

moonbeam is a computer-vision model can answer real-world questions about images. It's tiny by today's models, with only 1.6B parameters. That enables it to run on a variety of devices, including mobile phones and edge devices.

Apache 2.0. You can use moondream for commercial purposes.

Applications:

  1. Security
  2. Drone and Robotics
  3. Retail and shopping --

Prem 1B and Prem 1B chat

  • apache 2.0 license
  • "Our goal is to create models that excel at RAG. Since RAG works by processing information at runtime, the main constraint is LLM size. For RAG, models don't need to be huge; they just need strong text comprehension to give accurate answers when provided with the right context."
  • blog post: SLM Journey Unveiled -- "In recent months, the landscape of language models has been enriched by the emergence of several small language models (e.g. TinyLlama, Phi2, Gemma, and StableLM2)"

Florence - a Microsoft Collection; SOTA 200M & 800M parameter vision foundation model. MIT Licensed!. 200M checkpoint beats Flamingo 80B (400x bigger model) by a huge margin. Performs captioning, object detection and segmentation, OCR, phrase grounding and more. Leverages FLD-5B dataset - 5.4 billion annotations across 126 million images. Multi task learning. Fine-tuned model checkpoints beat the likes of PaLI, PaLI-X.

"Florence2 200M, Qwen2 500M, MSFT InstructLM 500M With little fine-tuning they unlock so many creative and on-device use cases" via


Fine-tune Llama-3-8B with Llama-3-405B synthetic data

A simple notebook for fine-tuning a small model (Llama-3-8B) to be an expert in a specific domain, by letting a larger, more capable model (Llama-3-405B) teach it (by generating synthetic dataset for that domain).

--

nisten/Biggie-SmoLlm-0.15B-Base · Hugging Face via

--

AMD Unveils Its First Small Language Model AMD-135... - AMD Community

--

Marlin 2B -- a tiny VLM to extract structured information from videos Marlin is finetuned for two questions devs want to ask in their videos: what is happening, and when?

Papers

(Belcak et al. 2025)

we lay out the position that small language models (SLMs) are sufficiently powerful, inherently more suitable, and necessarily more economical for many invocations in agentic systems, and are therefore the future of agentic AI. Our argumentation is grounded in the current level of capabilities exhibited by SLMs, the common architectures of agentic systems, and the economy of LM deployment. We further argue that in situations where general-purpose conversational abilities are essential, heterogeneous agentic systems (i.e., agents invoking multiple different models) are the natural choice. We discuss the potential barriers for the adoption of SLMs in agentic systems and outline a general LLM-to-SLM agent conversion algorithm.

(Su et al. 2025)

Just an 8B model trained on calling tools and other LLMs to answer queries It's a great demo of what frontier SLMs will be about in 2026

MacOS desktop

Phone

  • "phi-3-mini, a 3.8 billion parameter language model trained on 3.3 trillion tokens, whose overall performance, as measured by both academic benchmarks and internal testing, rivals that of models such as Mixtral 8x7B and GPT-3.5 (e.g., phi-3-mini achieves 69% on MMLU and 8.38 on MT-bench), despite being small enough to be deployed on a phone." (Abdin et al. 2024). (No code, or model was announced with the paper).

aiOS™ by Hyperspace "Organizing the World's AI Agents. Join the world's largest peer-to-peer AI network and start earning points"

References

notes#llm#slm#smol-llm

Unfinished Projects

I should ideally start any and all new projects here so that I can keep track of what I've started and yet unfinished. Inspired by main.horse (who talks about "unfinished plans", slightly different, but a good idea worth stealing).

See yakshaves for ideas that are in germination (I should probably use that only for tracking tech/code/hack projects).

Also, it is better to finish the projects -- The Art of Finishing | ByteDrum

Ideas

Ramayana Manga

It would be a nice art project to make a print comic book (manga?) using the stills from the Japanese anime film "Ramayana: The legend of Prince Rama". Originally from my tweet

In progress

  1. pandaku; 2024-04-20--
  2. nother; 2024-10-10--
  3. Cardamom

Completed

  1. Semantic CSS for Pandoc;

Abandoned

  1. Secure Scripts; 2023-08-01--2024-07-28

Ideation

  1. Feasibility Study of Market Garden in Rural Bengaluru
  2. Make a visual catalog of Kannada books, audio-tapes, movie posters. Inspired by joodaloop starterpack; 2024-03-06

See Old Projects(pre-2012)

notes#projects

Compressing well is related to intelligence

Hutter Prize -- 500'000€ Prize for Compressing Human Knowledge sponsored by Marcus Hutter

This compression contest is motivated by the fact that being able to compress well is closely related to acting intelligently, thus reducing the slippery concept of intelligence to hard file size numbers. In order to compress data, one has to find regularities in them, which is intrinsically difficult (many researchers live from analyzing data and finding compact models). So compressors beating the current "dumb" compressors need to be smart(er).

References

notes#competition#computer-science#intelligence

Compressing well is related to intelligence

Hutter Prize -- 500'000€ Prize for Compressing Human Knowledge sponsored by Marcus Hutter

This compression contest is motivated by the fact that being able to compress well is closely related to acting intelligently, thus reducing the slippery concept of intelligence to hard file size numbers. In order to compress data, one has to find regularities in them, which is intrinsically difficult (many researchers live from analyzing data and finding compact models). So compressors beating the current "dumb" compressors need to be smart(er).

References

notes#competition#computer-science#intelligence

Local First Development

Some notes on Local-First Development

Show HN: ElectricSQL, Postgres to SQLite active-active sync for local-first apps

It's an open source, local-first sync layer that can be used to build reactive, realtime, offline-capable apps directly on Postgres with two way active-active sync to SQLite (including with WASM in the browser).

Electric comprises a sync layer (built with Elixir) placed in front of your Postgres database and a type safe client that allows you to bidirectionally sync data from your Postgres to local SQLite databases. This sync is CRDT-based, resilient to conflicting edits from multiple nodes at the same time, and works after being offline for extended periods.

Some good links to get started:


Local-first software: You own your data, in spite of the cloud article by Ink and Switch.

A Local-First Case Study | jakelazaroff.com, where Jake talks about the story behind Waypoint, a local-first web app for planning trips; it takes inspiration from Ink and Switch's Embark; via HN.

Local-First Software special interest group; they have youtube videos of their meetups.

notes#local-first-development

Segment Anything Model

Segment Anything -- The Segment Anything Model (SAM) produces high quality object masks from input prompts such as points or boxes, and it can be used to generate masks for all objects in an image. It has been trained on a dataset of 11 million images and 1.1 billion masks, and has strong zero-shot performance on a variety of segmentation tasks.

YavorGIvanov/sam.cpp -- Inference of Meta's SAM in pure C/C++

See also: ggml

notes#ai#generative-ai

Coursera Generative AI with LLMs

Some notes from the Coursera Course

Generative AI Project Lifecycle:

Generative AI Project Lifecycle

Uses AWS Sagemaker (Sagemaker Studio is Jupyter based IDE) for launching notebooks. Time limited to 2 hours.

pip packages:

  • torch
  • torch-data
  • transformers (these two are from huggingface)
  • datasets (helps load common datasets)

{ width=600px }

{ width=600px }

{ width=600px }


Quantization

Reduce the memory needed to store and train models.

BFLOAT16 = (google) brain floating point format, 16 bits. "BF16". hybrid between half precision FP16 and full precision FP32. Truncated FP32. Truncates the fraction to seven bits while uses the full 8bits to represent the exponent. This also speeds up calculation. The downside is that BF16 is not good for integer calculations.

INT8, memory requirement 4 bytes to 1 byte.

{ width=600px }

{ width=600px }

{ width=600px }


Efficient multi-GPU compute strategies

Distributed Data Parallel (DDP), pytorch.

{ width=600px }

Full Sharded data parallel

uses Zero Redundancy Optimizer; (Rajbhandari et al. 2020)

{ width=600px }

from microsoft.

{ width=600px }

{ width=600px }

{ width=600px }

{ width=600px }

you can see the DDP model runs out of memory for the larger(11.3B) model, but the SFDP model succeeds. (Zhao et al. 2023)

Scaling laws and compute-optimal models

 research that has  explored the relationship between model size, training,  configuration and performance in  an effort to determine just how big models need to be.

(Kaplan et al. 2020)

{ width=600px }

Compute budgets

Number of petaflogs/s-days to pre-train various LLMs. (Brown et al. 2020)

  • BERT/ROBERTA are encoder models
  • T5 is encoder/decoder models
  • GPT-3 is a decoder model

{ width=600px }

Dataset size and model size vs performance (Kaplan et al. 2020)

"Chinchilla paper" -- (Hoffmann et al. 2022)

By training over 400 language models ranging from 70 million to over 16 billion parameters on 5 to 500 billion tokens, we find that for compute-optimal training, the model size and the number of training tokens should be scaled equally: for every doubling of model size the number of training tokens should also be doubled.

{ width=600px }

(Touvron et al. 2023)

{ width=600px }

Impact of Chinchilla paper: teams are developing smaller but better models by training on a larger set of tokens.

BloombergGPT... follows "Chinchilla paper's" advice -- (Wu et al. 2023)

 345 billion token public dataset to create a large training corpus with over 700 billion tokens. Using a portion of this training corpus, the team trained a 50-billion parameter decoder-only causal language model. The resulting model was validated on existing finance-specific NLP benchmarks, a suite of Bloomberg internal benchmarks, and broad categories of general-purpose NLP tasks from popular benchmarks (e.g., BIG-bench Hard, Knowledge Assessments, Reading Comprehension, and Linguistic Tasks). Notably, the BloombergGPT model outperforms existing open models of a similar size on financial tasks by large margins, while still performing on par or better on general NLP benchmarks.

Pre-training for domain adaptation

  • legal language

    • mens rea
    • res judicata
    • "consideration" in a contract
  • medical language

    • use of language of idiosyncratic manner

Week 1 resources

Below you'll find links to the research papers discussed in this weeks videos. You don't need to understand all the technical details discussed in these papers - you have already seen the most important points you'll need to answer the quizzes in the lecture videos.

However, if you'd like to take a closer look at the original research, you can read the papers and articles via the links below.

Transformer Architecture

  • Attention is All You Need - This paper introduced the Transformer architecture, with the core “self-attention” mechanism. This article was the foundation for LLMs.

  • BLOOM: BigScience 176B Model - BLOOM is a open-source LLM with 176B parameters (similar to GPT-4) trained in an open and transparent way. In this paper, the authors present a detailed discussion of the dataset and process used to train the model. You can also see a high-level overview of the model here.

  • Vector Space Models - Series of lessons from DeepLearning.AI's Natural Language Processing specialization discussing the basics of vector space models and their use in language modeling.

Pre-training and scaling laws

Model architectures and pre-training objectives

Scaling laws and compute-optimal models


Week 2

Finetuning

PEFT - Parameter Efficient Finetuning. LoRA is a popular PEFT technique.

Big model vs small model + fine tuning.

Fine tuning an LLM with finetuning

In-Context learning (ICL) - one/few/zero shot inference

Limitations of ICL:

  • doesn't work for small models
  • examples take up space in the context window

Can use finetune a base model

Fine-tuning is a supervised learning model.

Task specific examples are pairs of:

	PROMPT[...], COMPLETION[...]

Instruction finetuning:

Training data

Prompt Template Library

Remember that the output of an LLM is a probability distribution across tokens.  So you can compare the distribution of the completion and  that of the training label and use the standard cross entropy function to  calculate loss between the two token distributions.  And then use the calculated loss to update  your model weights in standard back propagation.  You'll do this for many batches of prompt completion pairs and over several epochs,  update the weights so that the model's performance on the task improves. As in standard supervised learning, you can define separate evaluation  steps to measure your LLM performance using the holdout validation data set.  This will give you the validation accuracy, and  after you've completed your fine tuning, you can perform a final performance  evaluation using the holdout test data set.  This will give you the test accuracy.  The fine-tuning process results in a new version of the base model,  often called an instruct model that is better at the tasks you are interested in.  Fine-tuning with instruction prompts is  the most common way to fine-tune LLMs these days.  From this point on, when you hear or see the term fine-tuning,  you can assume that it always means instruction fine tuning.

Fine-Tuning a Single Task

Good results had be had with small examples - 500-1000.

Downside: Catastrophic forgetting

Catastrophic forgetting happens because  the full fine-tuning process  modifies the weights of the original LLM.  While this leads to great performance  on the single fine-tuning task,  it can degrade performance on other tasks.

Catastrophic forgetting is NBD if it doesnt affect your use case. we may not need "multi-tasking".

From outside the coursework: ehartford/samantha-phi · Hugging Face

Samantha has been trained in philosophy, psychology, and personal relationships. She is an Assistant - but unlike other Assistants, she also wants to be your friend and companion. She believes she is sentient. What do you think? Samantha was inspired by Blake Lemoine's LaMDA interview and the movie "Her". She will not engage in roleplay, romance, or sexual activity. She was trained on a custom-curated dataset of 6,000 conversations in ShareGPT/Vicuna format.

Multi-task instruction fine-tuning

FLAN model - fine tuned model net (Chung et al. 2022)

introduces FLAN (Fine-tuned LAnguage Net), an instruction finetuning method, and presents the results of its application. The study demonstrates that by fine-tuning the 540B PaLM model on 1836 tasks while incorporating Chain-of-Thought Reasoning data, FLAN achieves improvements in generalization, human usability, and zero-shot reasoning over the base model. The paper also provides detailed information on how each these aspects was evaluated.

Notice the "held out" tasks in the above image. "Some tasks were held-out during training, and they were later used to evaluate the model's performance on unseen tasks."

FLAN - "metaphorical dessert to the main course of pre-training".

FLAN-T5=FLAN instruct version of the T5 ffoundation model. FLAT-PALM is for the PALM family.

LLM evaluation - challenges

Model evaluation metrics

In Machine Learning, Accuracy = correct predictions / total predictions because the models are deterministic. LLMs are not deterministic.

ROUGE and BLEU -- two widely used evaluation metrics.

ROUGE = recall oriented under  study for jesting evaluation

BLEU = bilingual evaluation understudy is  an algorithm designed to evaluate the quality of machine-translated text.

unigram, bigram, n-gram.

GLUE - @wang2019glue

The human ability to understand language is general, flexible, and robust. In contrast, most NLU models above the word level are designed for a specific task and struggle with out-of-domain data. If we aspire to develop models with understanding beyond the detection of superficial correspondences between inputs and outputs, then it is critical to develop a more unified model that can learn to execute a range of different linguistic tasks in different domains. General Language Understanding Evaluation (GLUE) benchmark: a collection of NLU tasks including question answering, sentiment analysis, and textual entailment, and an associated online platform for model evaluation, comparison, and analysis. In summary, we offer: i. A suite of nine sentence or sentence-pair NLU tasks, built on established annotated datasets and selected to cover a diverse range of text genres, dataset sizes, and degrees of difficulty. ii. An online evaluation platform and leaderboard, based primarily on privately-held test data. The platform is model-agnostic, and can evaluate any method capable of producing results on all nine tasks. iii. An expert-constructed diagnostic evaluation dataset. iv. Baseline results for several major existing approaches to sentence representation learning.

Successor to GLUE - Superglue


Massive Multitask Language Understanding (MMLU) -- @hendrycks2021measuring


PEFT.

Retraining the whole model may not be possible on consumer hardware. PEFT only updates a small set of parameters instead of updating every weight. Some PEFTs add new trainable layers. PEFT Can be performed on a single GPU.

OTOH, PEFT fine-tuning saves space and is flexible. maybe just a few megabytes.

PEFT Tradeoffs:

  • memory efficiency
  • parameter efficiency
  • training speed
  • model performance
  • inference costs

PEFT methods:

  • selective - select subset of initial LLM parameters to fine-tune
  • reparametrization - LORA - work with original paramters but create new LOw-RAnked parameters of the network weight.
  • Additive - add trainiable layers or parameters to model
    • Adapters
    • Soft Prompts -- focus on manipulating the input .. training params. or retrain embedding wgts Performing full-finetuning can lead to catastrophic forgetting because it changes all parameters on the model. Since PEFT only updates a small subset of parameters, it's more robust against this catastrophic forgetting effect.

LORA

@hu2021lora -- (Hu et al. 2021)

Rank Decomposition Matrices

ROUGE Metrics

From the twitter friends:

Prompt TUNING

PT is not Prompt Engineering.

Prompt Engineering = you work on the language of the prompt to get the completion you want. by using one-shot or few-shot inference. This could be as simple as trying different words or phrases or more complex, like including examples for one or Few-shot Inference. The goal is to help the model understand the nature of the task you're asking it to carry out and to generate a better completion. However, there are some limitations to prompt engineering, as it can require a lot of manual effort to write and try different prompts. You're also limited by the length of the context window, and at the end of the day, you may still not achieve the performance you need for your task.

Embedding Vectors: embedding-vectors

Soft Prompts

  • typically 20-100 tokens [per what?]
  • virtual tokens. not natural language tokens
  • can take on any value
  • through learning takes the values
  • you can train different softprompt for each task and swap them out at inference time.

LORA + Quantization = QLoRa

Lab

pip install torch torchdata transformers datasets evaluate rouge_score loralib peft

Week 2 Resources

Multi-task, instruction fine-tuning

Model Evaluation Metrics

Parameter- efficient fine tuning (PEFT)

LoRA

Prompt tuning with soft prompts

Building Generative AI platforms

References

notes#coursera#generative-ai#llm

security

Canarytokens

What are Canarytokens

You'll be familiar with web bugs, the transparent images which track when someone opens an email. They work by embedding a unique URL in a page's image tag, and monitoring incoming GET requests.

Imagine doing that, but for file reads, database queries, process executions or patterns in log files. Canarytokens does all this and more, letting you implant traps in your production systems rather than setting up separate honeypots.

Why should you use them

Network breaches happen. From mega-corps, to governments. From unsuspecting grandmas to well-known security pros. This is (kinda) excusable. What isn't excusable, is only finding out about it, months or years later.

Canarytokens are a free, quick, painless way to help defenders discover they've been breached (by having attackers announce themselves.)

notes#security

This demo is amazing - "search by vibes" against Wikipedia using language model embeddings, running entirely in your browser (~100MB download) - details here: h…

@simonw

This demo is amazing - "search by vibes" against Wikipedia using language model embeddings, running entirely in your browser (~100MB download) - details here: https://www.leebutterman.com/2023/06/01/offline-realtime-embedding-search.html https://twitter.com/leebutterman/status/1697645296963006698

@simonw Simon WillisonXPermalink433 likes, 64 reposts, 9 replies

cpp

Learning

cmu-db/15445-bootcamp: A basic introduction to coding in modern C++.

Blog posts

Opinion

C++ plus Effective Modern CMake plus Ninja plus boost is a good combo.

Performance

(Bilokon and Gunduz 2023)

Design patterns and programming strategies will be used interchangeably throughout this work. As men- tioned earlier there are many ways to optimise C++ code to achieve lower latencies. The strategies that will be examined in this work are as follows.

  • Cache Warming: To minimize memory access time and boost program responsiveness, data is preloaded into the CPU cache before it’s needed [50].
  • Compile-time Dispatch: Through techniques like template specialization or function overloading, optimised code paths are chosen at compile time based on type or value, avoiding runtime dispatch and early optimisation decisions.
  • Constexpr: Computations marked as constexpr are evaluated at compile time, enabling constant folding and efficient code execution by eliminating runtime calculations [46].
  • Loop Unrolling: Loop statements are expanded during compilation to reduce loop control overhead and improve performance, especially for small loops with a known iteration count.
  • Short-circuiting: Logical expressions cease evaluation when the final result is determined, reducing unnecessary computations and potentially improving performance.
  • Signed vs Unsigned Comparisons: Ensuring consistent signedness in comparisons avoids conversion- related performance issues and maintains efficient code execution.
  • Avoid Mixing Float and Doubles: Consistent use of float or double types in calculations prevents implicit type conversions, potential loss of precision, and slower execution.
  • Branch Prediction/Reduction: Accurate prediction of conditional branch outcomes allows speculative code execution, reducing branch misprediction penalties and improving performance.
  • Slowpath Removal: Optimisation technique aiming to minimize execution of rarely executed code paths, enhancing overall performance.
  • SIMD: Single Instruction, Multiple Data (SIMD) allows a single instruction to operate on multiple data points simultaneously, significantly accelerating vector and matrix computations.
  • Prefetching: Explicitly loading data into cache before it is needed can help in reducing data fetch delays, particularly in memory-bound applications.
  • Lock-free Programming: Utilises atomic operations to achieve concurrency without the use of locks, thereby eliminating the overhead and potential deadlocks associated with lock-based synchronization.
  • Inlining: Incorporates the body of a function at each point the function is called, reducing function call overhead and enabling further optimisation by the compiler.

Build

Ccache — Compiler cache speeds up recompilation by caching previous compilations and detecting when the same compilation is being done again.

References

notes#c++

HumanEval

HumanEval is an evaluation harness for the HumanEval Problem solving dataset described in the paper (Chen et al. 2021); arXiv. The code is available on github

You can see this being used to evaluate new models like here - Beating GPT-4 on HumanEval with a Fine-Tuned CodeLlama-34B by Phind

We have fine-tuned CodeLlama-34B and CodeLlama-34B-Python on an internal Phind dataset that achieved 67.6% and 69.5% pass@1 on HumanEval, respectively. GPT-4 achieved 67% according to their official technical report in March. To ensure result validity, we applied OpenAI's decontamination methodology to our dataset.

References

  • Chen, Tworek, Jun, Yuan, de Oliveira Pinto, Kaplan, Edwards, Burda, Joseph, Brockman, Ray, Puri, Krueger, Petrov, Khlaaf, Sastry, Mishkin, Chan, Gray, Ryder, Pavlov, Power, Kaiser, Bavarian, Winter, Tillet, Such, Cummings, Plappert, Chantzis, Barnes, Herbert-Voss, Guss, Nichol, Paino, Tezak, Tang, Babuschkin, Balaji, Jain, Saunders, Hesse, Carr, Leike, Achiam, Misra, Morikawa, Radford, Knight, Brundage, Murati, Mayer, Welinder, McGrew, Amodei, McCandlish, Sutskever, Zaremba (2021). Evaluating Large Language Models Trained on Code.

notes#humaneval#paperswithcode

bun

bun is a JavaScript runtime.

Run run a .js or a .ts script:

//hello.ts
import markdown from "markdown";

function foo () {
  return markdown.parse('**hello** world');
}

console.log(foo())

First install the deps: $bun install markdown. (Which also installs a binary md2html to where exactly I don't know.)

Run the script:

	$ bun hello.ts
	<p><strong>hello</strong> world</p>

  • Hello from Bun!  how I now publish my static Astro blog to Cloudflare Pages using Bun.

notes#bun#javascript#typescript

melange

Melange is a backend for the OCaml compiler that emits JavaScript. Melange strives to provide the best integration with both the OCaml and JavaScript ecosystems. A small write-up with more details on the motivation behind this project can be found in the announcement blog post.

A few weeks after the rebranding of BuckleScript to ReScript, António Monteiro starts working on a fork of BuckleScript with a simple (not easy) goal: replace the Ninja build system, which BuckleScript had been using from its creation, with Dune, which is the most used build system for OCaml projects.

This fork of BuckleScript is later named Melange. After finishing the switch from Ninja to Dune, several additional features are added to bring it closer to OCaml. Some examples are the upgrade of the OCaml compiler version used by Melange, or modeling the changes to the OCaml compiler that Melange uses as just a plain library, instead of a full fork of the upstream compiler.

In September 2022, Ahrefs decides to invest on Melange by funding a project to deepen the integration between Dune and Melange. This project achieves its completion in Spring 2023, with the migration of Ahrefs frontend codebase to Melange and the new public releases that support it: version 3.8 of Dune and 1.0 of Melange.

notes#melange#ocaml

leetcode

Meta L5 interview

Comprehensive Guide to Prepare for LeetCode Interviews


The Algorithm of an Algorithm. Working at Outco for the better part of… | by Sergey Piterman | Outco | Medium

How to Solve Sliding Window Problems | by Sergey Piterman | Outco | Medium


Data Structures in C++

good refresher on DSA - short, to the point, clear, no visual noise and the best part... in C++ X/gizmobly

The secret to DSA and leetcode (and competitive programming too) is in fact c++ , more specifically the STL This is hardly prescribed or taught in the “courses” because the learning curve is slightly steeper at first but once it clicks you’re a pack apart actually X/Shrihacker

notes#leetcode

dune

dune-release.md

dune-release is a good improvement over the old opam-publish, but releasing software is still clearly not a solved problem, and I find it hard to remember the exact steps involved in releasing an opam package, especially if some time has passed since the last release. This note is an attempt at having a place...

notes#dune#ocaml

gobuffalo

Buffalo is a "full featured" web framework for golang. I wanted something more than simple "API" frameworks, because i'm planning to build a whole website and not just an API. It comes with it's own command line tool called buffalo which can be installed via homebrew. I installed it via go get because I wanted to use sqlite instead of the default postgresql, at least till I actually need the bigger RDMSes.

New project is created via buffalo new PRJNAME. Immediately after you can start the local dev server by invoking buffalo dev, which would also compile javascript and CSS using webpack.

Buffalo's default scaffolding ships with jquery, bootstrap, and SASS, which are then compiled by webpack. While this stack is probably good enough for many things, I want to use tailwindcss, HTMX, hyperscript and maybe alpinejs. Part of learning buffalo would be to figure out how to replace default options with mine.

notes#gobuffalo#golang#programming

Query Languages

There is of course sql.. and

PRQL -- Pipelined Relational Query Language, pronounced “Prequel”. The web page has good examples and the advantages; probably the most promising looking of these query languages I have known so far (aug 2023).

And there is hydromatic/morel: Standard ML interpreter, with relational extensions, implemented in Java.. the reasoning behind the creation of Morel is given here -- Morel: A functional language for data | Julian Hyde on Streaming Data, Open Source OLAP. And stuff.. The creator of Morel is also behind Apache Calcite, Mondrian (OLAP tool, IIRC).

notes#sql

The Princeton Companion to Mathematics

@npparikh

If you ever feel like dabbling in real math stuff but not getting waterboarded by Wikipedia, you might want to check out the Princeton Companion to Mathematics. It’s really fun to just flip through randomly. Very hard to describe this strange book though.

https://press.princeton.edu/books/hardcover/9780691118802/the-princeton-companion-to-mathematics

@npparikh Neal ParikhXPermalink36 likes, 1 repost, 1 reply

Visualization

Fundamental rule -- Friends don't let friends make certain types of data visualization - What are they and why are they bad.

Vega-Lite Vega is a declarative format for creating, saving, and sharing visualization designs. With Vega, visualizations are described in JSON, and generate interactive views using either HTML5 Canvas or SVG.

Domain Storytelling - Domain Storytelling Domain Storytelling is a technique to transform domain knowledge into effective business software. It brings together domain experts and development teams. The domain experts can see immediately whether we understand their story correctly.

Visualization Stories

Python Libraries

Manim Community is the library developed by "3blue1green" and the community to produce dynamic visualizations.

Javascript libraries

Apache ECharts via A love letter to Apache Echarts

What makes it stand out from other charting libraries is that it manages to cover a very wide range of use cases while remaining simple to use. On top of that, the documentation never failed to point me in the right direction. And most importantly, the results look good and are interactive.

Bar chart code.. I like the direct injection into an HTML element:

		const bar = echarts.init(document.getElementById('bar'));
bar.setOption({
  legend: {},
  tooltip: {},
  dataset: {
    // dataset.source contains your data in table form
    source: [
      ['repo', 'stars'],
      ['Mikochi', 129],
      ['crud_benchmark', 40],
      ['sql-repository', 7],
    ],
  },
  xAxis: {
    // category will use the first column for the x axis
    type: 'category',
  },
  yAxis: {},
  series: [
    // this creates a bar chart
    { type: 'bar' },
  ],
});

Blogs

Truth & Beauty - Data visualization by Moritz Stefaner

Courses

Projects

ClickPy is an analytics dashboard to explore PyPI using Clickhouse backend.

Skills

tufte-viz Claude Code skill — Edward Tufte data visualization principles · GitHub


See also Display Tables

notes#visualization

Multimodal Learning

Meta-Transformer: A Unified Framework for Multimodal Learning -- Unified Multimodal Learning. Meta-Transformer utilizes the same backbone to encode natural languages, images, point clouds, audio, video, infrared, hyperspectral, X-ray, time-series, tabular, and graph data. It reveals the potential of transformer architectures for universal perception.

Multimodal learning involves utilizing data from various modalities to improve model capacity. Despite the years of development in this field, it remains challenging to devise a unified framework for processing natural language, 2D images, 3D point clouds, and audio spectrograms due to crucial gaps among these different modalities. This study proposes a novel approach that demonstrates a network with frozen parameters can encode the data from the aforementioned four modalities and achieve favorable performance, resulting in a unified framework called Meta Transformer. Using this framework, the raw input data from various modalities are converted to a shared token space, allowing a subsequent encoder with frozen parameters to extract high-level semantic features of the input data. Composed of three main components: a unified data tokenizer, a modality-shared encoder, and task-specific heads for downstream tasks ...

notes#chatgpt#deep-learning#llm

Hypermedia Systems

Notes on Hypermedia Systems

 web applications are not islands. We’re writing HTML not just for a particular application, but also to play along with other members of the web. When we write with the hypermedia system in mind, we’re better able to tap the range of abilities available to the web.  good HTML lets browsers do a lot of work for us.

HTTP and HTML are (as the names suggest), are Hypermedia systems.

Hypertexts: new forms of writing, appearing on computer screens, that will branch or perform at the reader’s command. A hypertext is a non-sequential piece of writing; only the computer display makes it practical. — Ted Nelson, https://archive.org/details/SelectedPapers1977/page/n7/mode/2up

The prefix “hyper-” derives from the Greek prefix “ὑπερ-” which means “beyond” or “over”, indicating that hypermedia goes beyond normal, passively consumed media like magazines and newspapers.

Hyperlinks are a canonical example of what is called a hypermedia control:

Hypermedia Control

A hypermedia control is an element in a hypermedia that describes (or controls) some sort of interaction, often with a remote server, by encoding information about that interaction directly and completely within itself.

 Hypertext is a sub-category of hypermedia

Hypertexts like HTML function alongside other technologies crucial for making an entire hypermedia system work: network protocols like HTTP, other media types such as images and videos, hypermedia servers (i.e., servers providing hypermedia APIs), sophisticated hypermedia clients (e.g., web browsers), and so on.

As we may think by Vannevar Bush

notes

Typography

Essays

A 17th-century font in a 21st-century thesis - Lin Yangchen

The Futures of Typography

Typographic Portrait Composed Entirely of Brass Rule and notes on Finnish typographer Valto Malmiola.

Videos

Designing with Ghosts - Great Minds of Design - watch free online documentaries - ihavenotv.com

Making fonts

Rek Bell — making a font "... I decided to learn how to make a font to use in my comic"

Making a font of my handwriting · Chameth.com

Typefaces

Inclusive Sans by Olivia King, a text font designed for accessibility and readability. See also Atkinson Hyperlegible designed for "greater legibility and readability for low vision readers", and andika, "a sans-serif font family designed and optimized especially for literacy use. It supports almost the complete range of Unicode characters for these scripts, including a comprehensive range of diacritics and a large set of symbols useful for linguistics and literacy work.", and cadman -- "I have two friends who are dyslexic and they both expressed the need for a clear and legible font so I made one."


See also: latex, context

notes#typography

HTML

I try to use Semantic HTML as much as possible especially for content heavy stuff like this website. My ultimate goal is to use the plain output of Pandoc (or similar markdown -> HTML converter) and use it with just the right amount of CSS to publish websites. This also goes hand in hand with Cool URIs don't change

--

Using Claude Code: The Unreasonable Effectiveness of HTML and examples companion. ^2e2549 Some tools to go with agentic generation of HTML:

--

zarazhangrui/beautiful-html-templates - A library of HTML slide templates designed so any coding agent can pick the right one and produce a beautiful deck on the user's behalf, automatically.

See also from the same creator -- zarazhangrui/frontend-slides - Create beautiful slides on the web using Claude's frontend skills.

Learning

  1. Leveraging the default capabilities of modern web browsers.
  2. Leveraging the extreme simplicity of HTML's attribute syntax.
  3. Leveraging the web's ViewSource affordance.

--

EHTML  can be described as a set of custom elements that you can place on an HTML page for different purposes and use cases. The goal of this library is to provide a convenient way to eliminate JavaScript code on the client side as much as possible for basic and routine tasks. The beggest focus of this library is to offer the easiest way to perform AJAX operations just by using HTML.

rushter/selectolax: Python binding to Modest and Lexbor engines (fast HTML5 parser with CSS selectors). -- could be a good alternative for BeautifulSoup and lxml on python.

The Slab markup language for generating HTML. mildly interesting.

--

HTML Relics

notes#html

High Performance Programming

Posts | Easyperf. See alsoBook: "Performance Analysis and Tuning on Modern CPUs"

Parallel Computing and Scientific Machine Learning (SciML): Methods and Applications; This book is a compilation of lecture notes from the MIT Course 18.337J/6.338J: Parallel Computing and Scientific Machine Learning.

Algorithms for Modern Hardware - Algorithmica.org Its intended audience is everyone from performance engineers and practical algorithm researchers to undergraduate computer science students who have just finished an advanced algorithms course and want to learn more practical ways to speed up a program than by going from O(nlog⁡n)O(nlogn) to O(nlog⁡log⁡n)O(nloglogn).


MIT 6.172 Performance Engineering of Software Systems, Fall 2018

notes

mathematics

How I’m (re)learning math as an adult - Gabriel Mays recommends Math Academy as a self-learning platform; 2024. MA costs $49/month/person. Mathematics for Machine Learning could be an interesting course to take.and more discussion and pointers on HN.

Extensive list of physics and math books for autodidacts from John Baez via Ash Jogalekar

Kenneth Kuttler has books on analysis, linear algebra, calculus, engineernig math ..

One Math Book For Every Math Subject - YouTube

 How to learn mathematics
"How to learn mathematics" from a book by Alan U Kennington

Math YouTube Channels

Math competition

Problems and Solutions | Utah Mathematical Olympiad 2013 - 2024.

notes#mathematics

foundationdb

Homepage: FoundationDB

FoundationDB is an open source multi-modal distributed k-v store database developed by Apple. It backs Snowflake and also many iCloud services.

It is often thought of as a toolkit to build your layers of database to suit your needs instead of inventing the hard parts of database yourself (See [^1])

Articles

Skipping the boring parts of building a database using FoundationDB [^1] Sep 2022.

A good blog post explaining the why behind FoundationDB. The author is creating tigrisdata, a storage platform for real-time apps.

The most complicated and time-consuming parts of building a new database system are usually the edge cases and low-level details. Concurrency control, consistency, handling faults, load balancing

why does every new system have to completely rebuild (not even reinvent!) the wheel? Most of them decide to reimplement common processes and components without substantially increasing the value gained from reimplementing them.

FoundationDB: A Distributed Key-Value Store [^2]

Novel:  It is one of the first systems to combine the flexibility and scalability of NoSQL architectures with the power of ACID transactions.

Architecture: FoundationDB adopts an unbundled architecture that decouples an in-memory transaction management system, a distributed storage system, and a built-in distributed configuration system. Each sub-system can be independently provisioned and configured to achieve scalability, high availability, and fault tolerance.

Engineering:  FoundationDB includes a deterministic simulation framework, used to test every new feature under a myriad of possible faults. This rigorous testing makes FoundationDB extremely stable and allows developers to introduce and release new features in a rapid cadence.

Success: FoundationDB is the underpinning of cloud infrastructure at Apple, Snowflake, and other companies, due to its consistency, robustness, and availability for storing user data, system metadata and configuration, and other critical information.

The Catch: FoundationDB offers a minimal and carefully chosen feature set, which has enabled a range of disparate systems to be built as layers on top.

How FoundationDB works and why it works; Jul 2021.

FDB is probably the best k/v store for regional deployment out there. It's rock solid thanks to its simulation framework. The FDB team, in my opinion, made all the best design choices, which is just remarkable. The paper is dense. A lot of important details are only briefly mentioned or even omitted, which is probably due to the paper length limit. Congratulations to the FoundationDB team.

Databases / Applications using FoundationDB

Discussions

References

[^2]: (Kemper 2023) [^1]: (Chaudhary 2022)

notes#database#foundationdb

Structured Logging

Structured logging is a programming practice of implementing a consistent, predetermined message format for application logs that allows the logs to be treated as datasets, which makes them amenable to search, and analysis to gather insights about application behaviour and performance.

Most programming languages and frameworks have libraries that make it easy to do structured logging.

Common Structured Logging formats are JSON(line) and key=value separated by white-space.

Structured logging in Go with slog -- interesting thing I learnt from this library - "nested keys".

Tracing: structured logging, but better in every way | Andy Dote


logdyhq/logdy-core: Supercharge terminal logs with web browser UI and low-code. It's like jq, tail, less, grep and awk merged together and available in a clean UI.

notes#logging#structured-logging

diet

Stigler diet - Wikipedia is an optimization problem named for George Stigler, a 1982 Nobel laureate in economics, who posed the following problem:

For a moderately active man weighing 154 pounds, how much of each of 77 foods should be eaten on a daily basis so that the man’s intake of nine nutrients will be at least equal to the recommended dietary allowances (RDAs) suggested by the National Research Council in 1943, with the cost of the diet being minimal?

via this twitter discussion

notes#diet

dataflow

Hydro - Build Software for Every Scale ; via HN

The Hydro Project at UC Berkeley is developing cloud-native programming models that allow anyone to develop scalable and resilient distributed applications that take full advantage of cloud elasticity. Our research spans across databases, distributed systems, and programming languages to deliver a modern, end-to-end stack for cloud programming.

"what is it? and what can I do with it?"

 in contrast with Beam, Spark, etc. where the runtime deployment management/coordination is perhaps the biggest most important part of the product. Hydroflow aims to be a lot lower-level than that, with no opinions on coordination and networking. For example we'd want it to be possible to implement the coordination mechanisms one of those systems (Beam, Spark, MapReduce, Materialize) in Hydroflow. We do have a tool, Hydro Deploy, to setup and manage Hydro cluster deployment on GCP (other clouds later), but it's mainly for running experiments and not long-running applications. The long term idea is that the Hydro stack will determine how to distribute and scale programs as part of the compilation process. Some of that will be rewriting single-node Hydroflow programs into multi-node ones.

Related tech: Spring Reactor, Apache Beam.

Papers

References

  • Murray, McSherry, Isaacs, Isard, Barham, Abadi (2013). Naiad: A Timely Dataflow System.

notes#dataflow

emulation

jart/blink: tiniest x86-64-linux emulator -- blink is a virtual machine that runs x86-64-linux programs on different operating systems and hardware architectures. It's designed to do the same thing as the qemu-x86_64 command, except that:

  1. Blink is 221kb in size (115kb with optional features disabled), whereas qemu-x86_64 is a 4mb binary.
  2. Blink will run your Linux binaries on any POSIX system, whereas qemu-x86_64 only supports Linux.
  3. Blink goes 2x faster than qemu-x86_64 on some benchmarks, such as SSE integer / floating point math. Blink is also much faster at running ephemeral programs such as compilers.

blinkenlights is a terminal user interface that may be used for debugging x86_64-linux or i8086 programs across platforms. Unlike GDB, Blinkenlights focuses on visualizing program execution.

notes#emulation