Skip to content

Instantly share code, notes, and snippets.

View alonsosilvaallende's full-sized avatar

Alonso Silva alonsosilvaallende

View GitHub Profile
@willccbb
willccbb / grpo_demo.py
Last active May 16, 2025 06:34
GRPO Llama-1B
# train_grpo.py
#
# See https://github.com/willccbb/verifiers for ongoing developments
#
"""
citation:
@misc{brown2025grpodemo,
title={Granular Format Rewards for Eliciting Mathematical Reasoning Capabilities in Small Language Models},
author={Brown, William},
@vgel
vgel / r1.py
Last active May 8, 2025 01:59
script to run deepseek-r1 with a min-thinking-tokens parameter, replacing </think> with a random continuation string to extend the model's chain of thought
import argparse
import random
import sys
from transformers import AutoModelForCausalLM, AutoTokenizer, DynamicCache
import torch
parser = argparse.ArgumentParser()
parser.add_argument("question", type=str)
parser.add_argument(
@balouf
balouf / ttt_llm.ipynb
Last active August 8, 2024 14:41
TTT - IPywidgets and LLMs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
import openai
import scipy.special
import tiktoken
def get_top_chat_logprobs(
model: str,
messages: list[dict[str, str]],
@sientifiko
sientifiko / guia_desigualdad1.R
Last active December 19, 2023 08:53
Script para la nota 1 sobre guía de desigualdad en medium
library(tidyverse)
theme_set(theme_bw(base_size = 21))
options(scipen = 999)
dat <- read.csv("dataregionesChile.csv")
# filtrar el año 2020
y2020 <- dat %>% filter(year == 2020)
# generar histograma
@jbwhit
jbwhit / example-ruff-formatting.ipynb
Last active May 4, 2025 00:37
Steps to use `ruff` in JupyterLab with the `jupyterlab_code_formatter` plugin.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@RaphaelWimmer
RaphaelWimmer / chatgpt_pick_random_number.py
Last active July 16, 2023 11:01
Ask GPT to pick a random number between 1 and 10
#!/usr/bin/env python3
import openai
import time
import matplotlib.pyplot as plt
def pick_numbers(n, model, temperature, clean_session):
numbers = []
messages = []
system_msg = "Please only respond with the number, don't say anything else."
messages.append({"role": "system", "content": system_msg})
@kylemcdonald
kylemcdonald / function-calling.ipynb
Created June 14, 2023 01:10
Example of OpenAI function calling API to extract data from LAPD newsroom articles.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
import openai
from rich.console import Console
console = Console()
openai.api_key = os.getenv("OPENAI_API_KEY")
history = [{"role": "system", "content": "You are a helpful assistant."},]
@AustinRochford
AustinRochford / revisit_bayes_survival.ipynb
Last active July 26, 2024 12:53
Revisiting Bayesian Survival Analysis in Python with PyMC
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.