Eric Tham (@erictham) profile picture

Energy and environmental economics interests. Please visit my blog.

Singapore
Joined May 2009
Photo by Eric Tham (@erictham)Photo by Eric Tham (@erictham)Photo by Eric Tham (@erictham)Photo by Eric Tham (@erictham)Photo by Eric Tham (@erictham)Photo by Eric Tham (@erictham)Photo by Eric Tham (@erictham)Photo by Eric Tham (@erictham)Photo by Eric Tham (@erictham)Photo by Eric Tham (@erictham)
"Understanding Transformers" is a 13-page introduction to the math behind modern language models. I'd recommend it to anyone new to the subject. It explains how text becomes vectors and how a Transformer combines the outputs of attention heads to produce a context-aware representation of each token. arxiv.org/pdf/2604.00965
44
473
14
3,507
215,599
Eric Tham retweeted
トレードを11年続けて気づいたこと。 ・相場はわからん。(大前提) ・暴落相場で「ここが底だ」と思った時ほど、まだ底じゃない。 ・どんなに上手くなっても、負ける日は必ず来る。 ・完璧な場所で買った時ほど、普通に負ける。 ・1回のトレードで人生は変わらないけど、1回の暴走で人生は壊れる。 ・トレードで壊れるのは、資金じゃなく“心”の方が先。 ・トレードとは、究極的には自分との対話。 ・勝てるようになった自分を維持する方が難しい。 ・トレードで勝てると退屈すぎて、身体が壊れる。 ・人間はトレードに向いていない。 ・勝ち続けている人は、色んな意味で人間やめてる。 ・最初はロットを上げた瞬間に別の人格が出てくる。 ・調子が悪い時ほどSNSを見るな。 ・トレードは生活に超影響する。 ・逆に、生活もトレードに超影響する。 ・どこで入るかより「どこで入らないか」が大事。 ・損切りが早いというより“決断が早い”人が稼げる。 ・予想よりも、事実の方が重要。 ・継続は才能ではなく、仕組み化された習慣。 ・買いポジを利確した後に上がるのは当たり前。 ・相場はわからん。(これが真理) でも、辞めなかった奴だけが、コツコツと資産を増やしていけるんだよな。
32
192
14
1,485
97,938
Eric Tham retweeted
I blew accounts so you don't have to. The 48 Laws of Trading:
83
1,358
46
5,501
222,646
Eric Tham retweeted
F*CK BLOOMBERG... Gemini 4 Neon just rebuilt the $32K terminal every Wall Street desk pays for & it runs on 2 free GitHub repos... it feels ILLEGAL... here's how to rebuild the $31,980-a-year Bloomberg Terminal with Gemini 4 Neon for free: 1. open Antigravity on Gemini 4 Neon & tell it to clone github.com/OpenBB-finance/Op… & Textualize/textual 2. have it pip install openbb textual: OpenBB pulls the data, Textual draws the terminal 3. tell it to build the screen: black background, amber text, a command line on top & panels for world markets, charts, news & backtests 4. type a ticker & GP, hit enter & the chart opens with daily candles & your 50 & 200 day averages 5. run textual serve & the same terminal opens in your browser how to test strategies on it: 1. have it pip install vectorbt & add a BTST panel: your rule vs buy & hold on 10 years of data 2. every test pays 0.1% fees & slippage & fills on the bar after the signal 3. read every result next to buy & hold: in our own 10-year BTC test the 50/200 trend rule cut the worst drawdown from -83% to -69% 4. run walk-forward before you trust a single number: the last 30% of the data only judges, it never tunes where to get the data for free: > prices: Nasdaq through OpenBB, no key > macro: FRED, one free key > filings: SEC EDGAR, no key > crypto: Binance through ccxt, no key > central banks: Fed, ECB & IMF, no key the exact prompt that rebuilds this terminal 1:1, same panels, same colours, live data, is in the replies ↓ i won't say anything more:
Gemini 4 Neon just replaced a whole quant team & it's honestly TERRIFYING... It's the #1 AI model in finance, ahead of Claude Opus 5.5 Plug it into Google's forecasting model & it does research, forecasts & backtests while you sleep Full setup below
45
131
7
987
128,014
Eric Tham retweeted
i am begging you... DO NOT LET YOUR AI TRADING AGENT TOUCH REAL MONEY UNTIL YOU FEED IT THESE 20 GITHUB REPOS this feels f*cking ILLEGAL... 559K combined GitHub stars. actual open-source code from Jane Street, J.P. Morgan, Bloomberg & Morgan Stanley. & you can hand the whole list to Claude, GPT or Gemini in one message your agent can pitch a trade in seconds. can it tell you what happens when that trade fills at the worst possible price? > give it an agent: 1. claude-code → Anthropic’s coding agent for building & testing your trading stack github.com/anthropics/claude… 2. skills → reusable instructions for tasks you want Claude to run the same way every time github.com/anthropics/skills 3. gemini-cli → gives Gemini access to your project files & coding tools github.com/google-gemini/gem… 4. adk-js → Google’s toolkit for building agents & wiring up their tools in JavaScript github.com/google/adk-js > straight from the pros: 5. core → Jane Street’s extended standard library for OCaml github.com/janestreet/core 6. hobbes → Morgan Stanley’s language & runtime for querying structured data github.com/morganstanley/hob… 7. blazingmq → Bloomberg’s messaging system for moving events between services github.com/bloomberg/blazing… 8. abides-jpmc-public → J.P. Morgan’s market simulator for seeing how orders interact on a simulated exchange github.com/jpmorganchase/abi… > make it work with market data: 9. lightweight-charts → TradingView’s library for candles, overlays & trade markers github.com/tradingview/light… 10. perspective → turns streaming data into interactive tables & charts github.com/perspective-dev/p… 11. csp → Point72’s engine for processing real-time data streams github.com/Point72/csp 12. mcp-toolbox → lets your agent query databases through MCP github.com/googleapis/mcp-to… > make it prove the strategy: 13. backtesting.py → runs your rule on historical candles & shows every trade it took github.com/kernc/backtesting… 14. statsmodels → tests the statistical assumptions your strategy depends on github.com/statsmodels/stats… 15. pykalman → uses Kalman filters to estimate a signal from noisy data github.com/pykalman/pykalman 16. arbitragelab → research tools for pairs trading & statistical arbitrage github.com/hudson-and-thames… > find out how ugly the losses get: 17. PyPortfolioOpt → compares portfolio allocations & their risk github.com/robertmartin8/PyP… 18. Riskfolio-Lib → optimizes portfolio weights under the risk constraints you set github.com/dcajasn/Riskfolio… 19. quantstats → shows Sharpe, drawdowns & performance in one report github.com/ranaroussi/quants… 20. empyrical-reloaded → calculates the same risk & return metrics across your backtests github.com/stefan-jansen/emp… start with 3. Claude Code or Gemini CLI to build it, lightweight-charts to see it & backtesting.py to test it paste this into your agent & say: “pick 3 repos. backtest one rule with fees & slippage. put every fill on the chart. start by showing me the worst trade.” then watch what happens to that beautiful equity curve when you turn on fees ↓
this is f*cking gold i pulled the full guide on how to build a 24/7 trading terminal with Fable 5.2 in this guide you will learn how to build your OWN trading terminal for FREE read it before everyone else starts using it:
13
48
1
408
32,718
A TEAM OF AI RESEARCHERS JUST OPEN-SOURCED THE BLOOMBERG TERMINAL FOR QUANT FINANCE. A Bloomberg Terminal costs $25,000 per year per seat. Banks pay for thousands of them. This thing reads every quant paper, every financial blog, every SEC filing, every arXiv preprint, and turns it into a searchable knowledge base. For free.
15
57
5
619
40,187
Eric Tham retweeted
If you're under 30 and broke, I'm begging you: Learn AI inference engineering. > Pick one area: GPU programming, CUDA, model optimization, quantization or distributed inference. > Lock yourself in and master the fundamentals of how models actually run. > Learn PyTorch, Triton, vLLM, TensorRT-LLM and inference serving. > Build 3–5 projects: optimize an LLM, reduce inference costs, improve latency or build a high-throughput serving system. > Benchmark everything. Learn to squeeze more tokens out of every GPU. > Make a list of 50 AI startups, GPU cloud providers and inference companies you'd love to work for. > Study their infrastructure bottlenecks and build something that solves one. > Reach out directly to founders and engineering leads. Show them your work and ask to intern. > Work your ass off for 12–18 months. Learn how production AI infrastructure actually works. > Then launch your own inference startup, optimization consultancy or GPU infrastructure company. The AI boom isn't just about building smarter models. It's about making intelligence cheaper, faster and accessible at scale. The people who figure out how to serve intelligence efficiently could capture an enormous part of the AI economy.
52
229
8
2,016
87,204
Eric Tham retweeted
This is f*cking wild. Someone open-sourced a one-person Wall Street. 7.5K stars on GitHub. Your AI agents get their own: → Research desk: market data, fundamentals, news → Quant lab: test ideas and run experiments → Prediction market workspace → Morning scans and weekly macro reviews on a schedule → Trading floor: the agent proposes a trade with its reasoning, you approve it like a git commit Plug in Claude Code and give it a task like: "Build a thesis on NVDA and tell me what would prove it wrong." Runs locally. Your files, your research, your keys. Paper trade first. 100% open source ↓
7
17
119
12,140
Eric Tham retweeted
Train your own 64M LLM from scratch in 2 hours! MiniMind is an open-source project that gives you the complete training pipeline for a small language model, implemented almost entirely from scratch in PyTorch. The current MiniMind-3 model has around 64M parameters, which makes the whole process small enough to reproduce on a single consumer GPU. You start with the tokenizer and model architecture, then actually pretrain the model on raw text before taking it through supervised fine-tuning. From there, the repo keeps going. It includes LoRA, DPO, PPO, GRPO, CISPO, tool use, Agentic RL, model distillation, and even a MoE version of the architecture. The main model structure is aligned with the Qwen3 ecosystem, and the tokenizer is built around BPE + ByteLevel with support for things like tool calls and thinking tokens. What I like is that the important parts are not hidden behind high-level training libraries. The core model, training loops, LoRA, preference optimization, and RL implementations are written directly in PyTorch, so you can actually trace what is happening during each stage. For the lightweight MiniMind Zero path, the repo estimates roughly 2 hours on a single RTX 3090 to go from pretraining to a basic conversational model. It is obviously not meant to compete with frontier LLMs. The point is that you can train the whole thing yourself and understand how an LLM goes from random weights to pretraining, instruction following, tool use, and post-training. One of the better repos if you want to learn LLM training by actually doing it. I’ve shared the GitHub repo below!
Train your own LLM from scratch! A step-by-step repo that walks you through building and training a transformer model from scratch using PyTorch. From downloading training data all the way to generating text. The architecture is built from the ground up following the original "Attention is All You Need" paper. MLP, single head attention, multi-head attention, transformer blocks, and the full transformer model - all coded and explained with detailed diagrams at each step. Training data comes from The Pile - a diverse 825GB open-source dataset covering books, articles, code, websites, and more. The repo includes scripts to download it, preprocess and tokenize it using tiktoken, store it in HDF5 format, and feed it into training batches. You can train a 13M parameter model on a single Colab T4 GPU. At 13M parameters the model starts generating proper grammar and coherent short sentences. For billion-parameter training you need at least an A100 or RTX 4090. The repo includes a full GPU compatibility table so you know exactly what's possible on your hardware. Includes a complete SFT and RLHF guide as a separate notebook for taking your trained model further. Key capabilities: • End-to-end pipeline: data download → preprocessing → training → text generation • Full transformer implementation from scratch with PyTorch • Trains models from 13M to 2B+ parameters on a single GPU • Training data from The Pile (825GB, 22 diverse datasets) • Tokenization via tiktoken (r50k_base) • SFT and RLHF guide included 100% open source. I've shared the link in the replies!
12
28
1
115
5,428
Eric Tham retweeted
DON'T LET MARKET FEAR SHAKE YOU OUT OF YOUR POSITIONS. Druckenmiller’s advice: When an investment incurs a loss, do not increase your position in a rush to break even; instead, reduce your position size and use smaller trades to regain your rhythm with the market. Here are his four key trading lessons: 1. Never rush to recover your losses...
15
53
3
352
57,174
Eric Tham retweeted
PETER LYNCH EXPLAINS EXACTLY WHAT TO DO WHEN THE STOCK MARKET GOES DOWN. THIS IS A MUST-WATCH FOR EVERY SERIOUS INVESTOR. ❌🐻
345
3,521
192
27,981
3,837,120
🚨BREAKING: New Python Library for Algorithmic Trading with AI It's called Ziplime (*not* Zipline). This is what you need to know:
10
49
1
360
31,600
Quantpedia is a goldmine for algorithmic trading strategies. 10,000s of strategies at your finger tips. But not all of them work. So let's fix that. Here are 5 profitable strategies (that actually work):
11
10
115
12,296
A TRADER SHOWED ME HIS ENTIRE ANALYSIS ON ONE NOTEBOOK PAGE 4H → 1H → 15m “4H tells me where to look.” “1H tells me what’s there.” “15m tells me when to click.” “If one of them disagrees, I don’t trade.” One page Three timeframes No clutter
25
385
11
2,083
117,802
GPU architecture, clearly explained. The usual assumption is that a faster GPU means more compute, so a chip rated for more operations per second should generate more tokens per second. That rarely holds. You can rent a top-end chip, load a model, watch utilization sit high, and still get a few dozen tokens per second out of hardware capable of a thousand trillion operations. The arithmetic units are not the limit. They spend most of their time waiting for numbers to arrive. Memory bandwidth is how fast those numbers can be delivered, and it grows far more slowly than arithmetic capability with each new generation. The H100 makes this concrete. It does 989 trillion operations per second at 16-bit precision, while its memory delivers 3.35 trillion bytes per second. Divide one by the other and you get about 295. That is how many operations the chip has to perform on every byte it fetches just to keep its arithmetic units busy. Generating a token comes nowhere close. Each weight gets multiplied by one number and added into a running total, so two operations per weight, and each weight costs 2 bytes to read at 16-bit precision. That works out to 1 operation per byte, roughly three hundred times short of what the chip needs. Once you see that, the layout of a GPU stops looking arbitrary. All of it is organized around distance, because every trip to fetch a value is the expensive part. Execution is nested in four steps, smallest first. → Thread. The smallest unit of work, doing arithmetic on its own handful of values. → Warp. A group of 32 threads that move in lockstep and share a single instruction, which is what the hardware actually schedules. → Thread block. A batch of warps, up to 32 of them or 1024 threads, handed to one compute unit and staying there until it finishes. → SM. The streaming multiprocessor, a small self-contained machine with its own arithmetic units, its own storage, and its own scheduler. An H100 has up to 132 of them. Memory is nested along the same lines, and that is the part that decides your speed. → Registers. 256 KB per SM, split so each thread gets a private slice nobody else can read. A value here already sits next to the thing that needs it, so reading it costs nothing worth measuring. → Shared memory and L1. A few hundred KB per SM. Shared memory is the only level you place things into yourself, and every thread in a block can read it, which is where the name comes from. → L2 cache. Around 50 MB sitting below all the SMs, and the first level every one of them can see. Reaching it means leaving your own SM. → HBM (High Bandwidth Memory). Around 80 GB, holding model weights, the KV cache, and activations. It sits outside the processing chip entirely, and reaching it is the slowest thing a GPU does. The nesting is what buys you speed. Anything that stays inside one SM is fast because nobody outside needs to see it, and anything the whole chip has to agree on pays for the trip down. Add up the registers across every SM and you get roughly as much storage as the L2 underneath them, which is nothing like the neat pyramid you see on a CPU. So making a GPU faster is mostly about how many round trips to HBM you can avoid. FlashAttention is the clearest case, since ordinary attention writes a large intermediate result all the way down and reads it back, while the tiled version keeps it up on the SM and runs far faster doing the same arithmetic. I wrote the full breakdown of how a GPU works, from this layout up to the ratio that sets your token rate. The article is quoted below. I have also put together a 10-week, 30-minutes-a-day roadmap for engineers who want to actually run LLM inference in production, not just read about it. Check this out: github.com/patchy631/time-to… (don't forget to star 🌟) Stay tuned for more on this!
31
44
2
253
14,338
Eric Tham retweeted
LLM Inference Engineering Roadmap Part 1: Foundations 1. Training vs Inference 2. Inference Engineering 3. Closed vs Open Models 4. Latency vs Throughput 5. Model Selection 6. Model Evaluation (Evals) Part 2: Transformers and LLM Architecture 1. Tokens 2. Token Embeddings 3. Positional Encoding 4. Transformer Architecture 5. Matrix Multiplication (Matmul) 6. Attention 7. Queries, Keys, Values 8. Causal Masking 9. Multi-Head Attention (MHA) 10. Feed-Forward Network (FFN) 11. Logits 12. Mixture of Experts (MoE) 13. Active vs Total Parameters Part 3: LLM Inference Mechanics 1. Autoregressive Generation 2. Chat Templates 3. Context Window 4. Prefill vs Decode 5. KV Cache 6. Sampling 7. Temperature 8. Top-k Sampling 9. Top-p (Nucleus) Sampling 10. Stop Tokens 11. Reasoning Models 12. Token Streaming Part 4: Performance Metrics 1. Time to First Token (TTFT) 2. Time Per Output Token (TPOT) 3. Throughput 4. End-to-End Latency 5. Latency Percentiles (P50, P90, P99) 6. Cost per Token Part 5: Bottleneck Analysis 1. Compute vs Memory Bandwidth 2. Arithmetic Intensity 3. Roofline Model 4. Compute-Bound vs Memory-Bound 5. Prefill Bottleneck (Compute) 6. Decode Bottleneck (Memory) 7. Memory Footprint 8. KV Cache Memory Calculation 9. Batching and Arithmetic Intensity Part 6: Hardware 1. CPU vs GPU 2. GPU Architecture 3. Tensor Cores 4. High-Bandwidth Memory (HBM) 5. DRAM vs SRAM 6. NVLink 7. InfiniBand 8. Groq LPU 9. Local (Edge) Inference 10. Cloud vs On-device Deployment Part 7: Software Stack 1. CUDA 2. CUDA Kernels 3. CUDA Graphs 4. Kernel Fusion 5. PyTorch 6. Inference Engines 7. OpenAI-Compatible Server Part 8: Benchmarking and Profiling 1. Performance Benchmarking 2. Traffic Simulation 3. Load Testing 4. Profiling Part 9: Attention Optimizations 1. Standard Attention Inefficiency 2. FlashAttention 3. PagedAttention 4. Multi-Query Attention (MQA) 5. Grouped-Query Attention (GQA) 6. Sliding Window Attention 7. Attention Sinks 8. KV Cache Compression Part 10: Batching and Scheduling 1. Batching 2. Static Batching 3. Continuous Batching 4. Batch Size vs Latency 5. Chunked Prefill 6. Prefill-Decode Interference Part 11: Caching 1. Prefix Caching 2. Cache-Friendly Prompt Design 3. Prompt Caching 4. KV Cache Offloading 5. Cache-Aware Routing 6. Long Context Handling Part 12: Speculative Decoding 1. Speculative Decoding 2. Rejection Sampling 3. Acceptance Rate 4. Draft-Target Speculation 5. N-gram Speculation 6. Speculation vs Batch Size Part 13: Quantization 1. Quantization 2. Number Formats 3. Post-Training Quantization (PTQ) 4. Weight-Only Quantization (W4A16) 5. Weight-Activation Quantization (W8A8) 6. KV Cache Quantization 7. Measuring Quality Impact Part 14: Model-Level Optimizations 1. Model Size vs Speed 2. LLM Routing Part 15: Parallelism 1. Why Multi-GPU 2. Model Parallelism 3. Communication Overhead 4. Data Parallelism 5. Tensor Parallelism (TP) Part 16: Disaggregation 1. Prefill-Decode Disaggregation 2. KV Cache Transfer 3. When to Disaggregate Part 17: Production Infrastructure 1. Replicas 2. Autoscaling 3. Cold Starts 4. Observability Start here: github.com/amitshekhariitbhu…
19
113
6
645
19,246
LLM engineer's handbook (30 minutes a day, 10 weeks, 50 lessons) a roadmap for llm inference serving where everything points at one service instead of scattering across demos. you get the mental model first, then serve a model, instrument it, load test it past 1000 concurrent requests, and tune it. you finish with a stack you configured yourself and a benchmark worth publishing. here is what it covers: → the roofline model, and why decode waits on memory while prefill waits on compute → vLLM internals, PagedAttention and the scheduler, read from the code → Prometheus and Grafana for TTFT, inter-token latency, and queue depth → SGLang and RadixAttention prefix reuse, benchmarked against vLLM → load testing past 1000 concurrent requests → quantization across FP16, FP8, and INT4, on quality as well as speed → speculative decoding and KV eviction, including where the gains disappear → disaggregated prefill and decode, deployed on Kubernetes → a cost, latency, and quality router with per-request token budgeting → publishing a reproducible benchmark the roadmap on GitHub: github.com/patchy631/time-to… (don't forget to star 🌟) i am also writing an article for each major topic. the first one is out, on how a GPU actually works. the article is quoted below.
46
83
577
26,860
Eric Tham retweeted
your AI trading bot is lying to you. and it doesn't even know it. i gave an agent 1,000 strategies with zero edge. pure coin flips. it still came back with a "winner." Sharpe 3.3. 10 tested → 1.5 100 tested → 2.5 1,000 tested → 3.3 10,000 tested → 3.9 the more it tests, the better the fake looks. agents made testing free. that made luck the most common result. 5 rules to catch it
Fable 5.2 is the MOST dangerous AI model right now. It gives you AGI-adjacent reasoning. That can discover new profitable trading strategies for you 24/7. If you set it up correctly, you gain super powers.
11
10
80
9,516