File size: 599 Bytes
e92d49a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import time

from rag.vectorstore import get_vectorstore
from rag.chain import aanswer


async def bench():
    t0 = time.perf_counter()
    vs = get_vectorstore()
    t1 = time.perf_counter()
    print(f'FAISS load/build time: {t1-t0:.3f}s')

    # Sample query; aanswer will initialize LLM when needed
    q = 'What is the Vicharanashala internship?'
    t2 = time.perf_counter()
    ans = await aanswer(q)
    t3 = time.perf_counter()
    print(f'LLM + retrieval time: {t3-t2:.3f}s')
    print('Answer length:', len(ans))


if __name__ == '__main__':
    import asyncio

    asyncio.run(bench())