alt.freeweights.granite / granite-3.2-8b-alora-rag-query-rewrite
From: ibm-granite <huggingface.co/ibm-granite>Newsgroups: alt.freeweights.graniteSubject:

granite-3.2-8b-alora-rag-query-rewrite

Date: 2026-11-15Commit: 4740af2Signed: 2DC28CC7B26A283B ✓

Text generation model. Safetensors weights, 94.4 MB in all. Published by ibm-granite under Apache-2.0.

granite94.4MBgranite-3.2-8b-alora-rag-query-rewritesafetensorspermissive
FactsParamsnot statedSize94.4 MBFormatssafetensorsTasktext generationLicenseApache-2.0From sourcepermissive
$ fw get ibm-granite/granite-3.2-8b-alora-rag-query-rewrite
# manifest sha256 6f0d670fd820… · 94.4 MB · 4 files
$ fw verify ./granite-3.2-8b-alora-rag-query-rewrite ibm-granite/granite-3.2-8b-alora-rag-query-rewrite
From sourceHosted (signed)ibm-granite/granite-3.2-8b-alora-rag-query-rewriteLast check: 2026-11-15 04:31 UTC

Get help: custom fine-tune or private deploy. We review your setup before we quote.

Works with

Overview

Size
94.4 MB
Weights
94.4 MB (safetensors)
Parameters
not stated
Formats
safetensors
Task
text generation
License
Apache-2.0 (permissive)
Files
4, each with a sha256
Publisher
ibm-granite
Added
2026-11-15
Section
alt.freeweights.granite
Lineage

Original release from the publisher.

Where these bytes come from
Publisher at the pinned commit→You

Sources are tried in order. A file counts only when its size and sha256 match the manifest. Sources are checked when you ask for them, not on a timer.

Sources
BadgeHostLast checkResult
From sourcehuggingface.co2026-11-15 04:31 UTCpassed

Model card

From the publisher at commit 4740af2. Shown as plain text with links; images open at the publisher.

Granite 3.2 8B Instruct - Query Rewrite aLoRA#

Welcome to Granite Experiments!

Think of Experiments as a preview of what's to come. These projects are still under development, but we wanted to let the open-source community take them for spin! Use them, break them, and help us build what's next for Granite – we'll keep an eye out for feedback and questions. Happy exploring!

Model Summary#

Granite 3.2 8b Instruct - Query Rewrite is an Activated LoRA (aLoRA) adapter for ibm-granite/granite-3.2-8b-instruct that is fine-tuned for the query rewrite task in multi-turn conversations:

Given a multi-turn conversation between a user and an AI assistant, decontextualize the last user utterance (query) by rewriting it (whenever necessary) into an equivalent version that is standalone and can be understood by itself.

In addition to query rewrite, the adapter retains the full abilities of the ibm-granite/granite-3.2-8b-instruct model.

Activated LoRA#

Activated LoRA (aLoRA) is a new low rank adapter architecture that allows for reusing existing base model KV cache for more efficient inference.

Whitepaper

IBM Research Blogpost

Github - needed to run inference

Usage#

Intended use#

This is a LoRA adaptor that gives the ability to rewrite the last user query in a multi-turn conversation. The rewrite is a form of expansion that inlines into the query any implicit references that are made to entities, concepts, or even parts of the conversation that occur in the previous turns (either by the user or the AI assistant). Such expansion can include coreference resolution (i.e., replacement of pronouns with the actual entities), handling of ellipsis, which is the common linguistic phenomenon where parts of a sentence or phrase are omitted by the user, but can be understood from the context (i.e., for whom, of what, with respect to something discussed above, etc.).

As a result of the expansion, the query becomes a standalone query, still equivalent in meaning with what the user asked in the last turn. The rewritten query can be sent to downstream tasks (e.g., to a retriever in a RAG setting) as a better replacement for the original user query, and without the need for (a potentially very long) context.

Model input: The input to the model is a list of conversational turns converted to a string using apply_chat_template function. These turns can alternate between the user and assistant roles, and the last turn is assumed to be from the user.

To prompt the LoRA adapter to rewrite the last user turn, a special rewrite role is used to trigger the rewrite capability of the model. The role includes the keyword "rewrite" followed by a short description of the query rewrite task.

