Text Classification
Transformers
Safetensors
PyTorch
qwen2
text-generation
causal-lm
qwen
decision-making
system-one
reasoning
jev
jevbench
joint-expected-value
classification
qlora
agent
decision-model
fast-inference
text-embeddings-inference
Instructions to use devankit7873/QJev-1.5B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use devankit7873/QJev-1.5B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="devankit7873/QJev-1.5B")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("devankit7873/QJev-1.5B") model = AutoModelForCausalLM.from_pretrained("devankit7873/QJev-1.5B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -92,81 +92,28 @@ Evaluated against the official **[JevBench](https://jevbench.github.io/)** test
|
|
| 92 |
|
| 93 |
---
|
| 94 |
|
| 95 |
-
## 🚀 Quickstart:
|
| 96 |
|
| 97 |
-
### 1. Installation
|
| 98 |
-
```bash
|
| 99 |
-
pip install torch transformers safetensors huggingface_hub
|
| 100 |
-
```
|
| 101 |
-
|
| 102 |
-
### 2. Standalone Inference Code
|
| 103 |
```python
|
| 104 |
-
import
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
self.act = nn.GELU()
|
| 119 |
-
self.dropout = nn.Dropout(dropout)
|
| 120 |
-
self.out_proj = nn.Linear(intermediate_size, max_choices)
|
| 121 |
-
self.score_proj = nn.Linear(intermediate_size, 1)
|
| 122 |
-
|
| 123 |
-
def forward(self, x: torch.Tensor, num_choices: torch.Tensor = None) -> torch.Tensor:
|
| 124 |
-
h = self.dropout(self.act(self.dense(self.norm(x))))
|
| 125 |
-
logits = self.out_proj(h)
|
| 126 |
-
if num_choices is not None:
|
| 127 |
-
mask = torch.arange(self.max_choices, device=logits.device).unsqueeze(0) >= num_choices.unsqueeze(1)
|
| 128 |
-
logits = logits.masked_fill(mask, -1e4)
|
| 129 |
-
return logits
|
| 130 |
-
|
| 131 |
-
# 1. Load model & weights
|
| 132 |
-
model_id = "devankit7873/QJev-1.5B"
|
| 133 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 134 |
-
|
| 135 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 136 |
-
backbone = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map=device)
|
| 137 |
-
head = DecisionHead().to(device=device, dtype=torch.bfloat16)
|
| 138 |
-
|
| 139 |
-
head_path = hf_hub_download(repo_id=model_id, filename="decision_head.safetensors")
|
| 140 |
-
head.load_state_dict(load_file(head_path))
|
| 141 |
-
head.eval()
|
| 142 |
-
|
| 143 |
-
# 2. Formulate Prompt & Query
|
| 144 |
-
context = "Production database primary replica CPU spiked to 100% and connection pool is exhausted with 5,000 waiting queries."
|
| 145 |
-
choices = [
|
| 146 |
-
"Trigger immediate automated failover to standby replica",
|
| 147 |
-
"Restart the primary database daemon immediately",
|
| 148 |
-
"Double connection pool limits without scaling compute",
|
| 149 |
-
"Silence alerts and monitor for next 15 minutes"
|
| 150 |
-
]
|
| 151 |
-
|
| 152 |
-
opts_str = "\n".join([f"[{i+1}] {c}" for i, c in enumerate(choices)])
|
| 153 |
-
prompt = (
|
| 154 |
-
"<|im_start|>system\n"
|
| 155 |
-
"You are an expert decision engine. Evaluate the context and select the optimal decision.<|im_end|>\n"
|
| 156 |
-
f"<|im_start|>user\nContext:\n{context}\n\nQuestion:\nSelect the most appropriate option:\n\nOptions:\n{opts_str}<|im_end|>\n"
|
| 157 |
-
"<|im_start|>assistant\nDecision:"
|
| 158 |
)
|
| 159 |
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
transformer = getattr(backbone, "model", backbone)
|
| 164 |
-
out = transformer(inputs["input_ids"], attention_mask=inputs["attention_mask"])
|
| 165 |
-
logits = head(out.last_hidden_state[:, -1, :], num_choices=torch.tensor([len(choices)], device=device))
|
| 166 |
-
probs = F.softmax(logits[0, :len(choices)], dim=-1).cpu().tolist()
|
| 167 |
-
|
| 168 |
-
for choice, prob in zip(choices, probs):
|
| 169 |
-
print(f"{choice}: {prob * 100:.2f}%")
|
| 170 |
```
|
| 171 |
|
| 172 |
---
|
|
|
|
| 92 |
|
| 93 |
---
|
| 94 |
|
| 95 |
+
## 🚀 Quickstart: Super Friendly 3-Line Decision
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
```python
|
| 98 |
+
from qjev import QJev
|
| 99 |
+
|
| 100 |
+
# 1. Load in 1 line:
|
| 101 |
+
model = QJev.from_pretrained("devankit7873/QJev-1.5B")
|
| 102 |
+
|
| 103 |
+
# 2. Decide in 31 ms!
|
| 104 |
+
result = model.decide(
|
| 105 |
+
context="Production database primary replica CPU spiked to 100% and connection pool is exhausted.",
|
| 106 |
+
choices=[
|
| 107 |
+
"Trigger immediate automated failover to standby replica",
|
| 108 |
+
"Restart the primary database daemon immediately",
|
| 109 |
+
"Double connection pool limits without scaling compute",
|
| 110 |
+
"Silence alerts and monitor for next 15 minutes"
|
| 111 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
)
|
| 113 |
|
| 114 |
+
print(f"👉 Recommended: {result['best_choice']} ({result['confidence']}%)")
|
| 115 |
+
for choice, prob in result['probabilities'].items():
|
| 116 |
+
print(f" [{prob:>5.2f}%] {choice}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
```
|
| 118 |
|
| 119 |
---
|