-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validator, logging and modelling improvements #127
Merged
Merged
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2e0bcd8
fixed a bug regarding lists of pydantic objects
MartBakler 8ef494e
updated tests and fixed a tuple bug
MartBakler dd174bb
Added loggings
MartBakler af896a4
added strip for llama output trimming
MartBakler 2f806db
fixed small bugs with logging
MartBakler 2b54602
updates to logging and adding new turbo model for finetuning
MartBakler 8139f97
updateing how we treat helper tokens
MartBakler e46cead
added turbo model to default models
MartBakler aabbdc4
Fixed issue when losing class definitions with Union or Optional
MartBakler ac2e368
added tests for register output class definitions
MartBakler 204d61a
separated default teacher and student models for cleaner implementati…
MartBakler f3e5279
updated the generator name for logging
MartBakler ff3df48
added new turbo model
MartBakler 2a1316e
un hardcoded distilled model
MartBakler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -83,17 +83,21 @@ def generate(self, args, kwargs, function_description, llm_parameters={}): | |
The main generation function, given the args, kwargs, function description and model type, generate a response and check if the datapoint can be saved to the finetune dataset | ||
""" | ||
|
||
func_hash = function_description.__hash__() | ||
prompt, model, save_to_finetune, is_distilled_model = self.get_generation_case(args, kwargs, | ||
function_description, | ||
llm_parameters) | ||
func_hash = function_description.__hash__() | ||
llm_parameters, | ||
func_hash) | ||
# loggings | ||
if func_hash not in self.current_generators: | ||
logging.info(f"Generating function outputs with {model.model_name}") | ||
self.current_generators[func_hash] = model.model_name | ||
elif self.current_generators[func_hash] != model.model_name: | ||
logging.info(f"Switching output generation from {self.current_generators[func_hash]} to {model.model_name}") | ||
self.current_generators[func_hash] = model.model_name | ||
current_generator = self.current_generators.get(func_hash, None) | ||
if current_generator: | ||
generator_model = current_generator["model"] | ||
if generator_model == "": | ||
logging.info(f"Found {len(current_generator['examples'])} align statements for {function_description.name}. Generating function outputs with {model.model_name}.") | ||
self.current_generators[func_hash]["model"] = model.model_name | ||
elif generator_model != model.model_name: | ||
logging.info(f"Switching output generation from {generator_model} to {model.model_name} for funcion {function_description.name}.") | ||
self.current_generators[func_hash]["model"] = model.model_name | ||
|
||
choice = self._synthesise_answer(prompt, model, llm_parameters) | ||
output = LanguageModelOutput(choice, save_to_finetune, is_distilled_model) | ||
|
@@ -114,7 +118,7 @@ def _synthesise_answer(self, prompt, model, llm_parameters): | |
return self.api_provider[model.provider].generate(model, system_message, prompt, **llm_parameters) | ||
|
||
|
||
def get_generation_case(self, args, kwargs, function_description, llm_parameters): | ||
def get_generation_case(self, args, kwargs, function_description, llm_parameters, func_hash): | ||
""" | ||
Get the generation case with the correct prompt and model | ||
First get the current model, then if distilled model, do zero-shot prompt and return False as suitable_for_finetune | ||
|
@@ -136,6 +140,9 @@ def get_generation_case(self, args, kwargs, function_description, llm_parameters | |
examples = [f"Inputs:\nArgs: {align['args']}\nKwargs: {align['kwargs']}\nOutput: {align['output']}" for align in | ||
aligns] | ||
|
||
if func_hash not in self.current_generators: | ||
self.current_generators[func_hash] = {"model": "", "examples": examples} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we change the variable name |
||
|
||
examples_token_count = sum([approximate_token_count(example) for example in examples]) | ||
generation_tokens = llm_parameters.get("max_new_tokens", self.default_generation_length) | ||
model = self.choose_model_from_tokens(teacher_models, | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't
teacher_models
a list? If so, how can you getmodel_name
from it?