Comments (6)
Yeah, I think it was intended that it runs on every token generated, and we can throw away the buffer entirely. This would address most issues.
It still needs a special case for streaming, since we need to anticipate a stop word, or we might stream parts of it. I have a prototype for that check currently, but still doing some testing.
from mlx-examples.
I'll try to sum it up
max_stop_id_sequence_len is the length of the longest stop id sequence. Now let's assume the buffer is the same size as the longest stop sequence.
if len(stop_sequence_buffer) > max_stop_id_sequence_len:
Since this check is non-inclusive, it would loop one extra time before running what comes after the if statement. Meaning the length of the buffer would now be 1 larger than the longest stop sequence.
Now when we take into account, that the stop_criteria function only checks for perfect matches, where the tail of the "tokens" matches a stop sequence. It can no longer ever match, because the extra tokens was generated before calling stop_criteria.
from mlx-examples.
Additionally the condition for checking the stop criteria is:
if len(stop_sequence_buffer) > max_stop_id_sequence_len:
It is not inclusive, meaning there will always be an extra token appended. Meaning no stop sequences can ever be matched.
from mlx-examples.
Additionally the condition for checking the stop criteria is:
if len(stop_sequence_buffer) > max_stop_id_sequence_len:It is not inclusive, meaning there will always be an extra token appended. Meaning no stop sequences can ever be matched.
Just curious, how did you find the issue? I ran a few tests before and didn't see any extra tokens added.
from mlx-examples.
I see, it would only happen when the model starts with the stop word. Maybe that's why it wasn't picked up by my testing. This edge case is a bit difficult to pick up with manual testing, but it would be more obvious when the model starts with a stop word.
from mlx-examples.
Yeah, you are right. The original implementation didn't have a buffer, so it ended up sending the stop word back to the client in the streaming. The buffer was introduced to solve that issue, but it seems like it wasn't well thought out in the implementation.
from mlx-examples.
Related Issues (20)
- LoRA: Increased volatility of train loss HOT 17
- Encountered mlx version issue in text2img example HOT 1
- LoRA llama2-70b not giving any info when fine tuning HOT 1
- Add chronos model(s) to mlx-lm HOT 6
- Can context size of llm be changed when generate text? HOT 3
- Add grok-1 to mlx-examples
- How to get a better trade-off between GPU-efficiency and memory footprint? HOT 2
- Training set not found HOT 2
- Could I use binary format data when fine tuning with lora? HOT 1
- How could I deal with the GPU memory issue when fine-tune with lora? HOT 5
- Add wav2vec2 support for real-time ASR
- [Feature Request] LLaVA 1.6 LoRA fine-tuning example HOT 15
- How to do the LoRA fine-tuning incrementally HOT 3
- Error in finetuning mistralai/Mixtral-8x7B-v0.1 using mlx_lm.lora HOT 10
- https://github.com/ml-explore/mlx-examples/blob/main/llms/mlx_lm/SERVER.md example is broken HOT 3
- Can't finetune mixtral-8x7B base model HOT 5
- No attribute 'state' issue when fine-tune with lora. HOT 1
- Question
- Question about code HOT 1
- Can't generate token with lora adapter HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mlx-examples.