File size: 6,163 Bytes
519b145 |
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
#!/usr/bin/env python3
"""
Script to check which models are currently being used on Hugging Face Space.
"""
import os
import sys
# Add backend to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'backend'))
def check_embedding_model():
"""Check embedding model configuration."""
from hue_portal.core.embeddings import (
DEFAULT_MODEL_NAME,
FALLBACK_MODEL_NAME,
AVAILABLE_MODELS,
get_embedding_model
)
print("=" * 60)
print("🔍 EMBEDDING MODEL CONFIGURATION")
print("=" * 60)
# Check environment variable
env_model = os.environ.get("EMBEDDING_MODEL")
if env_model:
print(f"📌 EMBEDDING_MODEL env var: {env_model}")
else:
print(f"📌 EMBEDDING_MODEL env var: Not set (using default)")
print(f"📌 Default model: {DEFAULT_MODEL_NAME}")
print(f"📌 Fallback model: {FALLBACK_MODEL_NAME}")
# Try to load model
print("\n🔄 Attempting to load embedding model...")
try:
model = get_embedding_model()
if model:
# Get dimension
test_embedding = model.encode("test", show_progress_bar=False)
dim = len(test_embedding)
print(f"✅ Model loaded successfully!")
print(f" Model name: {DEFAULT_MODEL_NAME}")
print(f" Dimension: {dim}")
print(f" Status: ✅ GOOD")
# Evaluate
if dim >= 768:
print(f" Quality: ⭐⭐⭐⭐ High quality (768+ dim)")
elif dim >= 384:
print(f" Quality: ⭐⭐⭐ Good quality (384 dim)")
else:
print(f" Quality: ⭐⭐ Basic quality")
else:
print("❌ Failed to load model")
except Exception as e:
print(f"❌ Error: {e}")
print("\n📊 Available models:")
for key, value in AVAILABLE_MODELS.items():
marker = "⭐" if value == DEFAULT_MODEL_NAME else " "
print(f" {marker} {key}: {value}")
def check_llm_model():
"""Check LLM model configuration."""
from hue_portal.chatbot.llm_integration import (
LLM_PROVIDER,
LLM_PROVIDER_NONE,
LLM_PROVIDER_OPENAI,
LLM_PROVIDER_ANTHROPIC,
LLM_PROVIDER_OLLAMA,
LLM_PROVIDER_HUGGINGFACE,
LLM_PROVIDER_LOCAL,
get_llm_generator
)
print("\n" + "=" * 60)
print("🔍 LLM MODEL CONFIGURATION")
print("=" * 60)
print(f"📌 LLM_PROVIDER: {LLM_PROVIDER}")
if LLM_PROVIDER == LLM_PROVIDER_NONE:
print("⚠️ No LLM provider configured!")
print(" Status: ❌ NOT USING LLM (template-based only)")
print(" Quality: ⭐⭐ Basic (no LLM generation)")
print("\n💡 To enable LLM, set LLM_PROVIDER to one of:")
print(" - ollama (for local Qwen)")
print(" - openai (for GPT)")
print(" - anthropic (for Claude)")
print(" - huggingface (for HF Inference API)")
print(" - local (for local Transformers)")
elif LLM_PROVIDER == LLM_PROVIDER_OPENAI:
model = os.environ.get("OPENAI_MODEL", "gpt-3.5-turbo")
print(f"✅ Using OpenAI")
print(f" Model: {model}")
print(f" Status: ✅ GOOD")
print(f" Quality: ⭐⭐⭐⭐⭐ Excellent")
elif LLM_PROVIDER == LLM_PROVIDER_ANTHROPIC:
model = os.environ.get("ANTHROPIC_MODEL", "claude-3-5-sonnet-20241022")
print(f"✅ Using Anthropic Claude")
print(f" Model: {model}")
print(f" Status: ✅ EXCELLENT")
print(f" Quality: ⭐⭐⭐⭐⭐ Best for Vietnamese")
elif LLM_PROVIDER == LLM_PROVIDER_OLLAMA:
model = os.environ.get("OLLAMA_MODEL", "qwen2.5:7b")
base_url = os.environ.get("OLLAMA_BASE_URL", "http://localhost:11434")
print(f"✅ Using Ollama (local)")
print(f" Model: {model}")
print(f" Base URL: {base_url}")
print(f" Status: ✅ GOOD (if Ollama running)")
print(f" Quality: ⭐⭐⭐⭐ Very good for Vietnamese")
elif LLM_PROVIDER == LLM_PROVIDER_HUGGINGFACE:
model = os.environ.get("HF_MODEL", "Qwen/Qwen2.5-7B-Instruct")
print(f"✅ Using Hugging Face Inference API")
print(f" Model: {model}")
print(f" Status: ✅ GOOD")
print(f" Quality: ⭐⭐⭐⭐ Good for Vietnamese")
elif LLM_PROVIDER == LLM_PROVIDER_LOCAL:
model = os.environ.get("LOCAL_MODEL_PATH", "Qwen/Qwen2.5-1.5B-Instruct")
device = os.environ.get("LOCAL_MODEL_DEVICE", "auto")
print(f"✅ Using Local Transformers")
print(f" Model: {model}")
print(f" Device: {device}")
print(f" Status: ✅ GOOD (if model loaded)")
print(f" Quality: ⭐⭐⭐⭐ Good for Vietnamese")
# Try to get LLM generator
print("\n🔄 Checking LLM availability...")
try:
llm = get_llm_generator()
if llm and llm.is_available():
print("✅ LLM is available and ready!")
else:
print("⚠️ LLM is not available")
except Exception as e:
print(f"❌ Error checking LLM: {e}")
def main():
"""Main function."""
print("\n" + "=" * 60)
print("📊 MODEL STATUS CHECK")
print("=" * 60)
print()
check_embedding_model()
check_llm_model()
print("\n" + "=" * 60)
print("📋 SUMMARY")
print("=" * 60)
# Embedding summary
from hue_portal.core.embeddings import DEFAULT_MODEL_NAME
embedding_model = os.environ.get("EMBEDDING_MODEL", DEFAULT_MODEL_NAME)
print(f"Embedding: {embedding_model}")
# LLM summary
from hue_portal.chatbot.llm_integration import LLM_PROVIDER, LLM_PROVIDER_NONE
if LLM_PROVIDER == LLM_PROVIDER_NONE:
print("LLM: None (template-based only)")
else:
print(f"LLM: {LLM_PROVIDER}")
print("\n💡 Recommendations:")
print(" - Embedding: multilingual-mpnet (current) is good ✅")
print(" - LLM: Consider adding Qwen 2.5 for better answers")
print()
if __name__ == "__main__":
main()
|