Skip to content

Instantly share code, notes, and snippets.

View bofenghuang's full-sized avatar
🎯
Focusing

bofeng huang bofenghuang

🎯
Focusing
View GitHub Profile
@younesbelkada
younesbelkada / finetune_llama_v2.py
Last active May 14, 2024 05:46
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
@MillionthOdin16
MillionthOdin16 / convert.py
Created April 2, 2023 14:49
Import pytorch model files (such as pytorch_model-00001-of-00006.bin) into the ggml format. Params.json (for llama 13B) included as example.
from sentencepiece import SentencePieceProcessor # type: ignore
import json, struct, os, re, zipfile, pickle, itertools, sys, enum, threading, concurrent.futures, argparse
from pathlib import Path
import numpy as np
from collections import namedtuple
from typing import Optional, Callable, Type, Any, Iterable, IO, Sequence, Union, TypeVar
from dataclasses import dataclass
NDArray = np.ndarray[Any, Any]
@stefanonardo
stefanonardo / early_stopping.py
Last active February 28, 2024 19:21
Early Stopping PyTorch
# MIT License
#
# Copyright (c) 2018 Stefano Nardo https://gist.github.com/stefanonardo
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions: