Skip to content

Instantly share code, notes, and snippets.

View alonsosilvaallende's full-sized avatar

Alonso Silva Allende alonsosilvaallende

View GitHub Profile
@balouf
balouf / ttt_llm.ipynb
Last active March 21, 2024 10:49
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 June 18, 2024 00:45
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 May 5, 2024 23:36
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.
@korakot
korakot / asyncio.py
Last active January 3, 2024 02:15
Use asyncio (async) in Colab
import nest_asyncio
nest_asyncio.apply()
---
title: "Muertes por comuna, mes y año en Chile 2000-2020"
output: html_notebook
---
```{r}
library(tidyverse)
```
# Cargar datos