Tonic commited on
Commit
915c7a7
1 Parent(s): ece93a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -16
app.py CHANGED
@@ -18,16 +18,9 @@ def wrap_text(text, width=90):
18
  wrapped_text = '\n'.join(wrapped_lines)
19
  return wrapped_text
20
  def multimodal_prompt(user_input, system_prompt="You are an expert medical analyst:"):
21
- """
22
- Generates text using a large language model, given a user input and a system prompt.
23
- Args:
24
- user_input: The user's input text to generate a response for.
25
- system_prompt: Optional system prompt.
26
- Returns:
27
- A string containing the generated text.
28
- """
29
  # Combine user input and system prompt
30
- formatted_input = f"[INSTRUCTION]{system_prompt} {user_input}"
31
 
32
  # Encode the input text
33
  encodeds = tokenizer(formatted_input, return_tensors="pt", add_special_tokens=False)
@@ -64,12 +57,6 @@ tokenizer = AutoTokenizer.from_pretrained("stabilityai/stablelm-3b-4e1t", trust_
64
  tokenizer.pad_token = tokenizer.eos_token
65
  tokenizer.padding_side = 'left'
66
 
67
- # Specify the configuration class for the model
68
- #model_config = AutoConfig.from_pretrained(base_model_id)
69
-
70
- # Load the PEFT model with the specified configuration
71
- #peft_model = AutoModelForCausalLM.from_pretrained(base_model_id, config=model_config)
72
-
73
  # Load the PEFT model
74
  peft_config = PeftConfig.from_pretrained("Tonic/stablemed", token=hf_token)
75
  peft_model = MistralForCausalLM.from_pretrained("stabilityai/stablelm-3b-4e1t", trust_remote_code=True)
@@ -105,7 +92,7 @@ class ChatBot:
105
  bot = ChatBot()
106
 
107
  title = "👋🏻Welcome to Tonic's StableMed Chat🚀"
108
- description = "You can use this Space to test out the current model [StableMed](https://huggingface.co/Tonic/stablemed) or You can also use 😷StableMed⚕️ on your own data & in your own way by cloning this space. 🧬🔬🔍 Simply click here: <a style="display:inline-block" href="https://huggingface.co/spaces/Tonic/StableMed_Chat?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></h3> #### Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community on 👻Discord: [Discord](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [PolyGPT](https://github.com/tonic-ai/polygpt-alpha)" "
109
  examples = [["What is the proper treatment for buccal herpes?", "Please provide information on the most effective antiviral medications and home remedies for treating buccal herpes."]]
110
 
111
  iface = gr.Interface(
 
18
  wrapped_text = '\n'.join(wrapped_lines)
19
  return wrapped_text
20
  def multimodal_prompt(user_input, system_prompt="You are an expert medical analyst:"):
21
+
 
 
 
 
 
 
 
22
  # Combine user input and system prompt
23
+ formatted_input = f"[INSTRUCTION]{system_prompt}[QUESTION]{user_input}"
24
 
25
  # Encode the input text
26
  encodeds = tokenizer(formatted_input, return_tensors="pt", add_special_tokens=False)
 
57
  tokenizer.pad_token = tokenizer.eos_token
58
  tokenizer.padding_side = 'left'
59
 
 
 
 
 
 
 
60
  # Load the PEFT model
61
  peft_config = PeftConfig.from_pretrained("Tonic/stablemed", token=hf_token)
62
  peft_model = MistralForCausalLM.from_pretrained("stabilityai/stablelm-3b-4e1t", trust_remote_code=True)
 
92
  bot = ChatBot()
93
 
94
  title = "👋🏻Welcome to Tonic's StableMed Chat🚀"
95
+ description = "You can use this Space to test out the current model [StableMed](https://huggingface.co/Tonic/stablemed) or You can also use 😷StableMed⚕️ on your own data & in your own way by cloning this space. 🧬🔬🔍 Simply click here: <a style='display:inline-block' href='https://huggingface.co/spaces/Tonic/StableMed_Chat?duplicate=true'><img src='https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14' alt='Duplicate Space'></a></h3> #### Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community on 👻Discord: [Discord](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [PolyGPT](https://github.com/tonic-ai/polygpt-alpha)" "
96
  examples = [["What is the proper treatment for buccal herpes?", "Please provide information on the most effective antiviral medications and home remedies for treating buccal herpes."]]
97
 
98
  iface = gr.Interface(