Skip to content

Instantly share code, notes, and snippets.

{"text":"[INST] <<SYS>>\nUse the Input to provide a summary of a conversation.\n<<\/SYS>>\n\nInput:\nAmanda: I baked cookies. Do you want some?\r\nJerry: Sure!\r\nAmanda: I'll bring you tomorrow :-) [\/INST]\n\nSummary: Amanda baked cookies and will bring Jerry some tomorrow."}
{"text":"[INST] <<SYS>>\nUse the Input to provide a summary of a conversation.\n<<\/SYS>>\n\nInput:\nOlivia: Who are you voting for in this election? \r\nOliver: Liberals as always.\r\nOlivia: Me too!!\r\nOliver: Great [\/INST]\n\nSummary: Olivia and Olivier are voting for liberals in this election. "}
{"text":"[INST] <<SYS>>\nUse the Input to provide a summary of a conversation.\n<<\/SYS>>\n\nInput:\nTim: Hi, what's up?\r\nKim: Bad mood tbh, I was going to do lots of stuff but ended up procrastinating\r\nTim: What did you plan on doing?\r\nKim: Oh you know, uni stuff and unfucking my room\r\nKim: Maybe tomorrow I'll move my ass and do everything\r\nKim: We were going to defrost a fridge so instead of shopping I'll eat some defrosted
@harrywang
harrywang / price-data.txt
Created March 12, 2024 00:40
api-comparison
make a comparison table to compare the api pricing between claude, mistral, openai, and gemini based on the following data:
Claude 3
MTok = million tokens. All Claude 3 models support vision and 200,000 token context windows.
Light & fast
Haiku
Input: $0.25 / MTok
Output: $1.25 / MTok
Hard-working
import torch
import pandas as pd
import logging
import os
from dotenv import load_dotenv
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
from datetime import datetime
@harrywang
harrywang / ask_iching.py
Created June 12, 2022 16:10
This program uses three-coin approach to consult the IChing and returns the hexagram (see https://harrywang.me/iching for more details)
def consult_oracle():
import random
hex = ''
for i in range(6): # toss 6 times to get the hex
toss = 0
line = 0
for i in range(3): # each toss with three coins to generate one line
@harrywang
harrywang / ensemble-learning-hints.py
Created May 13, 2021 21:43
ensemble learning hints
# partial code snippets shown as hints
# voting regressor
from sklearn.ensemble import VotingRegressor
voting_reg = VotingRegressor(
estimators = [
('lin', lin_reg_pipeline),
('svm', svm_reg_pipeline),
('sgd', sgd_reg_pipeline),
@harrywang
harrywang / sgd-grid-search-example.py
Created May 4, 2021 22:24
sgd grid search example
# sgd regression pipeline with grid search
from sklearn.linear_model import SGDRegressor
from sklearn.model_selection import GridSearchCV
param_grid = [
{
'sgd_reg__max_iter':[100000, 1000000], # if number is too small, you will get a warning
'sgd_reg__tol':[1e-10, 1e-3],
'sgd_reg__eta0':[0.001, 0.01]
}
@harrywang
harrywang / feature-type-based-selection.py
Last active May 4, 2021 19:41
code snippet to show how to select features based on type: numerical vs. categorical
# example to show how to select features based on type: numerical vs. categorical
import pandas as pd
# load the data
df = pd.read_csv("housing.csv")
# find numerical features and categorical features based on the type of feature
df_num = df.select_dtypes(exclude ='object')
df_cat = df.select_dtypes(include ='object')
# select numerical features and categorical features
@harrywang
harrywang / config.md
Last active June 10, 2020 14:08
tai-config

Setup

Use V3 from Tai: Screen Shot 2020-06-10 at 9 58 22 AM

python -m venv venv
source venv/bin/activate
pip install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple/
@harrywang
harrywang / lin_reg_full_pipeline.py
Created April 22, 2020 14:15
Linear Regression Full Pipeline Code Snippet
### code snippet ####
from sklearn.linear_model import LinearRegression
lin_reg_full_pipeline = Pipeline(
steps=[
('preprocessor', preprocessor),
('lin_reg', LinearRegression()),
]
)
@harrywang
harrywang / object-detection.json
Created March 14, 2020 14:53
google object detection result
{
"responses": [
{
"localizedObjectAnnotations": [
{
"mid": "/j/5qg9b8",
"name": "Packaged goods",
"score": 0.8396697,
"boundingPoly": {
"normalizedVertices": [