"/usr/local/miniconda3/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for <class 'numpy.float64'> type is zero.\n",
" setattr(self, word, getattr(machar, word).flat[0])\n",
"/usr/local/miniconda3/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for <class 'numpy.float64'> type is zero.\n",
"/usr/local/miniconda3/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for <class 'numpy.float32'> type is zero.\n",
" setattr(self, word, getattr(machar, word).flat[0])\n",
"/usr/local/miniconda3/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for <class 'numpy.float32'> type is zero.\n",
"Qwen2ForCausalLM has generative capabilities, as `prepare_inputs_for_generation` is explicitly overwritten. However, it doesn't directly inherit from `GenerationMixin`.`PreTrainedModel` will NOT inherit from `GenerationMixin`, and this model will lose the ability to call `generate` and other related functions.\n",
" - If you are the owner of the model architecture code, please modify your model class such that it inherits from `GenerationMixin` (after `PreTrainedModel`, otherwise you'll get an exception).\n",
" - If you are not the owner of the model architecture class, please contact the model code owner to update it.\n",
"Sliding Window Attention is enabled but not implemented for `eager`; unexpected results may be encountered.\n"
" t = Thread(target=model.generate, kwargs=generate_kwargs)\n",
" t.start() # Starting the generation in a separate thread.\n",
" partial_message = \"\"\n",
" for new_token in streamer:\n",
" partial_message += new_token\n",
" if '</s>' in partial_message: # Breaking the loop if the stop token is generated.\n",
" break\n",
" yield partial_message"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "689f36be-c14b-495e-9315-80c7b09773b7",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/miniconda3/lib/python3.9/site-packages/gradio/analytics.py:106: UserWarning: IMPORTANT: You are using gradio version 4.44.0, however version 4.44.1 is available, please upgrade. \n",
"--------\n",
" warnings.warn(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running on local URL: http://192.168.110.83:7862\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"