Skip to content

Instantly share code, notes, and snippets.

View kashif's full-sized avatar

Kashif Rasul kashif

  • Berlin, Germany
  • 08:20 (UTC +02:00)
  • X @krasul
View GitHub Profile
@kalomaze
kalomaze / modeling_mixtral.py
Created May 5, 2024 03:38
Fixed Mixtral training code for HF Transformers
# coding=utf-8
# Copyright 2023 Mixtral AI and the HuggingFace Inc. team. All rights reserved.
#
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
# and OPT implementations in this library. It has been modified from its
# original forms to accommodate minor architectural differences compared
# to GPT-NeoX and OPT used by the Meta AI team that trained the model.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
"""
1. First checkout the trl branch:
git clone https://github.com/huggingface/trl.git
git checkout debug-dpo
2. Install deps with:
make dev
from collections import defaultdict
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
from datasets import load_dataset
from rich.console import Console
from rich.table import Table
from transformers import (
AutoTokenizer,
@madebyollin
madebyollin / README.md
Last active April 2, 2024 13:50 — forked from mrsteyk/README.md
dalle_runner_api.model_infra.modules.public_diff_vae
@younesbelkada
younesbelkada / finetune_llama_v2.py
Last active July 12, 2024 06:54
Fine tune Llama v2 models on Guanaco Dataset
# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@karpathy
karpathy / stablediffusionwalk.py
Last active July 17, 2024 06:48
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 torch
import torch.utils.dlpack
import jax
import jax.dlpack
# A generic mechanism for turning a JAX function into a PyTorch function.
def j2t(x_jax):
x_torch = torch.utils.dlpack.from_dlpack(jax.dlpack.to_dlpack(x_jax))
return x_torch
@scastiel
scastiel / Makefile
Last active July 4, 2023 12:00
Resources for eBook creating using Pandoc
all: pdf epub kindle html examples
BOOK_TITLE = A\ React\ Developer’s\ Guide\ to\ Hooks\ -\ Sebastien\ Castiel
dist:
@mkdir -p dist
pdf: dist/${BOOK_TITLE}.pdf
@echo '✅ PDF'
//
// ContentView.swift
// TestingMoreSwiftUI
//
// Created by Chris Eidhof on 04.06.19.
// Copyright © 2019 Chris Eidhof. All rights reserved.
//
import SwiftUI
import Combine
@danijar
danijar / tf_char_rnn.py
Last active March 21, 2024 16:55
Simple character-level recurrent language model implemented in TensorFlow.
"""Character based language modeling with multi-layer GRUs.
To train the model:
python3 tf_char_rnn.py --mode training \
--logdir path/to/logdir --corpus path/to/corpus.txt
To generate text from seed words:
python3 tf_char_rnn.py --mode sampling \