Skip to content

Instantly share code, notes, and snippets.

View hugoabonizio's full-sized avatar
👾

Hugo Abonizio hugoabonizio

👾
View GitHub Profile
@younesbelkada
younesbelkada / example_code_int8.py
Last active December 9, 2022 08:00
An example script to run bnb int8 models using `bitsandbytes` and `transformers`
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
MAX_NEW_TOKENS = 128
model_name = 'facebook/opt-66b'
text = """
Q: On average Joe throws 25 punches per minute. A fight lasts 5 rounds of 3 minutes.
How many punches did he throw?\n
A: Let’s think step by step.\n"""
@Narsil
Narsil / pure_torch.py
Created November 10, 2022 15:06
Loading a safetensors file with pure torch only
import mmap
import torch
import json
import os
from huggingface_hub import hf_hub_download
def load_file(filename, device):
with open(filename, mode="r", encoding="utf8") as file_obj:
with mmap.mmap(file_obj.fileno(), length=0, access=mmap.ACCESS_READ) as m: