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

Archive

9,565 entries: 46 from X, 8,923 from Pinboard, saved 1998 to 2026.

Browse by tag, site, author, folder or language

Tags

Sites

Authors

Folders

Languages

Showing 1–50 of 2412024 ×

2024

Event Driven Systems

Drasi by Microsoft makes it easy and efficient to detect and react to changes in databases; source: github/drasi-project/drasi-platform

 It tracks system changes and events without the need to copy data to a central data lake or repeatedly query data sources. Drasi uses queries to continuously evaluate incoming data changes. When the changes match the criteria and conditions specified in these queries the result sets of these queries are updated. These updates then trigger context-aware reactions defined tuned to your specific requirements.

Drasi operates through three components:

  • Sources connect to data repositories within software systems to monitor logs and feeds to track changing data.
  • Continuous Queries interpret monitored changes by applying criteria and conditions to identify significant changes. In Drasi, these Continuous Queries are written using the Cypher Query Language.
  • Reactions trigger meaningful responses based on updates to the result sets of the Continuous Queries.

Drasi uses Cypher Query Language for Continuous Query Syntax

See also:

  • Feldera -- The Incremental Compute Engine for AI, ML and data teams. Feldera is a fast query engine with the unmatched ability to evaluate arbitrary SQL programs incrementally, over any number of live and historical data sources. Process millions of events per second and scale to larger than memory datasets, even on your laptop.. Commerical offering
  • Materialize; commercial offering.

notes#distributed-systems#event-driven-systems

nother.wiki

Status: DRAFT

nother -- a wiki software that is written using javascript / typescript, and to be deployed on cloudflare using sst.

The idea came to me after learning about otterwiki; only do this purely using cloudflare infrastructure -- workers, r2 storage, and d1 db engine, all of which are provided by cloudflare.

I registered nother.wiki domain 😬

some good ideas to consider/steal:

  • make it work for obsidian users to publish their entire vault (or parts of it?)

notes#cloudflare#ideas#javascript#nother#sst#wiki

Pair Programming with LLM

Pair Programming with Google's PaLM API.

Google Generative AI Studio: https://developers.generativeai.google/

