Instructions to use krogoldAI/QueryRefiner-0.5B-v0.1-GRPO 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-GRPO 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-GRPO") 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-GRPO") model = AutoModelForCausalLM.from_pretrained("krogoldAI/QueryRefiner-0.5B-v0.1-GRPO", 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-GRPO 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-GRPO" # 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-GRPO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/krogoldAI/QueryRefiner-0.5B-v0.1-GRPO
- SGLang
How to use krogoldAI/QueryRefiner-0.5B-v0.1-GRPO 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-GRPO" \ --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-GRPO", "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-GRPO" \ --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-GRPO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use krogoldAI/QueryRefiner-0.5B-v0.1-GRPO with Docker Model Runner:
docker model run hf.co/krogoldAI/QueryRefiner-0.5B-v0.1-GRPO
Update README.md
Browse files
README.md
CHANGED
|
@@ -337,7 +337,7 @@ messages = [
|
|
| 337 |
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 338 |
inputs = tokenizer(input_text, return_tensors="pt")
|
| 339 |
|
| 340 |
-
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 341 |
analysis = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 342 |
|
| 343 |
print(analysis)
|
|
@@ -345,8 +345,6 @@ print(analysis)
|
|
| 345 |
|
| 346 |
## Evaluation and Performance
|
| 347 |
|
| 348 |
-
<!-- The model was trained on data that passed stringent quality thresholds, with all training examples achieving perfect structural conformance and semantic quality scores of 4 or higher across six evaluation dimensions: domain accuracy, intent accuracy, ambiguity assessment, rephrasing quality, intent preservation, and guideline adherence. This ensures the model learned from consistently high-quality demonstrations of the desired behavior. -->
|
| 349 |
-
|
| 350 |
### Structural Validation
|
| 351 |
|
| 352 |
To assess the model's ability to produce correctly formatted outputs, we evaluated structural conformance across 1,000 examples from the test split of [krogoldAI/rag-ambiguous-queries](https://huggingface.co/datasets/krogoldAI/rag-ambiguous-queries), comparing both QueryRefiner-0.5B-v0.1 models against their base model [Qwen2.5-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct). The evaluation measured adherence to the required XML schema, including tag presence, well-formedness, element ordering, and confidence score formatting.
|
|
@@ -361,14 +359,6 @@ To assess the model's ability to produce correctly formatted outputs, we evaluat
|
|
| 361 |
|Confidence|3.1%|99.9%|99.9%|
|
| 362 |
|Perfectly structured output|0.0%|99.8%|99.9%|
|
| 363 |
|
| 364 |
-
<!-- |Metric|Qwen2.5-0.5B-Instruct|QueryRefiner-0.5B-v0.1-SFT|QueryRefiner-0.5B-v0.1-GRPO-SFT|QueryRefiner-0.5B-v0.1-GRPO-SFT1-SFT2-v2|
|
| 365 |
-
|----:|:-------------------:|:--------------------:|:--------------------:|:--------------------:|
|
| 366 |
-
|Tag structure|10.8%|99.9%|100%|99.9%|
|
| 367 |
-
|XML validity|41.0%|99.8%|99.8%|99.9%|
|
| 368 |
-
|Order|2.0%|99.9%|100%|99.9%|
|
| 369 |
-
|Confidence|3.1%|99.9%|100%|99.9%|
|
| 370 |
-
|Perfectly structured output|0.0%|99.8%|99.8%|99.9%| -->
|
| 371 |
-
|
| 372 |
Here, *tag structure* verifies that all required XML tags are present, *XML validity* ensures the output is well-formed and parseable, *order* confirms that required tags appear in the correct sequence, and *confidence* validates that confidence values are properly formatted and sum to `1.0`.
|
| 373 |
|
| 374 |
<!-- The results demonstrate that fine-tuning substantially improved structural reliability, with QueryRefiner achieving near-perfect conformance (99.6%) compared to the base model's inability to produce any fully compliant outputs. -->
|
|
@@ -389,17 +379,6 @@ Beyond structural correctness, we evaluated the semantic quality of the model's
|
|
| 389 |
|Follows guidelines|97.07 ± 13.78%|**97.40 ± 12.20%**|
|
| 390 |
|Overall semantic score|96.10 ± 9.74%|**96.81 ± 9.18%**|
|
| 391 |
|
| 392 |
-
<!-- |Metric|QueryRefiner-0.5B-v0.1-SFT|QueryRefiner-0.5B-v0.1-GRPO-SFT|QueryRefiner-0.5B-v0.1-GRPO-SFT1-SFT2-v2|
|
| 393 |
-
|----:|:--------------------:|:--------------------:|:--------------------:|
|
| 394 |
-
|Domain accuracy|**98.97 ± 8.43%**|98.57 ± 10.25%|98.95 ± 8.46%|
|
| 395 |
-
|Intent accuracy|98.20 ± 8.84%|**98.85 ± 8.30%**|98.75 ± 8.05%|
|
| 396 |
-
|Ambiguity assessment|99.04 ± 6.84%|99.10 ± 6.66%|**99.40 ± 5.79%**|
|
| 397 |
-
|Rephrasing quality|88.23 ± 18.20%|89.60 ± 17.50%|**90.33 ± 17.61%**|
|
| 398 |
-
|Intent preservation|95.09 ± 15.74%|95.52 ± 15.00%|**96.02 ± 14.72%**|
|
| 399 |
-
|Follows guidelines|97.07 ± 13.78%|97.07 ± 12.90%|**97.40 ± 12.20%**|
|
| 400 |
-
|Overall semantic score|96.10 ± 9.74%|96.45 ± 9.52%|**96.81 ± 9.18%**|
|
| 401 |
-
-->
|
| 402 |
-
|
| 403 |
All values are reported as mean ± standard deviation (%), computed over test examples. The base model produced too few valid XML samples for meaningful semantic evaluation.
|
| 404 |
|
| 405 |
<details>
|
|
|
|
| 337 |
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 338 |
inputs = tokenizer(input_text, return_tensors="pt")
|
| 339 |
|
| 340 |
+
outputs = model.generate(**inputs, temperature=0.7, max_new_tokens=512)
|
| 341 |
analysis = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 342 |
|
| 343 |
print(analysis)
|
|
|
|
| 345 |
|
| 346 |
## Evaluation and Performance
|
| 347 |
|
|
|
|
|
|
|
| 348 |
### Structural Validation
|
| 349 |
|
| 350 |
To assess the model's ability to produce correctly formatted outputs, we evaluated structural conformance across 1,000 examples from the test split of [krogoldAI/rag-ambiguous-queries](https://huggingface.co/datasets/krogoldAI/rag-ambiguous-queries), comparing both QueryRefiner-0.5B-v0.1 models against their base model [Qwen2.5-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct). The evaluation measured adherence to the required XML schema, including tag presence, well-formedness, element ordering, and confidence score formatting.
|
|
|
|
| 359 |
|Confidence|3.1%|99.9%|99.9%|
|
| 360 |
|Perfectly structured output|0.0%|99.8%|99.9%|
|
| 361 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
Here, *tag structure* verifies that all required XML tags are present, *XML validity* ensures the output is well-formed and parseable, *order* confirms that required tags appear in the correct sequence, and *confidence* validates that confidence values are properly formatted and sum to `1.0`.
|
| 363 |
|
| 364 |
<!-- The results demonstrate that fine-tuning substantially improved structural reliability, with QueryRefiner achieving near-perfect conformance (99.6%) compared to the base model's inability to produce any fully compliant outputs. -->
|
|
|
|
| 379 |
|Follows guidelines|97.07 ± 13.78%|**97.40 ± 12.20%**|
|
| 380 |
|Overall semantic score|96.10 ± 9.74%|**96.81 ± 9.18%**|
|
| 381 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
All values are reported as mean ± standard deviation (%), computed over test examples. The base model produced too few valid XML samples for meaningful semantic evaluation.
|
| 383 |
|
| 384 |
<details>
|