Skip to content

Instantly share code, notes, and snippets.

View GiulioCMSanto's full-sized avatar

Giulio Cesare Mastrocinque Santo GiulioCMSanto

View GitHub Profile
@GiulioCMSanto
GiulioCMSanto / llm-wiki.md
Created August 11, 2026 21:46 — forked from karpathy/llm-wiki.md
llm-wiki

LLM Wiki

A pattern for building personal knowledge bases using LLMs.

This is an idea file, it is designed to be copy pasted to your own LLM Agent (e.g. OpenAI Codex, Claude Code, OpenCode / Pi, or etc.). Its goal is to communicate the high level idea, but your agent will build out the specifics in collaboration with you.

The core idea

Most people's experience with LLMs and documents looks like RAG: you upload a collection of files, the LLM retrieves relevant chunks at query time, and generates an answer. This works, but the LLM is rediscovering knowledge from scratch on every question. There's no accumulation. Ask a subtle question that requires synthesizing five documents, and the LLM has to find and piece together the relevant fragments every time. Nothing is built up. NotebookLM, ChatGPT file uploads, and most RAG systems work this way.

@GiulioCMSanto
GiulioCMSanto / Processing Input Image
Created September 22, 2019 19:50
Classifying Flowers With Transfer Learning
def process_image(image):
''' Scales, crops, and normalizes a PIL image for a PyTorch model,
returns an Numpy array
'''
# TODO: Process a PIL image for use in a PyTorch model
#Loading image with PIL (https://pillow.readthedocs.io/en/latest/reference/Image.html)
im = Image.open(image)
@GiulioCMSanto
GiulioCMSanto / Saving the Model (Ckeckpoint)
Created September 22, 2019 16:05
Classifying Flowers With Transfer Learning
#Extract the class_to_idx transformation
model.class_to_idx = train_data.class_to_idx
#Put the model in CPU mode to allow predictions without having CUDA
model.to('cpu')
#Create the checkpoint
checkpoint = {'input_size':25088,
'output_size':102,
'hidden_layers':[each.out_features for each in classifier.hidden_layers],
@GiulioCMSanto
GiulioCMSanto / Creating Neural Network
Last active September 22, 2019 21:02
Classifying Flowers With Transfer Learning
#The class bellow was created based in the one provided by Udacity
class Network(nn.Module):
def __init__(self, input_size, output_size, hidden_layers, drop_p=0.5):
''' Builds a feedforward network with arbitrary hidden layers.
Arguments
---------
input_size: integer, size of the input layer
output_size: integer, size of the output layer
hidden_layers: list of integers, the sizes of the hidden layers
@GiulioCMSanto
GiulioCMSanto / Loading pre-trained Network
Created September 22, 2019 15:38
Classifying Flowers With Transfer Learning
model = models.vgg16(pretrained=True)
@GiulioCMSanto
GiulioCMSanto / Data Transformation Example
Last active September 22, 2019 15:34
Classifying Flowers With Transfer Learning
train_transforms = transforms.Compose([transforms.RandomRotation(30),
transforms.RandomResizedCrop(224),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406],
[0.229, 0.224, 0.225])])