-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathquickstart.py
More file actions
32 lines (28 loc) · 1.15 KB
/
quickstart.py
File metadata and controls
32 lines (28 loc) · 1.15 KB
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
27
28
29
30
31
32
from exit_rag import ExitRAG, Document
# Initialize pipeline
rag = ExitRAG(
retriever_model="google/gemma-2b-it",
compression_model="doubleyyh/exit-gemma-2b",
reader_model="meta-llama/Llama-3.1-8B-Instruct"
)
# Example query and document
query = "How do solid-state drives (SSDs) improve computer performance?"
documents = [Document(
title="Computer Storage Technologies",
text="""
Solid-state drives use flash memory to store data without moving parts.
Unlike traditional hard drives, SSDs have no mechanical components.
The absence of physical movement allows for much faster data access speeds.
I bought my computer last week.
SSDs significantly reduce boot times and application loading speeds.
They consume less power and are more reliable than mechanical drives.
The price of SSDs has decreased significantly in recent years.
"""
)]
# Run RAG pipeline with compression
result = rag.run_rag(query, documents)
# Print results
print("\nQuery:", result["query"])
print("\nCompressed Context:", result["compressed_context"])
print("\nAnswer:", result["answer"])
print(f"\nGeneration Time: {result['generation_time']:.2f}s")