Skip to content

Instantly share code, notes, and snippets.

@peterw
peterw / embed.py
Created April 17, 2023 16:30
embedding the pdf
import openai
import streamlit as st
from streamlit_chat import message
from dotenv import load_dotenv
import os
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import Chroma
import openai
from langchain.document_loaders import UnstructuredMarkdownLoader
from langchain.chains.question_answering import load_qa_chain
@carlineng
carlineng / tpch_graph.malloy
Created April 9, 2023 23:31
Explaining implicit context in queries in Sources
import "model.malloy"
/*
The file `model.malloy` (imported above) is defined as follows:
source: lineitem is table('duckdb:../data/lineitem.parquet') {
join_one:
orders is table('duckdb:../data/orders.parquet') on orders.o_orderkey = l_orderkey
customer is table('duckdb:../data/customer.parquet') on customer.c_custkey = orders.o_custkey
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@luigiMinardi
luigiMinardi / tex-colors.md
Last active June 30, 2025 08:08
Github markdown colors (Using Tex and the github MathJax support)

Small warning for everyone that are thinking if using Tex colors is a good idea or not

  • 2023-05-02 - Since a few days ago \colorbox and \fcolorbox are broken and Github did't talk about if it's a temporary thing or if it will not be added back.
    • 2024-01-04 - Since it has not being added back I deduce that it will never be so I removed all mentions to it on the rest of the gist.
  • 2023-09-29 - Tex seems to not work on h1 to h6 anymore (markdown #'s)
    • 2024-01-04 - Now it works again, I'll keep the message for a while to remember that it may change again in the future

As you can se with the above message(s) Tex may not be very stable and may not be an option to you as of the dates expressed above. You can also check other tex problems here.

Github released Tex support and colors* to the markdown and you din't realized

@rain-1
rain-1 / LLM.md
Last active August 16, 2025 00:39
LLM Introduction: Learn Language Models

Purpose

Bootstrap knowledge of LLMs ASAP. With a bias/focus to GPT.

Avoid being a link dump. Try to provide only valuable well tuned information.

Prelude

Neural network links before starting with transformers.

#!/usr/bin/env python3
from pathlib import Path
from numpy import sqrt, loadtxt, isclose
from pandas import read_table
from scipy.stats import t
def ttest(sample1, sample2):
vn1, vn2 = [s.var() / s.size for s in [sample1, sample2]]
@wiseman
wiseman / agent.py
Last active April 21, 2025 17:37
Langchain example: self-debugging
from io import StringIO
import sys
from typing import Dict, Optional
from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.agents.tools import Tool
from langchain.llms import OpenAI

This book is all about patterns for doing ML. It's broken up into several key parts, building and serving. Both of these are intertwined so it makes sense to read through the whole thing, there are very many good pieces of advice from seasoned professionals. The parts you can safely ignore relate to anything where they specifically use GCP. The other issue with the book it it's very heavily focused on deep learning cases. Not all modeling problems require these. Regardless, let's dive in. I've included the stuff that was relevant to me in the notes.

Most Interesting Bullets:

  • Machine learning models are not deterministic, so there are a number of ways we deal with them when building software, including setting random seeds in models during training and allowing for stateless functions, freezing layers, checkpointing, and generally making sure that flows are as reproducible as possib
@geoffreylitt
geoffreylitt / langchain-experiment.ipynb
Created January 29, 2023 21:27
Langchain experiment
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from scipy.stats import norm, uniform, gamma
from matplotlib.pyplot import rc, rcdefaults, subplots, imread, show
from matplotlib.lines import Line2D
from matplotlib.ticker import MultipleLocator
from matplotlib.transforms import blended_transform_factory
from matplotlib.offsetbox import VPacker, TextArea, AnchoredOffsetbox, DrawingArea
from matplotlib.image import BboxImage
from numpy.random import default_rng