Instructions to use Kausp11/querylm-dclm-3.3b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Kausp11/querylm-dclm-3.3b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Kausp11/querylm-dclm-3.3b", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Kausp11/querylm-dclm-3.3b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Kausp11/querylm-dclm-3.3b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Kausp11/querylm-dclm-3.3b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Kausp11/querylm-dclm-3.3b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Kausp11/querylm-dclm-3.3b
- SGLang
How to use Kausp11/querylm-dclm-3.3b 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 "Kausp11/querylm-dclm-3.3b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Kausp11/querylm-dclm-3.3b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "Kausp11/querylm-dclm-3.3b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Kausp11/querylm-dclm-3.3b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Kausp11/querylm-dclm-3.3b with Docker Model Runner:
docker model run hf.co/Kausp11/querylm-dclm-3.3b
QueryLM 3.3B (DCLM-Edu), base model
A 3.3B-parameter language model trained from scratch on DCLM-Edu web text in which search blocks were inserted during pretraining: at points where a lookup would help predict what comes next, the training text contains a search query followed by a retrieved passage. The model learned to write the queries and to use the passages; the passages themselves were never a prediction target.
This is the base model (pretraining only). The chat fine-tuned version is Kausp11/querylm-dclm-3.3b-sft-search. A compute-matched Standard baseline (same architecture and compute, plain text without search blocks) exists but is not published in this set yet.
| Stage | base model (pretraining only; no chat format) |
| Architecture | nanochat-style decoder: 32 layers, width 2,816, 22 heads, feed-forward 11,264, head dim 128, context 4,095 tokens |
| Parameters | 3,322.3M reported (5,539.7M stored, including value embeddings) |
| Loads with | transformers + trust_remote_code=True (the repo ships modeling_nanochat.py) |
How to use
The model can be used without search like any causal language model. To let it search: open a search block, let it write the query, run your own retriever, insert the result, and let it continue.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "Kausp11/querylm-dclm-3.3b"
tok = AutoTokenizer.from_pretrained(repo)
# trust_remote_code runs modeling_nanochat.py from this repo; pin `revision=` to a commit you have read.
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True, torch_dtype=torch.bfloat16).eval()
Q_OPEN, Q_CLOSE = tok.convert_tokens_to_ids("<WEB_QUERY>"), tok.convert_tokens_to_ids("</WEB_QUERY>")
def my_search(query: str) -> str:
"""Replace with your retriever (BM25 index, web search API, ...). Return one short passage."""
return "Canberra is the capital city of Australia. It was founded in 1913 and is the country's largest inland city."
@torch.no_grad()
def generate(text, max_new_tokens, stop_id=None, allow_search=True):
x = tok(text, add_special_tokens=False, return_tensors="pt")
kw = {} if allow_search else {"bad_words_ids": [[Q_OPEN]]}
out = model.generate(**x, max_new_tokens=max_new_tokens, do_sample=False,
eos_token_id=stop_id, pad_token_id=tok.eos_token_id, **kw)
return tok.decode(out[0, x.input_ids.shape[1]:], skip_special_tokens=True)
# Base model: it continues text. Few-shot examples set the question-answer format.
shots = ("Question: Who wrote the novel Pride and Prejudice?\nAnswer: Jane Austen\n\n"
"Question: What is the chemical symbol for gold?\nAnswer: Au\n\n")
prompt = shots + "Question: What is the capital of Australia?\n"
query = generate(prompt + "<WEB_QUERY>", max_new_tokens=24, stop_id=Q_CLOSE).strip() # 1) the model writes the query
block = f"<WEB_QUERY>{query}</WEB_QUERY> <WEB_RESPONSE>{my_search(query)}</WEB_RESPONSE>" # 2) you retrieve and insert the block
answer = generate(prompt + block + "\nAnswer:", max_new_tokens=16, allow_search=False) # 3) the model continues
print("query :", query)
print("answer:", answer.split("\n")[0].strip())
Output of this exact script (CPU, bfloat16, torch 2.8.0, transformers 4.56.0, run 2026-11-19 on the files in this repo):
query : capital of Australia
answer: Canberra
The passage here is a fixed example string; the output shows the mechanics, not the model's accuracy.
Search-block format
| Token | id |
|---|---|
<WEB_QUERY> |
49152 |
</WEB_QUERY> |
49153 |
<WEB_RESPONSE> |
49154 |
</WEB_RESPONSE> |
49155 |
Layout in the training text: …text<WEB_QUERY>query</WEB_QUERY> <WEB_RESPONSE>passage</WEB_RESPONSE> text continues…. The tokenizer is the SmolLM2 tokenizer plus these four tokens (vocabulary 49,156). The loss covered the text, the query and the query tags; the response tags and the passage carried no loss, so the model does not generate passages. The caller supplies them.
Training data
Pretraining: DCLM-Edu, annotated with search blocks by a fine-tuned annotator model (Gemma 4 E4B-it with a LoRA adapter). The annotator marks positions where a search would help (insertion probability at least 0.05, at least 40 characters apart) and writes a query of at most 24 tokens for each. Passages come from BM25 retrieval over the public Sphere web corpus and are shortened by extractive cleaning. An insertion is kept only if the passage overlaps the text that follows it in the document (ROUGE-1 F1 of at least 0.1 against the next 260 characters).
Training procedure
| Pretraining optimizer | Muon for matrix weights (peak LR 0.02828), AdamW for embeddings and output head |
| Batch | 256 sequences x 4,095 tokens = 1,048,320 tokens per update |
| Schedule | 40 warmup steps, constant, then linear decay to 5% of peak at the end |
| Pretraining budget | 95,172 updates; 99.8B tokens processed, of which 64.0B document tokens; 2.35e21 FLOPs; bf16 compute |
Provenance
| Checkpoint | run dclm_nc_v1_d32_64Bdoc, final step of the last training segment (segment step 17,327; 95,172 updates in total). Learning-rate decay over the last 3,327 updates; the schedule is finished |
| Initialised from | scratch |
| Code | nanochat (upstream commit 92d63d4) with a local search-data branch |
model-00001-of-00003.safetensors sha256 |
727e72d593822f32cbf549f5b5bfed486b73b70ac966cb069dff2caac3761784 |
model-00002-of-00003.safetensors sha256 |
4fd1a1d0f550e8d1c1effc9168a441ddff082babe67dce0e4cf073a218390ab3 |
model-00003-of-00003.safetensors sha256 |
c037a6e1aad7ef9d9d39f6fd9e29e2df3f222051c945504e2d82706775f2461a |
| Also published as | Kausp11/searchlm-dclm_nc-v1_d32_64Bdoc (identical weights, earlier name) |
Evaluation
Evaluation results will be added later.
Intended use and limitations
- A research artifact for studying models that learn to search during pretraining. Not a product.
- Base model: it continues text and has no chat format. For chat-style use see the fine-tuned version.
- English web text only; no safety or refusal training of any kind. It will state false things fluently.
- It searches usefully only when the caller runs the loop above. Passages are inserted verbatim into the context: whatever the retriever returns, the model conditions on, including wrong or adversarial text. The retrieval source is the caller's choice and responsibility.
- Loading executes Python from this repository (
modeling_nanochat.py). Read it or pin a revision.
License
Apache-2.0 (licence text in LICENSE). modeling_nanochat.py is adapted from nanochat, MIT License, Copyright (c) 2025 Andrej Karpathy (text in LICENSE-nanochat). Training text: DCLM-Edu (CC-BY-4.0). Retrieved passages used as masked context during pretraining come from Sphere (CC BY-NC 4.0); they are not part of this repo.
Citation
Paper: Search From the Start: Search-Native Pretraining for Language Models · Project page: https://kaustubhp11.github.io/querylm/
@article{ponkshe2026searchfromthestart,
title = {Search From the Start: Search-Native Pretraining for Language Models},
author = {Ponkshe, Kaustubh and Je, Gyung Hyun and Taga, Stefan and Raffel, Colin and Jaggi, Martin},
journal = {arXiv preprint arXiv:2611.26809},
year = {2026}
}
- Downloads last month
- 71