-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Sem_Extract Operator that schemas a list of documents and creates a DataFrame and provides the option to get quotes from context. --------- Co-authored-by: liana313 <[email protected]> Co-authored-by: Sid Jha <[email protected]>
- Loading branch information
1 parent
51c68f4
commit c85b8ed
Showing
6 changed files
with
176 additions
and
75 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pandas as pd | ||
|
||
import lotus | ||
from lotus.models import LM | ||
|
||
lm = LM(model="gpt-4o-mini") | ||
lotus.settings.configure(lm=lm) | ||
|
||
df = pd.DataFrame( | ||
{ | ||
"description": [ | ||
"Yoshi is 25 years old", | ||
"Bowser is 45 years old", | ||
"Luigi is 15 years old", | ||
] | ||
} | ||
) | ||
input_cols = ["description"] | ||
|
||
# A description can be specified for each output column | ||
output_cols = { | ||
"masked_col_1": "The name of the person", | ||
"masked_col_2": "The age of the person", | ||
} | ||
|
||
# you can optionally set extract_quotes=True to return quotes that support each output | ||
new_df = df.sem_extract(input_cols, output_cols, extract_quotes=True) | ||
print(new_df) | ||
|
||
# A description can also be omitted for each output column | ||
output_cols = { | ||
"name": None, | ||
"age": None, | ||
} | ||
new_df = df.sem_extract(input_cols, output_cols) | ||
print(new_df) |
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
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