mlc-llm [Bug] max_single_sequence_length被覆盖了吗?

55ooxyrt  于 2个月前  发布在  其他
关注(0)|答案(2)|浏览(35)

### 🐛 Bug

在使用mlc-ai/Llama-3.1-8B-Instruct-q4f16_1-MLC(支持"context_window_size": 131072)时,我尝试输入一个非常长的提示(基本上是一本书,以及关于这本书的一个问题)。尽管设置了"max_num_sequence": 1, "max_total_sequence_length": 131072, "max_single_sequence_length": 131072,但我仍然遇到了这个错误:
 `mlc_llm.protocol.error_protocol.BadRequestError: Request prompt has 38726 tokens in total, larger than the model input length limit 8192.`
一个相关的问题:Llama-3.1-8B-Instruct-q4f16_1-MLC是否支持注意力汇聚?我想反复询问关于这本书的问题,我不关心上下文(这些问题不相关),但我需要让所有问题都保持在书中的上下文。所以我在想将attention_sinks设置为书的长度。或者,有没有更好的方法在每次转弯后将缓存重置到书的末尾?

### 要复现

from mlc_llm import MLCEngine
from mlc_llm.serve.config import EngineConfig

model = "HF://mlc-ai/Llama-3-8B-Instruct-q4f16_1-MLC"
engine_config = EngineConfig.from_json('''{"additional_models": [], "max_num_sequence": 1, "max_total_sequence_length": 131072, "max_single_sequence_length": 131072}''')
engine = MLCEngine(model, mode = "interactive", engine_config = engine_config)

with open('alice_in_wonderland.txt', 'r') as f:
txt = f.read()

for response in engine.chat.completions.create(
messages=[{"role": "user", "content": f"{txt}\n\nIn chapter 5, the Pigeon says Alice must be kind of serpent if she eats what?"}],
model=model, stream=True):
for choice in response.choices:
print(choice.delta.content, end="", flush=True)


### 预期行为

代码应该在没有任何错误的情况下执行(并希望正确回答问题)。

### 环境

* 平台(例如WebGPU/Vulkan/IOS/Android/CUDA):CUDA
* 操作系统(例如Ubuntu/Windows/MacOS/...):Ubuntu
* 设备(例如iPhone 12 Pro,PC+RTX 3090,...)RTX3090
* 如何安装MLC-LLM( `conda` ,源代码):python -m pip install --pre -U -f  [https://mlc.ai/wheels](https://mlc.ai/wheels)  mlc-llm-nightly-cu121 mlc-ai-nightly-cu121
* 如何安装TVM-Unity( `pip` ,源代码):N/A
* Python版本(例如3.10):3.11.9
* GPU驱动程序版本(如适用):550.90.07
* CUDA/cuDNN版本(如适用):12.1
* TVM Unity哈希标签( `python -c "import tvm; print('\n'.join(f'{k}: {v}' for k, v in tvm.support.libinfo().items()))"` ,适用于编译模型):N/A

### 其他上下文

附加了'alice_in_wonderland.txt'(只是整本书)。
 [alice_in_wonderland.txt](https://github.com/user-attachments/files/16375550/alice_in_wonderland.txt)
mitkmikd

mitkmikd1#

感谢您的反馈。我们会对此进行调查,了解具体情况。

rslzwgfq

rslzwgfq2#

我们在#2759中修复了这个问题,现在它运行得很好(在合并后)。
顺便说一下,Llama3不支持如此长的上下文,因此会产生无意义的输出。请尝试使用HF://mlc-ai/Llama-3.1-8B-Instruct-q4f16_1-MLC,它在我这边回答“eggs”。

相关问题