Skip to content

Instantly share code, notes, and snippets.

View aasthavar's full-sized avatar
🎯
Focusing

Aastha Varma aasthavar

🎯
Focusing
View GitHub Profile
@vatsalsaglani
vatsalsaglani / mistral_ctx.py
Last active June 3, 2025 20:06
Token counting and message token management for MistralAI
from typing import List, Dict, Literal, Union
from transformers import AutoTokenizer
class MistralAICtx:
def __init__(self, model_name: str):
assert "mistral" in model_name, "MistralCtx only available for Mistral models"
self.tokenizer = AutoTokenizer.from_pretrained(
"mistralai/Mistral-7B-Instruct-v0.2")
@veekaybee
veekaybee / normcore-llm.md
Last active June 2, 2026 14:12
Normcore LLM Reads

Anti-hype LLM reading list

Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.

Foundational Concepts

Screenshot 2023-12-18 at 10 40 27 PM

Pre-Transformer Models

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Reinforcement Learning for Language Models

Yoav Goldberg, April 2023.

Why RL?

With the release of the ChatGPT model and followup large language models (LLMs), there was a lot of discussion of the importance of "RLHF training", that is, "reinforcement learning from human feedback". I was puzzled for a while as to why RL (Reinforcement Learning) is better than learning from demonstrations (a.k.a supervised learning) for training language models. Shouldn't learning from demonstrations (or, in language model terminology "instruction fine tuning", learning to immitate human written answers) be sufficient? I came up with a theoretical argument that was somewhat convincing. But I came to realize there is an additional argumment which not only supports the case of RL training, but also requires it, in particular for models like ChatGPT. This additional argument is spelled out in (the first half of) a talk by John Schulman from OpenAI. This post pretty much

@cedrickchee
cedrickchee / meta-llama-guide.md
Created March 12, 2023 11:37
Meta's LLaMA 4-bit chatbot guide for language model hackers and engineer

info 9-3-23 Added 4bit LLaMA install instructions for cards as small as 6GB VRAM! (See "BONUS 4" at the bottom of the guide)

warning 9-3-23 Added Torrent for HFv2 Model Weights, required for ooga's webUI, Kobold, Tavern and 4bit (+4bit model)! Update ASAP!

danger 11-3-23 There's a new torrent version of the 4bit weights called "LLaMA-HFv2-4bit". The old "LLaMA-4bit" torrent may be fine. But if you have any issues with it, it's recommended to update to the new 4bit torrent or use the decapoda-research versions off of HuggingFace or produce your own 4bit weights. Newer Torrent Link or [Newer Magnet Link](magnet:?xt=urn:btih:36945b5958b907b3ab69e963ba0de1abdf48c16c&dn=LLaMA-HFv2-4bit&tr=http%3a%2f%2fbt1.archive.org%3a6969%2fannounce&tr=http%3a%2f%2fbt2.archive.org%3a696

@MarkTension
MarkTension / memleak_debugger_pytorch.py
Created October 28, 2022 06:53
memory leak ContextDecorator
import gc
import torch
import gc
from contextlib import ContextDecorator
# pytorch method to find number of tensors in the graph
def get_n_tensors():
tensors= []
for obj in gc.get_objects():
try:
@karpathy
karpathy / stablediffusionwalk.py
Last active May 30, 2026 02:00
hacky stablediffusion code for generating videos
"""
stable diffusion dreaming
creates hypnotic moving videos by smoothly walking randomly through the sample space
example way to run this script:
$ python stablediffusionwalk.py --prompt "blueberry spaghetti" --name blueberry
to stitch together the images, e.g.:
$ ffmpeg -r 10 -f image2 -s 512x512 -i blueberry/frame%06d.jpg -vcodec libx264 -crf 10 -pix_fmt yuv420p blueberry.mp4
import ws from 'k6/ws';
import { check } from 'k6';
export let options = {
stages: [
{ duration: '10s', target: 30 },
{ duration: '30s', target: 30 },
{ duration: '20s', target: 60 },
{ duration: '30s', target: 60 },
{ duration: '20s', target: 30 },
@james-jory
james-jory / aws_personalize_delete_dsg.py
Last active September 28, 2024 07:43
Deletes an Amazon Personalize dataset group, including all of its associated resources
#!/usr/bin/env python
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
"""
Deletes one or more Amazon Personalize dataset groups, including all of their associated resources:
- Recommenders
- Campaigns
- Filters
@absent1706
absent1706 / datascience-visualize-grid-cv.py
Created April 7, 2019 08:49
datascience-visualize-grid-cv
def visualize_grid_cv_params(grid_cv):
df = pd.DataFrame(grid_cv.cv_results_['params'])
df['score'] = grid_cv.cv_results_['mean_test_score']
fig, axes = plt.subplots(1, len(grid_cv.param_grid), sharey=True, figsize=(15,4))
i = 0
for param in grid_cv.param_grid:
data = df.groupby(param).mean()['score'].to_dict()
param_values = list(data.keys())