Search in sources :

Example 1 with Rm3Reranker

use of io.anserini.rerank.lib.Rm3Reranker in project Anserini by castorini.

the class SearchCollection method constructRerankers.

private List<RerankerCascade> constructRerankers() throws IOException {
    List<RerankerCascade> cascades = new ArrayList<>();
    if (args.rm3) {
        for (String fbTerms : args.rm3_fbTerms) {
            for (String fbDocs : args.rm3_fbDocs) {
                for (String originalQueryWeight : args.rm3_originalQueryWeight) {
                    String tag;
                    if (this.args.rf_qrels != null) {
                        tag = String.format("rm3Rf(fbTerms=%s,originalQueryWeight=%s)", fbTerms, originalQueryWeight);
                    } else {
                        tag = String.format("rm3(fbTerms=%s,fbDocs=%s,originalQueryWeight=%s)", fbTerms, fbDocs, originalQueryWeight);
                    }
                    RerankerCascade cascade = new RerankerCascade(tag);
                    cascade.add(new Rm3Reranker(analyzer, IndexArgs.CONTENTS, Integer.valueOf(fbTerms), Integer.valueOf(fbDocs), Float.valueOf(originalQueryWeight), args.rm3_outputQuery, !args.rm3_noTermFilter));
                    cascade.add(new ScoreTiesAdjusterReranker());
                    cascades.add(cascade);
                }
            }
        }
    } else if (args.axiom) {
        for (String r : args.axiom_r) {
            for (String n : args.axiom_n) {
                for (String beta : args.axiom_beta) {
                    for (String top : args.axiom_top) {
                        for (String seed : args.axiom_seed) {
                            String tag;
                            if (this.args.rf_qrels != null) {
                                tag = String.format("axRf(seed=%s,n=%s,beta=%s,top=%s)", seed, n, beta, top);
                            } else {
                                tag = String.format("ax(seed=%s,r=%s,n=%s,beta=%s,top=%s)", seed, r, n, beta, top);
                            }
                            RerankerCascade cascade = new RerankerCascade(tag);
                            cascade.add(new AxiomReranker(args.index, args.axiom_index, IndexArgs.CONTENTS, args.axiom_deterministic, Integer.valueOf(seed), Integer.valueOf(r), Integer.valueOf(n), Float.valueOf(beta), Integer.valueOf(top), args.axiom_docids, args.axiom_outputQuery, args.searchtweets));
                            cascade.add(new ScoreTiesAdjusterReranker());
                            cascades.add(cascade);
                        }
                    }
                }
            }
        }
    } else if (args.bm25prf) {
        for (String fbTerms : args.bm25prf_fbTerms) {
            for (String fbDocs : args.bm25prf_fbDocs) {
                for (String k1 : args.bm25prf_k1) {
                    for (String b : args.bm25prf_b) {
                        for (String newTermWeight : args.bm25prf_newTermWeight) {
                            String tag;
                            if (this.args.rf_qrels != null) {
                                tag = String.format("bm25Rf(fbTerms=%s,k1=%s,b=%s,newTermWeight=%s)", fbTerms, k1, b, newTermWeight);
                            } else {
                                tag = String.format("bm25prf(fbTerms=%s,fbDocs=%s,k1=%s,b=%s,newTermWeight=%s)", fbTerms, fbDocs, k1, b, newTermWeight);
                            }
                            RerankerCascade cascade = new RerankerCascade(tag);
                            cascade.add(new BM25PrfReranker(analyzer, IndexArgs.CONTENTS, Integer.valueOf(fbTerms), Integer.valueOf(fbDocs), Float.valueOf(k1), Float.valueOf(b), Float.valueOf(newTermWeight), args.bm25prf_outputQuery));
                            cascade.add(new ScoreTiesAdjusterReranker());
                            cascades.add(cascade);
                        }
                    }
                }
            }
        }
    } else {
        RerankerCascade cascade = new RerankerCascade();
        cascade.add(new ScoreTiesAdjusterReranker());
        cascades.add(cascade);
    }
    return cascades;
}
Also used : RerankerCascade(io.anserini.rerank.RerankerCascade) Rm3Reranker(io.anserini.rerank.lib.Rm3Reranker) AxiomReranker(io.anserini.rerank.lib.AxiomReranker) ArrayList(java.util.ArrayList) ScoreTiesAdjusterReranker(io.anserini.rerank.lib.ScoreTiesAdjusterReranker) BM25PrfReranker(io.anserini.rerank.lib.BM25PrfReranker)

Example 2 with Rm3Reranker

use of io.anserini.rerank.lib.Rm3Reranker in project Anserini by castorini.

the class SimpleSearcher method setRM3.

/**
 * Enables RM3 query expansion with default parameters.
 *
 * @param fbTerms number of expansion terms
 * @param fbDocs number of expansion documents
 * @param originalQueryWeight weight to assign to the original query
 * @param outputQuery flag to print original and expanded queries
 * @param filterTerms whether to filter terms to be English only
 */
public void setRM3(int fbTerms, int fbDocs, float originalQueryWeight, boolean outputQuery, boolean filterTerms) {
    useRM3 = true;
    cascade = new RerankerCascade("rm3");
    cascade.add(new Rm3Reranker(this.analyzer, IndexArgs.CONTENTS, fbTerms, fbDocs, originalQueryWeight, outputQuery, filterTerms));
    cascade.add(new ScoreTiesAdjusterReranker());
}
Also used : RerankerCascade(io.anserini.rerank.RerankerCascade) Rm3Reranker(io.anserini.rerank.lib.Rm3Reranker) ScoreTiesAdjusterReranker(io.anserini.rerank.lib.ScoreTiesAdjusterReranker)

Aggregations

RerankerCascade (io.anserini.rerank.RerankerCascade)2 Rm3Reranker (io.anserini.rerank.lib.Rm3Reranker)2 ScoreTiesAdjusterReranker (io.anserini.rerank.lib.ScoreTiesAdjusterReranker)2 AxiomReranker (io.anserini.rerank.lib.AxiomReranker)1 BM25PrfReranker (io.anserini.rerank.lib.BM25PrfReranker)1 ArrayList (java.util.ArrayList)1