File size: 612 Bytes
51dabd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from src.fais_retriever import FAISRetriever
from src.utils.log import get_logger


logger = get_logger()


if __name__ == '__main__':
    # Initialize retriever
    r = FAISRetriever()

    # Retrieve example
    scores, result = r.retrieve(
        "What is the perplexity of a language model?")

    for i, score in enumerate(scores):
        logger.info(f"Result {i+1} (score: {score:.02f}):")
        logger.info(result['text'][i])

    # Compute overall performance
    exact_match, f1_score = r.evaluate()
    logger.info(f"Exact match: {exact_match:.02f}\n"
                f"F1-score: {f1_score:.02f}")