What we need:

  • API Key from above site
  • Generative AI Libraries
    • node.js, swift or python
  • Python programming skills (https://learnpython.org)

"Larger the animal, larger the model" - pip install -q google.generativeai

import google.generativeai as palm
palm.configure(api_key="....")
for m in palm.list_models():
	print(f"{m.name}")
	print(f"{m.description}")
	print(f"{m.supported_generation_methods}\n")

notes#course#llm#programming

Python Inline Script Metadata

The PEP-723 lays out the intentions and how the metadata that can be embedded into python scripts to assist launchers, IDEs etc to interact with the script. uv was the first tool (to my knowledge) that brought this into wide attention.

Since then many python ecosystem tools have started to leverage this.

notes#python

Observability Ecosystem

Papers

Dapper, a Large-Scale Distributed Systems Tracing Infrastructure (Sigelman et al. 2010)

Collectors

  • Buz serverless, auto-scaling collector that you can deploy and run yourself. Buz collects, validates, and delivers schematized data to where it needs to bee.

Sources:

  • Event-tracking SDK's like Snowplow Analytics (Segment and others in development)
  • Self-describing payloads
  • Webhooks
  • Pixels
  • Cloudevents

Destinations:

  • Databases like Postgres, Mysql, or Clickhouse
  • Streaming tech like Pub/Sub, Kinesis, or Redpanda
  • Hybrids like Kinesis Firehose
  • Message brokers like NATS or RabbitMQ
  • Indexes like Elasticsearch or Splunk

Quickstart talks about using redpanda with Buz.

Tracing

OpenTelemetry

Providers

Observability for Distributed Services | Honeycomb; Charity Major, author of many o11y blog posts, and talks works at honeycomb.

References

notes#observability

Concurrent Programming

Lock-free programming often results in slower programs at low CPU counts. Lock-free algorithms offer better scalability (w.r.t. the number of cores). But you need to pay something to achieve that, and what you pay is single-thread performance / performance on machines with only a dozen CPUs or so (depending on the problem and amount of contention).

Lock-free programming can be very, very difficult.

Lectures

Videos

Udemy

Concepts

A set of operations can be considered atomic when two conditions are met:

  1. Until the entire set of operations completes, no other process can know about the changes being made (invisibility); and
  2. If any of the operations fail then the entire set of operations fails, and the state of the system is restored to the state it was in before any of the operations began.

C++ and Beyond 2012: Herb Sutter - atomic Weapons 1 of 2 - YouTube; the C++ memory model and modern hardware.

Memory Consistency Models

memory consistency model: how memory operations behave in the parallel computer system. This is a contract between programmer and system, wherein the system guarantees that if the programmer follows the rules, memory will be consistent and the results of memory operations will be predictable.

Causal consistency is weaker than sequential consistency, which requires that all nodes see all writes in the same order

Sequential consistency was defined by Leslie Lamport (1979) for concurrent programming, as follows: the result of any execution is the same as if the operations of all the processors were executed in some sequential order, and the operations of each individual processor appear in this sequence in the order specified by its program.

The sequence of instructions as defined by a processor’s program are interleaved with the corresponding sequences defined by the other processors’s programs to produce a global linear order of all instructions.

Mutual Exclusion principal

Mutual exclusion (often abbreviated to mutex) algorithms are used in concurrent programming to avoid the simultaneous use of a common resource, such as a global variable, by pieces of code called critical sections.

A critical section is a piece of code where a process or thread accesses a common resource.

The synchronization of access to those resources is an acute problem because a thread can be stopped or started at any time.

Mutexes are enough to handle >90% of all cases. You should resort to lock-free algos only if you know that you need them to improve scalability (or because you need the lock-freedom for some other reason, e.g., to keep worst-case time bounded in real time programs). It also depends on your system and application. If you're targeting a quad-socket NUMA system, looking at lock-free algos makes a lot more sense than when you're targeting a laptop. via

Dekker’s algorithm guarantees mutual exclusion, freedom from deadlock, and freedom from starvation.

Peterson’s algorithm is another mutual exclusion mechanism that allows two processes to share a single-use resource without conflict, using only shared memory for communication.

While Peterson’s original formulation worked with only two processes, the algorithm can be generalized for more than two, which makes it more powerful than Dekker’s algorithm.

atomic read-modify-write instruction

test-and-set

The test-and-set instruction is an instruction used to write to a memory location and return its old value as a single atomic (i.e. non-interruptible) operation.

If multiple processes may access the same memory, and if a process is currently performing a test-and-set, no other process may begin another test-and-set until the first process is done.

Compare and Swap ( CAS )

is an atomic instruction used in multithreading to achieve synchronization. It compares the contents of a memory location with a given value and, only if they are the same, modifies the contents of that memory location to a new given value. This is done as a single atomic operation. The atomicity guarantees that the new value is calculated based on up-to-date information; if the value had been updated by another thread in the meantime, the write would fail. The result of the operation must indicate whether it performed the substitution; this can be done either with a simple boolean response (this variant is often called compare-and-set), or by returning the value read from the memory location (not the value written to it). Compare and Swap - YouTub by Rob Edwards at SDSU.


there a subset of lock-free algorithms, called wait-free algorithms, the lock-free algorithms do not give real-time guarantees.

Concurrent data structures

Concurrent data structures are designed to handle simultaneous access and modification by multiple threads or processes in a concurrent computing environment. In such environments, where multiple tasks or threads are executed in parallel, traditional data structures might encounter issues like race conditions, deadlocks, and data corruption if not appropriately managed. Concurrent data structures aim to address these challenges and allow multiple threads to work with the data structure concurrently with correctness.

Mark Moir and Nir Shavit - Concurrent Data Structures ( 32 page PDF ) is a good text book material.

See ACM review article [@10.1145/1897852.1897873]

  • Concurrent linked lists -- Lock-free or non-blocking implementations ensure that insertions, deletions, and traversals can be performed concurrently without causing conflicts.
  • Concurrent hash tables -- Techniques like fine-grained locking or lock-free approaches are used to manage access to individual buckets or entries.
  • Concurrent Queues and Stacks --  Lock-free queues, such as Michael-Scott queues, are commonly used for scenarios where multiple threads need to enqueue and dequeue items.
  • Concurrent Trees -- Concurrent versions of trees, such as binary search trees and AVL trees, are designed to enable concurrent insertion, deletion, and searching operations without causing conflicts or inconsistencies.
  • Concurrent sets and maps -- They use partitioning, sharding, or lock-free strategies to handle concurrent operations, among other techniques.

Michael Scott Queues

(Michael and Scott 1996) -- paper ( PDF)

Video lecture Michael Scott — Nonblocking data structures. Part 1. - YouTube, part 2

References

  • Michael, Scott (1996). Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms.

notes#concurrent-programming

In-Memory Data Store

Valkey -- " is an open source (BSD) high-performance key/value datastore that supports a variety of workloads such as caching, message queues, and can act as a primary database. Valkey can run as either a standalone daemon or in a cluster, with options for replication and high availability. Valkey natively supports a rich collection of datatypes, including strings, numbers, hashes, lists, sets, sorted sets, bitmaps, hyperloglogs and more. You can operate on data structures in-place with an expressive collection of commands. Valkey also supports native extensibility with built-in scripting support for Lua and supports module plugins to create new commands, data types, and more."

notes#in-memory-datastore

web-components

Web Components -- "a suite of different technologies allowing you to create reusable custom elements — with their functionality encapsulated away from the rest of your code — and utilize them in your web apps."

The <template> and <slot> elements enable you to write markup templates that are not displayed in the rendered page. These can then be reused multiple times as the basis of a custom element's structure.

--

kgscialdone/facet : Web components made simple and declarative using one line include of js.

<script src="https://cdn.jsdelivr.net/gh/kgscialdone/facet@0.1.2a/facet.min.js"></script>

<template component="hello-world">
  <p>Hello, <slot>world</slot>!</p>
</template>

<hello-world></hello-world>
<hello-world>Facet</hello-world> <!-- replaces "world" with "Facet" -->

notes

ParadeDB

ParadeDB

Claims:

  • Eliminate complex sync tools like ETL, kafka, and Debizium.
  • No broken sync with elastic
  • ACID guarantees
  • Automatic cleanups by integrating with postgres's vaccum process.
  • Uses postgresql dialect
  • RDS (and Azure Postgres and Google Cloud SQL) compatible
  • S3 (and GCS and ABS) compatible
docker run \
  --name paradedb \
  -e POSTGRES_USER=pradeep \
  -e POSTGRES_PASSWORD=tigerscott \
  -e POSTGRES_DB=testdb \
  -v paradedb_data:/var/lib/postgresql/data/ \
  -p 5432:5432 \
  -d \
  paradedb/paradedb:latest

Note: I'm using podman, and I had to add registries.

Things of note: API, Ingest.

notes#elasticsearch#postgresql

textbooks

Electromagnetic Field Theory: A Problem Solving Approach | Electrical Engineering and Computer Science | MIT OpenCourseWare recommended by X/karatalaamalaka

Linear Algebra by Shilov (PDF) via X/akbirthko

Applied Mathematical Programming; This book is a reference book for 15.053, Optimization Methods in  Business Analytics, taught at MIT. This is from 1977. I suppose it's ok for fundamentals but you can probably do better going with a modern text like "Model Building in Mathematical Programming by H. Paul Williams ". MIP formulations and linearizations ( PDF ). Convex Optimization – Boyd and Vandenberghe

notes#textbooks

cybersecurity

pwn.college is an education platform for students (and other interested parties) to learn about, and practice, core cybersecurity concepts in a hands-on fashion. In martial arts terms, it is designed to take a “white belt” in cybersecurity through the journey to becoming a “blue belt”, able to approach (simple) cybersecurity competitions (CTFs) and wargames. Our philosophy is “practice makes perfect”.

notes#cybersecurity

Fill-Empty-Use-framework

From Get Ahead Of 99% Of People With Deep Work & Monk Mode - YouTube:

Install a creative daily routine. You need three habits:

  1. To fill your mind,
  2. To empty your mind.
  3. To use your mind.

When you consume too much and create too little. You get anxious. When you create too much and consume too little, you get bored because you've run out of fuel to create with. So you repeat old patterns and lose the challenge of the craft you enjoy. This is what I call the fill empty use framework.

A big picture, sustainable routine that allows you to experiment with the details. Experiment with filling your mind in the afternoon with books, podcasts, and courses. Experiment with emptying your mind in the evening with journaling, planning, or meditation. Experiment with using your mind in the morning with writing deep work and building or front-load all of those habits first thing in the morning. Or pull out a piece of paper to start the creation of a system. Plan out those three habits over a week and start doing them. If something doesn't flow, change it and try until it does.

You can't get six years of work done in six months because you aren't aware of a way to do that. You aren't aware of a way to do that because you don't have great ideas flowing through your mind. Your mind has three functions consume, connect, create , Idea flow.

If you don't connect ideas or create with ideas, they sit in your head and weigh you down. You have to actualize an idea, to discover the one that can only be discovered once it's actualized. The tracker couldn't be conceived without the plow. Well, you may or may not understand is that you can't generate a life changing idea if you haven't already acted on the boring or shallow ideas that lead to that life changing idea.

notes#framework#mental-model

tensorflow

tensorflow is a platform for machine learning.

tensorflow can be deployed on the backend, web (tensorflow.js), mobile & embedded (tensorflow-lite).

TFX is a pipeline is a sequence of components that implement an ML pipeline for production uses. The various parts of the pipeline could be: Ingest and validate data, Train and analyze model, and finally deploy to production. Various components like - ML metadata, TF validation, TF Transform, TF (algo library), TF Model Analysis, TF Serving, TFlite, TF.js come into use in the above stages of the pipeline.

notes#tensorflow

scikit-learn

Scikit-learn provides libraries for - classification, regression, clustering, dimensionality reduction, model selection, preprocessing etc.

Scitkit-learn can be (should be) installed into a python virtualenv with pip install -U scikit-learn (the -U flag stands for "upgrade"). This installation in addition may requireother popular python data science libraries like numpy, pandas, matplotlib, cython, polars, .. etc for full functionality. The basic install only installed the following.

# 2024-08-27
$ pip freeze
joblib==1.4.2
numpy==2.1.0
scikit-learn==1.5.1
scipy==1.14.1
threadpoolctl==3.5.0

See also: pytorch, and tensorflow

notes#python#scikit

observability

SigNoz/signoz: SigNoz is an open-source observability platform native to OpenTelemetry with logs, traces and metrics in a single application. An open-source alternative to DataDog, NewRelic, etc. 🔥 🖥. 👉 Open source Application Performance Monitoring (APM) & Observability tool

hyperdxio/hyperdx: Resolve production issues, fast. An open source observability platform unifying session replays, logs, metrics, traces and errors powered by Clickhouse and OpenTelemetry.

LogChef — Log Explorer for ClickHouse from Zerodha; Dec 2025.

Query billions of logs in milliseconds. Single binary, no dependencies. Point it at your ClickHouse cluster and start exploring. AI Query Assistant -- Ask in plain English and get SQL instantly.

Logchef is a validation of the premlog idea.

-- Obeservability 2.0 -- Is It Time To Version Observability? (Signs Point To Yes) – charity.wtf

  1. who uses it, and how?
  2. how do you interact with production?
  3. how do you debug?
  4. the cost model

The o11y 2.0 article mentions - Debunking the 'Three Pillars of Observability' Myth - Software Engineering Daily

Another issue with “The Three Pillars” is the very notion that we should always aspire to build software that’s appropriate for the “planet-scale” infrastructure at Google (or Facebook, or Twitter, and so on). Long story short: don’t emulate Google.

notes#observability

Copywork

Copy work as a creative writing tool:

Copy work is: You take a piece of great writing, copy it down, with a pen (or type it). Copying down what others have written helps develop the connection between you, and your writing habits. The main reason to do copy writing is to simply become a better writer.

Copy work as an educational tool: Copy work is a good practice for handwriting. It's also important for kids to be familiar with proper spelling, grammar, and a higher level of vocabulary than they can produce on their own.

notes

just

casey/just: 🤖 Just a command runner; manual.

Interesting use of Just -- Create an Internal CLI using Just

This is my justfilethat I used to generate this file. I have almost deprecated the use of taskfile.

# Default recipe (similar to 'all' in Makefile)
default: full scrapbook calendar codefiles opml papers

here0:
    ./bin/mkhtmlindex ./content/tweetstorms > ./content/tweetstorms/here0.html

scrapbook:
    bin/scraps.py

calendar:
    bin/calendarview.py

c:
    ./sitebuild

full:
    ./sitebuild --full

sync:
    /usr/bin/rsync -avz -d --delete-after -e ssh ./output/ myweb@surya.btbytes.com:/data/web/www.btbytes.com/www/

push:
    git push origin master

serve:
    cd output && python3 -m http.server 8004

setup:
    python3 -m venv venv
    venv/bin/pip install --upgrade pip setuptools wheel virtualenv
    venv/bin/pip install -r requirements.txt
    mkdir -p .cache

weekly:
    bin/python3 weekly.py

pb:
    bin/pinboard-to-sqlite posts backups/pinboard.db

codefiles:
    pygmentize -O full,style=emacs,linenos=1,lineanchors=1 -f html -l python -o content/sitebuild.html sitebuild
    pygmentize -O full,style=emacs,linenos=1,lineanchors=1 -f html -l lua -o content/filters.html pandoc/filters.lua
    pygmentize -O full,style=emacs,linenos=1,lineanchors=1 -f html -l yaml -o content/Taskfile.yml.html Taskfile.yml
    pygmentize -O full,style=emacs,linenos=1,lineanchors=1 -f html -l python -o content/opml_to_html.html bin/opml_to_html.py
    pygmentize -O full,style=emacs,linenos=1  -l python -o content/papers/papersindex.html bin/papersindex.py
    pygmentize -O full,style=emacs,linenos=1  -l python -o content/papers/papersindex.html bin/papersindex.py

opml:
    bin/opml_to_html.py

papers: nbrefs
    python bin/papersindex.py

nbrefs:
    bibtex2html  -o content/bib/nbrefs -css https://www.btbytes.com/css/semantic.css \
        --title References \
        --header "<nav><p><a href="/">Home (www.btbytes.com)</a>, <a href="nbrefs_bib.html">View .bib file</a>, <a href="nbrefs.bib">Download .bib file</a>.</p></nav>" \
        --footer "<footer><p>Generated on <code>$(shell date)</code></p></footer>" \
        content/bib/nbrefs.bib

soupault:
    soupault

clean:
    rm -rf output

notes#just#make#rust

Package Management

xplshn/dbin: 📦 Poor man's package manager. +2510 statically linked binaries in the repos! The easy to use, easy to get, suckless software distribution system. note: not available for arm64.

JReleaser is a release automation tool. Its goal is to simplify creating releases and publishing artifacts to multiple package managers while providing customizable options. However, you may also use it with projects that do not require publishing binary assets. The tool can be used to create Git releases (tag, changelog, assets), announce releases, assemble additional binaries and files to be published via package managers. JReleaser supports any kind of project regardless of its source language (Java, Node, Rust, Perl, Python, C/C++, C#, Elixir, Haskell, etc), although it provides additional benefits to Java based projects.

notes#package-manager#packaging

downthemall

Originally written on Feb 24, 20218.

NOTE 2024-08-22: parseopt2 is deprecated. This script needs to be rewritten.


#[
downthemall.nim

Download documents matching a pattern from a webpage.

Build:
  nim c -r -d:ssl -d:release downthemall.nim


Example: (downloads all the PDFs linked in the URL)
  ./downthemall https://www.btbytes.com/pl.html -A .pdf
]#

import htmlparser
import httpclient
import xmltree
import strtabs
import os
import strutils
import streams
import parseopt2

when isMainModule:
  var url: string
  var extns: seq[string]
  for kind, key, val in getopt():
    case kind
    of cmdArgument:
      url = key
    of cmdShortOption:
      case key
      of "A": extns.add(val)
    of cmdLongOption: discard
    of cmdEnd: discard

  if url == nil or extns == nil:
    echo "usage: downthemall URL -A .extension [-A .another]"
    quit(0)


  let client = newHttpClient()
  let content = client.getContent(url)
  let html = parseHtml(newStringStream(content))
  for a in html.findall("a"):
    let href = a.attrs["href"]
    for extn in extns:
      if href.endswith(extn):
        let fname = href.split('/')[^1]
        downloadFile(href, fname)
        echo "Downloaded: $1 to $2" % [href, fname]

notes#code#nim#utility

Prompt Engineering

via Let the LLM Write the Prompts: An Intro to DSPy in Compound AI Pipelines

Prompt Engineering in Python | Automatic and Programmatic Prompt Optimization | Complete Course - YouTube by Maxime Rivest; Aug 2025.

--

Tools

<poml>
  <role>you are a ... </role>
  <task>describe the .. </task>
  <output-format> use a friendly tone</output-format>
  <hint>
    <document></document>
  </hint>
  <example>
    <input></input>
  </example>

notes#anthropic#chatgpt#llm#prompts

AV Setup

Full "YouTube" setup

$1800 😱 Entire Youtube Studio Setup ON ONE DESK! - YouTube

Video setup

Lighting for YouTube Videos - Make Your Videos STAND OUT! - YouTube

  • key light
  • fill light
  • color temperature
  • rim light - creates a rim around the head, makes the subject less flat.
    • off camera, above the head
  • practicals lights
    • ambience to the shot
    • Z-strips
    • lamps
    • signs

Audio Gear

What Kind of Mic Is BEST For YouTube? (All Budgets) - YouTube

Open Questions

  • Positioning of the camera
  • Positioning of the mic
  • noise removal
  • post processing (audio)
  • post processing (video)

Services

  • StreamYard "StreamYard is a professional live streaming and recording studio in your browser. Record your content, or stream live to Facebook, YouTube, and other platforms." ; found via Static sites for data apps?! given by Robert Kosara of observable.

notes#audio#streaming#video

Coming up to speed on NLP using HuggingFace

ATTENTION CONSERVATION NOTICE: This self-study guide was prepared with the help of Claude.

Introduction to Neuro Linguistic Programming (NLP)

Applications of NLP:

  • language translation
  • grammatical error correction
  • sentiment analysis
  • fake news detection

The input for NLP is text - unstructured data.

Methods of processing data for NLP include:

  • Tokenization -- break raw text into smaller chunks (could be words or sentences).
    • Libraries for Tokenization are:
      • NLTK
      • Gensim
      • Keras
    • Methods of tokenization are:
      • white space tokenization
      • rule based tokenization
      • penn tree tokenization
      • dictionary based tokenization
      • spacy tokenization
      • moses tokenization
      • subword tokenization
        • Byte pair encoding
        • word piece encoding
        • Sentence piece encoding
        • Unigram language model
  • Stop word removal -- stop words do not add any meaning to the sentence, and can be removed.
  • Stemming
  • Normalization
  • Lemmatization
  • Parts of speech tagging

NLP Basics and Hugging Face Introduction

Overview of NLP concepts (tokenization, embeddings, etc.)

  1. Tokenization:
  2. Embeddings:
  3. General NLP Concepts:
  4. Hugging Face-specific NLP concepts:

Introduction to Hugging Face and its ecosystem

Transformers Library

  1. Official Documentation:
  2. Tutorials and Guides:
  3. Video Tutorials:
  4. Practical Guides:
  5. Key Classes and Methods:
  6. Hands-on Practice:

Explore the Transformers library, focusing on key classes and methods

For your 60-minute deep dive, I'd recommend:

  1. Start with the "Introduction to Transformers" from the Hugging Face course (15 minutes)
  2. Watch the first 20-30 minutes of the "Hugging Face Transformers Library - Full Course" video
  3. Spend the remaining time exploring the "Main Classes" section of the official documentation and try running a few examples from the Notebooks repository

Practical NLP Tasks

Text classification with pre-trained models

Named Entity Recognition (NER) using Hugging Face

  1. What is NER? NER is the task of identifying and classifying named entities (like persons, organizations, locations) in text.
  2. Hugging Face and NER: Hugging Face offers pre-trained models and easy-to-use pipelines for NER tasks.
  3. Key Components: a) Pipeline API: The simplest way to perform NER with Hugging Face. b) Pre-trained Models: Models like BERT, RoBERTa, and others fine-tuned for NER. c) Tokenizers: Essential for preprocessing text for NER tasks.
  4. Basic Usage: Here's a simple example of using Hugging Face for NER:
