Skip to content
AI from Scratch
EN

Tools: what to use and when

The ecosystem is enormous and it changes every month. This document sorts it by what you want to do, not by popularity.

With a warning up front: the names age, the concepts do not. If a tool on this list disappears, its replacement will do the same thing under another name.

Tool map: from intent to toolA mind map with six branches (run, get, retrieve, build, tune, measure) and the tools for each one.WHAT DO YOUWANT TO DO?RUNOllamalocally, over an APILM Studiolocally, with a windowvLLMserving manyllama.cppthe engine underneathGETHugging Facemodels and datatransformersloading themGGUF Q4_K_Mthe usual formatRETRIEVEpgvectorif you already have PostgresChromato get startedQdrantin productionrerankerthe cheapest winBUILDyour own loopSTART HERELiteLLMswitching modelsLangGraphflows with cyclesMCPstandard toolingTUNEUnslothfast LoRA, 1 GPUAxolotlby configurationtrlSFT and DPODeepSpeedseveral GPUsMEASUREpromptfootesting promptsLangfusecost and tracesRagasRAG qualityyour own 50 casesWHAT MATTERS
Tool map: from intent to tool

1. Running models on your machine

ToolWhat it isWhen you want it
Ollamaa docker run for models. ollama run llama3 and you are offgetting started in 30 seconds, scripts, a local API
LM Studioa desktop app with a graphical interfaceexploring and comparing models without touching a terminal
llama.cppthe C++ engine almost all of them run ontotal control, CPU, custom quantization
Jan · GPT4Allopen source desktop alternativesprivacy, no connection at all
MLXApple's framework for its own chipsa Mac with an M chip, maximum performance
vLLMa high-performance inference serverserving several users at once

What to choose: Ollama if you are going to program against it, LM Studio if you want to tinker. Both use llama.cpp underneath.

What you already know: Ollama and LM Studio are, in essence, your etapas/08_inferencia/02_kv_cache.py + etapas/11_servidor_chat/servidor.py, with twenty person-years of optimization on top. The loop is the same.

The GGUF format and the odd names

You will see models called Q4_K_M, Q5_K_S, Q8_0. You already know how to read them:

LabelBitsQualityWhen
Q8_08practically identicalif you have memory to spare
Q6_K6excellentthe sweet spot if it fits
Q4_K_M~4.5very goodthe de facto standard
Q4_K_S~4.1goodif Q4_K_M just barely does not fit
Q3_K_M~3.5you can telllast resort
Q2_K~2.6badalmost never worth it

The K means group-wise quantization, and you measured it yourself in stage 08.3: int4 per tensor breaks the model (+0.256 of loss), int4 in groups of 64 holds up (+0.027). That letter is the whole difference.


2. Getting models and data

ToolWhat it isWhat for
Hugging Face Hubthe GitHub of AI: models, data, demosthe default place for everything
transformersthe library that loads and runs almost any modelloading, fine-tuning, experimenting
datasetsdatasets with lazy loading and streaminglarge data without filling your disk
tokenizersBPE tokenizers in Rust, extremely fastproduction
Spacesdemos hosted free (Gradio, Streamlit)showing something that works
peftLoRA, QLoRA and other efficient fine-tuningfine-tuning without 8 GPUs
trlSFT, DPO, PPO already implementedalignment without writing it yourself
accelerateabstracts CPU/GPU/multi-GPUthe same code running everywhere

What you already know: tokenizers is your etapas/01_tokenizador/bpe.py in Rust. peft is your etapas/09_finetuning_lora/02_lora.py. trl is your etapas/10_alineamiento_dpo/01_dpo.py. You have written all of them.


3. Vector databases (for RAG)

ToolTypeWhen
FAISSa library, in memoryprototypes, up to ~1 M vectors
Chromaembedded, zero configurationgetting started. It is the SQLite of this
Qdrant · Weaviateservers, with filters and metadataproduction, self-hosted
Pineconea managed serviceyou do not want to operate anything
pgvectora PostgreSQL extensionyou already have Postgres. Start here
Elasticsearch · OpenSearchhybrid search (text + vectors)you need both

