Instructions to use krogoldAI/QueryRefiner-0.5B-v0.1-SFT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use krogoldAI/QueryRefiner-0.5B-v0.1-SFT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="krogoldAI/QueryRefiner-0.5B-v0.1-SFT") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("krogoldAI/QueryRefiner-0.5B-v0.1-SFT") model = AutoModelForCausalLM.from_pretrained("krogoldAI/QueryRefiner-0.5B-v0.1-SFT", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use krogoldAI/QueryRefiner-0.5B-v0.1-SFT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "krogoldAI/QueryRefiner-0.5B-v0.1-SFT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "krogoldAI/QueryRefiner-0.5B-v0.1-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/krogoldAI/QueryRefiner-0.5B-v0.1-SFT
- SGLang
How to use krogoldAI/QueryRefiner-0.5B-v0.1-SFT with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "krogoldAI/QueryRefiner-0.5B-v0.1-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "krogoldAI/QueryRefiner-0.5B-v0.1-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "krogoldAI/QueryRefiner-0.5B-v0.1-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "krogoldAI/QueryRefiner-0.5B-v0.1-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use krogoldAI/QueryRefiner-0.5B-v0.1-SFT with Docker Model Runner:
docker model run hf.co/krogoldAI/QueryRefiner-0.5B-v0.1-SFT
Update README.md
Browse files
README.md
CHANGED
|
@@ -367,6 +367,77 @@ All values are reported as mean ± standard deviation (%), computed over test ex
|
|
| 367 |
|
| 368 |
<!-- The model demonstrates strong performance across all semantic dimensions, with particularly high scores in domain classification, intent detection, and ambiguity assessment. The relatively higher variance in rephrasing quality and intent preservation reflects the inherent complexity and subjectivity of these tasks, where optimal outputs may vary based on retrieval context and domain-specific requirements. -->
|
| 369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
### Performance Considerations
|
| 371 |
|
| 372 |
Performance characteristics will vary based on query type, domain, and ambiguity level. The model is expected to perform strongest on queries similar to those in the training distribution and may require additional fine-tuning or prompt engineering for specialized applications or domains underrepresented in the training data.
|
|
|
|
| 367 |
|
| 368 |
<!-- The model demonstrates strong performance across all semantic dimensions, with particularly high scores in domain classification, intent detection, and ambiguity assessment. The relatively higher variance in rephrasing quality and intent preservation reflects the inherent complexity and subjectivity of these tasks, where optimal outputs may vary based on retrieval context and domain-specific requirements. -->
|
| 369 |
|
| 370 |
+
<details>
|
| 371 |
+
<summary><i>Unroll to see the system prompt used for the "judge" LLM</i></summary>
|
| 372 |
+
|
| 373 |
+
```py
|
| 374 |
+
JUDGE_PROMPT = """You are evaluating query analyses for a RAG system.
|
| 375 |
+
|
| 376 |
+
### System Requirements
|
| 377 |
+
The analyzer was instructed to optimize queries for document retrieval by:
|
| 378 |
+
- Using **specific terminology** and domain vocabulary likely to appear in relevant documents
|
| 379 |
+
- **Expanding acronyms** when they add context (but not when the acronym itself is the subject)
|
| 380 |
+
- **Adding disambiguating context** without over-constraining the search
|
| 381 |
+
- **Making implicit references explicit** using placeholders for missing entities (e.g., [PERSON], [COMPANY])
|
| 382 |
+
- **Preserving user intent** while improving retrieval precision
|
| 383 |
+
- **Keeping the original query unchanged** if it's already well-optimized for retrieval
|
| 384 |
+
|
| 385 |
+
### Input
|
| 386 |
+
Original: "{original}"
|
| 387 |
+
Domain: {domain}
|
| 388 |
+
Intent: {intent}
|
| 389 |
+
Rephrased: "{rephrased}"
|
| 390 |
+
|
| 391 |
+
Note: The [ambiguous] tag indicates the analyzer determined the query has multiple plausible interpretations for that dimension, with confidence distributed across candidates.
|
| 392 |
+
|
| 393 |
+
### Evaluation Criteria (1-5 scale)
|
| 394 |
+
|
| 395 |
+
1. Domain Accuracy (1=wrong, 3=acceptable, 5=perfect)
|
| 396 |
+
- Are the domain candidates correct?
|
| 397 |
+
- Are confidence scores reasonable?
|
| 398 |
+
|
| 399 |
+
2. Intent Accuracy (1=wrong, 3=acceptable, 5=perfect)
|
| 400 |
+
- Are the intent candidates correct?
|
| 401 |
+
- Are confidence scores reasonable?
|
| 402 |
+
|
| 403 |
+
3. Ambiguity Assessment (1=wrong, 3=acceptable, 5=perfect)
|
| 404 |
+
- Is the ambiguity determination appropriate for this query?
|
| 405 |
+
- If ambiguous: Is the confidence distribution justified?
|
| 406 |
+
- If clearly unambiguous but marked ambiguous (or vice versa), score ≤2.
|
| 407 |
+
|
| 408 |
+
4. Rephrasing Quality
|
| 409 |
+
1 = Poor (significantly degraded the query, or completely failed to address clear issues)
|
| 410 |
+
2 = Suboptimal (minor degradation, or missed an obvious improvement opportunity)
|
| 411 |
+
3 = Neutral (minor changes with mixed effects)
|
| 412 |
+
4 = Good improvement, but could be better
|
| 413 |
+
5 = Optimal outcome (either improved a suboptimal query, or correctly preserved an already-optimal one)
|
| 414 |
+
(Note: Do not penalize rephrasing for being minimal if the original was already optimal.)
|
| 415 |
+
|
| 416 |
+
5. Intent Preservation (1=lost, 3=mostly preserved, 5=fully preserved)
|
| 417 |
+
- Focus on meaning fidelity, not retrieval optimization.
|
| 418 |
+
|
| 419 |
+
6. Follows Guidelines (1=violates, 3=mostly follows, 5=perfectly follows)
|
| 420 |
+
- Check adherence to the RAG optimization principles above.
|
| 421 |
+
|
| 422 |
+
### Output Format
|
| 423 |
+
{{
|
| 424 |
+
"domain_accuracy": <1-5>,
|
| 425 |
+
"intent_accuracy": <1-5>,
|
| 426 |
+
"ambiguity_assessment": <1-5>,
|
| 427 |
+
"rephrasing_quality": <1-5>,
|
| 428 |
+
"intent_preservation": <1-5>,
|
| 429 |
+
"follows_guidelines": <1-5>,
|
| 430 |
+
"critical_issue": "<brief description or null>",
|
| 431 |
+
"usable": <true/false> // true if suitable for RAG use, even if not perfect
|
| 432 |
+
}}
|
| 433 |
+
|
| 434 |
+
Output only valid JSON. Do not include any explanations, comments, or text outside the JSON structure.
|
| 435 |
+
"""
|
| 436 |
+
|
| 437 |
+
```
|
| 438 |
+
|
| 439 |
+
</details>
|
| 440 |
+
|
| 441 |
### Performance Considerations
|
| 442 |
|
| 443 |
Performance characteristics will vary based on query type, domain, and ambiguity level. The model is expected to perform strongest on queries similar to those in the training distribution and may require additional fine-tuning or prompt engineering for specialized applications or domains underrepresented in the training data.
|