from transformers import pipeline

ner = pipeline("ner")
text = "Apple Inc. is headquartered in Cupertino, California."
result = ner(text)
print(result)
  1. Fine-tuning: You can fine-tune pre-trained models on your specific NER dataset for better performance.
  2. Resources:

Advanced Topics and Hands-on Practice

Fine-tuning pre-trained models

  • Fine-tuning Concept: Fine-tuning adapts a pre-trained model to a specific task or domain by training it further on a smaller, task-specific dataset.

  • Custom Datasets: These are datasets you create or obtain that are specific to your NER task or domain.

  • Process Overview: a) Prepare your dataset:

    • Format your data (typically in CoNLL format for NER)
    • Split into train/validation/test sets

    b) Load a pre-trained model:

    • Choose a model (e.g., BERT, RoBERTa) from Hugging Face

    c) Set up fine-tuning:

    • Configure training arguments
    • Create a trainer

    d) Train the model:

    • Run the fine-tuning process
    • Monitor metricse) Evaluate and use the model
  • Code Example: Here's a simplified example of fine-tuning a model for NER:

from transformers import AutoTokenizer, AutoModelForTokenClassification, TrainingArguments, Trainer
from datasets import load_dataset

# Load dataset
dataset = load_dataset("your_custom_dataset")

