Skip to content

Instantly share code, notes, and snippets.

View morganmcg1's full-sized avatar
💭
Trying to ML

Morgan McGuire morganmcg1

💭
Trying to ML
View GitHub Profile
@morganmcg1
morganmcg1 / yea_test
Created February 21, 2022 17:27
yeah test
paperspace@pspx59qcl:~/client$ yea run functional_tests/imports/04-batch4.py
INFO: Timed out waiting for server to start... http://localhost:37211 1645464371.6856294
INFO: Timed out waiting for server to start... http://localhost:37211 1645464372.6893241
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn
conn = connection.create_connection(
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 84, in create_connection
raise err
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 74, in create_connection
sock.connect(sa)
@morganmcg1
morganmcg1 / yea-test
Created February 21, 2022 19:02
yea test
#!/usr/bin/env python
"""Test a batch of import telemetry
---
id: 0.imports.04-batch4
tag:
shard: imports
plugin:
- wandb
depend:
@morganmcg1
morganmcg1 / tables_logging.py
Created March 8, 2022 18:54
Logging images to Tables with references
# First table/ table for first iteration/epoch
original_table = ... # format [id, wandb.Image object, ...]
artifact.add(original_table, "my_table")
# Log the table as artifact. (optionally)Log the same table in dashboard if you want to
run.log_artifact(artifact)
run.log({"my_table": original_table})
# Use the logged artifact to get the reference of table
run.use_artifact(artifact)
@morganmcg1
morganmcg1 / DBPlot.py
Created June 21, 2022 17:57
Code for DBPlot
# Decision Boundary Utils
-# Modified from https://github.com/tmadl/highdimensional-decision-boundary-plot
-class DBPlot(BaseEstimator):
- def __init__(
- self,
- estimator=KNeighborsClassifier(n_neighbors=10),
- acceptance_threshold=0.03,
- n_decision_boundary_keypoints=60,
- n_connecting_keypoints=None,
- n_interpolated_keypoints=None,
# Needs datasets, albumentations
from PIL import Image
from datasets import load_dataset
from datasets.download.download_manager import DownloadMode #, REUSE_DATASET_IF_EXISTS, REUSE_CACHE_IF_EXISTS
import albumentations as A
from albumentations.pytorch.transforms import ToTensorV2
from albumentations.augmentations.transforms import Normalize
@morganmcg1
morganmcg1 / async_langchain_wandb.py
Created May 15, 2023 14:41
Async langchain with streaming
from typing import Callable, Dict, Any, List
from fastapi import Depends, FastAPI
from fastapi.encoders import jsonable_encoder
from fastapi.responses import JSONResponse
from lanarky.responses import StreamingResponse
from langchain.callbacks.manager import AsyncCallbackManager
from langchain.callbacks.base import AsyncCallbackHandler
from langchain.chat_models import ChatOpenAI
from langchain.chains import LLMChain, SequentialChain, ConversationChain
from pydantic import BaseModel
@morganmcg1
morganmcg1 / fastapi_prompts.py
Created May 15, 2023 15:38
Using prompts and fastapi
from typing import Callable, Dict, Any, List
from fastapi import Depends, FastAPI
from fastapi.encoders import jsonable_encoder
from fastapi.responses import JSONResponse
from lanarky.responses import StreamingResponse
from langchain.callbacks.manager import AsyncCallbackManager
from langchain.callbacks.base import AsyncCallbackHandler
from langchain.chat_models import ChatOpenAI
from langchain.chains import LLMChain, SequentialChain, ConversationChain
from pydantic import BaseModel
@morganmcg1
morganmcg1 / synthetic_wandbot_data.ipynb
Created May 15, 2023 19:00
Generating synthetic questions and answers for wandbot
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@morganmcg1
morganmcg1 / wandb_prompts_lanarky_patch.py
Created May 19, 2023 12:15
Monkey patching Lanarky for WandbTracer
import langchain
import wandb
from typing import Any, Awaitable, Callable, Dict, Optional, Union
from fastapi.responses import StreamingResponse as _StreamingResponse
from langchain.chains.base import Chain
from starlette.background import BackgroundTask
from starlette.types import Send
from dotenv import load_dotenv
#!/usr/bin/env python
# coding: utf-8
# In this notebook we will automatically generate a set of evaluation questions based on wandb docs
import random
import wandb
import re
import openai
import os