task/embedings
#6
by sriharsha-cr - opened
Files changed (3)
- config.py+4-5
- core/scorer.py+1-3
- models/model_loader.py+1-1
9 unmodified lines1011121314151613 unmodified lines303132333435363738399 unmodified lines"HuggingFaceTB/SmolLM2-135M-Instruct","HuggingFaceTB/SmolLM2-360M-Instruct","Qwen/Qwen2.5-1.5B-Instruct","meta-llama/Llama-3.2-1B-Instruct","HuggingFaceTB/SmolLM2-1.7B-Instruct","microsoft/Phi-3.5-mini-instruct",]13 unmodified lines"Strong instruction-following for its size; reliably respects token budgets. ""Best balance of speed and quality."),"meta-llama/Llama-3.2-1B-Instruct": ("🚀 **Fast · 1B params** — Loads in ~40 s. \n""Meta's smallest Llama; good general-purpose compression. ""Requires accepting the Llama licence on HF Hub."),"Qwen/Qwen2.5-1.5B-Instruct": ("⚖️ **Balanced · 1.5B params** — Loads in ~60 s. \n"9 unmodified lines1011121314151613 unmodified lines3031323334353637389 unmodified lines"HuggingFaceTB/SmolLM2-135M-Instruct","HuggingFaceTB/SmolLM2-360M-Instruct","Qwen/Qwen2.5-1.5B-Instruct","TinyLlama/TinyLlama-1.1B-Chat-v1.0","HuggingFaceTB/SmolLM2-1.7B-Instruct","microsoft/Phi-3.5-mini-instruct",]13 unmodified lines"Strong instruction-following for its size; reliably respects token budgets. ""Best balance of speed and quality."),"TinyLlama/TinyLlama-1.1B-Chat-v1.0": ("🚀 **Fast · 1.1B params** — Loads in ~40 s. \n""Fully open, no licence required. Good general-purpose compression at 1B scale."),"Qwen/Qwen2.5-1.5B-Instruct": ("⚖️ **Balanced · 1.5B params** — Loads in ~60 s. \n"
12347 unmodified lines1213141516171819import torchimport numpy as npfrom models.model_loader import get_embedder7 unmodified lines@_gpudef semantic_score(original: str, compressed: str) -> float:embedder = get_embedder()device = "cuda" if torch.cuda.is_available() else "cpu"vecs = embedder.encode([original, compressed], device=device, convert_to_numpy=True)cos = float(np.dot(vecs[0], vecs[1]) / (np.linalg.norm(vecs[0]) * np.linalg.norm(vecs[1])))1237 unmodified lines11121314151617import numpy as npfrom models.model_loader import get_embedder7 unmodified lines@_gpudef semantic_score(original: str, compressed: str) -> float:embedder = get_embedder()vecs = embedder.encode([original, compressed], convert_to_numpy=True)cos = float(np.dot(vecs[0], vecs[1]) / (np.linalg.norm(vecs[0]) * np.linalg.norm(vecs[1])))
94 unmodified lines959697989910010194 unmodified linesdef _load_embedder(model_id: str):global _embedder, _current_embedder_id_embedder = SentenceTransformer(model_id)_current_embedder_id = model_id94 unmodified lines959697989910010194 unmodified linesdef _load_embedder(model_id: str):global _embedder, _current_embedder_id_embedder = SentenceTransformer(model_id, device="cpu")_current_embedder_id = model_id
config.py+4-5
core/scorer.py+1-3
models/model_loader.py+1-1