Skip to content

Instantly share code, notes, and snippets.

import os
import time
import argparse
start = time.time()
os.system("nvidia-smi")
# import libraries
@AmgadHasan
AmgadHasan / install_driver_cuda.md
Last active August 31, 2023 22:21
install nvidia drivers + cuda
@AmgadHasan
AmgadHasan / convert_hf_ct2.sh
Last active October 30, 2023 10:48
How to Convert Whisper from HF's Transformer format into Ctranslate2 format (needed for FasterWhisper)
# Create a virtual environment named myenv
python3 -m venv myvenv
# Activate this venv
source myvenv/bin/activate
# Now the venv is activated, install the packages
pip install transformers ctranslate2
ct2-transformers-converter \
--model whisper-large-v2
--output_dir whisper-large-v2-ct2 \
--copy_files tokenizer_config.json \
@AmgadHasan
AmgadHasan / decode_audio_binary.md
Created December 25, 2023 13:29
Decode Audio from File Bytes

Overview

Sometimes we get data that resembles an opened file and we can't handle it easily. An example of this is if you download a wav audio file directly into memory, so that the binary contents of the file are already stored in an object. One way to handle it is to write the binary contents to an actual file on disk. However, this is inefficient.

Another way is to create a file-like object that can be dealt with as normal files.

In this example, we have the binary contents of a wav audio file and we would like to decode it to extract the audio array and sampling rate. We want to do this all in-memory without writing to disk.

1. Dependencies

We will be doing this using python.

@AmgadHasan
AmgadHasan / 1-overview.md
Last active May 2, 2024 20:27
Simplest Ways to Chat with LLMs Locally

Motivation

Many people want to get starting with using chatbots locally. However, they often are intimidated by the complexity and the steep learning curve needed to even run a basic chatbot.

In this gist, I share a few simple methods to run a chatbot locally without the need to do 69 installation steps. All you need a machine with enough memory to run the model. A computer with 8GB of cpu ram is the minimum requirement.

These are currently the recommneded methods.