ml-explore / ml-explore/mlx-examples
Fused & Uploaded Model Losing Coherence
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 9k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
I noticed today that when I use python -m mlx_lm.generate the output doesn't match what I get locally using python lora.py. For example:
Local output using lora adapters:
(base) Williams-MacBook-Pro-3:lora williammarcellino$ python lora.py --model /Users/williammarcellino/mlx-examples/lora/mlx_model \
> --adapter-file /Users/williammarcellino/mlx-examples/lora/adapters.npz \
> --max-tokens 250 \
> --temp .7 \
> --prompt "
> Q: How does Aristotle define the soul?
> A: "
Loading pretrained model
Total parameters 7243.436M
Trainable parameters 1.704M
Loading datasets
Generating
Q: How does Aristotle define the soul?
A:
Aristotle defines the soul as "the first act of a living body, which has in itself the faculty of movement and sensation."
This definition encompasses two key elements:
1) The soul is
the first act or principle of life in a living being.
2) The soul is
the faculties of movement and sensation in a living being.
Let's explore these two aspects further:
1. The Soul as the First Act:
Aristotle views the soul as the first and most fundamental aspect of a living being.
He argues that the soul is the source of life, and that it is responsible for all
the activities and functions of a living organism.
In this sense, the soul is not a separate entity from the body, but rather
the animating principle that gives rise to life in a living being.
2. The Soul as the Faculties of Movement and Sensation:
Aristotle defines the soul as the faculties of movement and sensation in a
living being.
Whereas the same prompt and arguments produces a pretty weird, incoherent response:
(base) Williams-MacBook-Pro-3:mlx_lm williammarcellino$ python -m mlx_lm.generate \
> --max-tokens 250 \
> --temp .7 \
> --prompt "
> > Q: How does Aristotle define the soul?
> > A: " \
> --model mlx-community/mistral-7b-v0.2-GreeceRome-v0
Fetching 6 files: 100%|██████████████████████████████████████████████████████████████| 6/6 [00:00<00:00, 21290.88it/s]
==========
Prompt:
> Q: How does Aristotle define the soul?
> A:
Aristotle defines the soul as the first principle and cause of the body's life-giving activities.
He considers the soul to be a substance that is inherent in every living body and is the actuality of all its processes.
The soul is the form and final cause of the organism, and the efficient cause of its operations and growth.
Aristotle's definition of the soul is complex and multifaceted, encompassing both material and formal aspects.
==========
Prompt: 52.869 tokens-per-sec
Generation: 19.099 tokens-per-sec
(base) Williams-MacBook-Pro-3:mlx_lm williammarcellino$
In particular it looks like the model forced out a bunch of blank tokens using mlx_lm.generate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the discrepancy with python lora.py using the local model and adapters.npz, then compare it with python -m mlx_lm.generate using the uploaded model and the same prompt and generation arguments. Investigate why the uploaded or fused model emits incoherent output and blank tokens; done means the two invocation paths produce consistent, coherent generation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100