# Load pre-trained model and tokenizer
model = AutoModelForTokenClassification.from_pretrained("bert-base-cased")
tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")

# Tokenize dataset
def tokenize_and_align_labels(examples):
    tokenized_inputs = tokenizer(examples["tokens"], truncation=True, is_split_into_words=True)
    labels = []
    for i, label in enumerate(examples["ner_tags"]):
        word_ids = tokenized_inputs.word_ids(batch_index=i)
        previous_word_idx = None
        label_ids = []
        for word_idx in word_ids:
            if word_idx is None:
                label_ids.append(-100)
            elif word_idx != previous_word_idx:
                label_ids.append(label[word_idx])
            else:
                label_ids.append(-100)
            previous_word_idx = word_idx
        labels.append(label_ids)
    tokenized_inputs["labels"] = labels
    return tokenized_inputs

tokenized_dataset = dataset.map(tokenize_and_align_labels, batched=True)

# Set up training arguments
training_args = TrainingArguments(
    output_dir="./results",
    evaluation_strategy="epoch",
    learning_rate=2e-5,
    per_device_train_batch_size=16,
    per_device_eval_batch_size=16,
    num_train_epochs=3,
    weight_decay=0.01,
)

# Create Trainer
trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=tokenized_dataset["train"],
    eval_dataset=tokenized_dataset["validation"],
    tokenizer=tokenizer,
)

