Skip to content

Instantly share code, notes, and snippets.

View gschoeni's full-sized avatar
🐂

Greg Schoeninger gschoeni

🐂
View GitHub Profile
@gschoeni
gschoeni / train.py
Created May 31, 2024 03:14
Mini Neural Network
import torch
import torch.nn as nn
from torch.utils.data import Dataset, DataLoader
import pandas as pd
from io import StringIO
from sklearn.preprocessing import LabelEncoder
# Define a dataset class
class CustomDataset(Dataset):
def __init__(self, features, labels):
@gschoeni
gschoeni / gist:d087ac241d1d683f032305957144ba47
Created December 14, 2023 00:51
Vision Transformer requirements.txt
accelerate==0.25.0
ai-dive==0.0.1
aiohttp==3.9.1
aiosignal==1.3.1
async-timeout==4.0.3
attrs==23.1.0
certifi==2023.7.22
charset-normalizer==3.3.2
datasets==2.14.5
dill==0.3.7
@gschoeni
gschoeni / run_on_cpu.py
Created October 23, 2023 22:53
Run llama-2 GGML model on CPU
from langchain.llms import CTransformers
from langchain.callbacks.base import BaseCallbackHandler
# Handler that prints each new token as it is computed
class NewTokenHandler(BaseCallbackHandler):
def on_llm_new_token(self, token: str, **kwargs) -> None:
print(f"{token}", end="", flush=True)
# Local CTransformers wrapper for Llama-2-7B-Chat
llm = CTransformers(
@gschoeni
gschoeni / http_upload_progress.rs
Last active July 20, 2022 18:32
Example HTTP upload with progress using reqwest and indicatif
// Read data into buffer
let path = std::path::Path::new("/path/to/your/file.zip");
let buffer: Vec<u8> = std::fs::read(path)?;
println!("Uploading {} bytes from {:?}", buffer.len(), path);
// Create the struct to hold onto and update the progress
let upload_progress = indicatif::ProgressBar::new(buffer.len() as u64);
let cursor = std::io::Cursor::new(Vec::from(buffer));
let upload_source = ReadProgress {