The classic mistake: setting up a vector database for 500 documents. With fewer than a few thousand chunks, a NumPy array in memory is faster and you do not have to operate anything.

And remember what you measured in stage 12.1: TF-IDF, an algorithm from 1972, beat your GPT's embeddings 88% against 25%. Before building vector infrastructure, try keyword search. In production what almost always wins is hybrid: both, fused.

Embedding models (which are NOT LLMs)

ModelNote
BGE-M3 · E5 · GTEopen, multilingual, very good
text-embedding-3 (OpenAI)paid, convenient, good quality
Cohere Embedstrong at multilingual
Reranker (BGE-reranker, Cohere Rerank)reorders the top 20. It is the cheapest improvement in all of RAG

4. Building applications and agents

ToolApproachWhen
LangChaincomplete, many integrationsrapid prototyping
LangGraphexplicit state graphsflows with cycles and fine control
LlamaIndexspecialized in RAGyour problem is retrieval
CrewAI · AutoGenmulti-agent with rolesteams of agents
PydanticAI · Instructorstructured, typed outputyou want strong validation
LiteLLMone API for 100 providersswitching models without touching code
MCP SDKconnecting tools in a standard wayreusable integrations
nothingyour own loopstart here

The loop in your stage 12 is 30 lines. Adopt a framework when something specific starts to hurt, not before.


5. Training and fine-tuning

ToolWhat it doesWhen
PyTorchthe de facto standardeverything
Axolotl · LLaMA-Factoryfine-tuning from a config filefine-tuning without writing the loop
UnslothLoRA 2-5× faster, less memorya single GPU
DeepSpeed · FSDPdistributed training, ZeROseveral GPUs
Megatron-LMserious tensor parallelismgenuine pre-training
Weights & Biases · MLflowexperiment trackingfrom day one
Modal · RunPod · LambdaGPUs by the houryou do not have hardware

docs/12-entrenamiento-distribuido.md explains what ZeRO does inside. Once you have read that, a DeepSpeed configuration stops being magic.


6. Evaluating and monitoring

The most ignored category and the one that prevents the most problems.

ToolWhat for
LangSmith · Langfusetraces, cost and latency of every call
RagasRAG-specific metrics (faithfulness, relevance)
DeepEval · promptfooautomated prompt testing
lm-evaluation-harnessthe standard benchmarks
Phoenix (Arize)observability, open source

And remember what docs/05 said: public benchmarks are contaminated. Your real evaluation is 50 examples from your case, published nowhere.


7. Closed model APIs

ProviderStrong at
Anthropic (Claude)long reasoning, code, following instructions
OpenAI (GPT)ecosystem, tooling, multimodal
Google (Gemini)enormous context, multimodal
MistralEuropean, good value
Groq · Together · Fireworksextremely fast inference of open models

Cost rule: always start with the most capable model so that it works, and then come down to the cheapest one that still passes your evaluations. The other way round wastes an enormous amount of time.


8. What to use in each case

I want to...Use
Try an open model right nowOllama
Compare models with a UILM Studio
A chatbot over my documentsLlamaIndex or pgvector + a reranker
A product with an APILiteLLM + your own code
Specialize a model in my domainUnsloth or Axolotl with LoRA
Serve many usersvLLM
Know whether my change improved anythingpromptfoo + your own cases
See what each query costsLangfuse
Train from scratchPyTorch + FSDP + a lot of money
Understand what happens insidethis project

Three pieces of advice that save months

1. Do not adopt a framework before you have the problem. Somebody else's abstractions force you to think the way they do. Start with direct calls.

2. Instrument from day one. Logging prompt, response, tokens, cost and latency takes twenty lines. Without it, two months from now you will not know why something got worse.

3. Evaluate before optimizing. "This model is better" with no test is an opinion. With a 50-case test of your own, it is a fact.


Next: 16-terminos-actuales.md