-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #307 from ohdearquant/merge_direct
Merge direct, vote
- Loading branch information
Showing
8 changed files
with
314 additions
and
329 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from .predict import predict | ||
from .select import select | ||
from .score import score | ||
from .vote import vote | ||
|
||
__all__ = [ | ||
"predict", | ||
"select", | ||
"score", | ||
"vote" | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from lionagi.libs import func_call | ||
import numpy as np | ||
from .predict import predict | ||
from .score import score | ||
|
||
# for example, directive=predict | ||
|
||
async def vote(sentence, directive=predict, num_generations=5, num_output=1, num_scorer=5, score_range=(0,100), num_digit=2, scorer_instruction=None, **kwargs): | ||
|
||
async def _inner(i): | ||
out_ = await directive(sentence, **kwargs) | ||
score_ = await score( | ||
out_.answer, | ||
context=sentence, | ||
instruction=scorer_instruction, | ||
score_range=score_range, | ||
num_digit=num_digit, | ||
num_instances=num_scorer, | ||
return_template=False | ||
) | ||
|
||
out_.__setattr__('score', score_) | ||
return out_ | ||
|
||
_outs = await func_call.alcall(list(range(num_generations)), _inner) | ||
|
||
top_index = np.argsort([i.score for i in _outs])[-num_output:] | ||
final_output = list(np.array(_outs)[top_index]) | ||
|
||
return final_output[0] if len(final_output) == 1 else final_output |
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 +1 @@ | ||
__version__ = "0.0.310" | ||
__version__ = "0.0.311" |
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
Oops, something went wrong.