Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained(
4 "kswhitecross/RecaLLM-Llama-3.1-8B",
5 trust_remote_code=True,
6 torch_dtype="auto",
7 device_map="auto",
8)
9tokenizer = AutoTokenizer.from_pretrained("kswhitecross/RecaLLM-Llama-3.1-8B")
10
11messages = [{"role": "user", "content": "Your prompt here..."}]
12inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
13outputs = model.generate(inputs, max_new_tokens=10240, temperature=0.6, top_p=0.95)
14print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=False))<|start_recall|> and <|end_recall|> to delimit recall spans. During a recall span, a constrained decoding mechanism (built into the model class) masks out invalid tokens at each step, allowing only tokens that continue a valid prefix match against the input context. This guarantees that every recall span is a verbatim contiguous substring of the searchable context.<think>
I need to find the population of the city mentioned in the document.
Looking at the context, I see <|start_recall|>The city of Springfield has a population of 167,376<|end_recall|>.
So the population is 167,376.
</think>
Answer: 167,376VLLMTokenRecaLLMLogitsProcessor from the RecaLLM code repository. vLLM should load the model using the base Llama architecture (not the custom RecaLLM transformers classes) via hf_overrides, with the logits processor applied as an overlay:1from vllm import LLM, SamplingParams
2from recallm import VLLMTokenRecaLLMLogitsProcessor
3
4llm = LLM(
5 model="kswhitecross/RecaLLM-Llama-3.1-8B",
6 trust_remote_code=True,
7 logits_processors=[VLLMTokenRecaLLMLogitsProcessor],
8 hf_overrides={
9 "model_type": "llama",
10 "architectures": ["LlamaForCausalLM"],
11 },
12)
13
14sampling_params = SamplingParams(temperature=0.6, top_p=0.95, max_tokens=10240)
15outputs = llm.generate(["Your prompt here..."], sampling_params=sampling_params)recallm/recallm_vllm.py in the code repo for the full logits processor implementation.1@article{whitecross2026recallm,
2 title={RecaLLM: Addressing the Lost-in-Thought Phenomenon with Explicit In-Context Retrieval},
3 author={Whitecross, Kyle and Rahimi, Negin},
4 journal={arXiv preprint arXiv:2604.09494},
5 year={2026}
6}