Files
mlx-swift-examples/Libraries/LLM
Anthony ac6bdfccec Add Llama 3.1 (#98)
* Update Mistral 7B config

* Add Mistral NeMo

* Update for Llama 3.1

* Align LlamaConfiguration with Python implementation

* Fix model configuration names

* Refine DynamicNTKScalingRoPE

* compute base only once

---------

Co-authored-by: Awni Hannun <awni@apple.com>
2024-07-26 13:05:42 -07:00
..
2024-04-22 09:30:12 -07:00
2024-07-01 09:35:43 -07:00
2024-07-03 16:22:29 -07:00
2024-07-01 09:35:43 -07:00
2024-07-26 13:05:42 -07:00
2024-02-22 10:41:02 -08:00
2024-04-22 09:30:12 -07:00
2024-07-26 13:05:42 -07:00
2024-04-24 09:31:01 -07:00
2024-04-22 09:30:12 -07:00
2024-04-22 09:30:12 -07:00
2024-04-22 09:30:12 -07:00
2024-04-22 09:30:12 -07:00

LLM

This is a port of several models from:

using the Hugging Face swift transformers package to provide tokenization:

The Models.swift provides minor overrides and customization -- if you require overrides for the tokenizer or prompt customizations they can be added there.

This is set up to load models from Hugging Face, e.g. https://huggingface.co/mlx-community

The following models have been tried:

  • mlx-community/Mistral-7B-v0.1-hf-4bit-mlx
  • mlx-community/CodeLlama-13b-Instruct-hf-4bit-MLX
  • mlx-community/phi-2-hf-4bit-mlx
  • mlx-community/quantized-gemma-2b-it

Currently supported model types are:

  • Llama / Mistral
  • Gemma
  • Phi

See Configuration.swift for more info.

See llm-tool

LoRA

Lora.swift contains an implementation of LoRA based on this example:

See llm-tool/LoraCommands.swift for an example of a driver and llm-tool for examples of how to run it.