Skip to content

Instantly share code, notes, and snippets.

View omrihar's full-sized avatar

Omri Har-Shemesh omrihar

View GitHub Profile
@yoavg
yoavg / stochastic-critique.md
Last active November 9, 2023 04:32
A criticism of Stochastic Parrots

A criticism of "On the Dangers of Stochastic Parrots: Can Languae Models be Too Big"

Yoav Goldberg, Jan 23, 2021.

The FAccT paper "On the Dangers of Stochastic Parrots: Can Languae Models be Too Big" by Bender, Gebru, McMillan-Major and Shmitchell has been the center of a controversary recently. The final version is now out, and, owing a lot to this controversary, would undoubtly become very widely read. I read an earlier draft of the paper, and I think that the new and updated final version is much improved in many ways: kudos for the authors for this upgrade. I also agree with and endorse most of the content. This is important stuff, you should read it.

However, I do find some aspects of the paper (and the resulting discourse around it and around technology) to be problematic. These weren't clear to me when initially reading the first draft several months ago, but they became very clear to me now. These points are for the most part

@dmontagu
dmontagu / orm_mode_patch.py
Created June 15, 2019 06:33
Inherit from APIModel instead of BaseModel to get from_orm functionality
from typing import Any, Dict, Set, Type, TypeVar
from pydantic import BaseConfig, BaseModel, ConfigError, DictError, validate_model
from pydantic.utils import change_exception
Model = TypeVar("Model", bound=BaseModel)
class APIModel(BaseModel):
@nqbao
nqbao / ssm_parameter_store.py
Last active May 29, 2024 06:01
Python class to provide a dictionary-like interface to access AWS SSM Parameter Store easily
# Copyright (c) 2018 Bao Nguyen <b@nqbao.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
@peatiscoding
peatiscoding / build-tag-push.py
Created January 24, 2018 15:20
a script to convert your docker-compose.yml (version 2) with build node to image node; this script required DOCKERHUB_USER environment available.
#!/usr/bin/python
import os
import subprocess
import time
import yaml
import re
user_name = os.environ.get("DOCKERHUB_USER")
@fermayo
fermayo / lambda_function.py
Last active February 9, 2023 09:23
Lambda function to trigger a one-off ECS Fargate task
# Adapted from https://lobster1234.github.io/2017/12/03/run-tasks-with-aws-fargate-and-lambda/
import boto3
import os
def lambda_handler(event,context):
client = boto3.client('ecs')
response = client.run_task(
cluster=os.getenv('CLUSTER'),
launchType=os.getenv('LAUNCH_TYPE', 'FARGATE'),
@ririw
ririw / ztp.py
Last active February 15, 2022 20:47
PYMC3 Zero truncated poisson distribution
import pymc3 as pm
from pymc3.distributions.dist_math import bound, logpow, factln
from pymc3.distributions import draw_values, generate_samples
import theano.tensor as tt
import numpy as np
import scipy.stats.distributions
class ZTP(pm.Discrete):
def __init__(self, mu, *args, **kwargs):
super().__init__(*args, **kwargs)
@akheron
akheron / smtpd_fixture.py
Last active June 30, 2021 10:26
SMTP server pytest fixture
# The SMTP server runs in a separate thread and stores sent messages in a list
#
# Usage:
#
# def test_fn(smtpd):
# host = smtpd.host
# port = smtpd.port
#
# # Run code that send email using an smtp server at host:port
#
@kissgyorgy
kissgyorgy / sqlalchemy_conftest.py
Last active June 26, 2024 20:01
Python: py.test fixture for SQLAlchemy test in a transaction, create tables only once!
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from myapp.models import BaseModel
import pytest
@pytest.fixture(scope="session")
def engine():
return create_engine("postgresql://localhost/test_database")
@coppeliaMLA
coppeliaMLA / binDiff.R
Created March 21, 2014 08:14
A function that gives the probability mass function for the difference between to binomially distributed random variables
modBin<-function(k, n, p){
if (k<=n) {
return(dbinom(k, n, p))
}
else {
return(0)
}
}
@carlohamalainen
carlohamalainen / tunnel.py
Created September 29, 2012 12:06
check ssh tunnel from Python
"""
From the man page for ssh:
-f Requests ssh to go to background just before command execution. This is useful if ssh is going to ask
for passwords or passphrases, but the user wants it in the background. This implies -n. The recommended way
to start X11 programs at a remote site is with something like ssh -f host xterm.
If the ExitOnForwardFailure configuration option is set to “yes”, then a client started with -f will wait
for all remote port forwards to be successfully established before placing itself in the background.