Skip to content

Commit

Permalink
example in examples of caching
Browse files Browse the repository at this point in the history
  • Loading branch information
liana313 committed Nov 12, 2024
1 parent 64dbd75 commit c9f8295
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions examples/model_examples/cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pandas as pd

import lotus
from lotus.models import LM

lm = LM(model="gpt-4o-mini")

lotus.settings.configure(lm=lm, enable_cache=True) # default caching is False
data = {
"Course Name": [
"Probability and Random Processes",
"Optimization Methods in Engineering",
"Digital Design and Integrated Circuits",
"Computer Security",
]
}
df = pd.DataFrame(data)
user_instruction = "{Course Name} requires a lot of math"
df = df.sem_filter(user_instruction)
print("====== intial run ======")
print(df)

# run a second time
df = df.sem_filter(user_instruction)
print("====== second run ======")
print(df)

0 comments on commit c9f8295

Please sign in to comment.