-
Notifications
You must be signed in to change notification settings - Fork 70
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
6 changed files
with
294 additions
and
91 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,44 +1,67 @@ | ||
import pandas as pd | ||
import time | ||
|
||
import pandas as pd | ||
|
||
import lotus | ||
from lotus.models import LM | ||
|
||
|
||
def main(): | ||
lm = LM(model="gpt-4o-mini") | ||
|
||
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" | ||
] | ||
"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", | ||
], | ||
} | ||
|
||
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"] | ||
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__': | ||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.