-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_test.py
More file actions
53 lines (46 loc) · 1.59 KB
/
Copy pathquick_test.py
File metadata and controls
53 lines (46 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
Quick LoRA Test - Works without DLL issues
Uses llama.cpp Python bindings
"""
import sys
import os
# Add llama.cpp to path
sys.path.insert(0, '../../llama.cpp/build/bin')
try:
from llama_cpp import Llama
print("✅ llama-cpp-python available")
except ImportError:
print("❌ llama-cpp-python not installed")
print("\nInstall it with:")
print(' pip install llama-cpp-python')
print('\nOr test via API after starting the server without --lora')
sys.exit(1)
# Test configuration
BASE_MODEL = "../../SmolLM2.Q4_K_M.gguf"
LORA_PATH = "./lora-output/Lora-Output-F16-LoRA.gguf"
PROMPT = "Once upon a time in a magical forest"
print("\n" + "="*70)
print("Testing Base Model vs LoRA-Enhanced Model")
print("="*70)
# Test 1: Without LoRA
print("\n🔵 Test 1: BASE MODEL (no LoRA)")
print("-"*70)
try:
llm = Llama(model_path=BASE_MODEL, n_ctx=512, n_threads=4, verbose=False)
result = llm(PROMPT, max_tokens=60, temperature=0.7, stop=["\n\n"])
print(f"Prompt: {PROMPT}")
print(f"Output: {result['choices'][0]['text']}")
except Exception as e:
print(f"❌ Error: {e}")
# Test 2: With LoRA
print("\n🟢 Test 2: WITH LORA ADAPTER")
print("-"*70)
try:
llm_lora = Llama(model_path=BASE_MODEL, lora_path=LORA_PATH, n_ctx=512, n_threads=4, verbose=False)
result = llm_lora(PROMPT, max_tokens=60, temperature=0.7, stop=["\n\n"])
print(f"Prompt: {PROMPT}")
print(f"Output: {result['choices'][0]['text']}")
print("\n✅ LoRA is working!")
except Exception as e:
print(f"❌ Error: {e}")
print("\n" + "="*70)