Llama trainer utility
Project description
🦙 Llama Trainer Utility
A "just few lines of code" utility for fine-tuning (not only) Llama models.
To install:
pip install llama-trainer
Training and Inference
Training
from llama_trainer import LlamaTrainer
from datasets import load_dataset
dataset = load_dataset("timdettmers/openassistant-guanaco")
# define your instruction-based sample
def to_instruction_fn(sample):
return sample["text"]
formatting_func = to_instruction_fn
output_dir = "llama-2-7b-hf-finetune"
llama_trainer = LlamaTrainer(
model_name="meta-llama/Llama-2-7b-hf",
dataset=dataset,
formatting_func=formatting_func,
output_dir=output_dir
)
llama_trainer.train()
Inference
from llama_trainer import LlamaInfer
import transformers as tr
llama_infer = LlamaInfer(output_dir)
prompt = "### Human: Give me some output!### Assistant:"
print(llama_infer(prompt))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
llama-trainer-0.2.1.tar.gz
(11.7 kB
view details)
Built Distribution
File details
Details for the file llama-trainer-0.2.1.tar.gz
.
File metadata
- Download URL: llama-trainer-0.2.1.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54ff7bac916315161c75549f11043cbc70a016afaac207d7163a24f7f8f820a8 |
|
MD5 | 8d6dbe2e6f068b05bca6c2f0ce25fc72 |
|
BLAKE2b-256 | 2baf3b04b223e875ffbe748d8fbc4c54ab1f16abc5ead1d68c86306286d75507 |
File details
Details for the file llama_trainer-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: llama_trainer-0.2.1-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03caffce8f476cbdea06f280e7a84fc55bc037b3489cce1ff3184a285b64afea |
|
MD5 | faa292397d747a76b474981841cc9958 |
|
BLAKE2b-256 | a13ab5ff93529be225059ad789d74233d973bf2bb631565a19b258c8190a3175 |