Skip to content

Instantly share code, notes, and snippets.

View cyberfox's full-sized avatar

Morgan Schweers cyberfox

View GitHub Profile
@cyberfox
cyberfox / starcoder-lora.diff
Created June 19, 2023 05:13
Patch to support training LoRA for StarCoder-based models on Oobabooga's text-generation-webui
diff --git a/modules/training.py b/modules/training.py
index 75ba82c..c90d823 100644
--- a/modules/training.py
+++ b/modules/training.py
@@ -30,12 +30,14 @@ try:
MODEL_CLASSES = {v: k for k, v in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES}
except:
standard_modules = ["q_proj", "v_proj"]
- model_to_lora_modules = {"llama": standard_modules, "opt": standard_modules, "gptj": standard_modules, "gpt_neox": ["query_key_value"]}
+ model_to_lora_modules = {"llama": standard_modules, "opt": standard_modules, "gptj": standard_modules, "gpt_neox": ["query_key_value"],
@cyberfox
cyberfox / stable_sort_example.rb
Created January 31, 2011 09:56
Showing unstable and stable sorting in Ruby.
# This example is flawed, but hopefully useful for demonstration purposes.
def test_stable_sorting
ary = (1..100).to_a.shuffle + (1..100).to_a.shuffle
# This associates an ordering with the randomized numbers
idx = 0
paired = ary.collect {|value| [value, idx += 1]}
puts "Now the numbers are paired; the first is the random number 1-100,"
puts "the second is its sequence within the 200 entries."
puts paired.inspect
@cyberfox
cyberfox / SetBehaviorVariable.cs
Created December 28, 2019 00:58
Allows setting Behavior Designer variables on a GameObject as a Task.
using System;
namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityGameObject
{
[TaskCategory("Unity/GameObject")]
[TaskDescription("Sets a Behavior Designer variable on a GameObject. Returns success.")]
public class SetBehaviorVariable : Action
{
[Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")]
public SharedGameObject TargetGameObject;
@cyberfox
cyberfox / DAZ.cs
Created April 11, 2020 12:40
C# set of classes for parsing DSF files
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using Newtonsoft.Json;
namespace DAZ
{
public class DataCollection<T>
{
public int count { get; set; }
@cyberfox
cyberfox / humanize.js
Created October 20, 2011 18:43
JavaScript humanize method.
com = { cyberfox: {} };
/**
* Convert a property name into a human readable string by replacing _ with
* spaces, and upcasing the first letter of each word.
*
* @param {string} property The property name to convert into a readable name.
* @return {string} The property name converted to a friendly readable format.
* @private
*/
@cyberfox
cyberfox / TaggedLeaderFollow.cs
Last active December 27, 2019 06:41
Use tags to automatically add spawned GameObjects to the list of followers-of-the-leader.
using System;
using System.Collections.Generic;
using Pathfinding;
using UnityEngine;
namespace BehaviorDesigner.Runtime.Tasks.Movement.AstarPathfindingProject
{
[TaskDescription("Tagged GameObjects Follow the leader with the A* Pathfinding Project.")]
[TaskCategory("Movement/A* Pathfinding Project")]
[TaskIcon("Assets/Behavior Designer Movement/Editor/Icons/{SkinColor}LeaderFollowIcon.png")]
@cyberfox
cyberfox / string_permutations.rb
Created January 7, 2012 09:11
Return all permutations of a string, without any duplicates.
require 'set'
# First I wanted to get an idea of the timing of the various approaches
def time
start = Time.now
yield
puts Time.now.to_f - start.to_f
end
# This optimizes for redundant strings of values, front-loading them to maximize duplicates
@cyberfox
cyberfox / whazzup.rb
Created January 5, 2011 01:43
Asks for status every 15-25 minutes to track where time goes. Traps USR2 to wake and prompt for status. Designed for Linux, works on OS X, needs tweaks for Windows. Uses JRuby, since it's the only easy-to-get cross-platform UI toolkit for Ruby.
require "java"
java_import javax.swing.JOptionPane
class Whazzup
def initialize(file = "#{ENV['HOME']}/snippets.txt")
@snippets ||= open(file, 'ab')
log('[Starting up (ruby)]')
thread_loop = Thread.current
@cyberfox
cyberfox / remove_dupes.rb
Last active April 2, 2017 09:16
Look for and remove duplicate files between a pair of trees that are similar.
require 'digest/md5'
class FindDupes
def initialize(base)
@allfiles = Dir['**/**']
@base = base
@files = @allfiles.select {|f| File.file? f}
end
def find_current
@cyberfox
cyberfox / post_test.rb
Created March 10, 2017 09:37
Demonstration of the problem with counter_cache in Rails 5 (and 4)
require 'test_helper'
# ActiveRecord::Schema.define(version: 20170310085807) do
# create_table "forums", force: :cascade do |t|
# t.string "title"
# t.integer "posts_count"
# t.datetime "created_at", null: false
# t.datetime "updated_at", null: false
# end
#