Skip to content

Instantly share code, notes, and snippets.

View duarteocarmo's full-sized avatar
🍓

Duarte OC duarteocarmo

🍓
View GitHub Profile
@duarteocarmo
duarteocarmo / app.tsx
Created February 20, 2026 14:42
LLM Response Annotation Tool
// app.tsx — LLM Response Annotation Tool
// bun run app.tsx
const html = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Annotate</title>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap" rel="stylesheet" />
@duarteocarmo
duarteocarmo / classify_edu_bagaco.py
Created February 18, 2026 18:07
Score fineweb2-bagaco with educational quality (0-5) using e5-small + MLP classifier (with progress bar)
# /// script
# dependencies = [
# "sentence-transformers",
# "torch",
# "scikit-learn",
# "numpy<2",
# "polars[pyarrow]",
# "pyarrow",
# "huggingface_hub",
# ]
@duarteocarmo
duarteocarmo / classify_edu_bagaco.py
Last active February 18, 2026 18:07
Score fineweb2-bagaco with educational quality (0-5) using e5-small + MLP classifier
# /// script
# dependencies = [
# "sentence-transformers",
# "torch",
# "scikit-learn",
# "numpy<2",
# "polars[pyarrow]",
# "pyarrow",
# "huggingface_hub",
# ]
@duarteocarmo
duarteocarmo / classify_edu_bagaco.py
Last active February 18, 2026 18:04
Score fineweb2-bagaco with educational quality (0-5) using e5-small ONNX + MLP
# /// script
# dependencies = [
# "sentence-transformers",
# "torch",
# "scikit-learn",
# "numpy<2",
# "polars[pyarrow]",
# "pyarrow",
# "huggingface_hub",
# ]
@duarteocarmo
duarteocarmo / lookup_gnd.py
Created February 17, 2026 19:40
Lookup a GND person record via lobid.org – returns VIAF ID, geocoordinates, Wikidata ID, ISNI, professions, etc. Usage: uv run lookup_gnd.py <gnd_id>
# /// script
# requires-python = ">=3.11"
# dependencies = ["httpx"]
# ///
"""Lookup a GND person record via lobid.org and return enriched info (VIAF, coordinates, etc).
Usage:
uv run scripts/lookup_gnd.py <gnd_id>
uv run scripts/lookup_gnd.py 110952928

Base

For the given query including a meal description, calculate the amount of carbohydrates in grams. If the serving size of any item in the
meal is not specified, assume it is a single standard serving based on common nutritional guidelines (e.g., USDA).
Respond with a dictionary object containing the total carbohydrates in grams as follows:
{{"total_carbohydrates": total grams of carbohydrates for the serving}}
For the total carbohydrates, respond with just the numeric amount of carbohydrates without extra text. If you don't know the answer,
respond with:
{{"total_carbohydrates": -1}}.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@duarteocarmo
duarteocarmo / opml_categorize.py
Created October 4, 2025 16:35
Categorize your OPML feed with an LLM
# requires-python = ">=3.13"
# /// script
# dependencies = [
# "pydantic",
# "feedparser",
# "tqdm",
# "litellm",
# ]
# ///
@duarteocarmo
duarteocarmo / gpt_grpo.py
Last active September 23, 2025 09:42
Uv script with minimal GRPO implementation
# /// script
# dependencies = [
# "transformers",
# "torch",
# "accelerate",
# "matplotlib",
# ]
# ///
# Notes: Mostly stolen from https://github.com/open-thought/tiny-grpo
# Run with uv run gpt_grpo.py