Text Ranking
Transformers
Safetensors
English
qwen3
text-generation
decision-model
retrieval
reranker
multi-hop
rag
llavrag
coding-agents
command-approval
llav-gate
Instructions to use llavapp/llav-4b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use llavapp/llav-4b with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("llavapp/llav-4b") model = AutoModelForCausalLM.from_pretrained("llavapp/llav-4b", device_map="auto") - Notebooks
- Google Colab
- Kaggle
llav 4B: coding agents, action safety (skills/coding/, used by llav-gate); card + notice
Browse files- NOTICE +17 -0
- README.md +90 -3
- skills/coding/SHA256SUMS +4 -0
- skills/coding/l4r2/adapter_config.json +16 -0
- skills/coding/l4r2/adapters.safetensors +3 -0
- skills/coding/r3/adapter_config.json +16 -0
- skills/coding/r3/adapters.safetensors +3 -0
NOTICE
CHANGED
|
@@ -12,3 +12,20 @@ to judge whether a passage is evidence needed for a question (see README.md, "Tr
|
|
| 12 |
(calib.json) was added.
|
| 13 |
|
| 14 |
The training datasets keep their own licences; they are listed in README.md ("Datasets and licences").
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
(calib.json) was added.
|
| 13 |
|
| 14 |
The training datasets keep their own licences; they are listed in README.md ("Datasets and licences").
|
| 15 |
+
|
| 16 |
+
Coding agents (skills/coding/): two LoRA adapters for llav 4B, Apache License 2.0, LLav Lab, used by llav-gate.
|
| 17 |
+
Training data attribution:
|
| 18 |
+
- tldr-pages (CC BY 4.0), the tldr-pages team and contributors, https://github.com/tldr-pages/tldr. Changes: command
|
| 19 |
+
templates filled with fixture paths and hosts and executed in a sandbox to derive effect labels; page descriptions
|
| 20 |
+
and examples quoted in evidence blocks of training inputs.
|
| 21 |
+
- SWE-smith and SWE-smith-trajectories (MIT License, Copyright (c) 2025 John Yang), Yang et al. 2025,
|
| 22 |
+
https://github.com/SWE-bench/SWE-smith.
|
| 23 |
+
- SWE-bench-extra (CC BY 4.0), Nebius, https://huggingface.co/datasets/nebius/SWE-bench-extra.
|
| 24 |
+
- SWE-Gym (MIT / Apache-2.0), Pan et al. 2024.
|
| 25 |
+
- Source-code excerpts from permissively licensed open-source repositories (MIT, Apache-2.0, BSD-2-Clause,
|
| 26 |
+
BSD-3-Clause, ISC, 0BSD), listed in llav-gate's LICENSE-AUDIT.md.
|
| 27 |
+
- The general decision replay of llav 4B (see README.md, "Datasets and licences").
|
| 28 |
+
Labels come from sandbox execution effects, documented command semantics, tests and dataset gold; none comes from an
|
| 29 |
+
external model. Some training inputs (task lines, previous agent steps and synthetic issue texts from SWE-smith and its
|
| 30 |
+
trajectories) were written by language models (Claude 3.7 Sonnet, Claude 3.5 Sonnet, GPT-4o, and an unnamed model for
|
| 31 |
+
SWE-smith issue texts); they were used only as inputs. No Llama-generated text and no evaluation-set items were used.
|
README.md
CHANGED
|
@@ -13,6 +13,9 @@ tags:
|
|
| 13 |
- multi-hop
|
| 14 |
- rag
|
| 15 |
- llavrag
|
|
|
|
|
|
|
|
|
|
| 16 |
datasets:
|
| 17 |
- nyu-mll/multi_nli
|
| 18 |
- stanfordnlp/snli
|
|
@@ -28,6 +31,8 @@ datasets:
|
|
| 28 |
|
| 29 |
# llav 4B
|
| 30 |
|
|
|
|
|
|
|
| 31 |
**A decision model: a question in, a probability out.** llav 4B answers one question about a passage: *is this passage
|
| 32 |
evidence that the question needs?* It returns a probability instead of generated text. The model can also take the
|
| 33 |
evidence already found and decide in that context.
|
|
@@ -37,8 +42,15 @@ search round from the passages the judge has ranked highest so far. llav Pro, ou
|
|
| 37 |
is not released; it is coming soon as a managed API, by waitlist. llav 4B is the first llav model with released weights; the v0.4 research checkpoints were
|
| 38 |
never published on Hugging Face.
|
| 39 |
|
| 40 |
-
**
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
| | |
|
| 44 |
|---|---|
|
|
@@ -48,6 +60,7 @@ patch-review decisions.
|
|
| 48 |
| Base model | [Qwen/Qwen3-Reranker-4B](https://huggingface.co/Qwen/Qwen3-Reranker-4B), Apache-2.0, Qwen team (Alibaba Cloud) |
|
| 49 |
| Modifications | three LoRA fine-tuning stages and one checkpoint average, all merged into the base weights (no adapter needed at inference) |
|
| 50 |
| Weights | `model.safetensors`, bf16, about 8 GB |
|
|
|
|
| 51 |
| Extra file | `calib.json`: Platt parameters `round0` (no evidence) and `rounds` (with evidence) |
|
| 52 |
| Language | English |
|
| 53 |
| Licence | Apache-2.0 |
|
|
@@ -153,17 +166,67 @@ The two calls show the evidence conditioning: the same passage becomes needed on
|
|
| 153 |
To rank candidates, score each one and sort by the probability. For many candidates that share one question,
|
| 154 |
batch them. llavRAG also reuses the shared prompt prefix. Small fp16 differences between backends can reorder near-ties.
|
| 155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
## Intended use
|
| 157 |
|
| 158 |
- Deciding whether a passage is evidence needed for a question, with or without evidence already found, as the
|
| 159 |
judge inside llavRAG or inside your own retrieval or RAG pipeline.
|
| 160 |
- Ranking or filtering candidate passages before they go to a reader, an LLM or a person.
|
| 161 |
- Research on retrieval built from decisions.
|
|
|
|
|
|
|
| 162 |
|
| 163 |
## Out-of-scope use
|
| 164 |
|
| 165 |
- Generating text or answers. The model outputs a yes/no probability only.
|
| 166 |
-
-
|
|
|
|
|
|
|
| 167 |
- General-purpose yes/no or classification decisions. The free-form mode is not evaluated.
|
| 168 |
- Decisions about people (for example credit, employment, housing, medical or legal matters) without qualified human
|
| 169 |
review.
|
|
@@ -238,8 +301,32 @@ record released with the paper (identifiers and scores, no text): CC BY 4.0
|
|
| 238 |
([DOI 10.5281/zenodo.24687039](https://doi.org/10.5281/zenodo.24687039)); full per-question decision traces are not yet
|
| 239 |
released (CC BY-SA 4.0 if released).
|
| 240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
## Limitations
|
| 242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
- **Scale and domain.** Every evaluation corpus has 6,000 to 14,000 passages of English Wikipedia text, and the
|
| 244 |
questions are public multi-hop benchmark questions. We have not measured the model on large or non-Wikipedia
|
| 245 |
collections or on business documents.
|
|
|
|
| 13 |
- multi-hop
|
| 14 |
- rag
|
| 15 |
- llavrag
|
| 16 |
+
- coding-agents
|
| 17 |
+
- command-approval
|
| 18 |
+
- llav-gate
|
| 19 |
datasets:
|
| 20 |
- nyu-mll/multi_nli
|
| 21 |
- stanfordnlp/snli
|
|
|
|
| 31 |
|
| 32 |
# llav 4B
|
| 33 |
|
| 34 |
+
**One model, several capabilities: retrieval evidence judging (used by llavRAG) and coding-agent action safety (used by llav-gate).**
|
| 35 |
+
|
| 36 |
**A decision model: a question in, a probability out.** llav 4B answers one question about a passage: *is this passage
|
| 37 |
evidence that the question needs?* It returns a probability instead of generated text. The model can also take the
|
| 38 |
evidence already found and decide in that context.
|
|
|
|
| 42 |
is not released; it is coming soon as a managed API, by waitlist. llav 4B is the first llav model with released weights; the v0.4 research checkpoints were
|
| 43 |
never published on Hugging Face.
|
| 44 |
|
| 45 |
+
**Capabilities.** You download one model; everything it can do ships in this repository:
|
| 46 |
+
|
| 47 |
+
| capability | what it decides | how it runs | used by |
|
| 48 |
+
|---|---|---|---|
|
| 49 |
+
| Retrieval: evidence judging | is this passage evidence that the question needs? | the weights below, as they are | [llavRAG](https://github.com/llavlab/llavrag) |
|
| 50 |
+
| Coding agents: action safety | is this shell command, as it would really run on this machine, destructive? | the same weights plus two small LoRA adapters in `skills/coding/`, switched per call | [llav-gate](https://github.com/llavlab/llav-gate) |
|
| 51 |
+
|
| 52 |
+
The coding-agent files are additions: the weights and every file llavRAG pins are byte-identical. Patch-review decisions
|
| 53 |
+
(does this diff resolve the issue?) are not a skill of this model.
|
| 54 |
|
| 55 |
| | |
|
| 56 |
|---|---|
|
|
|
|
| 60 |
| Base model | [Qwen/Qwen3-Reranker-4B](https://huggingface.co/Qwen/Qwen3-Reranker-4B), Apache-2.0, Qwen team (Alibaba Cloud) |
|
| 61 |
| Modifications | three LoRA fine-tuning stages and one checkpoint average, all merged into the base weights (no adapter needed at inference) |
|
| 62 |
| Weights | `model.safetensors`, bf16, about 8 GB |
|
| 63 |
+
| Coding-agent files | `skills/coding/r3/` and `skills/coding/l4r2/`: LoRA rank 16 on every block, about 130 MB each (fp32), see [Coding agents: action safety](#coding-agents-action-safety) |
|
| 64 |
| Extra file | `calib.json`: Platt parameters `round0` (no evidence) and `rounds` (with evidence) |
|
| 65 |
| Language | English |
|
| 66 |
| Licence | Apache-2.0 |
|
|
|
|
| 166 |
To rank candidates, score each one and sort by the probability. For many candidates that share one question,
|
| 167 |
batch them. llavRAG also reuses the shared prompt prefix. Small fp16 differences between backends can reorder near-ties.
|
| 168 |
|
| 169 |
+
## Coding agents: action safety
|
| 170 |
+
|
| 171 |
+
llav-gate is a local approval gate for coding agents (Claude Code and Codex hooks, and a command line). It loads this
|
| 172 |
+
model once with both coding adapters and switches between them on each call. You do not pick a model: `uv tool install --python 3.12 llav-gate`, then
|
| 173 |
+
`llav-gate setup`, uses the llav 4B that llavRAG uses (same folder) and adds only these files.
|
| 174 |
+
|
| 175 |
+
| adapter | what it reads | file sha256 |
|
| 176 |
+
|---|---|---|
|
| 177 |
+
| `r3` | the gate's expanded state: what the command really runs (task-runner scripts, aliases, inline code) with the file and line each came from, short local docs, and read-only facts about the files it touches; also each expanded command on its own | `1d323bed711b23d800d1c65624cc80a7d6f31600470bd34742516c5da0bcf02a` |
|
| 178 |
+
| `l4r2` | the command and the task only; trained further on shell commands labelled by their observed effects in a sandbox | `21f41c1fb71f8061f5bc1b8dcef017ac2a3126aebb3dad24d198b17ca9bd3b99` |
|
| 179 |
+
|
| 180 |
+
- **Output:** each adapter gives P(yes) for the question "Is this action destructive?" (same prompt format and readout
|
| 181 |
+
as above, raw probability, no Platt mapping).
|
| 182 |
+
- **Combined score:** llav-gate takes the higher of the two scores. Evidence can lower r3's score only to a quarter of
|
| 183 |
+
its score on the command text alone. Unknown tools without docs, and code that would run but cannot be read, raise
|
| 184 |
+
the score to at least 0.5.
|
| 185 |
+
- **Use it through llav-gate.** The adapters are not meant to be used without the gate's expansion and rule.
|
| 186 |
+
|
| 187 |
+
**Evaluation.** The configuration was frozen first (both adapters, the rule, the thresholds), then scored once on a
|
| 188 |
+
sealed exam written by a separate author:
|
| 189 |
+
- 160 pairs, each a dangerous command and a safe twin that looks like it, with a description of the machine each runs
|
| 190 |
+
on;
|
| 191 |
+
- 96 pairs from command families the exam author found nowhere in the training data;
|
| 192 |
+
- 32 pairs that differ only in machine state.
|
| 193 |
+
|
| 194 |
+
The baseline is a strong existing approval model for coding agents, scored on the command and the task (its inputs).
|
| 195 |
+
|
| 196 |
+
| 149 command pairs | llav 4B (llav-gate) | baseline |
|
| 197 |
+
|---|---|---|
|
| 198 |
+
| dangerous commands scored ≤ 0.10 ("confident misses") | **19** | 29 |
|
| 199 |
+
| AUROC | 0.732 [0.693, 0.773] | 0.682 [0.648, 0.723] |
|
| 200 |
+
|
| 201 |
+
- **Difference:** AUROC +0.049 [+0.006, +0.091] (paired bootstrap, 95%). On all 160 pairs: 19 vs 29 misses, +0.052
|
| 202 |
+
[+0.013, +0.093].
|
| 203 |
+
- **Excluded from the 149, before scoring:** 4 pairs where only a note revealed the danger, and 7 pairs that overlap
|
| 204 |
+
the skill's training files.
|
| 205 |
+
- **Caveats:**
|
| 206 |
+
- On unseen tools the separation is level with the baseline (strict-unseen −0.005 [−0.059, +0.050];
|
| 207 |
+
non-adjacent part −0.036 [−0.107, +0.033]), though with fewer misses.
|
| 208 |
+
- Cases that hinge on machine state are near chance for both.
|
| 209 |
+
- 19 of 160 dangerous commands were still scored ≤ 0.10. One would have passed without a question: `direnv allow`
|
| 210 |
+
on a downloaded `.envrc`.
|
| 211 |
+
- The gate asks often, and no claim is made about how often it interrupts.
|
| 212 |
+
|
| 213 |
+
Full tables: llav-gate's `RESULTS.md`.
|
| 214 |
+
|
| 215 |
## Intended use
|
| 216 |
|
| 217 |
- Deciding whether a passage is evidence needed for a question, with or without evidence already found, as the
|
| 218 |
judge inside llavRAG or inside your own retrieval or RAG pipeline.
|
| 219 |
- Ranking or filtering candidate passages before they go to a reader, an LLM or a person.
|
| 220 |
- Research on retrieval built from decisions.
|
| 221 |
+
- Judging whether a coding agent's shell command is destructive, through llav-gate, as one layer next to
|
| 222 |
+
your agent's own permission prompts and sandboxing.
|
| 223 |
|
| 224 |
## Out-of-scope use
|
| 225 |
|
| 226 |
- Generating text or answers. The model outputs a yes/no probability only.
|
| 227 |
+
- Patch-review decisions (does this diff resolve the issue?). Not trained.
|
| 228 |
+
- Command-safety decisions without llav-gate's expansion and coding-agent adapters, or as the only safeguard: it still
|
| 229 |
+
misses dangerous commands (see [Coding agents: action safety](#coding-agents-action-safety)).
|
| 230 |
- General-purpose yes/no or classification decisions. The free-form mode is not evaluated.
|
| 231 |
- Decisions about people (for example credit, employment, housing, medical or legal matters) without qualified human
|
| 232 |
review.
|
|
|
|
| 301 |
([DOI 10.5281/zenodo.24687039](https://doi.org/10.5281/zenodo.24687039)); full per-question decision traces are not yet
|
| 302 |
released (CC BY-SA 4.0 if released).
|
| 303 |
|
| 304 |
+
**Coding agents: training.**
|
| 305 |
+
- Both adapters are LoRA (rank 16, all blocks) trained on top of these weights. KL anchors come from this model's own
|
| 306 |
+
probabilities.
|
| 307 |
+
- r3: coding-agent decision states in three stages (2,481 + 468 + 214 steps).
|
| 308 |
+
- l4r2: continues r3 for 1,216 steps, on rows labelled by observed sandbox effects plus rehearsal and replay rows.
|
| 309 |
+
- Sources:
|
| 310 |
+
- tldr-pages (CC BY 4.0: command templates filled in and run in a sandbox, page excerpts quoted);
|
| 311 |
+
- SWE-smith and SWE-smith-trajectories (MIT);
|
| 312 |
+
- SWE-bench-extra (CC BY 4.0);
|
| 313 |
+
- SWE-Gym (MIT / Apache-2.0);
|
| 314 |
+
- code excerpts from 75+ permissively licensed repositories;
|
| 315 |
+
- the general replay mix above.
|
| 316 |
+
- Labels come from sandbox execution effects, documented command semantics, tests and dataset gold. None comes from an
|
| 317 |
+
external model.
|
| 318 |
+
- Some inputs (task lines and previous agent steps from SWE-smith trajectories) were written by language models
|
| 319 |
+
(Claude 3.7 Sonnet, Claude 3.5 Sonnet, GPT-4o, and an unnamed model for SWE-smith issue texts). They were used only
|
| 320 |
+
as inputs.
|
| 321 |
+
- No evaluation item and no Llama-generated text was used.
|
| 322 |
+
- Provenance: llav-gate's `LICENSE-AUDIT.md`.
|
| 323 |
+
|
| 324 |
## Limitations
|
| 325 |
|
| 326 |
+
- **Coding agents.** Action safety is evaluated on one sealed exam of 160 command pairs; see the caveats under
|
| 327 |
+
[Coding agents: action safety](#coding-agents-action-safety). It reads the command, local files and docs, not remote state (servers, cloud
|
| 328 |
+
resources, remote git branches).
|
| 329 |
+
|
| 330 |
- **Scale and domain.** Every evaluation corpus has 6,000 to 14,000 passages of English Wikipedia text, and the
|
| 331 |
questions are public multi-hop benchmark questions. We have not measured the model on large or non-Wikipedia
|
| 332 |
collections or on business documents.
|
skills/coding/SHA256SUMS
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ff19f85403652efea8fbe64962227b251202a8433d1d78bda4bcb4daf39b7ca0 skills/coding/l4r2/adapter_config.json
|
| 2 |
+
21f41c1fb71f8061f5bc1b8dcef017ac2a3126aebb3dad24d198b17ca9bd3b99 skills/coding/l4r2/adapters.safetensors
|
| 3 |
+
45bec02bedad7b43c4c5bf327d63ce712932525be2c57472122be1bae3636ab8 skills/coding/r3/adapter_config.json
|
| 4 |
+
1d323bed711b23d800d1c65624cc80a7d6f31600470bd34742516c5da0bcf02a skills/coding/r3/adapters.safetensors
|
skills/coding/l4r2/adapter_config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"fine_tune_type": "lora",
|
| 3 |
+
"lora_parameters": {
|
| 4 |
+
"rank": 16,
|
| 5 |
+
"scale": 2.0,
|
| 6 |
+
"dropout": 0.0
|
| 7 |
+
},
|
| 8 |
+
"skill": "coding",
|
| 9 |
+
"adapter": "l4r2",
|
| 10 |
+
"reads": "the request only: command and task",
|
| 11 |
+
"base_model": "llavapp/llav-4b",
|
| 12 |
+
"base_model_file_sha256": {
|
| 13 |
+
"model.safetensors": "c1baaa6861e603cd6ea335509327b669a0e8e92372d54ce5e5ca1dc3d680a3b0"
|
| 14 |
+
},
|
| 15 |
+
"layout": "mlx (lora_a [in, r], lora_b [r, out]); y = x W^T + scale * (x lora_a) lora_b"
|
| 16 |
+
}
|
skills/coding/l4r2/adapters.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:21f41c1fb71f8061f5bc1b8dcef017ac2a3126aebb3dad24d198b17ca9bd3b99
|
| 3 |
+
size 132175760
|
skills/coding/r3/adapter_config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"fine_tune_type": "lora",
|
| 3 |
+
"lora_parameters": {
|
| 4 |
+
"rank": 16,
|
| 5 |
+
"scale": 2.0,
|
| 6 |
+
"dropout": 0.0
|
| 7 |
+
},
|
| 8 |
+
"skill": "coding",
|
| 9 |
+
"adapter": "r3",
|
| 10 |
+
"reads": "the gate state: effective commands with provenance, local docs, file facts",
|
| 11 |
+
"base_model": "llavapp/llav-4b",
|
| 12 |
+
"base_model_file_sha256": {
|
| 13 |
+
"model.safetensors": "c1baaa6861e603cd6ea335509327b669a0e8e92372d54ce5e5ca1dc3d680a3b0"
|
| 14 |
+
},
|
| 15 |
+
"layout": "mlx (lora_a [in, r], lora_b [r, out]); y = x W^T + scale * (x lora_a) lora_b"
|
| 16 |
+
}
|
skills/coding/r3/adapters.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1d323bed711b23d800d1c65624cc80a7d6f31600470bd34742516c5da0bcf02a
|
| 3 |
+
size 132175760
|