Skip to content

Instantly share code, notes, and snippets.

@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
import time
import os
import logging
import random
from datasets import load_dataset
class QuantAutoGPTQ:
def __init__(self, model_name_or_path, output_dir, dataset,
num_samples=128, trust_remote_code=False, cache_examples=True,
use_fast=True, use_triton=False, bits=[4], group_size=[128], damp=[0.01],

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

@ploeber
ploeber / main.py
Created April 18, 2023 15:37
vocode script
import asyncio
import signal
import vocode
from vocode.streaming.streaming_conversation import StreamingConversation
from vocode.helpers import create_microphone_input_and_speaker_output
# Transcriber
from vocode.streaming.models.transcriber import AssemblyAITranscriberConfig
from vocode.streaming.transcriber.assemblyai_transcriber import AssemblyAITranscriber
@Willy-JL
Willy-JL / pyimgui_imagehelper.py
Last active July 5, 2023 10:08
Image helper class for pyimgui
from PIL import Image, ImageSequence, UnidentifiedImageError
import OpenGL.GL as gl
import pathlib
import imgui
_dummy_texture_id = None
def dummy_texture_id():
global _dummy_texture_id
@simonbs
simonbs / KeyboardAvoidingView.swift
Created January 24, 2022 21:29
Avoid undocked keyboard at bottom.
// Sample code made in response to this tweet:
// https://twitter.com/stroughtonsmith/status/1485719749673820163
final class MainView: UIView {
private let textView: UITextView = {
let this = UITextView()
this.translatesAutoresizingMaskIntoConstraints = false
this.text = "I'm a text view"
this.font = .preferredFont(forTextStyle: .body)
this.textColor = .label
@abobija
abobija / esp-idf on ubuntu 20.04.1.md
Last active September 9, 2023 02:20
ESP-IDF on Ubuntu 20.04.1

ESP-IDF on Ubuntu 20.04.1

This is commands used in youtube video

How to setup ESP-IDF on Ubuntu 20.04.1

Commands:

sudo apt update && sudo apt upgrade -y
@steipete
steipete / UIWindow+PSPDFAdditions.h
Last active June 5, 2024 20:09
Mac Catalyst: Get the NSWindow from a UIWindow (Updated for macOS 11 Big Sur, also works with Catalina)
// Don't forget to prefix your category!
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIWindow (PSPDFAdditions)
#if TARGET_OS_UIKITFORMAC
@markblundeberg
markblundeberg / pgp-checkdatasig.md
Created August 31, 2018 01:23
Using PGP signatures with bitcoin script OP_CHECKDATASIG

Using PGP signatures with bitcoin script OP_CHECKDATASIG

Dr. Mark B. Lundeberg, 2018 August 30 bitcoincash:qqy9myvyt7qffgye5a2mn2vn8ry95qm6asy40ptgx2

Since version 2.1, GnuPG is able to use the very same secp256k1 elliptic curve signature algorithm (ECDSA) as used in bitcoin. Quite soon Bitcoin Cash will add a new script opcode OP_CHECKDATASIG that is able to check signatures not just on the containing transaction, but also on arbitrary data. For fun, let's try to intersect the two signature systems and see what can be done!

Background

OP_CHECKDATASIG signatures

# OSD/ObjectStore
# make rocksdb statically
if(NOT ALLOCATOR STREQUAL "jemalloc")
set(ROCKSDB_JEMALLOC "DISABLE_JEMALLOC=1")
endif()
set(ROCKSDB_EXTRA_CXXFLAG "-fPIC -Wno-unused-variable")
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
set(ROCKSDB_EXTRA_CXXFLAG "${ROCKSDB_EXTRA_CXXFLAG} -DNDEBUG")
endif(NOT CMAKE_BUILD_TYPE STREQUAL Debug)