<|start_of_role|>rewrite: Reword the final utterance from the USER into a single utterance that doesn't need the prior conversation history to understand the user's intent. If the final utterance is a clear and standalone question, please DO NOT attempt to rewrite it, rather output the last utterance as is. Your output format should be in JSON: { \"rewritten_question\": <REWRITE> }"<|end_of_role|>

Model output: When prompted with the above special rewrite role, the model generates a json object, which contains a field with the actual rewritten question.

This LoRA adapter can be used to rewrite user questions for multiple conversational use cases, including but not limited to: RAG scenarios, natural language access to databases, routing to APIs or tools. The adapter does not need any documents (that may be present in the context in a RAG setting) and uses only the dialog turns with what is being said between the user and assistant.

Quickstart Example#

The following code describes how to use the Query Rewrite model.

The code required for Activated LoRA is on Github

Prior to running the code below, either clone the repo or install as

pip install git+ssh://git@github.com:IBM/activated-lora.git
import torch,os
from transformers import AutoTokenizer, AutoModelForCausalLM, DynamicCache
from alora.peft_model_alora import aLoRAPeftModelForCausalLM
from alora.config import aLoraConfig


token = os.getenv("HF_MISTRAL_TOKEN")
BASE_NAME = "ibm-granite/granite-3.2-8b-instruct"
LORA_NAME = "ibm-granite/granite-query-rewrite-3.2-8b-alora"
device=torch.device('cuda' if torch.cuda.is_available() else 'cpu')

# Load model
tokenizer = AutoTokenizer.from_pretrained(BASE_NAME,padding_side='left',trust_remote_code=True, token=token)
model_base = AutoModelForCausalLM.from_pretrained(BASE_NAME,device_map="auto")
model_rewrite = aLoRAPeftModelForCausalLM.from_pretrained(model_base, LORA_NAME)

INSTRUCTION_TEXT = "Reword the final utterance from the USER into a single utterance that doesn't need the prior conversation history to understand the user's intent. If the final utterance is a clear and standalone question, please DO NOT attempt to rewrite it, rather output the last user utterance as is. "
JSON = "Your output format should be in JSON: { \"rewritten_question\": <REWRITE> }"
REWRITE_PROMPT = "<|start_of_role|>rewrite: " + INSTRUCTION_TEXT + JSON + "<|end_of_role|>"


# Input conversation
conv = [
    {
        "role":"user",
        "content":"Tim Cook is the CEO of Apple Inc."
    },
    {
        "role":"assistant",
        "content":"Yes, Tim Cook is the Chief Executive Officer of Apple Inc."
    },
    {
        "role":"user",
        "content":"and for Microsoft?"
    }
]

# Generate the query rewrite for the last turn in the above conversation
conv = [{"role":"system", "content":""}] + conv
input_text = tokenizer.apply_chat_template(conv, tokenize=False) + REWRITE_PROMPT
inputs = tokenizer(input_text, return_tensors="pt")
output = model_rewrite.generate(inputs["input_ids"].to(device), attention_mask=inputs["attention_mask"].to(device), max_new_tokens=80)
output_text = tokenizer.decode(output[0])

# Regex pattern to extract the JSON with the rewrite from the output of the model
pattern = r'\{\s*"[^"]+"\s*:\s*"[^"]*"\s*\}'
match_js = re.findall(pattern, output_text)[0]
try:
    #Parse the JSON and extract the rewrite    
    rewrite = json.loads (match_js) ['rewritten_question']
except Exception as e: 
    rewrite = match_js.split ("\"rewritten_question\": ", 1)[1]

print(f"Rewrite: {rewrite}\n")
# Rewrite: Who is the CEO of Microsoft?

Training Details#

The training data contains both: 1) standalone examples, which teach the adapter to refrain from rewriting user questions that are already standalone, and 2) non-standalone examples containing a diversity of patterns that are used to teach the adapter to expand the user turn so that it becomes standalone.

Training Data#

The training data uses the publicly available Cloud corpus of technical documentation pages from MT-RAG. Based on this corpus of documents, we constructed a dataset consisting of high-quality, human-created conversations, where the last turn of the conversation comes into versions: non-standalone version, and corresponding standalone version. The training dataset is proprietary and was obtained in combination with a third-party company who contracted the human annotators.

Training Hyperparameters#

The aLoRA adapter was fine-tuned using the new low rank adapter architecture (Activated LoRA) under the following regime: rank = 32, learning rate = 3e-6, number of epochs = 25, with early stopping based on validation set, and 90/10 split between training and validation.

