-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,44 @@ | ||
import pandas as pd | ||
import time | ||
|
||
import lotus | ||
from lotus.models import LM | ||
|
||
lm = LM(model="gpt-4o-mini") | ||
def main(): | ||
lm = LM(model="gpt-4o-mini") | ||
|
||
lotus.settings.configure(lm=lm) | ||
data = { | ||
"Course Name": [ | ||
"Probability and Random Processes", | ||
"Optimization Methods in Engineering", | ||
"Digital Design and Integrated Circuits", | ||
"Computer Security", | ||
] | ||
} | ||
df = pd.DataFrame(data) | ||
lotus.settings.configure(lm=lm) | ||
lotus.settings.configure(enable_multithreading=True) | ||
|
||
data = { | ||
"Department": ["Math", "Physics", "Computer Science", "Biology"] * 7, | ||
"Course Name": [ | ||
"Calculus", "Quantum Mechanics", "Data Structures", "Genetics", | ||
"Linear Algebra", "Thermodynamics", "Algorithms", "Ecology", | ||
"Statistics", "Optics", "Machine Learning", "Molecular Biology", | ||
"Number Theory", "Relativity", "Computer Networks", "Evolutionary Biology", | ||
"Differential Equations", "Particle Physics", "Operating Systems", "Biochemistry", | ||
"Complex Analysis", "Fluid Dynamics", "Artificial Intelligence", "Microbiology", | ||
"Topology", "Astrophysics", "Cybersecurity", "Immunology" | ||
] | ||
} | ||
|
||
for method in ["quick", "heap", "naive"]: | ||
sorted_df, stats = df.sem_topk( | ||
"Which {Course Name} requires the least math?", | ||
K=2, | ||
method=method, | ||
return_stats=True, | ||
) | ||
print(sorted_df) | ||
print(stats) | ||
df = pd.DataFrame(data) | ||
|
||
for method in ["quick", "heap", "naive"]: | ||
|
||
start_time = time.time() | ||
sorted_df, stats = df.sem_topk( | ||
"Which {Course Name} is the most challenging?", | ||
K=2, | ||
method=method, | ||
return_stats=True, | ||
group_by=["Department"] | ||
) | ||
end_time = time.time() | ||
print(sorted_df) | ||
print(stats) | ||
print(f"Total execution time: {end_time - start_time:.2f} seconds") | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters