Skip to main content

🦙 Llama Trainer Utility

Upload to PyPi

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))

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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_trainer-0.2.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

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

Hashes for llama-trainer-0.2.1.tar.gz
Algorithm Hash digest
SHA256 54ff7bac916315161c75549f11043cbc70a016afaac207d7163a24f7f8f820a8
MD5 8d6dbe2e6f068b05bca6c2f0ce25fc72
BLAKE2b-256 2baf3b04b223e875ffbe748d8fbc4c54ab1f16abc5ead1d68c86306286d75507

See more details on using hashes here.

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

Hashes for llama_trainer-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 03caffce8f476cbdea06f280e7a84fc55bc037b3489cce1ff3184a285b64afea
MD5 faa292397d747a76b474981841cc9958
BLAKE2b-256 a13ab5ff93529be225059ad789d74233d973bf2bb631565a19b258c8190a3175

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page