File size: 2,516 Bytes
ebc3bf5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os

# Model settings
LLM_MODEL = os.getenv("LLM_MODEL", "Qwen/Qwen2.5-1.5B-Instruct")
EMBEDDER_MODEL = os.getenv("EMBEDDER_MODEL", "sentence-transformers/all-MiniLM-L6-v2")

# Curated <32B open-weight causal LMs for local inference (shown in the UI dropdown).
AVAILABLE_MODELS = [
    "Qwen/Qwen2.5-1.5B-Instruct",
    "Qwen/Qwen2.5-0.5B-Instruct",
    "HuggingFaceTB/SmolLM2-1.7B-Instruct",
    "microsoft/Phi-3.5-mini-instruct",
    "meta-llama/Llama-3.2-1B-Instruct",
]

# Curated sentence-transformer embedding models for quality scoring.
AVAILABLE_EMBEDDER_MODELS = [
    "sentence-transformers/all-MiniLM-L6-v2",
    "sentence-transformers/all-mpnet-base-v2",
    "BAAI/bge-small-en-v1.5",
    "BAAI/bge-base-en-v1.5",
    "mixedbread-ai/mxbai-embed-large-v1",
    "Alibaba-NLP/gte-Qwen2-1.5B-instruct",
]

EMBEDDER_INFO = {
    "sentence-transformers/all-MiniLM-L6-v2": (
        "⚡ **Fast · 22M params · Default**  \n"
        "Great baseline. Scores are reliable for typical compression ratios. "
        "Runs comfortably on CPU — minimal overhead."
    ),
    "sentence-transformers/all-mpnet-base-v2": (
        "⚖️ **Balanced · 110M params**  \n"
        "Noticeably sharper quality scores than MiniLM, especially on longer texts. "
        "Small speed trade-off; fine on CPU."
    ),
    "BAAI/bge-small-en-v1.5": (
        "⚡ **Fast · 33M params**  \n"
        "Strong quality-to-size ratio — often matches MiniLM on accuracy while being "
        "slightly more sensitive to meaning shifts. Good CPU option."
    ),
    "BAAI/bge-base-en-v1.5": (
        "⚖️ **Balanced · 109M params**  \n"
        "Consistently strong on semantic similarity benchmarks. "
        "Scores will be more discriminating — small differences in compression quality show up more clearly."
    ),
    "mixedbread-ai/mxbai-embed-large-v1": (
        "🏆 **High quality · 335M params**  \n"
        "Top-tier similarity scores. Quality readings will be the most accurate here, "
        "but slower to load and run. GPU recommended."
    ),
    "Alibaba-NLP/gte-Qwen2-1.5B-instruct": (
        "🔬 **Best quality · 1.5B params**  \n"
        "Strongest semantic understanding in this list. Scores will reflect subtle meaning loss "
        "that smaller models miss. Requires significant RAM/VRAM — GPU strongly recommended."
    ),
}

# Compression settings
DEFAULT_TARGET_TOKENS = 500
MAX_NEW_TOKENS = 1024

# Gradio
APP_TITLE = "TinyPress"
SERVER_PORT = int(os.getenv("PORT", 7860))