Skip to content

Instantly share code, notes, and snippets.

View kalomaze's full-sized avatar

kalomaze

View GitHub Profile
datasets:
- path: anthracite-core/c2_logs_8k_llama3_v1.2
# contents of this dataset were filtered for quality, but not safety or safe for work-ness. be advised
type: sharegpt
conversation: llama3
- path: anthracite-org/kalo-opus-instruct-22k-no-refusal
type: sharegpt
conversation: llama3
- path: lodrick-the-lafted/kalo-opus-instruct-3k-filtered
type: sharegpt
@kalomaze
kalomaze / tp_latency.txt
Created August 25, 2024 02:03
Tensor Parallel latency
== Results torch.int8 meta-llama/Llama-2-7b-hf-TP1 ====
[--------------------------------------- scaled-torch.int8-gemm --------------------------------------]
| pytorch_bf16_bf16_bf16_matmul-no-scales | cutlass_i8_i8_bf16_scaled_mm
1 threads: --------------------------------------------------------------------------------------------
MKN=(1x4096x12288) | 195.3 | 142.4
MKN=(1x4096x4096) | 64.5 | 47.5
MKN=(1x4096x22016) | 322.9 | 235.6
MKN=(1x11008x4096) | 162.6 | 112.9
MKN=(16x4096x12288) | 187.5 | 142.6
MKN=(16x4096x4096) | 66.2 | 47.6
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig
import random
import os
import shutil
# Set a seed for reproducibility
random.seed(42)
# Load the model, tokenizer, and configuration
@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.
@kalomaze
kalomaze / llm_samplers_explained.md
Last active November 15, 2024 17:40
LLM Samplers Explained

LLM Samplers Explained

Everytime a large language model makes predictions, all of the thousands of tokens in the vocabulary are assigned some degree of probability, from almost 0%, to almost 100%. There are different ways you can decide to choose from those predictions. This process is known as "sampling", and there are various strategies you can use which I will cover here.

OpenAI Samplers

Temperature

  • Temperature is a way to control the overall confidence of the model's scores (the logits). What this means is that, if you use a lower value than 1.0, the relative distance between the tokens will become larger (more deterministic), and if you use a larger value than 1.0, the relative distance between the tokens becomes smaller (less deterministic).
  • 1.0 Temperature is the original distribution that the model was trained to optimize for, since the scores remain the same.
  • Graph demonstration with voiceover: https://files.catbox.moe/6ht56x.mp4
@kalomaze
kalomaze / llama_sillytavern_guide.md
Last active September 14, 2024 16:36
Simple Llama + SillyTavern Setup Guide

Simple Llama + SillyTavern Setup Guide

This guide is meant for Windows users who wish to run Facebook's Llama AI language model on their own PC locally. Our focus will be on character chats, reminiscent of platforms like character.ai / c.ai, using Llama architecture models. Most recently, in late 2023 and early 2024, Mistral AI has released high quality models that are based of the Llama architecture, and will work in the same way if you choose to use them.

  • Requirements

    • Windows operating system (may make Mac version of the guide later)
    • GPU with at least a few gigabytes of VRAM (NVIDIA graphics cards recommended)
  • Sufficient regular RAM for a model (system memory)

@kalomaze
kalomaze / local_llm_glossary.md
Last active August 26, 2024 21:47
Local LLM Glossary v2

Kalomaze's Local LLM Glossary

Not super comprehensive (yet), but I think having up to date documentation like this should be quite helpful for those out of the loop. Things change all the time in local AI circles, and it can be dizzying to catch up from an outsider's perspective, especially if you are new to the more technical aspects of language models in general (and not just locally hosted LLMs).

Available Models

Llama

  • A language model series created by Meta. Llama 1 was originally leaked in February 2023; Llama 2 then officially released later that year with openly available model weights & a permissive license. Kicked off the initial wave of open source developments that have been made when it comes to open source language modeling. The Llama series comes in four distinct sizes: 7b, 13b, 34b (only Code Llama was released for Llama 2 34b), and 70b. As of writing, the hotly anticipated Llama 3 has yet to arrive.

Mistral

  • Mistral AI is a French company that also distributes open weight