Research-friendly implementation of LLMs in JAX
Project description
fabrique
Fabrique is a collection of popular LLMs in JAX. It provides clean and research-friendly code as well as easy-to-use wrappers for end users.
Fabrique uses model snapshots from Huggingface Hub and provides familiar high-level API.
Installation
You can install the latest released version of fabrique from PYPI:
pip install fabrique
Alternatively, you can mount the development version of fabrique directly to your project and use existing code as reference for your own models:
cd /path/to/your/project
# clone the repository
git clone https://github.com/dfdx/fabrique
# or even add it as a submodule
# git submodule add git@github.com:dfdx/fabrique.git
# set up PYTHONPATH to include fabrique as a package
export PYTHONPATH=.:fabrique
Usage
High-level API
from fabrique.models.llm import LLM
model_id = "microsoft/phi-4"
# note: use keyword arguments that fit your hardware
llm = LLM.from_pretrained(model_id, max_batch_size=1, max_seq_len=512)
out = llm.generate("""<|user|>\nHow to print a value in Python?<|end|>\n<|assistant|>""")
print(out)
Working with models directly
Fabrique is built using Flax NNX. Citing NNX's home page:
NNX is a Neural Network library for JAX that focuses on providing the best development experience, so building and experimenting with neural networks is easy and intuitive. It achieves this by embracing Python’s object-oriented model and making it compatible with JAX transforms, resulting in code that is easy to inspect, debug, and analyze.
All Fabrique models can be found in fabrique/models/<model-name>/modeling.py files. Feel free to
copy and modify them. If something in the code is unclear, consider it a bug.
The very first model was inspired by the Meta's Llama 3 repo.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fabrique-0.1.0.tar.gz.
File metadata
- Download URL: fabrique-0.1.0.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
444671d453726b992a406bd8733125a2940ba47f5f684f3434f84c782dcab0b0
|
|
| MD5 |
ed4d7048b4c35c35095fdd9a93810a4c
|
|
| BLAKE2b-256 |
5005cd2ab5df62b20cfc43675702cd8cf0d24acf9f73f93b34e8a8bbef8ba15c
|
File details
Details for the file fabrique-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fabrique-0.1.0-py3-none-any.whl
- Upload date:
- Size: 40.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8334cfc0b09454d1d7e83fcd82b437dce2ab1af412061eaf7c7e788024c3ded
|
|
| MD5 |
24f56927611d2bd390c2e5f8f2a5bf64
|
|
| BLAKE2b-256 |
d025b09774916236c7baaa61dd52e35054715e208dfb50a08fd259734b5abec6
|