# Fine-tune the model
trainer.train()
  1. Challenges and Considerations:
  • Data quality and quantity are crucial
  • Balancing classes in your dataset
  • Overfitting on small datasets
  • Computational resources required
  1. Benefits:
  • Improved performance on domain-specific tasks
  • Ability to recognize custom entity types
  1. Resources:

Exploring the Model Hub and implementing a chosen NLP task

The Hugging Face Model Hub is a central repository for pre-trained models, and it's an excellent resource for implementing various NLP tasks. Here's an overview of exploring the Model Hub and implementing an NLP task:

  1. The Model Hub:
    • A platform hosting thousands of pre-trained models
    • Covers various NLP tasks, including translation, summarization, question answering, etc.
    • URL: https://huggingface.co/models
  2. Exploring the Model Hub:
    • Use filters to narrow down models by task, language, framework, etc.
    • Each model has a dedicated page with description, usage examples, and performance metrics
    • You can directly use models or download them for local use
  3. Implementing an NLP Task: Let's walk through the process of implementing a task using a model from the Hub. We'll use text summarization as an example.

Step 1: Find a suitable model

  • Go to the Model Hub and filter for "summarization" task
  • Choose a model, e.g., "facebook/bart-large-cnn"

Step 2: Load the model and tokenizer

from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

