jhu-clsp / FollowIR-7B

huggingface.co
Total runs: 532
24-hour runs: 0
7-day runs: -17
30-day runs: -74
Model's Last Updated: April 30 2024
text-generation

Introduction of FollowIR-7B

Model Details of FollowIR-7B

Model Summary

FollowIR-7B is an instruction-tuned language model to be used for reranking in retrieval. It is Mistral-7B-Instruct-v0.2 fine-tuned on retrieval data with instructions from the FollowIR dataset. These instructions were taken from TREC tracks and are human written. FollowIR-7B outperforms all other retrieval models at following instructions. See the paper for more details.

Use

Below is an example to compute the similarity score of a query-document pair

from transformers import (
    AutoTokenizer,
    AutoModelForCausalLM,
)
import torch

# model loading and setup
model_name = "jhu-clsp/FollowIR-7B"
model = AutoModelForCausalLM.from_pretrained(
    model_name
).cuda()
tokenizer = AutoTokenizer.from_pretrained(
    model_name, padding_side="left"
)
tokenizer.pad_token = tokenizer.eos_token
tokenizer.padding_side = "left"
token_false_id = tokenizer.get_vocab()["false"]
token_true_id = tokenizer.get_vocab()["true"]
template = """<s> [INST] You are an expert Google searcher, whose job is to determine if the following document is relevant to the query (true/false). Answer using only one word, one of those two choices.

Query: {query}
Document: {text}
Relevant (only output one word, either "true" or "false"): [/INST] """


## Lets define some example queries with instructions in the query and the passage
query1 = "What movies were written by James Cameron? A relevant document would describe a movie that was written by James Cameron only and not with anyone else"
query2 = "What movies were directed by James Cameron? A relevant document would describe any movie that was directed by James Cameron"
passages = ["Avatar: The Way of Water is a 2022 American epic science fiction film co-produced and directed by James Cameron, who co-wrote the screenplay with Rick Jaffa and Amanda Silver from a story the trio wrote with Josh Friedman and Shane Salerno. Distributed by 20th Century Studios, it is the sequel to Avatar (2009) and the second installment in the Avatar film series."] * 2

prompts = [
    template.format(query=query, text=text) for (query, text) in zip([query1, query2], passages)
]
tokens = tokenizer(
    prompts,
    padding=True,
    truncation=True,
    return_tensors="pt",
    pad_to_multiple_of=None,
)

# move to cuda if desired
for key in tokens:
    tokens[key] = tokens[key].cuda()

# calculate the scores by comparing true and false tokens
batch_scores = model(**tokens).logits[:, -1, :]
true_vector = batch_scores[:, token_true_id]
false_vector = batch_scores[:, token_false_id]
batch_scores = torch.stack([false_vector, true_vector], dim=1)
batch_scores = torch.nn.functional.log_softmax(batch_scores, dim=1)
scores = batch_scores[:, 1].exp().tolist()
print(scores) # [0.0020704232156276703, 0.9999990463256836] first document is not relevant, as expected

Training

We used LLaMA-Factory to fine-tune Mistral to create FollowIR-7B, after transforming it to fit their format (input of "query" + "instruction" inside the template, output is the label, and instruction as the beginning of the template) with the following training script:

#!/bin/bash
accelerate launch src/train_bash.py \
    --stage sft \
    --do_train \
    --model_name_or_path "mistralai/Mistral-7B-Instruct-v0.2" \
    --dataset followIR-train \
    --template mistral \
    --output_dir OUTPUT \
    --finetuning_type lora \
    --lora_target q_proj,v_proj,o_proj,k_proj \
    --overwrite_cache \
    --per_device_train_batch_size 32 \
    --gradient_accumulation_steps 1 \
    --lr_scheduler_type cosine \
    --logging_steps 2 \
    --save_steps 29 \
    --learning_rate 3e-5 \
    --num_train_epochs 8.0 \
    --plot_loss \
    --max_length 2048 \
    --lora_rank 8 \
    --lora_alpha 16 \
    --bf16 

