Improve inference output and add optional system prompt#393
Improve inference output and add optional system prompt#393CYHSM wants to merge 2 commits intoModalities:mainfrom
Conversation
|
Thanks for your commit, it was really helpful. As a quick-to-implement suggestion, in the def run(self):
print("\n" + "🚀 Modalities Chat Interface ".center(60, "="))
print("=" * 60)
while True:
try:
user_prompt = self._get_prompt(self.prompt_template)
full_prompt = self.chat_template.format(system_prompt=self.system_prompt, user_prompt=user_prompt)
temp_input = input("\n🌡️ Enter temperatures (comma-separated) or press Enter for default [0.8]: ")
if not temp_input.strip():
temperatures = [0.8]
print("Using default temperature: 0.8")
else:
try:
temperatures = [float(t.strip()) for t in temp_input.split(",")]
if not temperatures:
raise ValueError("No temperatures provided.")
except ValueError:
print("\n❌ Invalid input. Please enter comma-separated numbers or press Enter for default.\n")
continue
for i, temp in enumerate(temperatures):
if len(temperatures) > 1:
print(f"\n\n{'🎯 GENERATION ' + str(i+1) + f' (Temperature: {temp})'.center(60, '=')}")
else:
print(f"\n\n{'🎯 GENERATING (Temperature: ' + str(temp) + ')'.center(60, '=')}")
try:
self.temperature = temp
self.generate_tokens(context=full_prompt)
except:
continue
print("\n\n" + "🏁 ALL GENERATIONS COMPLETE".center(60, "="))
print("=" * 60)
except KeyboardInterrupt:
print("\n\n👋 Closing app... Goodbye!")
break |
|
Thanks @behzadshomali, I integrated your suggestion now and also added tests for general inference:
@rrutmann this is ready from my side |
There was a problem hiding this comment.
At first glance the code looks good. I want to run it locally to check if everything works. Could you please add an inference config using the newly added variable system_prompt_path as well as an example file for such a system prompt to the repo?I would suggest to put it into config_files/text_inference
What does this PR do?
This PR makes the inference look a bit nicer and also adds:
I have found no inference tests so not sure if there are none or I am just not seeing them. If someone points me towards an existing test I can create one for this PR or create a full inference one
Breaking Changes
Checklist before submitting final PR
python tests/tests.py)Not all tests run through but the errors are seemingly unrelated to this change (sh scripts/run_checkpoint_conversion.sh)
CHANGELOG_DEV.md)