Text Generation
Transformers
Safetensors
English
clarification
ambiguity-detection
question-answering
qwen2.5
grpo
reinforcement-learning
conversational
Instructions to use chrisjcc/ask-before-answer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use chrisjcc/ask-before-answer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="chrisjcc/ask-before-answer") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("chrisjcc/ask-before-answer", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use chrisjcc/ask-before-answer with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "chrisjcc/ask-before-answer" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "chrisjcc/ask-before-answer", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/chrisjcc/ask-before-answer
- SGLang
How to use chrisjcc/ask-before-answer 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 "chrisjcc/ask-before-answer" \ --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": "chrisjcc/ask-before-answer", "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 "chrisjcc/ask-before-answer" \ --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": "chrisjcc/ask-before-answer", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use chrisjcc/ask-before-answer with Docker Model Runner:
docker model run hf.co/chrisjcc/ask-before-answer
Upload folder using huggingface_hub
Browse files- README.md +117 -27
- adapter_config.json +4 -4
- adapter_model.safetensors +1 -1
- training_args.bin +2 -2
README.md
CHANGED
|
@@ -1,48 +1,138 @@
|
|
| 1 |
---
|
| 2 |
-
language:
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
tags:
|
| 5 |
-
- reinforcement-learning
|
| 6 |
-
- dpo
|
| 7 |
-
- sft
|
| 8 |
-
- qwen2.5
|
| 9 |
- clarification
|
| 10 |
-
|
| 11 |
-
-
|
|
|
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
-
# AskBeforeAnswer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
The **AskBeforeAnswer** model exhibits "clarification-seeking" behavior. When presented with an ambiguous question, rather than hallucinating or blindly assuming an intent, the model:
|
| 20 |
-
1. Detects the ambiguity.
|
| 21 |
-
2. Explains the reasoning behind the ambiguity.
|
| 22 |
-
3. Identifies the missing facets of information.
|
| 23 |
-
4. Asks a targeted clarification question to the user.
|
| 24 |
|
| 25 |
-
|
| 26 |
-
-
|
| 27 |
-
-
|
| 28 |
-
|
| 29 |
|
|
|
|
|
|
|
| 30 |
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
## Usage
|
| 35 |
-
```
|
| 36 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 37 |
from peft import PeftModel
|
| 38 |
|
| 39 |
base_model_name = "Qwen/Qwen2.5-7B-Instruct"
|
| 40 |
adapter_model_name = "chrisjcc/ask-before-answer"
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
| 47 |
-
model
|
|
|
|
|
|
|
| 48 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
base_model:
|
| 8 |
+
- Qwen/Qwen2.5-7B-Instruct
|
| 9 |
+
datasets:
|
| 10 |
+
- chrisjcc/ask-before-answer-dataset
|
| 11 |
tags:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
- clarification
|
| 13 |
+
- ambiguity-detection
|
| 14 |
+
- question-answering
|
| 15 |
+
- qwen2.5
|
| 16 |
+
- sft
|
| 17 |
+
- reinforcement-learning
|
| 18 |
---
|
| 19 |
|
| 20 |
+
# AskBeforeAnswer
|
| 21 |
+
|
| 22 |
+
The **AskBeforeAnswer** model is a clarification-seeking language model
|
| 23 |
+
based on **Qwen2.5-7B-Instruct**.
|
| 24 |
+
|
| 25 |
+
Instead of immediately answering an ambiguous question, the model is trained
|
| 26 |
+
to determine whether clarification is required and, when necessary, identify
|
| 27 |
+
the missing information and ask a targeted clarification question.
|
| 28 |
+
|
| 29 |
+
## Production Model
|
| 30 |
+
|
| 31 |
+
This repository contains the exact W&B artifact approved by the project's
|
| 32 |
+
model promotion procedure.
|
| 33 |
+
|
| 34 |
+
- **Training method:** Supervised Fine-Tuning (SFT)
|
| 35 |
+
- **Model variant:** `sft`
|
| 36 |
+
- **W&B Registry alias at promotion:** `production`
|
| 37 |
+
- **W&B artifact:** `wandb-registry-Model/AskBeforeAnswer-Models:v0`
|
| 38 |
+
- **W&B artifact digest:** `8dd12fd8a79a7f5be7eac5d94def44c1`
|
| 39 |
+
- **Release:** `v0.1.5`
|
| 40 |
+
- **Base model:** `Qwen/Qwen2.5-7B-Instruct`
|
| 41 |
+
- **Dataset:** `chrisjcc/ask-before-answer-dataset`
|
| 42 |
+
|
| 43 |
+
The model was obtained directly from the immutable W&B artifact recorded in
|
| 44 |
+
the promotion record.
|
| 45 |
+
|
| 46 |
+
The DVC-managed training output is not modified during deployment.
|
| 47 |
+
|
| 48 |
+
## Behavior
|
| 49 |
+
|
| 50 |
+
The model produces structured responses containing:
|
| 51 |
+
|
| 52 |
+
1. **Action**: whether to `Clarify` or `Answer`
|
| 53 |
+
2. **Reasoning**: why clarification is or is not required
|
| 54 |
+
3. **Facets**: missing information required to disambiguate the question
|
| 55 |
+
4. **Response**: either a clarification question or a direct answer
|
| 56 |
+
|
| 57 |
+
Expected format:
|
| 58 |
|
| 59 |
+
```text
|
| 60 |
+
Action: Clarify|Answer
|
| 61 |
+
Reasoning: <reasoning>
|
| 62 |
+
Facets: <list of missing facets>
|
| 63 |
+
Response: <clarifying question or direct answer>
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
## Training
|
| 67 |
+
|
| 68 |
+
The production winner was selected through the project's experiment
|
| 69 |
+
selection, verification, and promotion procedure.
|
| 70 |
|
| 71 |
+
The training pipeline supports:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
+
- Supervised Fine-Tuning (SFT)
|
| 74 |
+
- Direct Preference Optimization (DPO)
|
| 75 |
+
- Group Relative Policy Optimization (GRPO)
|
| 76 |
+
- Odds Ratio Preference Optimization (ORPO)
|
| 77 |
|
| 78 |
+
This repository corresponds specifically to the model variant recorded in
|
| 79 |
+
the promotion record.
|
| 80 |
|
| 81 |
+
## Evaluation
|
| 82 |
|
| 83 |
+
Evaluation results are maintained in the project evaluation artifacts.
|
| 84 |
|
| 85 |
## Usage
|
| 86 |
+
```
|
| 87 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 88 |
from peft import PeftModel
|
| 89 |
|
| 90 |
base_model_name = "Qwen/Qwen2.5-7B-Instruct"
|
| 91 |
adapter_model_name = "chrisjcc/ask-before-answer"
|
| 92 |
|
| 93 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 94 |
+
base_model_name,
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 98 |
+
base_model_name,
|
| 99 |
+
)
|
| 100 |
|
| 101 |
+
model = PeftModel.from_pretrained(
|
| 102 |
+
model,
|
| 103 |
+
adapter_model_name,
|
| 104 |
+
)
|
| 105 |
```
|
| 106 |
+
|
| 107 |
+
## Dataset
|
| 108 |
+
|
| 109 |
+
The training datasets are available from:
|
| 110 |
+
|
| 111 |
+
chrisjcc/ask-before-answer-dataset
|
| 112 |
+
|
| 113 |
+
The repository contains separate sft and dpo configurations.
|
| 114 |
+
|
| 115 |
+
## Intended Use
|
| 116 |
+
|
| 117 |
+
This model is intended for research into clarification-seeking behavior in
|
| 118 |
+
language models, particularly for systems that should distinguish between
|
| 119 |
+
answerable and underspecified user questions.
|
| 120 |
+
|
| 121 |
+
## Limitations
|
| 122 |
+
|
| 123 |
+
The model may incorrectly classify questions as ambiguous or unambiguous.
|
| 124 |
+
|
| 125 |
+
Its generated reasoning and answers should not be treated as authoritative.
|
| 126 |
+
|
| 127 |
+
The model was trained on English-language data and may not generalize
|
| 128 |
+
reliably to other languages or domains.
|
| 129 |
+
|
| 130 |
+
## Reproducibility
|
| 131 |
+
|
| 132 |
+
The model published here was selected through the project's experiment
|
| 133 |
+
selection, verification, and promotion procedure.
|
| 134 |
+
|
| 135 |
+
The promotion record identifies the exact W&B artifact version and digest
|
| 136 |
+
used for deployment.
|
| 137 |
+
|
| 138 |
+
The local DVC training artifact is treated as immutable during deployment.
|
adapter_config.json
CHANGED
|
@@ -35,13 +35,13 @@
|
|
| 35 |
"rank_pattern": {},
|
| 36 |
"revision": null,
|
| 37 |
"target_modules": [
|
|
|
|
|
|
|
| 38 |
"gate_proj",
|
| 39 |
-
"up_proj",
|
| 40 |
-
"o_proj",
|
| 41 |
"k_proj",
|
|
|
|
| 42 |
"v_proj",
|
| 43 |
-
"
|
| 44 |
-
"q_proj"
|
| 45 |
],
|
| 46 |
"target_parameters": null,
|
| 47 |
"task_type": "CAUSAL_LM",
|
|
|
|
| 35 |
"rank_pattern": {},
|
| 36 |
"revision": null,
|
| 37 |
"target_modules": [
|
| 38 |
+
"q_proj",
|
| 39 |
+
"down_proj",
|
| 40 |
"gate_proj",
|
|
|
|
|
|
|
| 41 |
"k_proj",
|
| 42 |
+
"o_proj",
|
| 43 |
"v_proj",
|
| 44 |
+
"up_proj"
|
|
|
|
| 45 |
],
|
| 46 |
"target_parameters": null,
|
| 47 |
"task_type": "CAUSAL_LM",
|
adapter_model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 161533192
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:44531fd80e249b7cbf4fc124522fc7f6be0b0202382eb865bb0e2c1590b469c1
|
| 3 |
size 161533192
|
training_args.bin
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1d5e8814a1cbbbf820e4191c98a514605ae36e48454ddd9eb02b6e69b79b2049
|
| 3 |
+
size 6008
|