import os from threading import Thread from typing import Iterator import gradio as gr import spaces import torch from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer import subprocess subprocess.run( "pip install flash-attn --no-build-isolation", env={"FLASH_ATTENTION_SKIP_CUDA_BUILD": "TRUE"}, shell=True, ) CUSTOM_CSS = """ .container { max-width: 1000px !important; margin: auto !important; padding-top: 2rem !important; } .header-container { background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%); padding: 2rem; border-radius: 1rem; margin-bottom: 2rem; color: white; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); } .model-info { background: white; padding: 1.5rem; border-radius: 0.5rem; margin-top: 1rem; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } .chat-container { border: 1px solid #e5e7eb; border-radius: 1rem; background: white; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); } .message { padding: 1rem; margin: 0.5rem; border-radius: 0.5rem; } .user-message { background: #f3f4f6; } .assistant-message { background: #dbeafe; } .controls-container { background: #f8fafc; padding: 1.5rem; border-radius: 0.5rem; margin-top: 1rem; } .slider-label { font-weight: 600; color: #374151; } .duplicate-button { background: #2563eb !important; color: white !important; padding: 0.75rem 1.5rem !important; border-radius: 0.5rem !important; font-weight: 600 !important; transition: all 0.2s !important; } .duplicate-button:hover { background: #1d4ed8 !important; transform: translateY(-1px) !important; } """ DESCRIPTION = '''
This Space demonstrates Lexora-Lite-3B Chat ITA, currently the best open-source large language model for the Italian language. Compare its performance with other models on the official leaderboard.