Citation

@misc{weller2024followir,
      title={FollowIR: Evaluating and Teaching Information Retrieval Models to Follow Instructions}, 
      author={Orion Weller and Benjamin Chang and Sean MacAvaney and Kyle Lo and Arman Cohan and Benjamin Van Durme and Dawn Lawrie and Luca Soldaini},
      year={2024},
      eprint={2403.15246},
      archivePrefix={arXiv},
      primaryClass={cs.IR}
}

Runs of jhu-clsp FollowIR-7B on huggingface.co

532
Total runs
0
24-hour runs
-25
3-day runs
-17
7-day runs
-74
30-day runs

More Information About FollowIR-7B huggingface.co Model

More FollowIR-7B license Visit here:

https://choosealicense.com/licenses/apache-2.0

FollowIR-7B huggingface.co

FollowIR-7B huggingface.co is an AI model on huggingface.co that provides FollowIR-7B's model effect (), which can be used instantly with this jhu-clsp FollowIR-7B model. huggingface.co supports a free trial of the FollowIR-7B model, and also provides paid use of the FollowIR-7B. Support call FollowIR-7B model through api, including Node.js, Python, http.

FollowIR-7B huggingface.co Url

https://huggingface.co/jhu-clsp/FollowIR-7B

jhu-clsp FollowIR-7B online free

FollowIR-7B huggingface.co is an online trial and call api platform, which integrates FollowIR-7B's modeling effects, including api services, and provides a free online trial of FollowIR-7B, you can try FollowIR-7B online for free by clicking the link below.

jhu-clsp FollowIR-7B online free url in huggingface.co:

https://huggingface.co/jhu-clsp/FollowIR-7B

FollowIR-7B install

FollowIR-7B is an open source model from GitHub that offers a free installation service, and any user can find FollowIR-7B on GitHub to install. At the same time, huggingface.co provides the effect of FollowIR-7B install, users can directly use FollowIR-7B installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

FollowIR-7B install url in huggingface.co:

https://huggingface.co/jhu-clsp/FollowIR-7B

Url of FollowIR-7B

FollowIR-7B huggingface.co Url

Provider of FollowIR-7B huggingface.co

jhu-clsp
ORGANIZATIONS

Other API from jhu-clsp

huggingface.co

Total runs: 426.5K
Run Growth: 48.6K
Growth Rate: 11.46%
Updated:October 07 2025
huggingface.co

Total runs: 102.7K
Run Growth: 63.4K
Growth Rate: 61.09%
Updated:October 18 2025
huggingface.co

Total runs: 2.3K
Run Growth: -6.3K
Growth Rate: -274.79%
Updated:April 09 2025
huggingface.co

Total runs: 1.3K
Run Growth: 534
Growth Rate: 41.62%
Updated:April 05 2023
huggingface.co

Total runs: 402
Run Growth: 67
Growth Rate: 16.67%
Updated:April 09 2025
huggingface.co

Total runs: 256
Run Growth: 45
Growth Rate: 17.58%
Updated:June 02 2024
huggingface.co

Total runs: 75
Run Growth: 43
Growth Rate: 57.33%
Updated:April 09 2025
huggingface.co

Total runs: 55
Run Growth: -409
Growth Rate: -743.64%
Updated:April 09 2025
huggingface.co

Total runs: 51
Run Growth: -76
Growth Rate: -149.02%
Updated:August 25 2022
huggingface.co

Total runs: 50
Run Growth: -4
Growth Rate: -8.00%
Updated:September 18 2023
huggingface.co

Total runs: 31
Run Growth: 6
Growth Rate: 19.35%
Updated:April 09 2025
huggingface.co

Total runs: 23
Run Growth: -17
Growth Rate: -73.91%
Updated:April 09 2025