model_name = "facebook/bart-large-cnn"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)

Step 3: Prepare your input text

text = """ Your long text to be summarized goes here. It can be multiple sentences or paragraphs long. """

Step 4: Tokenize the input and generate the summary

inputs = tokenizer([text], max_length=1024, return_tensors="pt", truncation=True)
summary_ids = model.generate(inputs["input_ids"], max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)

Step 5: Decode and print the summary

summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True) print(summary)
  • Other Popular NLP Tasks:
    • Text Classification
    • Named Entity Recognition
    • Question Answering
    • Machine Translation
    • Sentiment Analysis
  • Best Practices:
    • Read the model card for usage instructions and limitations
    • Check the license for commercial use if applicable
    • Consider fine-tuning for domain-specific tasks
    • Be aware of potential biases in pre-trained models
  • Community Aspect:
    • You can contribute your own models to the Hub
    • Collaborate with others and build on existing work
  • Resources:

notes#claude#huggingface#nlp

Podcast interview of Sam Parr by David Perell

The episode of "How I Write" podcast is here - Sam Parr: Copywriting... What You Need to Know

I heard this episode while biking 10.7 miles on my bike.

People mentioned:

  • Dharmesh Shah
  • Scott Galloway
  • Robert Caro
  • Felix Dennis
  • Gregory David Roberts
  • Ben Franklin
  • Hunter S. Thompson
  • Neil Gaiman
  • Neil Armstrong
  • James Madison
  • Thomas Jefferson
  • Harry Dry -- Learn Great Copywriting in 76 minutes
    • Kaplan's law of words -- any words that aren't working for you, are working against you.