Evaluation#

Evaluation of retriever#

We evaluate Recall@k on the MT-RAG benchmark, under various query rewrite strategies for the retriever. All retrieved passages are obtained using the Elser retriever with the same settings as in the above paper. In addition to the adapter, we include several other baselines, including no-rewrite (where we send the last user turn to the retriever as-is), Mixtral rewrites, as well as gold rewrites (human-created) as an upper ceiling baseline. We evaluate on three different testsets: a) full MT-RAG dataset (842 data points with last user turns); b) the non-standalone subset of MT-RAG dataset, which is a subset of 260 (out of 842) last user turns that were annotated by humans as non-standalone (i.e., they are dependent on the prior context); c) the standalone subset of MT-RAG dataset, which is the complementary subset, with all the last user turns that were annotated by humans as standalone.

a. Evaluation of Recall@k on full MT-RAG dataset.

StrategyRecall@5Recall@10Recall@20
No rewrite0.4860.5870.665
Mixtral 8x7b rewrite0.5220.6420.72
Granite 3.2-8b aLoRA rewrite0.5410.6640.742
Gold rewrite0.5630.6740.747

b. Evaluation of Recall@k on the non-standalone subset of MT-RAG.

StrategyRecall@5Recall@10Recall@20
No rewrite0.2630.3380.435
Mixtral 8x7b rewrite0.3620.4880.574
Granite 3.2-8b aLoRA rewrite0.4150.5350.644
Gold rewrite0.4790.5820.662

c. Evaluation of Recall@k on the standalone subset of MT-RAG.

StrategyRecall@5Recall@10Recall@20
No rewrite0.6090.7230.792
Mixtral 8x7b rewrite0.6130.7330.809
Granite 3.2-8b aLoRA rewrite0.6250.7520.818
Gold rewrite0.6090.7230.792
Evaluation of answer generation#

We evaluate answer generation quality, with top-k passages retrieved under the various query rewrite strategies for the retriever. We choose here k = 20, but similar trends take place for other values of k. We used Granite-3.2-8b instruct as the answer generator, and RAGAS Faithfulness and RAD-Bench score as metrics for answer quality. We use the same three testsets as above.

a. Evaluation of answer quality on full MT-RAG dataset.

StrategyRAGAS-FRAD-Bench
No rewrite0.730.66
Mixtral 8x7b rewrite0.80.68
Granite 3.2-8b aLoRA rewrite0.810.69
Gold rewrite0.790.69

a. Evaluation of answer quality on non-standalone subset of MT-RAG.

StrategyRAGAS-FRAD-Bench
No rewrite0.610.62
Mixtral 8x7b rewrite0.760.65
Granite 3.2-8b aLoRA rewrite0.770.69
Gold rewrite0.80.69

a. Evaluation of answer quality on standalone MT-RAG subset.

StrategyRAGAS-FRAD-Bench
No rewrite0.790.68
Mixtral 8x7b rewrite0.820.7
Granite 3.2-8b aLoRA rewrite0.830.7
Gold rewrite0.790.69

Contact#

Lucian Popa

Files

4 files · 94.4 MBWeights 94.4 MB (safetensors). Sizes and sha256 from the signed manifest.
Hide all 4 files with their sha256
FileSizesha256
.gitattributes1.52 KB11ad7efa24975ee4b0c3c3a38ed18737f0658a5f75a0a96787b576a78a023361
README.md13.0 KBa95f787a28d481f5229a3839b2271b09a05beab58b2493135f9f99b266e3a778
adapter_config.json1.17 KB8b7f7ec511bcf5aab654abcb970c031c9a9211f7af9f8e6bd0bf7428f731291c
adapter_model.safetensors94.4 MBecb2d17dee8147b310d3d8e1ac925d34aac3551b3a960540b7a7f57165cdaa2e
VersionsEach time the pinned upstream commit or file list changed in this repo. Newest first.
Upstream commitDateContents
4740af20cb pinned now2026-11-15 04:31 UTC4 files · 94.4 MB

Use it

