Giter Site home page Giter Site logo

fblissjr / outlines-mlx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sacha-ichbiah/outlines-mlx

1.0 1.0 0.0 451 KB

A fast minimalistic implementation of guided generation on Apple Silicon using Outlines and MLX

License: Apache License 2.0

Python 100.00%

outlines-mlx's Introduction

outlinesmlx

outlinesmlx is a minimalistic library aimed at adapting the Outlines library for use with the MLX framework.

To install, use: pip install outlinesmlx.

Outlines provides methods to control the generation of language models to make their output more predictable. Combined with MLX, it enables guided generation with large language models while leveraging Apple Silicon hardware.

Outlines-MLX

Design Principles

We designed it as an adapter that replaces the PyTorch parts of the original Outlines library with MLX compatible components. We will continue to update it actively as Outlines evolves over time.

Versioning

outlinesmlx-x is the MLX adapter for outlines-x. Versions can easily be checked with :

pip list | grep outlines

Why Outlines MLX?

We believe that guided generation is an important technology that will define the future of AI applications beyond chatbots. As Apple Silicon chips become increasingly powerful, we aim to extend guided-generation capabilities to a whole new family of devices. The original Outlines library relies on PyTorch, and adapting it to MLX requires changing many key components.

Installation

outlinesmlx can be installed directly from the PyPI repository:

pip install outlinesmlx

Supported Models

The models are imported using the library mlx-lm.

This allows for seamless importation of quantized models. You can import any model from the HuggingFace hub using this library.

Load Model with an MLX Backend

Refer to the examples folder and the original Outlines library for more use cases.

import outlinesmlx as outlines

model = outlines.models.mlx("mlx-community/Mistral-7B-Instruct-v0.1-4bit-mlx")

prompt = """You are a sentiment-labelling assistant.
Is the following review positive or negative?

Review: This restaurant is just awesome!
"""
answer = outlines.generate.choice(model, ["Positive", "Negative"])(prompt)

Disclaimer

This library is maintained on a monthly basis. Due to the rapid evolution of the MLX framework and the original Outlines library, it may not be up-to-date with their latest advancements. outlinesmlx is designed for experiments with guided generation on Apple Silicon. Please refer to the original Outlines library for an up-to-date implementation.

outlinesmlx is only compatible with MLX models. If you wish to perform guided generation using transformers or other architectures, please use the original Outlines library.

Contributions

We welcome external contributions!

Citation

Please do not forget to cite the original paper:

@article{willard2023efficient,
  title={Efficient Guided Generation for LLMs},
  author={Willard, Brandon T and Louf, R{\'e}mi},
  journal={arXiv preprint arXiv:2307.09702},
  year={2023}
}

outlines-mlx's People

Contributors

sacha-ichbiah avatar fblissjr avatar sroecker avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.