The following code is from a Google Colab Jupyter notebook. It generates two links,…
- User
The following code is from a Google Colab Jupyter notebook. It generates two links, enabling me to chat with the LLM on the web UI from the second link:
Running on local URL: http://127.0.0.1:7860 Running on public URL: https://489e41305a2cb9d0f4.gradio.live
If instead I want to chat with the LLM in the same jupyter notebook, and without a gradio link generated, how can the code be amended? In other words, I want to chat with the model using only python code. Tell me the strategy, then rewrite the code yourself.
Jupyter Notebook Code:
#@title 2. Launch the web UI
#@markdown If unsure about the branch, write "main" or leave it blank.
import torch from pathlib import Path
if Path.cwd().name != 'text-generation-webui': print("Installing the webui...")
!git clone https://github.com/oobabooga/text-generation-webui %cd text-generation-webui
torver = torch.version print(f"TORCH: {torver}") is_cuda118 = '+cu118' in torver # 2.1.0+cu118 is_cuda117 = '+cu117' in torver # 2.0.1+cu117
textgen_requirements = open('requirements.txt').read().splitlines() if is_cuda117: textgen_requirements = [req.replace('+cu121', '+cu117').replace('+cu122', '+cu117').replace('torch2.1', 'torch2.0') for req in textgen_requirements] elif is_cuda118: textgen_requirements = [req.replace('+cu121', '+cu118').replace('+cu122', '+cu118') for req in textgen_requirements] with open('temp_requirements.txt', 'w') as file: file.write('\n'.join(textgen_requirements))
!pip install -r extensions/openai/requirements.txt --upgrade !pip install -r temp_requirements.txt --upgrade
print("\033[1;32;1m\n --> If you see a warning about "previously imported packages", just ignore it.\033[0;37;0m") print("\033[1;32;1m\n --> There is no need to restart the runtime.\n\033[0;37;0m")
try: import flash_attn except: !pip uninstall -y flash_attn
Parameters
model_url = "https://huggingface.co/TheBloke/Utopia-13B-GPTQ" #@param {type:"string"} branch = "main" #@param {type:"string"} command_line_flags = "--n-gpu-layers 128 --load-in-4bit --use_double_quant" #@param {type:"string"} api = False #@param {type:"boolean"}
if api: for param in ['--api', '--public-api']: if param not in command_line_flags: command_line_flags += f" {param}"
model_url = model_url.strip() if model_url != "": if not model_url.startswith('http'): model_url = '' + model_url
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.