$ fw get ibm-granite/granite-3.2-8b-alora-rag-query-rewrite
# manifest sha256 6f0d670fd820… · 94.4 MB · 4 files
$ fw verify ./granite-3.2-8b-alora-rag-query-rewrite ibm-granite/granite-3.2-8b-alora-rag-query-rewrite
fw.pyChecks the signature and every sha256, tries each source in order, resumes.
$ python3 fw.py get https://freeweights.allternit.com/manifests/ibm-granite/granite-3.2-8b-alora-rag-query-rewrite.json --dir ./granite-3.2-8b-alora-rag-query-rewrite $ python3 fw.py verify ./granite-3.2-8b-alora-rag-query-rewrite ./ibm-granite__granite-3.2-8b-alora-rag-query-rewrite.json
hfThe Hugging Face CLI with one setting. Same repo id.
$ HF_ENDPOINT=https://freeweights.allternit.com hf download ibm-granite/granite-3.2-8b-alora-rag-query-rewrite --revision 4740af20cb05eb801cdef6f45f2fb24c44b8f2a2 --local-dir ./granite-3.2-8b-alora-rag-query-rewrite

License

Name
Apache License 2.0
Id
Apache-2.0
Class
Permissive
Redistribution
yes
Listing
Hosted (signed)
Decided
License as declared by the publisher. No person read it. 2026-11-15
Text in
README.md
Text sha256
a95f787a28d481f5229a3839b2271b09a05beab58b2493135f9f99b266e3a778
Terms gate
No extra terms beyond the license.

Read the license text

Licenses are checked against the license table. A custom license passes only after a person reads it.

Provenance

From: ibm-granite <huggingface.co/ibm-granite>Newsgroups: alt.freeweights.graniteSubject: granite-3.2-8b-alora-rag-query-rewriteDate: 2026-11-15Commit: 4740af2Signed: 2DC28CC7B26A283B ✓
Upstream
ibm-granite/granite-3.2-8b-alora-rag-query-rewrite
Pinned commit
4740af20cb05eb801cdef6f45f2fb24c44b8f2a2
Manifest
granite-3.2-8b-alora-rag-query-rewrite.json · .minisig
Manifest sha256
6f0d670fd82057dfd2f174f7b10c32313e8f0f0b199bdd25037d4ec3468340d7
Signature
minisign, Ed25519, key 2DC28CC7B26A283B
Created
2026-11-15 04:31 UTC
Generator
freeweights-manifest/0.1.0
Takedowns
None.

How to verify

$ curl -O https://freeweights.allternit.com/manifests/ibm-granite/granite-3.2-8b-alora-rag-query-rewrite.json $ curl -O https://freeweights.allternit.com/manifests/ibm-granite/granite-3.2-8b-alora-rag-query-rewrite.json.minisig $ minisign -Vm granite-3.2-8b-alora-rag-query-rewrite.json -P RWQ7KGqyx4zCLXtUFOqvfv8L3g+8fpKJ1FsuxPyOYMF+4KufbUxKq1Oq $ shasum -a 256 <file> # compare with the Files tab

A manifest whose signature fails must be rejected. A file whose size or sha256 does not match must be discarded. Verify a download

Model tree

No related models in this catalog.Nothing here lists this model as its parent, and it names no parent.
Get it
Download
$ HF_ENDPOINT=https://freeweights.allternit.com hf download ibm-granite/granite-3.2-8b-alora-rag-query-rewrite
Open in Freeweights Studio

Pull, verify and run it in the Allternit app on Desktop, web or phone.

Signed manifest
minisign, key 2DC28CC7B26A283B. granite-3.2-8b-alora-rag-query-rewrite.json. Provenance. Takedown history: none.
From: ibm-granite <huggingface.co/ibm-granite>Subject: GneissWeb.7B_ablation_model_on_350B_FineWeb.Edu.seed1
From: ibm-granite <huggingface.co/ibm-granite>Subject: GneissWeb.7B_ablation_model_on_350B_FineWeb.Edu.seed2
From: ibm-granite <huggingface.co/ibm-granite>Subject: GneissWeb.7B_ablation_model_on_350B_FineWeb.Edu.seed3
From: ibm-granite <huggingface.co/ibm-granite>Subject: GneissWeb.7B_ablation_model_on_350B_FineWeb.seed1
From: ibm-granite <huggingface.co/ibm-granite>Subject: GneissWeb.7B_ablation_model_on_350B_FineWeb.seed2
From: ibm-granite <huggingface.co/ibm-granite>Subject: GneissWeb.7B_ablation_model_on_350B_FineWeb.seed3