Books mentioned:

Websites and Products mentioned:

Concepts and Ideas:

  • AIDA (Attention, Interest, Desire, Action)
  • Copy work
  • Merism
  • Antithesis

Key takeaways:

  1. The headline is VERY important. It should be attention grabbing, and the hook should be the beginning of a slope that keeps the attention of the user going down the length of the piece - advert, article, book, ... If you nail the headline, you will nail the rest of it.

The following summary was generated by Clade from the text transcript of the video

Key topics discussed:

  • Writing viral articles and effective copy
  • Building email newsletters and media businesses
  • Reading habits and favorite books
  • Techniques for memorable writing and phrasing
  • Company vision and branding
  • The importance of speed and boldness in business

Key insights:

  • Focus on email subscribers as a core metric for media businesses
  • Use "forgotten text" like thank you pages to enhance branding
  • Study early versions of successful company websites for inspiration
  • Employ techniques like antithesis and merism for memorable phrasing
  • Read history books for entertainment and business books for enrichment
  • Define what your company stands for and against in your vision
  • Move fast and create stakes to build momentum in new projects
  • Written words have power to shape institutions and societies

notes#books#copy-writing#podcast#writing

Movies

Watched

Attention Conservation Notice

Clearly, not exhaustive, but a good time start (June 26, 2025)

