Text Classification
PEFT
Safetensors
English
lora
complexity-classification
llm-routing
query-difficulty
brick
semantic-router
inference-optimization
cost-reduction
reasoning-budget
Eval Results (legacy)
Instructions to use regolo/brick-complexity-extractor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use regolo/brick-complexity-extractor with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-0.8B") model = PeftModel.from_pretrained(base_model, "regolo/brick-complexity-extractor") - Notebooks
- Google Colab
- Kaggle
root commited on
Commit ·
60a6bce
1
Parent(s): e6d73e1
Add GGUF quantized models (BF16, Q8_0, Q4_K_M) and update README with GGUF usage section
Browse filesFiles changed (5)
33 unmodified lines34353633 unmodified lines*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -texttokenizer.json filter=lfs diff=lfs merge=lfs -text33 unmodified lines3435363733 unmodified lines*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -texttokenizer.json filter=lfs diff=lfs merge=lfs -text*.gguf filter=lfs diff=lfs merge=lfs -text
6 unmodified lines78910111228 unmodified lines414243444546474849505112 unmodified lines64656667686912 unmodified lines8283848586878821 unmodified lines11011111211311411511611711811912012112212312412512612712812913013113213313413561 unmodified lines19719819920020120233 unmodified lines23623723823924024124224324424524624724824911 unmodified lines2612622632642652662675 unmodified lines2732742752762772782793 unmodified lines28328428528628728828929029116 unmodified lines3083093103113123136 unmodified lines- peft- safetensors- lora- complexity-classification- llm-routing- query-difficulty28 unmodified lines<div align="center"># 🧱 Brick Complexity Extractor### A lightweight LoRA adapter for real-time query complexity classification**[Regolo.ai](https://regolo.ai) · [Dataset](https://huggingface.co/datasets/regolo/brick-complexity-extractor) · [Brick SR1 on GitHub](https://github.com/regolo-ai/brick-SR1) · [API Docs](https://docs.regolo.ai)**[](https://creativecommons.org/licenses/by-nc/4.0/)[](https://huggingface.co/Qwen/Qwen3.5-0.8B)12 unmodified lines- [Label Definitions](#label-definitions)- [Performance](#performance)- [Quick Start](#quick-start)- [Integration with Brick Semantic Router](#integration-with-brick-semantic-router)- [Intended Uses](#intended-uses)- [Limitations](#limitations)12 unmodified lines## The Problem: Why LLM Routing Needs Complexity ClassificationNot all prompts are equal. A factual recall question ("What is the capital of France?") and a multi-step reasoning task ("Derive the optimal portfolio allocation given these constraints…") require fundamentally different compute budgets. Sending every query to a frontier reasoning model wastes resources; sending hard queries to a lightweight model degrades quality.**Brick** solves this by routing each query to the right model tier in real time. Complexity classification is one of several routing signals (alongside keyword matching, domain detection, and reasoning-depth estimation) that Brick uses to make sub-50ms routing decisions.21 unmodified lines```Qwen3.5-0.8B (frozen)└── Attention Layers × 24├── q_proj ← LoRA(r=16, α=32)└── v_proj ← LoRA(r=16, α=32)└── Last Hidden State└── Classification Head (3 classes)```## Label Definitions| Label | Reasoning Steps | Description | Example ||---|---|---|---|| **easy** | 1–2 | Surface knowledge, factual recall, simple lookups | "What is the capital of Italy?" || **medium** | 3–5 | Domain familiarity, multi-step reasoning, comparison | "Compare REST and GraphQL for a mobile app backend" || **hard** | 6+ | Deep expertise, multi-constraint optimization, creative synthesis | "Design a distributed cache eviction policy that minimizes tail latency under bursty traffic" |Labels were generated by **Qwen3.5-122B** acting as an LLM judge on 76,831 diverse user prompts. See the [dataset card](https://huggingface.co/datasets/regolo/brick-complexity-extractor) for full labeling methodology.## Performance### Classification Metrics (Test Set — 3,841 samples)| Metric | Value ||---|---|61 unmodified lines# https://github.com/regolo-ai/brick-SR1```## Integration with Brick Semantic RouterBrick Complexity Extractor is designed to work as a signal within the **Brick Semantic Router** pipeline. In a typical deployment:33 unmodified lines## Intended Uses### ✅ Primary Use Cases- **LLM routing**: Classify query complexity to route to the optimal model tier, reducing inference cost by 30–60% compared to always-frontier routing- **Reasoning budget allocation**: Decide how many reasoning tokens to allocate before inference begins- **Traffic shaping**: Balance GPU load across model pools based on real-time complexity distribution- **Cost monitoring**: Track complexity distribution over time to optimize fleet sizing### ⚠️ Out-of-Scope Uses- **Content moderation or safety filtering** — this model classifies cognitive difficulty, not content safety- **Non-English queries** trained on English data only; accuracy degrades significantly on other languages- **Direct use as a chatbot or generative model** this is a classification adapter, not a generative model11 unmodified lines|---|---|| **Base model** | Qwen/Qwen3.5-0.8B || **LoRA rank (r)** | 16 || **LoRA alpha (α)** | 32 || **LoRA dropout** | 0.05 || **Target modules** | q_proj, v_proj || **Learning rate** | 2e-4 |5 unmodified lines| **Training samples** | 65,307 || **Validation samples** | 7,683 || **Test samples** | 3,841 || **Training hardware** | 1× NVIDIA A100 80GB || **Training time** | ~2 hours || **Framework** | PyTorch + HuggingFace PEFT |3 unmodified lines| Metric | Value ||---|---|| **Hardware** | 1× NVIDIA A100 80GB || **Training duration** | ~2 hours || **Estimated CO₂** | < 0.5 kg CO₂eq || **Energy source** | Renewable (certified) || **Location** | Italy (EU) |16 unmodified lines<div align="center">**[Website](https://regolo.ai) · [Docs](https://docs.regolo.ai) · [Discord](https://discord.gg/myuuVFcfJw) · [GitHub](https://github.com/regolo-ai) · [LinkedIn](https://www.linkedin.com/company/regolo-ai/)**</div>6 unmodified lines7891011121328 unmodified lines424344454647484950515212 unmodified lines6566676869707112 unmodified lines8485868788899021 unmodified lines11211311411511611711811912012112212312412512612712812913013113213313413513613761 unmodified lines19920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430533 unmodified lines33934034134234334434534634734834935035135211 unmodified lines3643653663673683693705 unmodified lines3763773783793803813823 unmodified lines38638738838939039139239339416 unmodified lines4114124134144154166 unmodified lines- peft- safetensors- lora- gguf- complexity-classification- llm-routing- query-difficulty28 unmodified lines<div align="center"># Brick Complexity Extractor### A lightweight LoRA adapter for real-time query complexity classification**[Regolo.ai](https://regolo.ai) | [Dataset](https://huggingface.co/datasets/regolo/brick-complexity-extractor) | [Brick SR1 on GitHub](https://github.com/regolo-ai/brick-SR1) | [API Docs](https://docs.regolo.ai)**[](https://creativecommons.org/licenses/by-nc/4.0/)[](https://huggingface.co/Qwen/Qwen3.5-0.8B)12 unmodified lines- [Label Definitions](#label-definitions)- [Performance](#performance)- [Quick Start](#quick-start)- [GGUF Quantized Models](#gguf-quantized-models)- [Integration with Brick Semantic Router](#integration-with-brick-semantic-router)- [Intended Uses](#intended-uses)- [Limitations](#limitations)12 unmodified lines## The Problem: Why LLM Routing Needs Complexity ClassificationNot all prompts are equal. A factual recall question ("What is the capital of France?") and a multi-step reasoning task ("Derive the optimal portfolio allocation given these constraints...") require fundamentally different compute budgets. Sending every query to a frontier reasoning model wastes resources; sending hard queries to a lightweight model degrades quality.**Brick** solves this by routing each query to the right model tier in real time. Complexity classification is one of several routing signals (alongside keyword matching, domain detection, and reasoning-depth estimation) that Brick uses to make sub-50ms routing decisions.21 unmodified lines```Qwen3.5-0.8B (frozen)+-- Attention Layers x 24|-- q_proj <- LoRA(r=16, alpha=32)+-- v_proj <- LoRA(r=16, alpha=32)+-- Last Hidden State+-- Classification Head (3 classes)```## Label Definitions| Label | Reasoning Steps | Description | Example ||---|---|---|---|| **easy** | 1-2 | Surface knowledge, factual recall, simple lookups | "What is the capital of Italy?" || **medium** | 3-5 | Domain familiarity, multi-step reasoning, comparison | "Compare REST and GraphQL for a mobile app backend" || **hard** | 6+ | Deep expertise, multi-constraint optimization, creative synthesis | "Design a distributed cache eviction policy that minimizes tail latency under bursty traffic" |Labels were generated by **Qwen3.5-122B** acting as an LLM judge on 76,831 diverse user prompts. See the [dataset card](https://huggingface.co/datasets/regolo/brick-complexity-extractor) for full labeling methodology.## Performance### Classification Metrics (Test Set -- 3,841 samples)| Metric | Value ||---|---|61 unmodified lines# https://github.com/regolo-ai/brick-SR1```---## GGUF Quantized ModelsPre-built GGUF files are available for inference with [llama.cpp](https://github.com/ggml-org/llama.cpp), [Ollama](https://ollama.com), [LM Studio](https://lmstudio.ai), [vLLM](https://github.com/vllm-project/vllm), and other GGUF-compatible runtimes.These files contain the **full merged model** (base Qwen3.5-0.8B + LoRA adapter merged), so no separate adapter loading is needed.### Available Quantizations| File | Quant | Size | BPW | Notes ||---|---|---|---|---|| `brick-complexity-extractor-BF16.gguf` | BF16 | 1.5 GB | 16.0 | Full precision, no quality loss || `brick-complexity-extractor-Q8_0.gguf` | Q8_0 | 775 MB | 8.0 | Near-lossless, recommended for accuracy || `brick-complexity-extractor-Q4_K_M.gguf` | Q4_K_M | 494 MB | 5.5 | Best quality/size ratio |### Usage with llama.cpp```bash# Download a quantized modelhuggingface-cli download regolo/brick-complexity-extractor \brick-complexity-extractor-Q8_0.gguf \--local-dir ./models# Run inference./llama-cli -m ./models/brick-complexity-extractor-Q8_0.gguf \-p "<|im_start|>systemYou are a query difficulty classifier for an LLM routing system.Classify each query as easy, medium, or hard based on the cognitive depth and domain expertise required to answer correctly.Respond with ONLY one word: easy, medium, or hard.<|im_end|><|im_start|>userClassify: What is the capital of France?<|im_end|><|im_start|>assistant" \-n 5 --temp 0```### Usage with Ollama```bash# Create a Modelfilecat > Modelfile <<EOFFROM ./brick-complexity-extractor-Q8_0.ggufSYSTEM """You are a query difficulty classifier for an LLM routing system.Classify each query as easy, medium, or hard based on the cognitive depth and domain expertise required to answer correctly.Respond with ONLY one word: easy, medium, or hard."""TEMPLATE """<|im_start|>system{{ .System }}<|im_end|><|im_start|>userClassify: {{ .Prompt }}<|im_end|><|im_start|>assistant"""PARAMETER temperature 0PARAMETER num_predict 5EOFollama create brick-complexity -f Modelfileollama run brick-complexity "Design a distributed consensus algorithm"# Output: hard```### Usage with vLLM```pythonfrom vllm import LLM, SamplingParamsllm = LLM(model="regolo/brick-complexity-extractor",quantization="gguf",# Point to a specific GGUF file:# model="./brick-complexity-extractor-Q8_0.gguf")sampling_params = SamplingParams(temperature=0, max_tokens=5)prompt = """<|im_start|>systemYou are a query difficulty classifier for an LLM routing system.Classify each query as easy, medium, or hard.Respond with ONLY one word: easy, medium, or hard.<|im_end|><|im_start|>userClassify: Explain the rendering equation from radiometric first principles<|im_end|><|im_start|>assistant"""output = llm.generate([prompt], sampling_params)print(output[0].outputs[0].text.strip())# Output: hard```### Important Note on GGUF InferenceThe GGUF models use **generative text output** (the model generates the word "easy", "medium", or "hard") rather than the logit-based classification used by the LoRA adapter. This means:- **LoRA adapter (recommended for production)**: Uses logit extraction at the last token position for the three label tokens. Faster and more reliable.- **GGUF (recommended for local/edge deployment)**: Generates the classification label as text. Slightly lower accuracy but works with any GGUF runtime without Python dependencies.---## Integration with Brick Semantic RouterBrick Complexity Extractor is designed to work as a signal within the **Brick Semantic Router** pipeline. In a typical deployment:33 unmodified lines## Intended Uses### Primary Use Cases- **LLM routing**: Classify query complexity to route to the optimal model tier, reducing inference cost by 30-60% compared to always-frontier routing- **Reasoning budget allocation**: Decide how many reasoning tokens to allocate before inference begins- **Traffic shaping**: Balance GPU load across model pools based on real-time complexity distribution- **Cost monitoring**: Track complexity distribution over time to optimize fleet sizing### Out-of-Scope Uses- **Content moderation or safety filtering** -- this model classifies cognitive difficulty, not content safety- **Non-English queries** trained on English data only; accuracy degrades significantly on other languages- **Direct use as a chatbot or generative model** this is a classification adapter, not a generative model11 unmodified lines|---|---|| **Base model** | Qwen/Qwen3.5-0.8B || **LoRA rank (r)** | 16 || **LoRA alpha** | 32 || **LoRA dropout** | 0.05 || **Target modules** | q_proj, v_proj || **Learning rate** | 2e-4 |5 unmodified lines| **Training samples** | 65,307 || **Validation samples** | 7,683 || **Test samples** | 3,841 || **Training hardware** | 1x NVIDIA A100 80GB || **Training time** | ~2 hours || **Framework** | PyTorch + HuggingFace PEFT |3 unmodified lines| Metric | Value ||---|---|| **Hardware** | 1x NVIDIA A100 80GB || **Training duration** | ~2 hours || **Estimated CO2** | < 0.5 kg CO2eq || **Energy source** | Renewable (certified) || **Location** | Italy (EU) |16 unmodified lines<div align="center">**[Website](https://regolo.ai) | [Docs](https://docs.regolo.ai) | [Discord](https://discord.gg/myuuVFcfJw) | [GitHub](https://github.com/regolo-ai) | [LinkedIn](https://www.linkedin.com/company/regolo-ai/)**</div>
123version https://git-lfs.github.com/spec/v1oid sha256:6fc8392a811ff1b3dbdb7348110893bac25f912540a58ae7ff4e1cb96ceced92size 1516736384123version https://git-lfs.github.com/spec/v1oid sha256:8bb38e63a7eeabddd729f2cdadfc7bd04b82aea413778e77bd4dee2b03a5489esize 529289088123version https://git-lfs.github.com/spec/v1oid sha256:1f74b88a1b7149dd9074eed60cadfc7555fca227ddbc1c71ec30a635f7cd3913size 811835264.gitattributes+1
README.md+123-20
brick-complexity-extractor-BF16.ggufAdded+3
brick-complexity-extractor-Q4_K_M.ggufAdded+3
brick-complexity-extractor-Q8_0.ggufAdded+3