AI_test / ai.py
SWYfisher's picture
Update ai.py
9b2ff3e verified
Raw History Blame Contribute Delete
1.36 kB
import os
from huggingface_hub import hf_hub_download
from llama_cpp import Llama
# Define the model details
model_name = "mradermacher/Llama3.3-8B-Instruct-Thinking-Heretic-Uncensored-Claude-4.5-Opus-High-Reasoning-i1-GGUF" # Changing to Deepseek Coder Instruct (6.7B parameters)
model_file = "Llama3.3-8B-Instruct-Thinking-Heretic-Uncensored-Claude-4.5-Opus-High-Reasoning.i1-Q6_K.gguf" # A quantized model file for Deepseek Coder
# Define the path where the model will be downloaded
model_path = os.path.join(os.getcwd(), model_file)
# Download the model if it doesn't exist
if not os.path.exists(model_path):
print(f"Downloading {model_file} from Hugging Face Hub...")
hf_hub_download(
repo_id=model_name,
filename=model_file,
local_dir=os.getcwd(),
local_dir_use_symlinks=False,
)
print("Download complete.")
else:
print(f"{model_file} already exists, skipping download.")
# Initialize the Llama model
print("Initializing Llama model...")
llm = Llama(model_path=model_path, n_ctx=2048, n_gpu_layers=-1)
print("Model initialized.")
# Example of using the model
prompt = "Q: What is the capital of China? A:"
print(f"\nUser: {prompt}")
output = llm(
prompt,
max_tokens=2048,
stop=["Q:", "\n"],
echo=True,
temperature=0.7,
)
print("LLM Output:")
print(output["choices"][0]["text"])