Title Language Year Starring Started Finished Where Rating (max5) Comments
Arbitrage English 2012 Richar Gere 2025-05-26 2025-07-01 tubi ⭐⭐⭐
The Matador English 2005 Pierce Brosnon 2025-07-01 tubi
The Accountant 2 English 2025 Ben Affleck 2025-05-20 2025-07-02 amazon ⭐ Nothing like the first movie
A most wanted man English 2014 Philip Seymor Hoffman (story by John Le Carre) 2025-07-03 2025-07-05 amazon ⭐⭐ They didn't know how to make spy stories
The Holdover English Blueray from CCPL. Returned unwatched. Have to reborrow
The Great Beauty Italian Paolo Sorrentino Blueray from CCPL. Returned unwatched. Have to reborrow
The Hudsucker Proxy English 1994 Time Robbins; by Coeh Brothers 2025-07-06 2025-07-06 tubi ⭐⭐⭐ "Muncie, Indiana"!
Bad Moon Rising English 1986 Tommy Lee Jones 2025-07-10 tubi

Links

Why Lawrence of Arabia Still Looks Like a Billion Bucks - the background about lenses, film, photography, and directorial (David Lean) choices. Inspired by John Ford's "The Searchers", shot in Monument Valley. The music of LoA was composed by Maurice Jarre.

"Artistic Vision and Technical Innovation and sheer dedication"


Movies with the largest disparity when ranked by men and women
Movies with the largest disparity when ranked by men and women (via)

To watch

Top 4-5 classics of these actors:

  • Humphrey Bogart: Maltese Falcon, Casablanca, Treasure of the Sierra Madre, African Queen.
  • John Cazale: The Godfather The Deer Hunter Dog Day Afternoon The Godfather Part II
  • Robert DeNiro: Goodfellas Taxi Driver Heat Raging Bull
  • Marlon Brando: A Streetcar Named Desire On The Waterfront The Godfather Apocalypse Now
  • Jimmy Stewart: Mr Smith Goes to Washington The Philadelphia Story Wonderful Life Rear Window Vertigo The Man who Shot Liberty Valance
  • Daniel Day Lewis Gangs of NY Last of the Mohicans There Will Be Blood In the Name of the Father
  • Bette Davis: The Little Foxes All About Eve What Ever Happened to Baby Jane Jezebel
  • Katharine Hepburn: Woman of the Year The Philadelphia Story Guess Who's Coming to Dinner The Lion in Winter
  • Val Kilmer: Willow, Top Gun, Tombstone, Heat

James Stewart Movies

notes#movies

Andrew Carnegie

Andrew Carnegie's 45 causes of failure

  1. Habit of drifting through life without a definite major purpose
  2. Unfavorable physical heredity at birth
  3. Habit of meddlesome curiosity into other people’s affairs
  4. Inadequate preparation for the work in which one engages
  5. Lack of self-discipline
  6. Indifference towards opportunities for self-advancement
  7. Lack of ambition to aim above mediocrity
  8. Ill health (due to wrong thinking, improper diet and exercise)
  9. Unfavorable environmental influences (esp during childhood)
  10. Lack of persistence in carrying through a finish what one starts
  11. Habit of maintaining a negative mental attitude
  12. Lack of control of emotions
  13. The desire for something for nothing
  14. indecision and indefiniteness
  15. Fear of poverty, criticism, ill health, loss of love, old age, loss of liberty, death
  16. Wrong selection for mate in marriage
  17. Over caution in business and occupational relationships
  18. Excess tendency towards chance
  19. Wrong choice of associates in business or occupational work
  20. Wrong choice of a vocation or total neglect to make a choice
  21. Lack of concentration of effort leading to dissipation of time and energy
  22. Habit of indiscriminate spending
  23. Failure to budget and use time properly
  24. Lack of control of enthusiasm
  25. Intolerance, close-mindedness and prejudice
  26. Failure to cooperate with others in a spirit of harmony
  27. Craving for power or wealth not earned or based on merit
  28. Lack of a spirit of loyalty where loyalty is due
  29. Egotism and vanity not under control
  30. Exaggerated selfishness
  31. The habit of creating plans without basing them on known facts
  32. Lack of vision and imagination
  33. Failure to make mastermind alliance
  34. Failure to recognize the existence of and adapting to the power of infinite intelligence
  35. Profanity of speech (unclean and undisciplined mind)
  36. Speaking before thinking. Talking too much.
  37. Covetousness, revenge, and greed
  38. A habit of procrastination
  39. Speaking slanderously of other people
  40. Ignorance of the power of thought & lack of knowledge on the operation of the mind
  41. Lack of personal initiative
  42. Lack of self-reliance
  43. Lack of the qualities of a pleasing personality
  44. Lack of faith in oneself, fellow men and God
  45. Failure to develop the power of will through voluntary controlled habits of thought

via X

notes#people#quotes