Views
No views yet
1from verbatim_rag.extractors import ModelSpanExtractor
2from verbatim_rag.document import Document
3
4# Initialize the extractor
5extractor = ModelSpanExtractor(
6 model_path="KRLabsOrg/chiliground-base-modernbert-v1",
7 threshold=0.5
8)
9
10# Create documents
11documents = [
12 Document(
13 content="""
14 Climate change is a significant and lasting change in the statistical distribution of weather patterns.
15 Global warming is the observed increase in the average temperature of the Earth's atmosphere and oceans.
16 Greenhouse gases include water vapor, carbon dioxide, methane, nitrous oxide, and ozone.
17 Human activities since the beginning of the Industrial Revolution have increased greenhouse gas levels.
18 """,
19 metadata={"source": "example_doc_1", "id": "climate_1"},
20 ),
21 Document(
22 content="""
23 Renewable energy comes from sources that are naturally replenished on a human timescale.
24 Solar power is the conversion of energy from sunlight into electricity.
25 Wind power is the use of wind to provide mechanical power or electricity.
26 Hydropower is electricity generated from the energy of falling water.
27 """,
28 metadata={"source": "example_doc_2", "id": "energy_1"},
29 ),
30]
31
32
33# Extract relevant spans
34question = "What causes climate change?"
35results = extractor.extract_spans(question, documents)
36
37# Print the results
38for doc_content, spans in results.items():
39 for span in spans:
40 print(span)